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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
89/// secret,
90/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
91/// ).build().await.unwrap();
92///
93/// let client = hyper_util::client::legacy::Client::builder(
94/// hyper_util::rt::TokioExecutor::new()
95/// )
96/// .build(
97/// hyper_rustls::HttpsConnectorBuilder::new()
98/// .with_native_roots()
99/// .unwrap()
100/// .https_or_http()
101/// .enable_http1()
102/// .build()
103/// );
104/// let mut hub = Analytics::new(client, auth);
105/// // As the method needs a request, you would usually fill it with the desired information
106/// // into the respective structure. Some of the parts shown here might not be applicable !
107/// // Values shown here are possibly random and not representative !
108/// let mut req = EntityUserLink::default();
109///
110/// // You can configure optional parameters by calling the respective setters at will, and
111/// // execute the final call using `doit()`.
112/// // Values shown here are possibly random and not representative !
113/// let result = hub.management().profile_user_links_update(req, "accountId", "webPropertyId", "profileId", "linkId")
114/// .doit().await;
115///
116/// match result {
117/// Err(e) => match e {
118/// // The Error enum provides details about what exactly happened.
119/// // You can also just use its `Debug`, `Display` or `Error` traits
120/// Error::HttpError(_)
121/// |Error::Io(_)
122/// |Error::MissingAPIKey
123/// |Error::MissingToken(_)
124/// |Error::Cancelled
125/// |Error::UploadSizeLimitExceeded(_, _)
126/// |Error::Failure(_)
127/// |Error::BadRequest(_)
128/// |Error::FieldClash(_)
129/// |Error::JsonDecodeError(_, _) => println!("{}", e),
130/// },
131/// Ok(res) => println!("Success: {:?}", res),
132/// }
133/// # }
134/// ```
135#[derive(Clone)]
136pub struct Analytics<C> {
137 pub client: common::Client<C>,
138 pub auth: Box<dyn common::GetToken>,
139 _user_agent: String,
140 _base_url: String,
141 _root_url: String,
142}
143
144impl<C> common::Hub for Analytics<C> {}
145
146impl<'a, C> Analytics<C> {
147 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Analytics<C> {
148 Analytics {
149 client,
150 auth: Box::new(auth),
151 _user_agent: "google-api-rust-client/6.0.0".to_string(),
152 _base_url: "https://www.googleapis.com/analytics/v3/".to_string(),
153 _root_url: "https://analytics.googleapis.com/".to_string(),
154 }
155 }
156
157 pub fn data(&'a self) -> DataMethods<'a, C> {
158 DataMethods { hub: self }
159 }
160 pub fn management(&'a self) -> ManagementMethods<'a, C> {
161 ManagementMethods { hub: self }
162 }
163 pub fn metadata(&'a self) -> MetadataMethods<'a, C> {
164 MetadataMethods { hub: self }
165 }
166 pub fn provisioning(&'a self) -> ProvisioningMethods<'a, C> {
167 ProvisioningMethods { hub: self }
168 }
169 pub fn user_deletion(&'a self) -> UserDeletionMethods<'a, C> {
170 UserDeletionMethods { hub: self }
171 }
172
173 /// Set the user-agent header field to use in all requests to the server.
174 /// It defaults to `google-api-rust-client/6.0.0`.
175 ///
176 /// Returns the previously set user-agent.
177 pub fn user_agent(&mut self, agent_name: String) -> String {
178 std::mem::replace(&mut self._user_agent, agent_name)
179 }
180
181 /// Set the base url to use in all requests to the server.
182 /// It defaults to `https://www.googleapis.com/analytics/v3/`.
183 ///
184 /// Returns the previously set base url.
185 pub fn base_url(&mut self, new_base_url: String) -> String {
186 std::mem::replace(&mut self._base_url, new_base_url)
187 }
188
189 /// Set the root url to use in all requests to the server.
190 /// It defaults to `https://analytics.googleapis.com/`.
191 ///
192 /// Returns the previously set root url.
193 pub fn root_url(&mut self, new_root_url: String) -> String {
194 std::mem::replace(&mut self._root_url, new_root_url)
195 }
196}
197
198// ############
199// SCHEMAS ###
200// ##########
201/// JSON template for Analytics account entry.
202///
203/// This type is not used in any activity, and only used as *part* of another schema.
204///
205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
206#[serde_with::serde_as]
207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
208pub struct Account {
209 /// Child link for an account entry. Points to the list of web properties for this account.
210 #[serde(rename = "childLink")]
211 pub child_link: Option<AccountChildLink>,
212 /// Time the account was created.
213 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
214 /// Account ID.
215 pub id: Option<String>,
216 /// Resource type for Analytics account.
217 pub kind: Option<String>,
218 /// Account name.
219 pub name: Option<String>,
220 /// Permissions the user has for this account.
221 pub permissions: Option<AccountPermissions>,
222 /// Link for this account.
223 #[serde(rename = "selfLink")]
224 pub self_link: Option<String>,
225 /// Indicates whether this account is starred or not.
226 pub starred: Option<bool>,
227 /// Time the account was last modified.
228 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
229}
230
231impl common::Part for Account {}
232
233/// JSON template for a linked account.
234///
235/// This type is not used in any activity, and only used as *part* of another schema.
236///
237#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
238#[serde_with::serde_as]
239#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
240pub struct AccountRef {
241 /// Link for this account.
242 pub href: Option<String>,
243 /// Account ID.
244 pub id: Option<String>,
245 /// Analytics account reference.
246 pub kind: Option<String>,
247 /// Account name.
248 pub name: Option<String>,
249}
250
251impl common::Part for AccountRef {}
252
253/// 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.
254///
255/// # Activities
256///
257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
259///
260/// * [account summaries list management](ManagementAccountSummaryListCall) (response)
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct AccountSummaries {
265 /// A list of AccountSummaries.
266 pub items: Option<Vec<AccountSummary>>,
267 /// 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.
268 #[serde(rename = "itemsPerPage")]
269 pub items_per_page: Option<i32>,
270 /// Collection type.
271 pub kind: Option<String>,
272 /// Link to next page for this AccountSummary collection.
273 #[serde(rename = "nextLink")]
274 pub next_link: Option<String>,
275 /// Link to previous page for this AccountSummary collection.
276 #[serde(rename = "previousLink")]
277 pub previous_link: Option<String>,
278 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
279 #[serde(rename = "startIndex")]
280 pub start_index: Option<i32>,
281 /// The total number of results for the query, regardless of the number of results in the response.
282 #[serde(rename = "totalResults")]
283 pub total_results: Option<i32>,
284 /// Email ID of the authenticated user
285 pub username: Option<String>,
286}
287
288impl common::ResponseResult for AccountSummaries {}
289
290/// JSON template for an Analytics AccountSummary. An AccountSummary is a lightweight tree comprised of properties/profiles.
291///
292/// This type is not used in any activity, and only used as *part* of another schema.
293///
294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
295#[serde_with::serde_as]
296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
297pub struct AccountSummary {
298 /// Account ID.
299 pub id: Option<String>,
300 /// Resource type for Analytics AccountSummary.
301 pub kind: Option<String>,
302 /// Account name.
303 pub name: Option<String>,
304 /// Indicates whether this account is starred or not.
305 pub starred: Option<bool>,
306 /// List of web properties under this account.
307 #[serde(rename = "webProperties")]
308 pub web_properties: Option<Vec<WebPropertySummary>>,
309}
310
311impl common::Part for AccountSummary {}
312
313/// 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.
314///
315/// # Activities
316///
317/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
318/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
319///
320/// * [create account ticket provisioning](ProvisioningCreateAccountTicketCall) (request|response)
321#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
322#[serde_with::serde_as]
323#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
324pub struct AccountTicket {
325 /// Account for this ticket.
326 pub account: Option<Account>,
327 /// Account ticket ID used to access the account ticket.
328 pub id: Option<String>,
329 /// Resource type for account ticket.
330 pub kind: Option<String>,
331 /// View (Profile) for the account.
332 pub profile: Option<Profile>,
333 /// Redirect URI where the user will be sent after accepting Terms of Service. Must be configured in APIs console as a callback URL.
334 #[serde(rename = "redirectUri")]
335 pub redirect_uri: Option<String>,
336 /// Web property for the account.
337 pub webproperty: Option<Webproperty>,
338}
339
340impl common::RequestValue for AccountTicket {}
341impl common::ResponseResult for AccountTicket {}
342
343/// 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.
344///
345/// # Activities
346///
347/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
348/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
349///
350/// * [create account tree provisioning](ProvisioningCreateAccountTreeCall) (request)
351#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
352#[serde_with::serde_as]
353#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
354pub struct AccountTreeRequest {
355 /// no description provided
356 #[serde(rename = "accountName")]
357 pub account_name: Option<String>,
358 /// Resource type for account ticket.
359 pub kind: Option<String>,
360 /// no description provided
361 #[serde(rename = "profileName")]
362 pub profile_name: Option<String>,
363 /// no description provided
364 pub timezone: Option<String>,
365 /// no description provided
366 #[serde(rename = "webpropertyName")]
367 pub webproperty_name: Option<String>,
368 /// no description provided
369 #[serde(rename = "websiteUrl")]
370 pub website_url: Option<String>,
371}
372
373impl common::RequestValue for AccountTreeRequest {}
374
375/// 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).
376///
377/// # Activities
378///
379/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
380/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
381///
382/// * [create account tree provisioning](ProvisioningCreateAccountTreeCall) (response)
383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
384#[serde_with::serde_as]
385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
386pub struct AccountTreeResponse {
387 /// The account created.
388 pub account: Option<Account>,
389 /// Resource type for account ticket.
390 pub kind: Option<String>,
391 /// View (Profile) for the account.
392 pub profile: Option<Profile>,
393 /// Web property for the account.
394 pub webproperty: Option<Webproperty>,
395}
396
397impl common::ResponseResult for AccountTreeResponse {}
398
399/// 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.
400///
401/// # Activities
402///
403/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
404/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
405///
406/// * [accounts list management](ManagementAccountListCall) (response)
407#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
408#[serde_with::serde_as]
409#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
410pub struct Accounts {
411 /// A list of accounts.
412 pub items: Option<Vec<Account>>,
413 /// 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.
414 #[serde(rename = "itemsPerPage")]
415 pub items_per_page: Option<i32>,
416 /// Collection type.
417 pub kind: Option<String>,
418 /// Next link for this account collection.
419 #[serde(rename = "nextLink")]
420 pub next_link: Option<String>,
421 /// Previous link for this account collection.
422 #[serde(rename = "previousLink")]
423 pub previous_link: Option<String>,
424 /// The starting index of the entries, which is 1 by default or otherwise specified by the start-index query parameter.
425 #[serde(rename = "startIndex")]
426 pub start_index: Option<i32>,
427 /// The total number of results for the query, regardless of the number of results in the response.
428 #[serde(rename = "totalResults")]
429 pub total_results: Option<i32>,
430 /// Email ID of the authenticated user
431 pub username: Option<String>,
432}
433
434impl common::ResponseResult for Accounts {}
435
436/// JSON template for an Google Ads account.
437///
438/// This type is not used in any activity, and only used as *part* of another schema.
439///
440#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
441#[serde_with::serde_as]
442#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
443pub struct AdWordsAccount {
444 /// True if auto-tagging is enabled on the Google Ads account. Read-only after the insert operation.
445 #[serde(rename = "autoTaggingEnabled")]
446 pub auto_tagging_enabled: Option<bool>,
447 /// Customer ID. This field is required when creating a Google Ads link.
448 #[serde(rename = "customerId")]
449 pub customer_id: Option<String>,
450 /// Resource type for Google Ads account.
451 pub kind: Option<String>,
452}
453
454impl common::Part for AdWordsAccount {}
455
456/// Request template for the delete upload data request.
457///
458/// # Activities
459///
460/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
461/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
462///
463/// * [uploads delete upload data management](ManagementUploadDeleteUploadDataCall) (request)
464#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
465#[serde_with::serde_as]
466#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
467pub struct AnalyticsDataimportDeleteUploadDataRequest {
468 /// A list of upload UIDs.
469 #[serde(rename = "customDataImportUids")]
470 pub custom_data_import_uids: Option<Vec<String>>,
471}
472
473impl common::RequestValue for AnalyticsDataimportDeleteUploadDataRequest {}
474
475/// JSON template for a metadata column.
476///
477/// This type is not used in any activity, and only used as *part* of another schema.
478///
479#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
480#[serde_with::serde_as]
481#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
482pub struct Column {
483 /// Map of attribute name and value for this column.
484 pub attributes: Option<HashMap<String, String>>,
485 /// Column id.
486 pub id: Option<String>,
487 /// Resource type for Analytics column.
488 pub kind: Option<String>,
489}
490
491impl common::Part for Column {}
492
493/// Lists columns (dimensions and metrics) for a particular report type.
494///
495/// # Activities
496///
497/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
498/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
499///
500/// * [columns list metadata](MetadataColumnListCall) (response)
501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
502#[serde_with::serde_as]
503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
504pub struct Columns {
505 /// List of attributes names returned by columns.
506 #[serde(rename = "attributeNames")]
507 pub attribute_names: Option<Vec<String>>,
508 /// Etag of collection. This etag can be compared with the last response etag to check if response has changed.
509 pub etag: Option<String>,
510 /// List of columns for a report type.
511 pub items: Option<Vec<Column>>,
512 /// Collection type.
513 pub kind: Option<String>,
514 /// Total number of columns returned in the response.
515 #[serde(rename = "totalResults")]
516 pub total_results: Option<i32>,
517}
518
519impl common::ResponseResult for Columns {}
520
521/// JSON template for an Analytics custom data source.
522///
523/// This type is not used in any activity, and only used as *part* of another schema.
524///
525#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
526#[serde_with::serde_as]
527#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
528pub struct CustomDataSource {
529 /// Account ID to which this custom data source belongs.
530 #[serde(rename = "accountId")]
531 pub account_id: Option<String>,
532 /// no description provided
533 #[serde(rename = "childLink")]
534 pub child_link: Option<CustomDataSourceChildLink>,
535 /// Time this custom data source was created.
536 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
537 /// Description of custom data source.
538 pub description: Option<String>,
539 /// Custom data source ID.
540 pub id: Option<String>,
541 /// no description provided
542 #[serde(rename = "importBehavior")]
543 pub import_behavior: Option<String>,
544 /// Resource type for Analytics custom data source.
545 pub kind: Option<String>,
546 /// Name of this custom data source.
547 pub name: Option<String>,
548 /// Parent link for this custom data source. Points to the web property to which this custom data source belongs.
549 #[serde(rename = "parentLink")]
550 pub parent_link: Option<CustomDataSourceParentLink>,
551 /// IDs of views (profiles) linked to the custom data source.
552 #[serde(rename = "profilesLinked")]
553 pub profiles_linked: Option<Vec<String>>,
554 /// Collection of schema headers of the custom data source.
555 pub schema: Option<Vec<String>>,
556 /// Link for this Analytics custom data source.
557 #[serde(rename = "selfLink")]
558 pub self_link: Option<String>,
559 /// Type of the custom data source.
560 #[serde(rename = "type")]
561 pub type_: Option<String>,
562 /// Time this custom data source was last modified.
563 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
564 /// Upload type of the custom data source.
565 #[serde(rename = "uploadType")]
566 pub upload_type: Option<String>,
567 /// Web property ID of the form UA-XXXXX-YY to which this custom data source belongs.
568 #[serde(rename = "webPropertyId")]
569 pub web_property_id: Option<String>,
570}
571
572impl common::Part for CustomDataSource {}
573
574/// Lists Analytics custom data sources to which the user has access. Each resource in the collection corresponds to a single Analytics custom data source.
575///
576/// # Activities
577///
578/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
579/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
580///
581/// * [custom data sources list management](ManagementCustomDataSourceListCall) (response)
582#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
583#[serde_with::serde_as]
584#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
585pub struct CustomDataSources {
586 /// Collection of custom data sources.
587 pub items: Option<Vec<CustomDataSource>>,
588 /// 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.
589 #[serde(rename = "itemsPerPage")]
590 pub items_per_page: Option<i32>,
591 /// Collection type.
592 pub kind: Option<String>,
593 /// Link to next page for this custom data source collection.
594 #[serde(rename = "nextLink")]
595 pub next_link: Option<String>,
596 /// Link to previous page for this custom data source collection.
597 #[serde(rename = "previousLink")]
598 pub previous_link: Option<String>,
599 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
600 #[serde(rename = "startIndex")]
601 pub start_index: Option<i32>,
602 /// The total number of results for the query, regardless of the number of results in the response.
603 #[serde(rename = "totalResults")]
604 pub total_results: Option<i32>,
605 /// Email ID of the authenticated user
606 pub username: Option<String>,
607}
608
609impl common::ResponseResult for CustomDataSources {}
610
611/// JSON template for Analytics Custom Dimension.
612///
613/// # Activities
614///
615/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
616/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
617///
618/// * [custom dimensions get management](ManagementCustomDimensionGetCall) (response)
619/// * [custom dimensions insert management](ManagementCustomDimensionInsertCall) (request|response)
620/// * [custom dimensions patch management](ManagementCustomDimensionPatchCall) (request|response)
621/// * [custom dimensions update management](ManagementCustomDimensionUpdateCall) (request|response)
622#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
623#[serde_with::serde_as]
624#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
625pub struct CustomDimension {
626 /// Account ID.
627 #[serde(rename = "accountId")]
628 pub account_id: Option<String>,
629 /// Boolean indicating whether the custom dimension is active.
630 pub active: Option<bool>,
631 /// Time the custom dimension was created.
632 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
633 /// Custom dimension ID.
634 pub id: Option<String>,
635 /// Index of the custom dimension.
636 pub index: Option<i32>,
637 /// Kind value for a custom dimension. Set to "analytics#customDimension". It is a read-only field.
638 pub kind: Option<String>,
639 /// Name of the custom dimension.
640 pub name: Option<String>,
641 /// Parent link for the custom dimension. Points to the property to which the custom dimension belongs.
642 #[serde(rename = "parentLink")]
643 pub parent_link: Option<CustomDimensionParentLink>,
644 /// Scope of the custom dimension: HIT, SESSION, USER or PRODUCT.
645 pub scope: Option<String>,
646 /// Link for the custom dimension
647 #[serde(rename = "selfLink")]
648 pub self_link: Option<String>,
649 /// Time the custom dimension was last modified.
650 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
651 /// Property ID.
652 #[serde(rename = "webPropertyId")]
653 pub web_property_id: Option<String>,
654}
655
656impl common::RequestValue for CustomDimension {}
657impl common::ResponseResult for CustomDimension {}
658
659/// 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.
660///
661/// # Activities
662///
663/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
664/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
665///
666/// * [custom dimensions list management](ManagementCustomDimensionListCall) (response)
667#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
668#[serde_with::serde_as]
669#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
670pub struct CustomDimensions {
671 /// Collection of custom dimensions.
672 pub items: Option<Vec<CustomDimension>>,
673 /// 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.
674 #[serde(rename = "itemsPerPage")]
675 pub items_per_page: Option<i32>,
676 /// Collection type.
677 pub kind: Option<String>,
678 /// Link to next page for this custom dimension collection.
679 #[serde(rename = "nextLink")]
680 pub next_link: Option<String>,
681 /// Link to previous page for this custom dimension collection.
682 #[serde(rename = "previousLink")]
683 pub previous_link: Option<String>,
684 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
685 #[serde(rename = "startIndex")]
686 pub start_index: Option<i32>,
687 /// The total number of results for the query, regardless of the number of results in the response.
688 #[serde(rename = "totalResults")]
689 pub total_results: Option<i32>,
690 /// Email ID of the authenticated user
691 pub username: Option<String>,
692}
693
694impl common::ResponseResult for CustomDimensions {}
695
696/// JSON template for Analytics Custom Metric.
697///
698/// # Activities
699///
700/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
701/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
702///
703/// * [custom metrics get management](ManagementCustomMetricGetCall) (response)
704/// * [custom metrics insert management](ManagementCustomMetricInsertCall) (request|response)
705/// * [custom metrics patch management](ManagementCustomMetricPatchCall) (request|response)
706/// * [custom metrics update management](ManagementCustomMetricUpdateCall) (request|response)
707#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
708#[serde_with::serde_as]
709#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
710pub struct CustomMetric {
711 /// Account ID.
712 #[serde(rename = "accountId")]
713 pub account_id: Option<String>,
714 /// Boolean indicating whether the custom metric is active.
715 pub active: Option<bool>,
716 /// Time the custom metric was created.
717 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
718 /// Custom metric ID.
719 pub id: Option<String>,
720 /// Index of the custom metric.
721 pub index: Option<i32>,
722 /// Kind value for a custom metric. Set to "analytics#customMetric". It is a read-only field.
723 pub kind: Option<String>,
724 /// Max value of custom metric.
725 pub max_value: Option<String>,
726 /// Min value of custom metric.
727 pub min_value: Option<String>,
728 /// Name of the custom metric.
729 pub name: Option<String>,
730 /// Parent link for the custom metric. Points to the property to which the custom metric belongs.
731 #[serde(rename = "parentLink")]
732 pub parent_link: Option<CustomMetricParentLink>,
733 /// Scope of the custom metric: HIT or PRODUCT.
734 pub scope: Option<String>,
735 /// Link for the custom metric
736 #[serde(rename = "selfLink")]
737 pub self_link: Option<String>,
738 /// Data type of custom metric.
739 #[serde(rename = "type")]
740 pub type_: Option<String>,
741 /// Time the custom metric was last modified.
742 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
743 /// Property ID.
744 #[serde(rename = "webPropertyId")]
745 pub web_property_id: Option<String>,
746}
747
748impl common::RequestValue for CustomMetric {}
749impl common::ResponseResult for CustomMetric {}
750
751/// 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.
752///
753/// # Activities
754///
755/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
756/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
757///
758/// * [custom metrics list management](ManagementCustomMetricListCall) (response)
759#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
760#[serde_with::serde_as]
761#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
762pub struct CustomMetrics {
763 /// Collection of custom metrics.
764 pub items: Option<Vec<CustomMetric>>,
765 /// 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.
766 #[serde(rename = "itemsPerPage")]
767 pub items_per_page: Option<i32>,
768 /// Collection type.
769 pub kind: Option<String>,
770 /// Link to next page for this custom metric collection.
771 #[serde(rename = "nextLink")]
772 pub next_link: Option<String>,
773 /// Link to previous page for this custom metric collection.
774 #[serde(rename = "previousLink")]
775 pub previous_link: Option<String>,
776 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
777 #[serde(rename = "startIndex")]
778 pub start_index: Option<i32>,
779 /// The total number of results for the query, regardless of the number of results in the response.
780 #[serde(rename = "totalResults")]
781 pub total_results: Option<i32>,
782 /// Email ID of the authenticated user
783 pub username: Option<String>,
784}
785
786impl common::ResponseResult for CustomMetrics {}
787
788/// JSON template for Analytics Entity Google Ads Link.
789///
790/// # Activities
791///
792/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
793/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
794///
795/// * [web property ad words links get management](ManagementWebPropertyAdWordsLinkGetCall) (response)
796/// * [web property ad words links insert management](ManagementWebPropertyAdWordsLinkInsertCall) (request|response)
797/// * [web property ad words links patch management](ManagementWebPropertyAdWordsLinkPatchCall) (request|response)
798/// * [web property ad words links update management](ManagementWebPropertyAdWordsLinkUpdateCall) (request|response)
799#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
800#[serde_with::serde_as]
801#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
802pub struct EntityAdWordsLink {
803 /// 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.
804 #[serde(rename = "adWordsAccounts")]
805 pub ad_words_accounts: Option<Vec<AdWordsAccount>>,
806 /// Web property being linked.
807 pub entity: Option<EntityAdWordsLinkEntity>,
808 /// Entity Google Ads link ID
809 pub id: Option<String>,
810 /// Resource type for entity Google Ads link.
811 pub kind: Option<String>,
812 /// Name of the link. This field is required when creating a Google Ads link.
813 pub name: Option<String>,
814 /// IDs of linked Views (Profiles) represented as strings.
815 #[serde(rename = "profileIds")]
816 pub profile_ids: Option<Vec<String>>,
817 /// URL link for this Google Analytics - Google Ads link.
818 #[serde(rename = "selfLink")]
819 pub self_link: Option<String>,
820}
821
822impl common::RequestValue for EntityAdWordsLink {}
823impl common::ResponseResult for EntityAdWordsLink {}
824
825/// An entity Google Ads link collection provides a list of GA-Google Ads links Each resource in this collection corresponds to a single link.
826///
827/// # Activities
828///
829/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
830/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
831///
832/// * [web property ad words links list management](ManagementWebPropertyAdWordsLinkListCall) (response)
833#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
834#[serde_with::serde_as]
835#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
836pub struct EntityAdWordsLinks {
837 /// A list of entity Google Ads links.
838 pub items: Option<Vec<EntityAdWordsLink>>,
839 /// 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.
840 #[serde(rename = "itemsPerPage")]
841 pub items_per_page: Option<i32>,
842 /// Collection type.
843 pub kind: Option<String>,
844 /// Next link for this Google Ads link collection.
845 #[serde(rename = "nextLink")]
846 pub next_link: Option<String>,
847 /// Previous link for this Google Ads link collection.
848 #[serde(rename = "previousLink")]
849 pub previous_link: Option<String>,
850 /// The starting index of the entries, which is 1 by default or otherwise specified by the start-index query parameter.
851 #[serde(rename = "startIndex")]
852 pub start_index: Option<i32>,
853 /// The total number of results for the query, regardless of the number of results in the response.
854 #[serde(rename = "totalResults")]
855 pub total_results: Option<i32>,
856}
857
858impl common::ResponseResult for EntityAdWordsLinks {}
859
860/// JSON template for an Analytics Entity-User Link. Returns permissions that a user has for an entity.
861///
862/// # Activities
863///
864/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
865/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
866///
867/// * [account user links insert management](ManagementAccountUserLinkInsertCall) (request|response)
868/// * [account user links update management](ManagementAccountUserLinkUpdateCall) (request|response)
869/// * [profile user links insert management](ManagementProfileUserLinkInsertCall) (request|response)
870/// * [profile user links update management](ManagementProfileUserLinkUpdateCall) (request|response)
871/// * [webproperty user links insert management](ManagementWebpropertyUserLinkInsertCall) (request|response)
872/// * [webproperty user links update management](ManagementWebpropertyUserLinkUpdateCall) (request|response)
873#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
874#[serde_with::serde_as]
875#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
876pub struct EntityUserLink {
877 /// Entity for this link. It can be an account, a web property, or a view (profile).
878 pub entity: Option<EntityUserLinkEntity>,
879 /// Entity user link ID
880 pub id: Option<String>,
881 /// Resource type for entity user link.
882 pub kind: Option<String>,
883 /// Permissions the user has for this entity.
884 pub permissions: Option<EntityUserLinkPermissions>,
885 /// Self link for this resource.
886 #[serde(rename = "selfLink")]
887 pub self_link: Option<String>,
888 /// User reference.
889 #[serde(rename = "userRef")]
890 pub user_ref: Option<UserRef>,
891}
892
893impl common::RequestValue for EntityUserLink {}
894impl common::ResponseResult for EntityUserLink {}
895
896/// An entity user link collection provides a list of Analytics ACL links Each resource in this collection corresponds to a single link.
897///
898/// # Activities
899///
900/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
901/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
902///
903/// * [account user links list management](ManagementAccountUserLinkListCall) (response)
904/// * [profile user links list management](ManagementProfileUserLinkListCall) (response)
905/// * [webproperty user links list management](ManagementWebpropertyUserLinkListCall) (response)
906#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
907#[serde_with::serde_as]
908#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
909pub struct EntityUserLinks {
910 /// A list of entity user links.
911 pub items: Option<Vec<EntityUserLink>>,
912 /// 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.
913 #[serde(rename = "itemsPerPage")]
914 pub items_per_page: Option<i32>,
915 /// Collection type.
916 pub kind: Option<String>,
917 /// Next link for this account collection.
918 #[serde(rename = "nextLink")]
919 pub next_link: Option<String>,
920 /// Previous link for this account collection.
921 #[serde(rename = "previousLink")]
922 pub previous_link: Option<String>,
923 /// The starting index of the entries, which is 1 by default or otherwise specified by the start-index query parameter.
924 #[serde(rename = "startIndex")]
925 pub start_index: Option<i32>,
926 /// The total number of results for the query, regardless of the number of results in the response.
927 #[serde(rename = "totalResults")]
928 pub total_results: Option<i32>,
929}
930
931impl common::ResponseResult for EntityUserLinks {}
932
933/// JSON template for Analytics experiment resource.
934///
935/// # Activities
936///
937/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
938/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
939///
940/// * [experiments get management](ManagementExperimentGetCall) (response)
941/// * [experiments insert management](ManagementExperimentInsertCall) (request|response)
942/// * [experiments patch management](ManagementExperimentPatchCall) (request|response)
943/// * [experiments update management](ManagementExperimentUpdateCall) (request|response)
944#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
945#[serde_with::serde_as]
946#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
947pub struct Experiment {
948 /// Account ID to which this experiment belongs. This field is read-only.
949 #[serde(rename = "accountId")]
950 pub account_id: Option<String>,
951 /// Time the experiment was created. This field is read-only.
952 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
953 /// Notes about this experiment.
954 pub description: Option<String>,
955 /// If true, the end user will be able to edit the experiment via the Google Analytics user interface.
956 #[serde(rename = "editableInGaUi")]
957 pub editable_in_ga_ui: Option<bool>,
958 /// 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.
959 #[serde(rename = "endTime")]
960 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
961 /// 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.
962 #[serde(rename = "equalWeighting")]
963 pub equal_weighting: Option<bool>,
964 /// Experiment ID. Required for patch and update. Disallowed for create.
965 pub id: Option<String>,
966 /// Internal ID for the web property to which this experiment belongs. This field is read-only.
967 #[serde(rename = "internalWebPropertyId")]
968 pub internal_web_property_id: Option<String>,
969 /// Resource type for an Analytics experiment. This field is read-only.
970 pub kind: Option<String>,
971 /// 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.
972 #[serde(rename = "minimumExperimentLengthInDays")]
973 pub minimum_experiment_length_in_days: Option<i32>,
974 /// Experiment name. This field may not be changed for an experiment whose status is ENDED. This field is required when creating an experiment.
975 pub name: Option<String>,
976 /// 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".
977 #[serde(rename = "objectiveMetric")]
978 pub objective_metric: Option<String>,
979 /// 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".
980 #[serde(rename = "optimizationType")]
981 pub optimization_type: Option<String>,
982 /// Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
983 #[serde(rename = "parentLink")]
984 pub parent_link: Option<ExperimentParentLink>,
985 /// View (Profile) ID to which this experiment belongs. This field is read-only.
986 #[serde(rename = "profileId")]
987 pub profile_id: Option<String>,
988 /// 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.
989 #[serde(rename = "reasonExperimentEnded")]
990 pub reason_experiment_ended: Option<String>,
991 /// 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.
992 #[serde(rename = "rewriteVariationUrlsAsOriginal")]
993 pub rewrite_variation_urls_as_original: Option<bool>,
994 /// Link for this experiment. This field is read-only.
995 #[serde(rename = "selfLink")]
996 pub self_link: Option<String>,
997 /// The framework used to serve the experiment variations and evaluate the results. One of:
998 /// - REDIRECT: Google Analytics redirects traffic to different variation pages, reports the chosen variation and evaluates the results.
999 /// - API: Google Analytics chooses and reports the variation to serve and evaluates the results; the caller is responsible for serving the selected variation.
1000 /// - 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.
1001 #[serde(rename = "servingFramework")]
1002 pub serving_framework: Option<String>,
1003 /// The snippet of code to include on the control page(s). This field is read-only.
1004 pub snippet: Option<String>,
1005 /// 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.
1006 #[serde(rename = "startTime")]
1007 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1008 /// 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.
1009 pub status: Option<String>,
1010 /// 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.
1011 #[serde(rename = "trafficCoverage")]
1012 pub traffic_coverage: Option<f64>,
1013 /// Time the experiment was last modified. This field is read-only.
1014 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1015 /// 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.
1016 pub variations: Option<Vec<ExperimentVariations>>,
1017 /// Web property ID to which this experiment belongs. The web property ID is of the form UA-XXXXX-YY. This field is read-only.
1018 #[serde(rename = "webPropertyId")]
1019 pub web_property_id: Option<String>,
1020 /// 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.
1021 #[serde(rename = "winnerConfidenceLevel")]
1022 pub winner_confidence_level: Option<f64>,
1023 /// Boolean specifying whether a winner has been found for this experiment. This field is read-only.
1024 #[serde(rename = "winnerFound")]
1025 pub winner_found: Option<bool>,
1026}
1027
1028impl common::RequestValue for Experiment {}
1029impl common::ResponseResult for Experiment {}
1030
1031/// 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.
1032///
1033/// # Activities
1034///
1035/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1036/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1037///
1038/// * [experiments list management](ManagementExperimentListCall) (response)
1039#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1040#[serde_with::serde_as]
1041#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1042pub struct Experiments {
1043 /// A list of experiments.
1044 pub items: Option<Vec<Experiment>>,
1045 /// 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.
1046 #[serde(rename = "itemsPerPage")]
1047 pub items_per_page: Option<i32>,
1048 /// Collection type.
1049 pub kind: Option<String>,
1050 /// Link to next page for this experiment collection.
1051 #[serde(rename = "nextLink")]
1052 pub next_link: Option<String>,
1053 /// Link to previous page for this experiment collection.
1054 #[serde(rename = "previousLink")]
1055 pub previous_link: Option<String>,
1056 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
1057 #[serde(rename = "startIndex")]
1058 pub start_index: Option<i32>,
1059 /// The total number of results for the query, regardless of the number of resources in the result.
1060 #[serde(rename = "totalResults")]
1061 pub total_results: Option<i32>,
1062 /// Email ID of the authenticated user
1063 pub username: Option<String>,
1064}
1065
1066impl common::ResponseResult for Experiments {}
1067
1068/// JSON template for an Analytics account filter.
1069///
1070/// # Activities
1071///
1072/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1073/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1074///
1075/// * [filters delete management](ManagementFilterDeleteCall) (response)
1076/// * [filters get management](ManagementFilterGetCall) (response)
1077/// * [filters insert management](ManagementFilterInsertCall) (request|response)
1078/// * [filters patch management](ManagementFilterPatchCall) (request|response)
1079/// * [filters update management](ManagementFilterUpdateCall) (request|response)
1080#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1081#[serde_with::serde_as]
1082#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1083pub struct Filter {
1084 /// Account ID to which this filter belongs.
1085 #[serde(rename = "accountId")]
1086 pub account_id: Option<String>,
1087 /// Details for the filter of the type ADVANCED.
1088 #[serde(rename = "advancedDetails")]
1089 pub advanced_details: Option<FilterAdvancedDetails>,
1090 /// Time this filter was created.
1091 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
1092 /// Details for the filter of the type EXCLUDE.
1093 #[serde(rename = "excludeDetails")]
1094 pub exclude_details: Option<FilterExpression>,
1095 /// Filter ID.
1096 pub id: Option<String>,
1097 /// Details for the filter of the type INCLUDE.
1098 #[serde(rename = "includeDetails")]
1099 pub include_details: Option<FilterExpression>,
1100 /// Resource type for Analytics filter.
1101 pub kind: Option<String>,
1102 /// Details for the filter of the type LOWER.
1103 #[serde(rename = "lowercaseDetails")]
1104 pub lowercase_details: Option<FilterLowercaseDetails>,
1105 /// Name of this filter.
1106 pub name: Option<String>,
1107 /// Parent link for this filter. Points to the account to which this filter belongs.
1108 #[serde(rename = "parentLink")]
1109 pub parent_link: Option<FilterParentLink>,
1110 /// Details for the filter of the type SEARCH_AND_REPLACE.
1111 #[serde(rename = "searchAndReplaceDetails")]
1112 pub search_and_replace_details: Option<FilterSearchAndReplaceDetails>,
1113 /// Link for this filter.
1114 #[serde(rename = "selfLink")]
1115 pub self_link: Option<String>,
1116 /// Type of this filter. Possible values are INCLUDE, EXCLUDE, LOWERCASE, UPPERCASE, SEARCH_AND_REPLACE and ADVANCED.
1117 #[serde(rename = "type")]
1118 pub type_: Option<String>,
1119 /// Time this filter was last modified.
1120 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1121 /// Details for the filter of the type UPPER.
1122 #[serde(rename = "uppercaseDetails")]
1123 pub uppercase_details: Option<FilterUppercaseDetails>,
1124}
1125
1126impl common::RequestValue for Filter {}
1127impl common::ResponseResult for Filter {}
1128
1129/// JSON template for an Analytics filter expression.
1130///
1131/// This type is not used in any activity, and only used as *part* of another schema.
1132///
1133#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1134#[serde_with::serde_as]
1135#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1136pub struct FilterExpression {
1137 /// Determines if the filter is case sensitive.
1138 #[serde(rename = "caseSensitive")]
1139 pub case_sensitive: Option<bool>,
1140 /// Filter expression value
1141 #[serde(rename = "expressionValue")]
1142 pub expression_value: Option<String>,
1143 /// Field to filter. Possible values:
1144 /// - Content and Traffic
1145 /// - PAGE_REQUEST_URI,
1146 /// - PAGE_HOSTNAME,
1147 /// - PAGE_TITLE,
1148 /// - REFERRAL,
1149 /// - COST_DATA_URI (Campaign target URL),
1150 /// - HIT_TYPE,
1151 /// - INTERNAL_SEARCH_TERM,
1152 /// - INTERNAL_SEARCH_TYPE,
1153 /// - SOURCE_PROPERTY_TRACKING_ID,
1154 /// - Campaign or AdGroup
1155 /// - CAMPAIGN_SOURCE,
1156 /// - CAMPAIGN_MEDIUM,
1157 /// - CAMPAIGN_NAME,
1158 /// - CAMPAIGN_AD_GROUP,
1159 /// - CAMPAIGN_TERM,
1160 /// - CAMPAIGN_CONTENT,
1161 /// - CAMPAIGN_CODE,
1162 /// - CAMPAIGN_REFERRAL_PATH,
1163 /// - E-Commerce
1164 /// - TRANSACTION_COUNTRY,
1165 /// - TRANSACTION_REGION,
1166 /// - TRANSACTION_CITY,
1167 /// - TRANSACTION_AFFILIATION (Store or order location),
1168 /// - ITEM_NAME,
1169 /// - ITEM_CODE,
1170 /// - ITEM_VARIATION,
1171 /// - TRANSACTION_ID,
1172 /// - TRANSACTION_CURRENCY_CODE,
1173 /// - PRODUCT_ACTION_TYPE,
1174 /// - Audience/Users
1175 /// - BROWSER,
1176 /// - BROWSER_VERSION,
1177 /// - BROWSER_SIZE,
1178 /// - PLATFORM,
1179 /// - PLATFORM_VERSION,
1180 /// - LANGUAGE,
1181 /// - SCREEN_RESOLUTION,
1182 /// - SCREEN_COLORS,
1183 /// - JAVA_ENABLED (Boolean Field),
1184 /// - FLASH_VERSION,
1185 /// - GEO_SPEED (Connection speed),
1186 /// - VISITOR_TYPE,
1187 /// - GEO_ORGANIZATION (ISP organization),
1188 /// - GEO_DOMAIN,
1189 /// - GEO_IP_ADDRESS,
1190 /// - GEO_IP_VERSION,
1191 /// - Location
1192 /// - GEO_COUNTRY,
1193 /// - GEO_REGION,
1194 /// - GEO_CITY,
1195 /// - Event
1196 /// - EVENT_CATEGORY,
1197 /// - EVENT_ACTION,
1198 /// - EVENT_LABEL,
1199 /// - Other
1200 /// - CUSTOM_FIELD_1,
1201 /// - CUSTOM_FIELD_2,
1202 /// - USER_DEFINED_VALUE,
1203 /// - Application
1204 /// - APP_ID,
1205 /// - APP_INSTALLER_ID,
1206 /// - APP_NAME,
1207 /// - APP_VERSION,
1208 /// - SCREEN,
1209 /// - IS_APP (Boolean Field),
1210 /// - IS_FATAL_EXCEPTION (Boolean Field),
1211 /// - EXCEPTION_DESCRIPTION,
1212 /// - Mobile device
1213 /// - IS_MOBILE (Boolean Field, Deprecated. Use DEVICE_CATEGORY=mobile),
1214 /// - IS_TABLET (Boolean Field, Deprecated. Use DEVICE_CATEGORY=tablet),
1215 /// - DEVICE_CATEGORY,
1216 /// - MOBILE_HAS_QWERTY_KEYBOARD (Boolean Field),
1217 /// - MOBILE_HAS_NFC_SUPPORT (Boolean Field),
1218 /// - MOBILE_HAS_CELLULAR_RADIO (Boolean Field),
1219 /// - MOBILE_HAS_WIFI_SUPPORT (Boolean Field),
1220 /// - MOBILE_BRAND_NAME,
1221 /// - MOBILE_MODEL_NAME,
1222 /// - MOBILE_MARKETING_NAME,
1223 /// - MOBILE_POINTING_METHOD,
1224 /// - Social
1225 /// - SOCIAL_NETWORK,
1226 /// - SOCIAL_ACTION,
1227 /// - SOCIAL_ACTION_TARGET,
1228 /// - Custom dimension
1229 /// - CUSTOM_DIMENSION (See accompanying field index),
1230 pub field: Option<String>,
1231 /// The Index of the custom dimension. Set only if the field is a is CUSTOM_DIMENSION.
1232 #[serde(rename = "fieldIndex")]
1233 pub field_index: Option<i32>,
1234 /// Kind value for filter expression
1235 pub kind: Option<String>,
1236 /// 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.
1237 #[serde(rename = "matchType")]
1238 pub match_type: Option<String>,
1239}
1240
1241impl common::Part for FilterExpression {}
1242
1243/// JSON template for a profile filter link.
1244///
1245/// This type is not used in any activity, and only used as *part* of another schema.
1246///
1247#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1248#[serde_with::serde_as]
1249#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1250pub struct FilterRef {
1251 /// Account ID to which this filter belongs.
1252 #[serde(rename = "accountId")]
1253 pub account_id: Option<String>,
1254 /// Link for this filter.
1255 pub href: Option<String>,
1256 /// Filter ID.
1257 pub id: Option<String>,
1258 /// Kind value for filter reference.
1259 pub kind: Option<String>,
1260 /// Name of this filter.
1261 pub name: Option<String>,
1262}
1263
1264impl common::Part for FilterRef {}
1265
1266/// A filter collection lists filters created by users in an Analytics account. Each resource in the collection corresponds to a filter.
1267///
1268/// # Activities
1269///
1270/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1271/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1272///
1273/// * [filters list management](ManagementFilterListCall) (response)
1274#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1275#[serde_with::serde_as]
1276#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1277pub struct Filters {
1278 /// A list of filters.
1279 pub items: Option<Vec<Filter>>,
1280 /// 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.
1281 #[serde(rename = "itemsPerPage")]
1282 pub items_per_page: Option<i32>,
1283 /// Collection type.
1284 pub kind: Option<String>,
1285 /// Link to next page for this filter collection.
1286 #[serde(rename = "nextLink")]
1287 pub next_link: Option<String>,
1288 /// Link to previous page for this filter collection.
1289 #[serde(rename = "previousLink")]
1290 pub previous_link: Option<String>,
1291 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
1292 #[serde(rename = "startIndex")]
1293 pub start_index: Option<i32>,
1294 /// The total number of results for the query, regardless of the number of results in the response.
1295 #[serde(rename = "totalResults")]
1296 pub total_results: Option<i32>,
1297 /// Email ID of the authenticated user
1298 pub username: Option<String>,
1299}
1300
1301impl common::ResponseResult for Filters {}
1302
1303/// Analytics data for a given view (profile).
1304///
1305/// # Activities
1306///
1307/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1308/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1309///
1310/// * [ga get data](DataGaGetCall) (response)
1311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1312#[serde_with::serde_as]
1313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1314pub struct GaData {
1315 /// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
1316 #[serde(rename = "columnHeaders")]
1317 pub column_headers: Option<Vec<GaDataColumnHeaders>>,
1318 /// Determines if Analytics data contains samples.
1319 #[serde(rename = "containsSampledData")]
1320 pub contains_sampled_data: Option<bool>,
1321 /// The last refreshed time in seconds for Analytics data.
1322 #[serde(rename = "dataLastRefreshed")]
1323 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1324 pub data_last_refreshed: Option<i64>,
1325 /// no description provided
1326 #[serde(rename = "dataTable")]
1327 pub data_table: Option<GaDataDataTable>,
1328 /// Unique ID for this data response.
1329 pub id: Option<String>,
1330 /// 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.
1331 #[serde(rename = "itemsPerPage")]
1332 pub items_per_page: Option<i32>,
1333 /// Resource type.
1334 pub kind: Option<String>,
1335 /// Link to next page for this Analytics data query.
1336 #[serde(rename = "nextLink")]
1337 pub next_link: Option<String>,
1338 /// Link to previous page for this Analytics data query.
1339 #[serde(rename = "previousLink")]
1340 pub previous_link: Option<String>,
1341 /// Information for the view (profile), for which the Analytics data was requested.
1342 #[serde(rename = "profileInfo")]
1343 pub profile_info: Option<GaDataProfileInfo>,
1344 /// Analytics data request query parameters.
1345 pub query: Option<GaDataQuery>,
1346 /// 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.
1347 pub rows: Option<Vec<Vec<String>>>,
1348 /// The number of samples used to calculate the result.
1349 #[serde(rename = "sampleSize")]
1350 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1351 pub sample_size: Option<i64>,
1352 /// Total size of the sample space from which the samples were selected.
1353 #[serde(rename = "sampleSpace")]
1354 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1355 pub sample_space: Option<i64>,
1356 /// Link to this page.
1357 #[serde(rename = "selfLink")]
1358 pub self_link: Option<String>,
1359 /// The total number of rows for the query, regardless of the number of rows in the response.
1360 #[serde(rename = "totalResults")]
1361 pub total_results: Option<i32>,
1362 /// 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.
1363 #[serde(rename = "totalsForAllResults")]
1364 pub totals_for_all_results: Option<HashMap<String, String>>,
1365}
1366
1367impl common::ResponseResult for GaData {}
1368
1369/// JSON template for Analytics goal resource.
1370///
1371/// # Activities
1372///
1373/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1374/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1375///
1376/// * [goals get management](ManagementGoalGetCall) (response)
1377/// * [goals insert management](ManagementGoalInsertCall) (request|response)
1378/// * [goals patch management](ManagementGoalPatchCall) (request|response)
1379/// * [goals update management](ManagementGoalUpdateCall) (request|response)
1380#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1381#[serde_with::serde_as]
1382#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1383pub struct Goal {
1384 /// Account ID to which this goal belongs.
1385 #[serde(rename = "accountId")]
1386 pub account_id: Option<String>,
1387 /// Determines whether this goal is active.
1388 pub active: Option<bool>,
1389 /// Time this goal was created.
1390 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
1391 /// Details for the goal of the type EVENT.
1392 #[serde(rename = "eventDetails")]
1393 pub event_details: Option<GoalEventDetails>,
1394 /// Goal ID.
1395 pub id: Option<String>,
1396 /// Internal ID for the web property to which this goal belongs.
1397 #[serde(rename = "internalWebPropertyId")]
1398 pub internal_web_property_id: Option<String>,
1399 /// Resource type for an Analytics goal.
1400 pub kind: Option<String>,
1401 /// Goal name.
1402 pub name: Option<String>,
1403 /// Parent link for a goal. Points to the view (profile) to which this goal belongs.
1404 #[serde(rename = "parentLink")]
1405 pub parent_link: Option<GoalParentLink>,
1406 /// View (Profile) ID to which this goal belongs.
1407 #[serde(rename = "profileId")]
1408 pub profile_id: Option<String>,
1409 /// Link for this goal.
1410 #[serde(rename = "selfLink")]
1411 pub self_link: Option<String>,
1412 /// Goal type. Possible values are URL_DESTINATION, VISIT_TIME_ON_SITE, VISIT_NUM_PAGES, AND EVENT.
1413 #[serde(rename = "type")]
1414 pub type_: Option<String>,
1415 /// Time this goal was last modified.
1416 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1417 /// Details for the goal of the type URL_DESTINATION.
1418 #[serde(rename = "urlDestinationDetails")]
1419 pub url_destination_details: Option<GoalUrlDestinationDetails>,
1420 /// Goal value.
1421 pub value: Option<f32>,
1422 /// Details for the goal of the type VISIT_NUM_PAGES.
1423 #[serde(rename = "visitNumPagesDetails")]
1424 pub visit_num_pages_details: Option<GoalVisitNumPagesDetails>,
1425 /// Details for the goal of the type VISIT_TIME_ON_SITE.
1426 #[serde(rename = "visitTimeOnSiteDetails")]
1427 pub visit_time_on_site_details: Option<GoalVisitTimeOnSiteDetails>,
1428 /// Web property ID to which this goal belongs. The web property ID is of the form UA-XXXXX-YY.
1429 #[serde(rename = "webPropertyId")]
1430 pub web_property_id: Option<String>,
1431}
1432
1433impl common::RequestValue for Goal {}
1434impl common::ResponseResult for Goal {}
1435
1436/// 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.
1437///
1438/// # Activities
1439///
1440/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1441/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1442///
1443/// * [goals list management](ManagementGoalListCall) (response)
1444#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1445#[serde_with::serde_as]
1446#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1447pub struct Goals {
1448 /// A list of goals.
1449 pub items: Option<Vec<Goal>>,
1450 /// 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.
1451 #[serde(rename = "itemsPerPage")]
1452 pub items_per_page: Option<i32>,
1453 /// Collection type.
1454 pub kind: Option<String>,
1455 /// Link to next page for this goal collection.
1456 #[serde(rename = "nextLink")]
1457 pub next_link: Option<String>,
1458 /// Link to previous page for this goal collection.
1459 #[serde(rename = "previousLink")]
1460 pub previous_link: Option<String>,
1461 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
1462 #[serde(rename = "startIndex")]
1463 pub start_index: Option<i32>,
1464 /// The total number of results for the query, regardless of the number of resources in the result.
1465 #[serde(rename = "totalResults")]
1466 pub total_results: Option<i32>,
1467 /// Email ID of the authenticated user
1468 pub username: Option<String>,
1469}
1470
1471impl common::ResponseResult for Goals {}
1472
1473/// JSON template for a hash Client Id request resource.
1474///
1475/// # Activities
1476///
1477/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1478/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1479///
1480/// * [client id hash client id management](ManagementClientIdHashClientIdCall) (request)
1481#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1482#[serde_with::serde_as]
1483#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1484pub struct HashClientIdRequest {
1485 /// no description provided
1486 #[serde(rename = "clientId")]
1487 pub client_id: Option<String>,
1488 /// no description provided
1489 pub kind: Option<String>,
1490 /// no description provided
1491 #[serde(rename = "webPropertyId")]
1492 pub web_property_id: Option<String>,
1493}
1494
1495impl common::RequestValue for HashClientIdRequest {}
1496
1497/// JSON template for a hash Client Id response resource.
1498///
1499/// # Activities
1500///
1501/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1502/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1503///
1504/// * [client id hash client id management](ManagementClientIdHashClientIdCall) (response)
1505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1506#[serde_with::serde_as]
1507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1508pub struct HashClientIdResponse {
1509 /// no description provided
1510 #[serde(rename = "clientId")]
1511 pub client_id: Option<String>,
1512 /// no description provided
1513 #[serde(rename = "hashedClientId")]
1514 pub hashed_client_id: Option<String>,
1515 /// no description provided
1516 pub kind: Option<String>,
1517 /// no description provided
1518 #[serde(rename = "webPropertyId")]
1519 pub web_property_id: Option<String>,
1520}
1521
1522impl common::ResponseResult for HashClientIdResponse {}
1523
1524/// JSON template for an Analytics Remarketing Include Conditions.
1525///
1526/// This type is not used in any activity, and only used as *part* of another schema.
1527///
1528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1529#[serde_with::serde_as]
1530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1531pub struct IncludeConditions {
1532 /// 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.
1533 #[serde(rename = "daysToLookBack")]
1534 pub days_to_look_back: Option<i32>,
1535 /// Boolean indicating whether this segment is a smart list. https://support.google.com/analytics/answer/4628577
1536 #[serde(rename = "isSmartList")]
1537 pub is_smart_list: Option<bool>,
1538 /// Resource type for include conditions.
1539 pub kind: Option<String>,
1540 /// Number of days (in the range 1 to 540) a user remains in the audience.
1541 #[serde(rename = "membershipDurationDays")]
1542 pub membership_duration_days: Option<i32>,
1543 /// The segment condition that will cause a user to be added to an audience.
1544 pub segment: Option<String>,
1545}
1546
1547impl common::Part for IncludeConditions {}
1548
1549/// JSON template for an Analytics Remarketing Audience Foreign Link.
1550///
1551/// This type is not used in any activity, and only used as *part* of another schema.
1552///
1553#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1554#[serde_with::serde_as]
1555#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1556pub struct LinkedForeignAccount {
1557 /// Account ID to which this linked foreign account belongs.
1558 #[serde(rename = "accountId")]
1559 pub account_id: Option<String>,
1560 /// Boolean indicating whether this is eligible for search.
1561 #[serde(rename = "eligibleForSearch")]
1562 pub eligible_for_search: Option<bool>,
1563 /// Entity ad account link ID.
1564 pub id: Option<String>,
1565 /// Internal ID for the web property to which this linked foreign account belongs.
1566 #[serde(rename = "internalWebPropertyId")]
1567 pub internal_web_property_id: Option<String>,
1568 /// Resource type for linked foreign account.
1569 pub kind: Option<String>,
1570 /// The foreign account ID. For example the an Google Ads `linkedAccountId` has the following format XXX-XXX-XXXX.
1571 #[serde(rename = "linkedAccountId")]
1572 pub linked_account_id: Option<String>,
1573 /// Remarketing audience ID to which this linked foreign account belongs.
1574 #[serde(rename = "remarketingAudienceId")]
1575 pub remarketing_audience_id: Option<String>,
1576 /// The status of this foreign account link.
1577 pub status: Option<String>,
1578 /// The type of the foreign account. For example, `ADWORDS_LINKS`, `DBM_LINKS`, `MCC_LINKS` or `OPTIMIZE`.
1579 #[serde(rename = "type")]
1580 pub type_: Option<String>,
1581 /// Web property ID of the form UA-XXXXX-YY to which this linked foreign account belongs.
1582 #[serde(rename = "webPropertyId")]
1583 pub web_property_id: Option<String>,
1584}
1585
1586impl common::Part for LinkedForeignAccount {}
1587
1588/// Multi-Channel Funnels data for a given view (profile).
1589///
1590/// # Activities
1591///
1592/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1593/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1594///
1595/// * [mcf get data](DataMcfGetCall) (response)
1596#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1597#[serde_with::serde_as]
1598#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1599pub struct McfData {
1600 /// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
1601 #[serde(rename = "columnHeaders")]
1602 pub column_headers: Option<Vec<McfDataColumnHeaders>>,
1603 /// Determines if the Analytics data contains sampled data.
1604 #[serde(rename = "containsSampledData")]
1605 pub contains_sampled_data: Option<bool>,
1606 /// Unique ID for this data response.
1607 pub id: Option<String>,
1608 /// 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.
1609 #[serde(rename = "itemsPerPage")]
1610 pub items_per_page: Option<i32>,
1611 /// Resource type.
1612 pub kind: Option<String>,
1613 /// Link to next page for this Analytics data query.
1614 #[serde(rename = "nextLink")]
1615 pub next_link: Option<String>,
1616 /// Link to previous page for this Analytics data query.
1617 #[serde(rename = "previousLink")]
1618 pub previous_link: Option<String>,
1619 /// Information for the view (profile), for which the Analytics data was requested.
1620 #[serde(rename = "profileInfo")]
1621 pub profile_info: Option<McfDataProfileInfo>,
1622 /// Analytics data request query parameters.
1623 pub query: Option<McfDataQuery>,
1624 /// 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.
1625 pub rows: Option<Vec<Vec<McfDataRows>>>,
1626 /// The number of samples used to calculate the result.
1627 #[serde(rename = "sampleSize")]
1628 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1629 pub sample_size: Option<i64>,
1630 /// Total size of the sample space from which the samples were selected.
1631 #[serde(rename = "sampleSpace")]
1632 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1633 pub sample_space: Option<i64>,
1634 /// Link to this page.
1635 #[serde(rename = "selfLink")]
1636 pub self_link: Option<String>,
1637 /// The total number of rows for the query, regardless of the number of rows in the response.
1638 #[serde(rename = "totalResults")]
1639 pub total_results: Option<i32>,
1640 /// 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.
1641 #[serde(rename = "totalsForAllResults")]
1642 pub totals_for_all_results: Option<HashMap<String, String>>,
1643}
1644
1645impl common::ResponseResult for McfData {}
1646
1647/// JSON template for an Analytics view (profile).
1648///
1649/// # Activities
1650///
1651/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1652/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1653///
1654/// * [profiles get management](ManagementProfileGetCall) (response)
1655/// * [profiles insert management](ManagementProfileInsertCall) (request|response)
1656/// * [profiles patch management](ManagementProfilePatchCall) (request|response)
1657/// * [profiles update management](ManagementProfileUpdateCall) (request|response)
1658#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1659#[serde_with::serde_as]
1660#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1661pub struct Profile {
1662 /// Account ID to which this view (profile) belongs.
1663 #[serde(rename = "accountId")]
1664 pub account_id: Option<String>,
1665 /// Indicates whether bot filtering is enabled for this view (profile).
1666 #[serde(rename = "botFilteringEnabled")]
1667 pub bot_filtering_enabled: Option<bool>,
1668 /// Child link for this view (profile). Points to the list of goals for this view (profile).
1669 #[serde(rename = "childLink")]
1670 pub child_link: Option<ProfileChildLink>,
1671 /// Time this view (profile) was created.
1672 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
1673 /// The currency type associated with this view (profile), defaults to USD. The supported values are:
1674 /// 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
1675 pub currency: Option<String>,
1676 /// Default page for this view (profile).
1677 #[serde(rename = "defaultPage")]
1678 pub default_page: Option<String>,
1679 /// Indicates whether ecommerce tracking is enabled for this view (profile).
1680 #[serde(rename = "eCommerceTracking")]
1681 pub e_commerce_tracking: Option<bool>,
1682 /// Indicates whether enhanced ecommerce tracking is enabled for this view (profile). This property can only be enabled if ecommerce tracking is enabled.
1683 #[serde(rename = "enhancedECommerceTracking")]
1684 pub enhanced_e_commerce_tracking: Option<bool>,
1685 /// The query parameters that are excluded from this view (profile).
1686 #[serde(rename = "excludeQueryParameters")]
1687 pub exclude_query_parameters: Option<String>,
1688 /// View (Profile) ID.
1689 pub id: Option<String>,
1690 /// Internal ID for the web property to which this view (profile) belongs.
1691 #[serde(rename = "internalWebPropertyId")]
1692 pub internal_web_property_id: Option<String>,
1693 /// Resource type for Analytics view (profile).
1694 pub kind: Option<String>,
1695 /// Name of this view (profile).
1696 pub name: Option<String>,
1697 /// Parent link for this view (profile). Points to the web property to which this view (profile) belongs.
1698 #[serde(rename = "parentLink")]
1699 pub parent_link: Option<ProfileParentLink>,
1700 /// Permissions the user has for this view (profile).
1701 pub permissions: Option<ProfilePermissions>,
1702 /// Link for this view (profile).
1703 #[serde(rename = "selfLink")]
1704 pub self_link: Option<String>,
1705 /// Site search category parameters for this view (profile).
1706 #[serde(rename = "siteSearchCategoryParameters")]
1707 pub site_search_category_parameters: Option<String>,
1708 /// The site search query parameters for this view (profile).
1709 #[serde(rename = "siteSearchQueryParameters")]
1710 pub site_search_query_parameters: Option<String>,
1711 /// Indicates whether this view (profile) is starred or not.
1712 pub starred: Option<bool>,
1713 /// Whether or not Analytics will strip search category parameters from the URLs in your reports.
1714 #[serde(rename = "stripSiteSearchCategoryParameters")]
1715 pub strip_site_search_category_parameters: Option<bool>,
1716 /// Whether or not Analytics will strip search query parameters from the URLs in your reports.
1717 #[serde(rename = "stripSiteSearchQueryParameters")]
1718 pub strip_site_search_query_parameters: Option<bool>,
1719 /// Time zone for which this view (profile) has been configured. Time zones are identified by strings from the TZ database.
1720 pub timezone: Option<String>,
1721 /// View (Profile) type. Supported types: WEB or APP.
1722 #[serde(rename = "type")]
1723 pub type_: Option<String>,
1724 /// Time this view (profile) was last modified.
1725 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1726 /// Web property ID of the form UA-XXXXX-YY to which this view (profile) belongs.
1727 #[serde(rename = "webPropertyId")]
1728 pub web_property_id: Option<String>,
1729 /// Website URL for this view (profile).
1730 #[serde(rename = "websiteUrl")]
1731 pub website_url: Option<String>,
1732}
1733
1734impl common::RequestValue for Profile {}
1735impl common::ResponseResult for Profile {}
1736
1737/// JSON template for an Analytics profile filter link.
1738///
1739/// # Activities
1740///
1741/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1742/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1743///
1744/// * [profile filter links get management](ManagementProfileFilterLinkGetCall) (response)
1745/// * [profile filter links insert management](ManagementProfileFilterLinkInsertCall) (request|response)
1746/// * [profile filter links patch management](ManagementProfileFilterLinkPatchCall) (request|response)
1747/// * [profile filter links update management](ManagementProfileFilterLinkUpdateCall) (request|response)
1748#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1749#[serde_with::serde_as]
1750#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1751pub struct ProfileFilterLink {
1752 /// Filter for this link.
1753 #[serde(rename = "filterRef")]
1754 pub filter_ref: Option<FilterRef>,
1755 /// Profile filter link ID.
1756 pub id: Option<String>,
1757 /// Resource type for Analytics filter.
1758 pub kind: Option<String>,
1759 /// View (Profile) for this link.
1760 #[serde(rename = "profileRef")]
1761 pub profile_ref: Option<ProfileRef>,
1762 /// The rank of this profile filter link relative to the other filters linked to the same profile.
1763 /// For readonly (i.e., list and get) operations, the rank always starts at 1.
1764 /// 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.
1765 pub rank: Option<i32>,
1766 /// Link for this profile filter link.
1767 #[serde(rename = "selfLink")]
1768 pub self_link: Option<String>,
1769}
1770
1771impl common::RequestValue for ProfileFilterLink {}
1772impl common::ResponseResult for ProfileFilterLink {}
1773
1774/// A profile filter link collection lists profile filter links between profiles and filters. Each resource in the collection corresponds to a profile filter link.
1775///
1776/// # Activities
1777///
1778/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1779/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1780///
1781/// * [profile filter links list management](ManagementProfileFilterLinkListCall) (response)
1782#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1783#[serde_with::serde_as]
1784#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1785pub struct ProfileFilterLinks {
1786 /// A list of profile filter links.
1787 pub items: Option<Vec<ProfileFilterLink>>,
1788 /// 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.
1789 #[serde(rename = "itemsPerPage")]
1790 pub items_per_page: Option<i32>,
1791 /// Collection type.
1792 pub kind: Option<String>,
1793 /// Link to next page for this profile filter link collection.
1794 #[serde(rename = "nextLink")]
1795 pub next_link: Option<String>,
1796 /// Link to previous page for this profile filter link collection.
1797 #[serde(rename = "previousLink")]
1798 pub previous_link: Option<String>,
1799 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
1800 #[serde(rename = "startIndex")]
1801 pub start_index: Option<i32>,
1802 /// The total number of results for the query, regardless of the number of results in the response.
1803 #[serde(rename = "totalResults")]
1804 pub total_results: Option<i32>,
1805 /// Email ID of the authenticated user
1806 pub username: Option<String>,
1807}
1808
1809impl common::ResponseResult for ProfileFilterLinks {}
1810
1811/// JSON template for a linked view (profile).
1812///
1813/// This type is not used in any activity, and only used as *part* of another schema.
1814///
1815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1816#[serde_with::serde_as]
1817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1818pub struct ProfileRef {
1819 /// Account ID to which this view (profile) belongs.
1820 #[serde(rename = "accountId")]
1821 pub account_id: Option<String>,
1822 /// Link for this view (profile).
1823 pub href: Option<String>,
1824 /// View (Profile) ID.
1825 pub id: Option<String>,
1826 /// Internal ID for the web property to which this view (profile) belongs.
1827 #[serde(rename = "internalWebPropertyId")]
1828 pub internal_web_property_id: Option<String>,
1829 /// Analytics view (profile) reference.
1830 pub kind: Option<String>,
1831 /// Name of this view (profile).
1832 pub name: Option<String>,
1833 /// Web property ID of the form UA-XXXXX-YY to which this view (profile) belongs.
1834 #[serde(rename = "webPropertyId")]
1835 pub web_property_id: Option<String>,
1836}
1837
1838impl common::Part for ProfileRef {}
1839
1840/// JSON template for an Analytics ProfileSummary. ProfileSummary returns basic information (i.e., summary) for a profile.
1841///
1842/// This type is not used in any activity, and only used as *part* of another schema.
1843///
1844#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1845#[serde_with::serde_as]
1846#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1847pub struct ProfileSummary {
1848 /// View (profile) ID.
1849 pub id: Option<String>,
1850 /// Resource type for Analytics ProfileSummary.
1851 pub kind: Option<String>,
1852 /// View (profile) name.
1853 pub name: Option<String>,
1854 /// Indicates whether this view (profile) is starred or not.
1855 pub starred: Option<bool>,
1856 /// View (Profile) type. Supported types: WEB or APP.
1857 #[serde(rename = "type")]
1858 pub type_: Option<String>,
1859}
1860
1861impl common::Part for ProfileSummary {}
1862
1863/// 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).
1864///
1865/// # Activities
1866///
1867/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1868/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1869///
1870/// * [profiles list management](ManagementProfileListCall) (response)
1871#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1872#[serde_with::serde_as]
1873#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1874pub struct Profiles {
1875 /// A list of views (profiles).
1876 pub items: Option<Vec<Profile>>,
1877 /// 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.
1878 #[serde(rename = "itemsPerPage")]
1879 pub items_per_page: Option<i32>,
1880 /// Collection type.
1881 pub kind: Option<String>,
1882 /// Link to next page for this view (profile) collection.
1883 #[serde(rename = "nextLink")]
1884 pub next_link: Option<String>,
1885 /// Link to previous page for this view (profile) collection.
1886 #[serde(rename = "previousLink")]
1887 pub previous_link: Option<String>,
1888 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
1889 #[serde(rename = "startIndex")]
1890 pub start_index: Option<i32>,
1891 /// The total number of results for the query, regardless of the number of results in the response.
1892 #[serde(rename = "totalResults")]
1893 pub total_results: Option<i32>,
1894 /// Email ID of the authenticated user
1895 pub username: Option<String>,
1896}
1897
1898impl common::ResponseResult for Profiles {}
1899
1900/// Real time data for a given view (profile).
1901///
1902/// # Activities
1903///
1904/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1905/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1906///
1907/// * [realtime get data](DataRealtimeGetCall) (response)
1908#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1909#[serde_with::serde_as]
1910#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1911pub struct RealtimeData {
1912 /// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
1913 #[serde(rename = "columnHeaders")]
1914 pub column_headers: Option<Vec<RealtimeDataColumnHeaders>>,
1915 /// Unique ID for this data response.
1916 pub id: Option<String>,
1917 /// Resource type.
1918 pub kind: Option<String>,
1919 /// Information for the view (profile), for which the real time data was requested.
1920 #[serde(rename = "profileInfo")]
1921 pub profile_info: Option<RealtimeDataProfileInfo>,
1922 /// Real time data request query parameters.
1923 pub query: Option<RealtimeDataQuery>,
1924 /// 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.
1925 pub rows: Option<Vec<Vec<String>>>,
1926 /// Link to this page.
1927 #[serde(rename = "selfLink")]
1928 pub self_link: Option<String>,
1929 /// The total number of rows for the query, regardless of the number of rows in the response.
1930 #[serde(rename = "totalResults")]
1931 pub total_results: Option<i32>,
1932 /// 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.
1933 #[serde(rename = "totalsForAllResults")]
1934 pub totals_for_all_results: Option<HashMap<String, String>>,
1935}
1936
1937impl common::ResponseResult for RealtimeData {}
1938
1939/// JSON template for an Analytics remarketing audience.
1940///
1941/// # Activities
1942///
1943/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1944/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1945///
1946/// * [remarketing audience get management](ManagementRemarketingAudienceGetCall) (response)
1947/// * [remarketing audience insert management](ManagementRemarketingAudienceInsertCall) (request|response)
1948/// * [remarketing audience patch management](ManagementRemarketingAudiencePatchCall) (request|response)
1949/// * [remarketing audience update management](ManagementRemarketingAudienceUpdateCall) (request|response)
1950#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1951#[serde_with::serde_as]
1952#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1953pub struct RemarketingAudience {
1954 /// Account ID to which this remarketing audience belongs.
1955 #[serde(rename = "accountId")]
1956 pub account_id: Option<String>,
1957 /// The simple audience definition that will cause a user to be added to an audience.
1958 #[serde(rename = "audienceDefinition")]
1959 pub audience_definition: Option<RemarketingAudienceAudienceDefinition>,
1960 /// The type of audience, either SIMPLE or STATE_BASED.
1961 #[serde(rename = "audienceType")]
1962 pub audience_type: Option<String>,
1963 /// Time this remarketing audience was created.
1964 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
1965 /// The description of this remarketing audience.
1966 pub description: Option<String>,
1967 /// Remarketing Audience ID.
1968 pub id: Option<String>,
1969 /// Internal ID for the web property to which this remarketing audience belongs.
1970 #[serde(rename = "internalWebPropertyId")]
1971 pub internal_web_property_id: Option<String>,
1972 /// Collection type.
1973 pub kind: Option<String>,
1974 /// The linked ad accounts associated with this remarketing audience. A remarketing audience can have only one linkedAdAccount currently.
1975 #[serde(rename = "linkedAdAccounts")]
1976 pub linked_ad_accounts: Option<Vec<LinkedForeignAccount>>,
1977 /// The views (profiles) that this remarketing audience is linked to.
1978 #[serde(rename = "linkedViews")]
1979 pub linked_views: Option<Vec<String>>,
1980 /// The name of this remarketing audience.
1981 pub name: Option<String>,
1982 /// A state based audience definition that will cause a user to be added or removed from an audience.
1983 #[serde(rename = "stateBasedAudienceDefinition")]
1984 pub state_based_audience_definition: Option<RemarketingAudienceStateBasedAudienceDefinition>,
1985 /// Time this remarketing audience was last modified.
1986 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1987 /// Web property ID of the form UA-XXXXX-YY to which this remarketing audience belongs.
1988 #[serde(rename = "webPropertyId")]
1989 pub web_property_id: Option<String>,
1990}
1991
1992impl common::RequestValue for RemarketingAudience {}
1993impl common::ResponseResult for RemarketingAudience {}
1994
1995/// 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.
1996///
1997/// # Activities
1998///
1999/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2000/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2001///
2002/// * [remarketing audience list management](ManagementRemarketingAudienceListCall) (response)
2003#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2004#[serde_with::serde_as]
2005#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2006pub struct RemarketingAudiences {
2007 /// A list of remarketing audiences.
2008 pub items: Option<Vec<RemarketingAudience>>,
2009 /// 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.
2010 #[serde(rename = "itemsPerPage")]
2011 pub items_per_page: Option<i32>,
2012 /// Collection type.
2013 pub kind: Option<String>,
2014 /// Link to next page for this remarketing audience collection.
2015 #[serde(rename = "nextLink")]
2016 pub next_link: Option<String>,
2017 /// Link to previous page for this view (profile) collection.
2018 #[serde(rename = "previousLink")]
2019 pub previous_link: Option<String>,
2020 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
2021 #[serde(rename = "startIndex")]
2022 pub start_index: Option<i32>,
2023 /// The total number of results for the query, regardless of the number of results in the response.
2024 #[serde(rename = "totalResults")]
2025 pub total_results: Option<i32>,
2026 /// Email ID of the authenticated user
2027 pub username: Option<String>,
2028}
2029
2030impl common::ResponseResult for RemarketingAudiences {}
2031
2032/// JSON template for an Analytics segment.
2033///
2034/// This type is not used in any activity, and only used as *part* of another schema.
2035///
2036#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2037#[serde_with::serde_as]
2038#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2039pub struct Segment {
2040 /// Time the segment was created.
2041 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
2042 /// Segment definition.
2043 pub definition: Option<String>,
2044 /// Segment ID.
2045 pub id: Option<String>,
2046 /// Resource type for Analytics segment.
2047 pub kind: Option<String>,
2048 /// Segment name.
2049 pub name: Option<String>,
2050 /// Segment ID. Can be used with the 'segment' parameter in Core Reporting API.
2051 #[serde(rename = "segmentId")]
2052 pub segment_id: Option<String>,
2053 /// Link for this segment.
2054 #[serde(rename = "selfLink")]
2055 pub self_link: Option<String>,
2056 /// Type for a segment. Possible values are "BUILT_IN" or "CUSTOM".
2057 #[serde(rename = "type")]
2058 pub type_: Option<String>,
2059 /// Time the segment was last modified.
2060 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
2061}
2062
2063impl common::Part for Segment {}
2064
2065/// An segment collection lists Analytics segments that the user has access to. Each resource in the collection corresponds to a single Analytics segment.
2066///
2067/// # Activities
2068///
2069/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2070/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2071///
2072/// * [segments list management](ManagementSegmentListCall) (response)
2073#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2074#[serde_with::serde_as]
2075#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2076pub struct Segments {
2077 /// A list of segments.
2078 pub items: Option<Vec<Segment>>,
2079 /// 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.
2080 #[serde(rename = "itemsPerPage")]
2081 pub items_per_page: Option<i32>,
2082 /// Collection type for segments.
2083 pub kind: Option<String>,
2084 /// Link to next page for this segment collection.
2085 #[serde(rename = "nextLink")]
2086 pub next_link: Option<String>,
2087 /// Link to previous page for this segment collection.
2088 #[serde(rename = "previousLink")]
2089 pub previous_link: Option<String>,
2090 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
2091 #[serde(rename = "startIndex")]
2092 pub start_index: Option<i32>,
2093 /// The total number of results for the query, regardless of the number of results in the response.
2094 #[serde(rename = "totalResults")]
2095 pub total_results: Option<i32>,
2096 /// Email ID of the authenticated user
2097 pub username: Option<String>,
2098}
2099
2100impl common::ResponseResult for Segments {}
2101
2102/// JSON template for Analytics unsampled report resource.
2103///
2104/// # Activities
2105///
2106/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2107/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2108///
2109/// * [unsampled reports get management](ManagementUnsampledReportGetCall) (response)
2110/// * [unsampled reports insert management](ManagementUnsampledReportInsertCall) (request|response)
2111#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2112#[serde_with::serde_as]
2113#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2114pub struct UnsampledReport {
2115 /// Account ID to which this unsampled report belongs.
2116 #[serde(rename = "accountId")]
2117 pub account_id: Option<String>,
2118 /// Download details for a file stored in Google Cloud Storage.
2119 #[serde(rename = "cloudStorageDownloadDetails")]
2120 pub cloud_storage_download_details: Option<UnsampledReportCloudStorageDownloadDetails>,
2121 /// Time this unsampled report was created.
2122 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
2123 /// The dimensions for the unsampled report.
2124 pub dimensions: Option<String>,
2125 /// 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.
2126 #[serde(rename = "downloadType")]
2127 pub download_type: Option<String>,
2128 /// Download details for a file stored in Google Drive.
2129 #[serde(rename = "driveDownloadDetails")]
2130 pub drive_download_details: Option<UnsampledReportDriveDownloadDetails>,
2131 /// The end date for the unsampled report.
2132 #[serde(rename = "end-date")]
2133 pub end_date: Option<String>,
2134 /// The filters for the unsampled report.
2135 pub filters: Option<String>,
2136 /// Unsampled report ID.
2137 pub id: Option<String>,
2138 /// Resource type for an Analytics unsampled report.
2139 pub kind: Option<String>,
2140 /// The metrics for the unsampled report.
2141 pub metrics: Option<String>,
2142 /// View (Profile) ID to which this unsampled report belongs.
2143 #[serde(rename = "profileId")]
2144 pub profile_id: Option<String>,
2145 /// The segment for the unsampled report.
2146 pub segment: Option<String>,
2147 /// Link for this unsampled report.
2148 #[serde(rename = "selfLink")]
2149 pub self_link: Option<String>,
2150 /// The start date for the unsampled report.
2151 #[serde(rename = "start-date")]
2152 pub start_date: Option<String>,
2153 /// Status of this unsampled report. Possible values are PENDING, COMPLETED, or FAILED.
2154 pub status: Option<String>,
2155 /// Title of the unsampled report.
2156 pub title: Option<String>,
2157 /// Time this unsampled report was last modified.
2158 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
2159 /// Web property ID to which this unsampled report belongs. The web property ID is of the form UA-XXXXX-YY.
2160 #[serde(rename = "webPropertyId")]
2161 pub web_property_id: Option<String>,
2162}
2163
2164impl common::RequestValue for UnsampledReport {}
2165impl common::ResponseResult for UnsampledReport {}
2166
2167/// 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.
2168///
2169/// # Activities
2170///
2171/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2172/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2173///
2174/// * [unsampled reports list management](ManagementUnsampledReportListCall) (response)
2175#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2176#[serde_with::serde_as]
2177#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2178pub struct UnsampledReports {
2179 /// A list of unsampled reports.
2180 pub items: Option<Vec<UnsampledReport>>,
2181 /// 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.
2182 #[serde(rename = "itemsPerPage")]
2183 pub items_per_page: Option<i32>,
2184 /// Collection type.
2185 pub kind: Option<String>,
2186 /// Link to next page for this unsampled report collection.
2187 #[serde(rename = "nextLink")]
2188 pub next_link: Option<String>,
2189 /// Link to previous page for this unsampled report collection.
2190 #[serde(rename = "previousLink")]
2191 pub previous_link: Option<String>,
2192 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
2193 #[serde(rename = "startIndex")]
2194 pub start_index: Option<i32>,
2195 /// The total number of results for the query, regardless of the number of resources in the result.
2196 #[serde(rename = "totalResults")]
2197 pub total_results: Option<i32>,
2198 /// Email ID of the authenticated user
2199 pub username: Option<String>,
2200}
2201
2202impl common::ResponseResult for UnsampledReports {}
2203
2204/// Metadata returned for an upload operation.
2205///
2206/// # Activities
2207///
2208/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2209/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2210///
2211/// * [uploads get management](ManagementUploadGetCall) (response)
2212/// * [uploads upload data management](ManagementUploadUploadDataCall) (response)
2213#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2214#[serde_with::serde_as]
2215#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2216pub struct Upload {
2217 /// Account Id to which this upload belongs.
2218 #[serde(rename = "accountId")]
2219 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2220 pub account_id: Option<i64>,
2221 /// Custom data source Id to which this data import belongs.
2222 #[serde(rename = "customDataSourceId")]
2223 pub custom_data_source_id: Option<String>,
2224 /// Data import errors collection.
2225 pub errors: Option<Vec<String>>,
2226 /// A unique ID for this upload.
2227 pub id: Option<String>,
2228 /// Resource type for Analytics upload.
2229 pub kind: Option<String>,
2230 /// Upload status. Possible values: PENDING, COMPLETED, FAILED, DELETING, DELETED.
2231 pub status: Option<String>,
2232 /// Time this file is uploaded.
2233 #[serde(rename = "uploadTime")]
2234 pub upload_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2235}
2236
2237impl common::ResponseResult for Upload {}
2238
2239/// 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.
2240///
2241/// # Activities
2242///
2243/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2244/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2245///
2246/// * [uploads list management](ManagementUploadListCall) (response)
2247#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2248#[serde_with::serde_as]
2249#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2250pub struct Uploads {
2251 /// A list of uploads.
2252 pub items: Option<Vec<Upload>>,
2253 /// 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.
2254 #[serde(rename = "itemsPerPage")]
2255 pub items_per_page: Option<i32>,
2256 /// Collection type.
2257 pub kind: Option<String>,
2258 /// Link to next page for this upload collection.
2259 #[serde(rename = "nextLink")]
2260 pub next_link: Option<String>,
2261 /// Link to previous page for this upload collection.
2262 #[serde(rename = "previousLink")]
2263 pub previous_link: Option<String>,
2264 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
2265 #[serde(rename = "startIndex")]
2266 pub start_index: Option<i32>,
2267 /// The total number of results for the query, regardless of the number of resources in the result.
2268 #[serde(rename = "totalResults")]
2269 pub total_results: Option<i32>,
2270}
2271
2272impl common::ResponseResult for Uploads {}
2273
2274/// JSON template for a user deletion request resource.
2275///
2276/// # Activities
2277///
2278/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2279/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2280///
2281/// * [user deletion request upsert user deletion](UserDeletionUserDeletionRequestUpsertCall) (request|response)
2282#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2283#[serde_with::serde_as]
2284#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2285pub struct UserDeletionRequest {
2286 /// This marks the point in time for which all user data before should be deleted
2287 #[serde(rename = "deletionRequestTime")]
2288 pub deletion_request_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2289 /// Firebase Project Id
2290 #[serde(rename = "firebaseProjectId")]
2291 pub firebase_project_id: Option<String>,
2292 /// User ID.
2293 pub id: Option<UserDeletionRequestId>,
2294 /// Value is "analytics#userDeletionRequest".
2295 pub kind: Option<String>,
2296 /// Property ID
2297 #[serde(rename = "propertyId")]
2298 pub property_id: Option<String>,
2299 /// Web property ID of the form UA-XXXXX-YY.
2300 #[serde(rename = "webPropertyId")]
2301 pub web_property_id: Option<String>,
2302}
2303
2304impl common::RequestValue for UserDeletionRequest {}
2305impl common::ResponseResult for UserDeletionRequest {}
2306
2307/// JSON template for a user reference.
2308///
2309/// This type is not used in any activity, and only used as *part* of another schema.
2310///
2311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2312#[serde_with::serde_as]
2313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2314pub struct UserRef {
2315 /// Email ID of this user.
2316 pub email: Option<String>,
2317 /// User ID.
2318 pub id: Option<String>,
2319 /// no description provided
2320 pub kind: Option<String>,
2321}
2322
2323impl common::Part for UserRef {}
2324
2325/// JSON template for a web property reference.
2326///
2327/// This type is not used in any activity, and only used as *part* of another schema.
2328///
2329#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2330#[serde_with::serde_as]
2331#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2332pub struct WebPropertyRef {
2333 /// Account ID to which this web property belongs.
2334 #[serde(rename = "accountId")]
2335 pub account_id: Option<String>,
2336 /// Link for this web property.
2337 pub href: Option<String>,
2338 /// Web property ID of the form UA-XXXXX-YY.
2339 pub id: Option<String>,
2340 /// Internal ID for this web property.
2341 #[serde(rename = "internalWebPropertyId")]
2342 pub internal_web_property_id: Option<String>,
2343 /// Analytics web property reference.
2344 pub kind: Option<String>,
2345 /// Name of this web property.
2346 pub name: Option<String>,
2347}
2348
2349impl common::Part for WebPropertyRef {}
2350
2351/// JSON template for an Analytics WebPropertySummary. WebPropertySummary returns basic information (i.e., summary) for a web property.
2352///
2353/// This type is not used in any activity, and only used as *part* of another schema.
2354///
2355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2356#[serde_with::serde_as]
2357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2358pub struct WebPropertySummary {
2359 /// Web property ID of the form UA-XXXXX-YY.
2360 pub id: Option<String>,
2361 /// Internal ID for this web property.
2362 #[serde(rename = "internalWebPropertyId")]
2363 pub internal_web_property_id: Option<String>,
2364 /// Resource type for Analytics WebPropertySummary.
2365 pub kind: Option<String>,
2366 /// Level for this web property. Possible values are STANDARD or PREMIUM.
2367 pub level: Option<String>,
2368 /// Web property name.
2369 pub name: Option<String>,
2370 /// List of profiles under this web property.
2371 pub profiles: Option<Vec<ProfileSummary>>,
2372 /// Indicates whether this web property is starred or not.
2373 pub starred: Option<bool>,
2374 /// Website url for this web property.
2375 #[serde(rename = "websiteUrl")]
2376 pub website_url: Option<String>,
2377}
2378
2379impl common::Part for WebPropertySummary {}
2380
2381/// 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.
2382///
2383/// # Activities
2384///
2385/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2386/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2387///
2388/// * [webproperties list management](ManagementWebpropertyListCall) (response)
2389#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2390#[serde_with::serde_as]
2391#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2392pub struct Webproperties {
2393 /// A list of web properties.
2394 pub items: Option<Vec<Webproperty>>,
2395 /// 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.
2396 #[serde(rename = "itemsPerPage")]
2397 pub items_per_page: Option<i32>,
2398 /// Collection type.
2399 pub kind: Option<String>,
2400 /// Link to next page for this web property collection.
2401 #[serde(rename = "nextLink")]
2402 pub next_link: Option<String>,
2403 /// Link to previous page for this web property collection.
2404 #[serde(rename = "previousLink")]
2405 pub previous_link: Option<String>,
2406 /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
2407 #[serde(rename = "startIndex")]
2408 pub start_index: Option<i32>,
2409 /// The total number of results for the query, regardless of the number of results in the response.
2410 #[serde(rename = "totalResults")]
2411 pub total_results: Option<i32>,
2412 /// Email ID of the authenticated user
2413 pub username: Option<String>,
2414}
2415
2416impl common::ResponseResult for Webproperties {}
2417
2418/// JSON template for an Analytics web property.
2419///
2420/// # Activities
2421///
2422/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2423/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2424///
2425/// * [webproperties get management](ManagementWebpropertyGetCall) (response)
2426/// * [webproperties insert management](ManagementWebpropertyInsertCall) (request|response)
2427/// * [webproperties patch management](ManagementWebpropertyPatchCall) (request|response)
2428/// * [webproperties update management](ManagementWebpropertyUpdateCall) (request|response)
2429#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2430#[serde_with::serde_as]
2431#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2432pub struct Webproperty {
2433 /// Account ID to which this web property belongs.
2434 #[serde(rename = "accountId")]
2435 pub account_id: Option<String>,
2436 /// Child link for this web property. Points to the list of views (profiles) for this web property.
2437 #[serde(rename = "childLink")]
2438 pub child_link: Option<WebpropertyChildLink>,
2439 /// Time this web property was created.
2440 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
2441 /// 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).
2442 /// Set to false to delete data associated with the user identifier automatically after the rentention period.
2443 /// This property cannot be set on insert.
2444 #[serde(rename = "dataRetentionResetOnNewActivity")]
2445 pub data_retention_reset_on_new_activity: Option<bool>,
2446 /// The length of time for which user and event data is retained.
2447 /// This property cannot be set on insert.
2448 #[serde(rename = "dataRetentionTtl")]
2449 pub data_retention_ttl: Option<String>,
2450 /// Default view (profile) ID.
2451 #[serde(rename = "defaultProfileId")]
2452 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2453 pub default_profile_id: Option<i64>,
2454 /// Web property ID of the form UA-XXXXX-YY.
2455 pub id: Option<String>,
2456 /// The industry vertical/category selected for this web property.
2457 #[serde(rename = "industryVertical")]
2458 pub industry_vertical: Option<String>,
2459 /// Internal ID for this web property.
2460 #[serde(rename = "internalWebPropertyId")]
2461 pub internal_web_property_id: Option<String>,
2462 /// Resource type for Analytics WebProperty.
2463 pub kind: Option<String>,
2464 /// Level for this web property. Possible values are STANDARD or PREMIUM.
2465 pub level: Option<String>,
2466 /// Name of this web property.
2467 pub name: Option<String>,
2468 /// Parent link for this web property. Points to the account to which this web property belongs.
2469 #[serde(rename = "parentLink")]
2470 pub parent_link: Option<WebpropertyParentLink>,
2471 /// Permissions the user has for this web property.
2472 pub permissions: Option<WebpropertyPermissions>,
2473 /// View (Profile) count for this web property.
2474 #[serde(rename = "profileCount")]
2475 pub profile_count: Option<i32>,
2476 /// Link for this web property.
2477 #[serde(rename = "selfLink")]
2478 pub self_link: Option<String>,
2479 /// Indicates whether this web property is starred or not.
2480 pub starred: Option<bool>,
2481 /// Time this web property was last modified.
2482 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
2483 /// Website url for this web property.
2484 #[serde(rename = "websiteUrl")]
2485 pub website_url: Option<String>,
2486}
2487
2488impl common::RequestValue for Webproperty {}
2489impl common::ResponseResult for Webproperty {}
2490
2491/// Child link for an account entry. Points to the list of web properties for this account.
2492///
2493/// This type is not used in any activity, and only used as *part* of another schema.
2494///
2495#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2496#[serde_with::serde_as]
2497#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2498pub struct AccountChildLink {
2499 /// Link to the list of web properties for this account.
2500 pub href: Option<String>,
2501 /// Type of the child link. Its value is "analytics#webproperties".
2502 #[serde(rename = "type")]
2503 pub type_: Option<String>,
2504}
2505
2506impl common::NestedType for AccountChildLink {}
2507impl common::Part for AccountChildLink {}
2508
2509/// Permissions the user has for this account.
2510///
2511/// This type is not used in any activity, and only used as *part* of another schema.
2512///
2513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2514#[serde_with::serde_as]
2515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2516pub struct AccountPermissions {
2517 /// All the permissions that the user has for this account. These include any implied permissions (e.g., EDIT implies VIEW).
2518 pub effective: Option<Vec<String>>,
2519}
2520
2521impl common::NestedType for AccountPermissions {}
2522impl common::Part for AccountPermissions {}
2523
2524/// There is no detailed description.
2525///
2526/// This type is not used in any activity, and only used as *part* of another schema.
2527///
2528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2529#[serde_with::serde_as]
2530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2531pub struct CustomDataSourceChildLink {
2532 /// Link to the list of daily uploads for this custom data source. Link to the list of uploads for this custom data source.
2533 pub href: Option<String>,
2534 /// Value is "analytics#dailyUploads". Value is "analytics#uploads".
2535 #[serde(rename = "type")]
2536 pub type_: Option<String>,
2537}
2538
2539impl common::NestedType for CustomDataSourceChildLink {}
2540impl common::Part for CustomDataSourceChildLink {}
2541
2542/// Parent link for this custom data source. Points to the web property to which this custom data source belongs.
2543///
2544/// This type is not used in any activity, and only used as *part* of another schema.
2545///
2546#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2547#[serde_with::serde_as]
2548#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2549pub struct CustomDataSourceParentLink {
2550 /// Link to the web property to which this custom data source belongs.
2551 pub href: Option<String>,
2552 /// Value is "analytics#webproperty".
2553 #[serde(rename = "type")]
2554 pub type_: Option<String>,
2555}
2556
2557impl common::NestedType for CustomDataSourceParentLink {}
2558impl common::Part for CustomDataSourceParentLink {}
2559
2560/// Parent link for the custom dimension. Points to the property to which the custom dimension belongs.
2561///
2562/// This type is not used in any activity, and only used as *part* of another schema.
2563///
2564#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2565#[serde_with::serde_as]
2566#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2567pub struct CustomDimensionParentLink {
2568 /// Link to the property to which the custom dimension belongs.
2569 pub href: Option<String>,
2570 /// Type of the parent link. Set to "analytics#webproperty".
2571 #[serde(rename = "type")]
2572 pub type_: Option<String>,
2573}
2574
2575impl common::NestedType for CustomDimensionParentLink {}
2576impl common::Part for CustomDimensionParentLink {}
2577
2578/// Parent link for the custom metric. Points to the property to which the custom metric belongs.
2579///
2580/// This type is not used in any activity, and only used as *part* of another schema.
2581///
2582#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2583#[serde_with::serde_as]
2584#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2585pub struct CustomMetricParentLink {
2586 /// Link to the property to which the custom metric belongs.
2587 pub href: Option<String>,
2588 /// Type of the parent link. Set to "analytics#webproperty".
2589 #[serde(rename = "type")]
2590 pub type_: Option<String>,
2591}
2592
2593impl common::NestedType for CustomMetricParentLink {}
2594impl common::Part for CustomMetricParentLink {}
2595
2596/// Web property being linked.
2597///
2598/// This type is not used in any activity, and only used as *part* of another schema.
2599///
2600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2601#[serde_with::serde_as]
2602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2603pub struct EntityAdWordsLinkEntity {
2604 /// no description provided
2605 #[serde(rename = "webPropertyRef")]
2606 pub web_property_ref: Option<WebPropertyRef>,
2607}
2608
2609impl common::NestedType for EntityAdWordsLinkEntity {}
2610impl common::Part for EntityAdWordsLinkEntity {}
2611
2612/// Entity for this link. It can be an account, a web property, or a view (profile).
2613///
2614/// This type is not used in any activity, and only used as *part* of another schema.
2615///
2616#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2617#[serde_with::serde_as]
2618#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2619pub struct EntityUserLinkEntity {
2620 /// Account for this link.
2621 #[serde(rename = "accountRef")]
2622 pub account_ref: Option<AccountRef>,
2623 /// View (Profile) for this link.
2624 #[serde(rename = "profileRef")]
2625 pub profile_ref: Option<ProfileRef>,
2626 /// Web property for this link.
2627 #[serde(rename = "webPropertyRef")]
2628 pub web_property_ref: Option<WebPropertyRef>,
2629}
2630
2631impl common::NestedType for EntityUserLinkEntity {}
2632impl common::Part for EntityUserLinkEntity {}
2633
2634/// Permissions the user has for this entity.
2635///
2636/// This type is not used in any activity, and only used as *part* of another schema.
2637///
2638#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2639#[serde_with::serde_as]
2640#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2641pub struct EntityUserLinkPermissions {
2642 /// 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.
2643 pub effective: Option<Vec<String>>,
2644 /// Permissions that a user has been assigned at this very level. Does not include any implied or inherited permissions. Local permissions are modifiable.
2645 pub local: Option<Vec<String>>,
2646}
2647
2648impl common::NestedType for EntityUserLinkPermissions {}
2649impl common::Part for EntityUserLinkPermissions {}
2650
2651/// Parent link for an experiment. Points to the view (profile) to which this experiment belongs.
2652///
2653/// This type is not used in any activity, and only used as *part* of another schema.
2654///
2655#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2656#[serde_with::serde_as]
2657#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2658pub struct ExperimentParentLink {
2659 /// Link to the view (profile) to which this experiment belongs. This field is read-only.
2660 pub href: Option<String>,
2661 /// Value is "analytics#profile". This field is read-only.
2662 #[serde(rename = "type")]
2663 pub type_: Option<String>,
2664}
2665
2666impl common::NestedType for ExperimentParentLink {}
2667impl common::Part for ExperimentParentLink {}
2668
2669/// 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.
2670///
2671/// This type is not used in any activity, and only used as *part* of another schema.
2672///
2673#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2674#[serde_with::serde_as]
2675#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2676pub struct ExperimentVariations {
2677 /// 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.
2678 pub name: Option<String>,
2679 /// 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.
2680 pub status: Option<String>,
2681 /// The URL of the variation. This field may not be changed for an experiment whose status is RUNNING or ENDED.
2682 pub url: Option<String>,
2683 /// Weight that this variation should receive. Only present if the experiment is running. This field is read-only.
2684 pub weight: Option<f64>,
2685 /// True if the experiment has ended and this variation performed (statistically) significantly better than the original. This field is read-only.
2686 pub won: Option<bool>,
2687}
2688
2689impl common::NestedType for ExperimentVariations {}
2690impl common::Part for ExperimentVariations {}
2691
2692/// Details for the filter of the type ADVANCED.
2693///
2694/// This type is not used in any activity, and only used as *part* of another schema.
2695///
2696#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2697#[serde_with::serde_as]
2698#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2699pub struct FilterAdvancedDetails {
2700 /// Indicates if the filter expressions are case sensitive.
2701 #[serde(rename = "caseSensitive")]
2702 pub case_sensitive: Option<bool>,
2703 /// Expression to extract from field A.
2704 #[serde(rename = "extractA")]
2705 pub extract_a: Option<String>,
2706 /// Expression to extract from field B.
2707 #[serde(rename = "extractB")]
2708 pub extract_b: Option<String>,
2709 /// Field A.
2710 #[serde(rename = "fieldA")]
2711 pub field_a: Option<String>,
2712 /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2713 #[serde(rename = "fieldAIndex")]
2714 pub field_a_index: Option<i32>,
2715 /// Indicates if field A is required to match.
2716 #[serde(rename = "fieldARequired")]
2717 pub field_a_required: Option<bool>,
2718 /// Field B.
2719 #[serde(rename = "fieldB")]
2720 pub field_b: Option<String>,
2721 /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2722 #[serde(rename = "fieldBIndex")]
2723 pub field_b_index: Option<i32>,
2724 /// Indicates if field B is required to match.
2725 #[serde(rename = "fieldBRequired")]
2726 pub field_b_required: Option<bool>,
2727 /// Expression used to construct the output value.
2728 #[serde(rename = "outputConstructor")]
2729 pub output_constructor: Option<String>,
2730 /// Output field.
2731 #[serde(rename = "outputToField")]
2732 pub output_to_field: Option<String>,
2733 /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2734 #[serde(rename = "outputToFieldIndex")]
2735 pub output_to_field_index: Option<i32>,
2736 /// Indicates if the existing value of the output field, if any, should be overridden by the output expression.
2737 #[serde(rename = "overrideOutputField")]
2738 pub override_output_field: Option<bool>,
2739}
2740
2741impl common::NestedType for FilterAdvancedDetails {}
2742impl common::Part for FilterAdvancedDetails {}
2743
2744/// Details for the filter of the type LOWER.
2745///
2746/// This type is not used in any activity, and only used as *part* of another schema.
2747///
2748#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2749#[serde_with::serde_as]
2750#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2751pub struct FilterLowercaseDetails {
2752 /// Field to use in the filter.
2753 pub field: Option<String>,
2754 /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2755 #[serde(rename = "fieldIndex")]
2756 pub field_index: Option<i32>,
2757}
2758
2759impl common::NestedType for FilterLowercaseDetails {}
2760impl common::Part for FilterLowercaseDetails {}
2761
2762/// Parent link for this filter. Points to the account to which this filter belongs.
2763///
2764/// This type is not used in any activity, and only used as *part* of another schema.
2765///
2766#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2767#[serde_with::serde_as]
2768#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2769pub struct FilterParentLink {
2770 /// Link to the account to which this filter belongs.
2771 pub href: Option<String>,
2772 /// Value is "analytics#account".
2773 #[serde(rename = "type")]
2774 pub type_: Option<String>,
2775}
2776
2777impl common::NestedType for FilterParentLink {}
2778impl common::Part for FilterParentLink {}
2779
2780/// Details for the filter of the type SEARCH_AND_REPLACE.
2781///
2782/// This type is not used in any activity, and only used as *part* of another schema.
2783///
2784#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2785#[serde_with::serde_as]
2786#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2787pub struct FilterSearchAndReplaceDetails {
2788 /// Determines if the filter is case sensitive.
2789 #[serde(rename = "caseSensitive")]
2790 pub case_sensitive: Option<bool>,
2791 /// Field to use in the filter.
2792 pub field: Option<String>,
2793 /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2794 #[serde(rename = "fieldIndex")]
2795 pub field_index: Option<i32>,
2796 /// Term to replace the search term with.
2797 #[serde(rename = "replaceString")]
2798 pub replace_string: Option<String>,
2799 /// Term to search.
2800 #[serde(rename = "searchString")]
2801 pub search_string: Option<String>,
2802}
2803
2804impl common::NestedType for FilterSearchAndReplaceDetails {}
2805impl common::Part for FilterSearchAndReplaceDetails {}
2806
2807/// Details for the filter of the type UPPER.
2808///
2809/// This type is not used in any activity, and only used as *part* of another schema.
2810///
2811#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2812#[serde_with::serde_as]
2813#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2814pub struct FilterUppercaseDetails {
2815 /// Field to use in the filter.
2816 pub field: Option<String>,
2817 /// The Index of the custom dimension. Required if field is a CUSTOM_DIMENSION.
2818 #[serde(rename = "fieldIndex")]
2819 pub field_index: Option<i32>,
2820}
2821
2822impl common::NestedType for FilterUppercaseDetails {}
2823impl common::Part for FilterUppercaseDetails {}
2824
2825/// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
2826///
2827/// This type is not used in any activity, and only used as *part* of another schema.
2828///
2829#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2830#[serde_with::serde_as]
2831#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2832pub struct GaDataColumnHeaders {
2833 /// Column Type. Either DIMENSION or METRIC.
2834 #[serde(rename = "columnType")]
2835 pub column_type: Option<String>,
2836 /// 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.
2837 #[serde(rename = "dataType")]
2838 pub data_type: Option<String>,
2839 /// Column name.
2840 pub name: Option<String>,
2841}
2842
2843impl common::NestedType for GaDataColumnHeaders {}
2844impl common::Part for GaDataColumnHeaders {}
2845
2846/// There is no detailed description.
2847///
2848/// This type is not used in any activity, and only used as *part* of another schema.
2849///
2850#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2851#[serde_with::serde_as]
2852#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2853pub struct GaDataDataTable {
2854 /// no description provided
2855 pub cols: Option<Vec<GaDataDataTableCols>>,
2856 /// no description provided
2857 pub rows: Option<Vec<GaDataDataTableRows>>,
2858}
2859
2860impl common::NestedType for GaDataDataTable {}
2861impl common::Part for GaDataDataTable {}
2862
2863/// There is no detailed description.
2864///
2865/// This type is not used in any activity, and only used as *part* of another schema.
2866///
2867#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2868#[serde_with::serde_as]
2869#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2870pub struct GaDataDataTableCols {
2871 /// no description provided
2872 pub id: Option<String>,
2873 /// no description provided
2874 pub label: Option<String>,
2875 /// no description provided
2876 #[serde(rename = "type")]
2877 pub type_: Option<String>,
2878}
2879
2880impl common::NestedType for GaDataDataTableCols {}
2881impl common::Part for GaDataDataTableCols {}
2882
2883/// There is no detailed description.
2884///
2885/// This type is not used in any activity, and only used as *part* of another schema.
2886///
2887#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2888#[serde_with::serde_as]
2889#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2890pub struct GaDataDataTableRows {
2891 /// no description provided
2892 pub c: Option<Vec<GaDataDataTableRowsC>>,
2893}
2894
2895impl common::NestedType for GaDataDataTableRows {}
2896impl common::Part for GaDataDataTableRows {}
2897
2898/// There is no detailed description.
2899///
2900/// This type is not used in any activity, and only used as *part* of another schema.
2901///
2902#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2903#[serde_with::serde_as]
2904#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2905pub struct GaDataDataTableRowsC {
2906 /// no description provided
2907 pub v: Option<String>,
2908}
2909
2910impl common::NestedType for GaDataDataTableRowsC {}
2911impl common::Part for GaDataDataTableRowsC {}
2912
2913/// Information for the view (profile), for which the Analytics data was requested.
2914///
2915/// This type is not used in any activity, and only used as *part* of another schema.
2916///
2917#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2918#[serde_with::serde_as]
2919#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2920pub struct GaDataProfileInfo {
2921 /// Account ID to which this view (profile) belongs.
2922 #[serde(rename = "accountId")]
2923 pub account_id: Option<String>,
2924 /// Internal ID for the web property to which this view (profile) belongs.
2925 #[serde(rename = "internalWebPropertyId")]
2926 pub internal_web_property_id: Option<String>,
2927 /// View (Profile) ID.
2928 #[serde(rename = "profileId")]
2929 pub profile_id: Option<String>,
2930 /// View (Profile) name.
2931 #[serde(rename = "profileName")]
2932 pub profile_name: Option<String>,
2933 /// Table ID for view (profile).
2934 #[serde(rename = "tableId")]
2935 pub table_id: Option<String>,
2936 /// Web Property ID to which this view (profile) belongs.
2937 #[serde(rename = "webPropertyId")]
2938 pub web_property_id: Option<String>,
2939}
2940
2941impl common::NestedType for GaDataProfileInfo {}
2942impl common::Part for GaDataProfileInfo {}
2943
2944/// Analytics data request query parameters.
2945///
2946/// This type is not used in any activity, and only used as *part* of another schema.
2947///
2948#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2949#[serde_with::serde_as]
2950#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2951pub struct GaDataQuery {
2952 /// List of analytics dimensions.
2953 pub dimensions: Option<String>,
2954 /// End date.
2955 #[serde(rename = "end-date")]
2956 pub end_date: Option<String>,
2957 /// Comma-separated list of dimension or metric filters.
2958 pub filters: Option<String>,
2959 /// Unique table ID.
2960 pub ids: Option<String>,
2961 /// Maximum results per page.
2962 #[serde(rename = "max-results")]
2963 pub max_results: Option<i32>,
2964 /// List of analytics metrics.
2965 pub metrics: Option<Vec<String>>,
2966 /// Desired sampling level
2967 #[serde(rename = "samplingLevel")]
2968 pub sampling_level: Option<String>,
2969 /// Analytics advanced segment.
2970 pub segment: Option<String>,
2971 /// List of dimensions or metrics based on which Analytics data is sorted.
2972 pub sort: Option<Vec<String>>,
2973 /// Start date.
2974 #[serde(rename = "start-date")]
2975 pub start_date: Option<String>,
2976 /// Start index.
2977 #[serde(rename = "start-index")]
2978 pub start_index: Option<i32>,
2979}
2980
2981impl common::NestedType for GaDataQuery {}
2982impl common::Part for GaDataQuery {}
2983
2984/// Details for the goal of the type EVENT.
2985///
2986/// This type is not used in any activity, and only used as *part* of another schema.
2987///
2988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2989#[serde_with::serde_as]
2990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2991pub struct GoalEventDetails {
2992 /// List of event conditions.
2993 #[serde(rename = "eventConditions")]
2994 pub event_conditions: Option<Vec<GoalEventDetailsEventConditions>>,
2995 /// Determines if the event value should be used as the value for this goal.
2996 #[serde(rename = "useEventValue")]
2997 pub use_event_value: Option<bool>,
2998}
2999
3000impl common::NestedType for GoalEventDetails {}
3001impl common::Part for GoalEventDetails {}
3002
3003/// List of event conditions.
3004///
3005/// This type is not used in any activity, and only used as *part* of another schema.
3006///
3007#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3008#[serde_with::serde_as]
3009#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3010pub struct GoalEventDetailsEventConditions {
3011 /// Type of comparison. Possible values are LESS_THAN, GREATER_THAN or EQUAL.
3012 #[serde(rename = "comparisonType")]
3013 pub comparison_type: Option<String>,
3014 /// Value used for this comparison.
3015 #[serde(rename = "comparisonValue")]
3016 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3017 pub comparison_value: Option<i64>,
3018 /// Expression used for this match.
3019 pub expression: Option<String>,
3020 /// Type of the match to be performed. Possible values are REGEXP, BEGINS_WITH, or EXACT.
3021 #[serde(rename = "matchType")]
3022 pub match_type: Option<String>,
3023 /// Type of this event condition. Possible values are CATEGORY, ACTION, LABEL, or VALUE.
3024 #[serde(rename = "type")]
3025 pub type_: Option<String>,
3026}
3027
3028impl common::NestedType for GoalEventDetailsEventConditions {}
3029impl common::Part for GoalEventDetailsEventConditions {}
3030
3031/// Parent link for a goal. Points to the view (profile) to which this goal belongs.
3032///
3033/// This type is not used in any activity, and only used as *part* of another schema.
3034///
3035#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3036#[serde_with::serde_as]
3037#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3038pub struct GoalParentLink {
3039 /// Link to the view (profile) to which this goal belongs.
3040 pub href: Option<String>,
3041 /// Value is "analytics#profile".
3042 #[serde(rename = "type")]
3043 pub type_: Option<String>,
3044}
3045
3046impl common::NestedType for GoalParentLink {}
3047impl common::Part for GoalParentLink {}
3048
3049/// Details for the goal of the type URL_DESTINATION.
3050///
3051/// This type is not used in any activity, and only used as *part* of another schema.
3052///
3053#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3054#[serde_with::serde_as]
3055#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3056pub struct GoalUrlDestinationDetails {
3057 /// Determines if the goal URL must exactly match the capitalization of visited URLs.
3058 #[serde(rename = "caseSensitive")]
3059 pub case_sensitive: Option<bool>,
3060 /// Determines if the first step in this goal is required.
3061 #[serde(rename = "firstStepRequired")]
3062 pub first_step_required: Option<bool>,
3063 /// Match type for the goal URL. Possible values are HEAD, EXACT, or REGEX.
3064 #[serde(rename = "matchType")]
3065 pub match_type: Option<String>,
3066 /// List of steps configured for this goal funnel.
3067 pub steps: Option<Vec<GoalUrlDestinationDetailsSteps>>,
3068 /// URL for this goal.
3069 pub url: Option<String>,
3070}
3071
3072impl common::NestedType for GoalUrlDestinationDetails {}
3073impl common::Part for GoalUrlDestinationDetails {}
3074
3075/// List of steps configured for this goal funnel.
3076///
3077/// This type is not used in any activity, and only used as *part* of another schema.
3078///
3079#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3080#[serde_with::serde_as]
3081#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3082pub struct GoalUrlDestinationDetailsSteps {
3083 /// Step name.
3084 pub name: Option<String>,
3085 /// Step number.
3086 pub number: Option<i32>,
3087 /// URL for this step.
3088 pub url: Option<String>,
3089}
3090
3091impl common::NestedType for GoalUrlDestinationDetailsSteps {}
3092impl common::Part for GoalUrlDestinationDetailsSteps {}
3093
3094/// Details for the goal of the type VISIT_NUM_PAGES.
3095///
3096/// This type is not used in any activity, and only used as *part* of another schema.
3097///
3098#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3099#[serde_with::serde_as]
3100#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3101pub struct GoalVisitNumPagesDetails {
3102 /// Type of comparison. Possible values are LESS_THAN, GREATER_THAN, or EQUAL.
3103 #[serde(rename = "comparisonType")]
3104 pub comparison_type: Option<String>,
3105 /// Value used for this comparison.
3106 #[serde(rename = "comparisonValue")]
3107 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3108 pub comparison_value: Option<i64>,
3109}
3110
3111impl common::NestedType for GoalVisitNumPagesDetails {}
3112impl common::Part for GoalVisitNumPagesDetails {}
3113
3114/// Details for the goal of the type VISIT_TIME_ON_SITE.
3115///
3116/// This type is not used in any activity, and only used as *part* of another schema.
3117///
3118#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3119#[serde_with::serde_as]
3120#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3121pub struct GoalVisitTimeOnSiteDetails {
3122 /// Type of comparison. Possible values are LESS_THAN or GREATER_THAN.
3123 #[serde(rename = "comparisonType")]
3124 pub comparison_type: Option<String>,
3125 /// Value used for this comparison.
3126 #[serde(rename = "comparisonValue")]
3127 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3128 pub comparison_value: Option<i64>,
3129}
3130
3131impl common::NestedType for GoalVisitTimeOnSiteDetails {}
3132impl common::Part for GoalVisitTimeOnSiteDetails {}
3133
3134/// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
3135///
3136/// This type is not used in any activity, and only used as *part* of another schema.
3137///
3138#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3139#[serde_with::serde_as]
3140#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3141pub struct McfDataColumnHeaders {
3142 /// Column Type. Either DIMENSION or METRIC.
3143 #[serde(rename = "columnType")]
3144 pub column_type: Option<String>,
3145 /// Data type. Dimension and metric values data types such as INTEGER, DOUBLE, CURRENCY, MCF_SEQUENCE etc.
3146 #[serde(rename = "dataType")]
3147 pub data_type: Option<String>,
3148 /// Column name.
3149 pub name: Option<String>,
3150}
3151
3152impl common::NestedType for McfDataColumnHeaders {}
3153impl common::Part for McfDataColumnHeaders {}
3154
3155/// Information for the view (profile), for which the Analytics data was requested.
3156///
3157/// This type is not used in any activity, and only used as *part* of another schema.
3158///
3159#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3160#[serde_with::serde_as]
3161#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3162pub struct McfDataProfileInfo {
3163 /// Account ID to which this view (profile) belongs.
3164 #[serde(rename = "accountId")]
3165 pub account_id: Option<String>,
3166 /// Internal ID for the web property to which this view (profile) belongs.
3167 #[serde(rename = "internalWebPropertyId")]
3168 pub internal_web_property_id: Option<String>,
3169 /// View (Profile) ID.
3170 #[serde(rename = "profileId")]
3171 pub profile_id: Option<String>,
3172 /// View (Profile) name.
3173 #[serde(rename = "profileName")]
3174 pub profile_name: Option<String>,
3175 /// Table ID for view (profile).
3176 #[serde(rename = "tableId")]
3177 pub table_id: Option<String>,
3178 /// Web Property ID to which this view (profile) belongs.
3179 #[serde(rename = "webPropertyId")]
3180 pub web_property_id: Option<String>,
3181}
3182
3183impl common::NestedType for McfDataProfileInfo {}
3184impl common::Part for McfDataProfileInfo {}
3185
3186/// Analytics data request query parameters.
3187///
3188/// This type is not used in any activity, and only used as *part* of another schema.
3189///
3190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3191#[serde_with::serde_as]
3192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3193pub struct McfDataQuery {
3194 /// List of analytics dimensions.
3195 pub dimensions: Option<String>,
3196 /// End date.
3197 #[serde(rename = "end-date")]
3198 pub end_date: Option<String>,
3199 /// Comma-separated list of dimension or metric filters.
3200 pub filters: Option<String>,
3201 /// Unique table ID.
3202 pub ids: Option<String>,
3203 /// Maximum results per page.
3204 #[serde(rename = "max-results")]
3205 pub max_results: Option<i32>,
3206 /// List of analytics metrics.
3207 pub metrics: Option<Vec<String>>,
3208 /// Desired sampling level
3209 #[serde(rename = "samplingLevel")]
3210 pub sampling_level: Option<String>,
3211 /// Analytics advanced segment.
3212 pub segment: Option<String>,
3213 /// List of dimensions or metrics based on which Analytics data is sorted.
3214 pub sort: Option<Vec<String>>,
3215 /// Start date.
3216 #[serde(rename = "start-date")]
3217 pub start_date: Option<String>,
3218 /// Start index.
3219 #[serde(rename = "start-index")]
3220 pub start_index: Option<i32>,
3221}
3222
3223impl common::NestedType for McfDataQuery {}
3224impl common::Part for McfDataQuery {}
3225
3226/// A union object representing a dimension or metric value. Only one of "primitiveValue" or "conversionPathValue" attribute will be populated.
3227///
3228/// This type is not used in any activity, and only used as *part* of another schema.
3229///
3230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3231#[serde_with::serde_as]
3232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3233pub struct McfDataRows {
3234 /// A conversion path dimension value, containing a list of interactions with their attributes.
3235 #[serde(rename = "conversionPathValue")]
3236 pub conversion_path_value: Option<Vec<McfDataRowsConversionPathValue>>,
3237 /// A primitive dimension value. A primitive metric value.
3238 #[serde(rename = "primitiveValue")]
3239 pub primitive_value: Option<String>,
3240}
3241
3242impl common::NestedType for McfDataRows {}
3243impl common::Part for McfDataRows {}
3244
3245/// A conversion path dimension value, containing a list of interactions with their attributes.
3246///
3247/// This type is not used in any activity, and only used as *part* of another schema.
3248///
3249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3250#[serde_with::serde_as]
3251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3252pub struct McfDataRowsConversionPathValue {
3253 /// Type of an interaction on conversion path. Such as CLICK, IMPRESSION etc.
3254 #[serde(rename = "interactionType")]
3255 pub interaction_type: Option<String>,
3256 /// Node value of an interaction on conversion path. Such as source, medium etc.
3257 #[serde(rename = "nodeValue")]
3258 pub node_value: Option<String>,
3259}
3260
3261impl common::NestedType for McfDataRowsConversionPathValue {}
3262impl common::Part for McfDataRowsConversionPathValue {}
3263
3264/// Child link for this view (profile). Points to the list of goals for this view (profile).
3265///
3266/// This type is not used in any activity, and only used as *part* of another schema.
3267///
3268#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3269#[serde_with::serde_as]
3270#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3271pub struct ProfileChildLink {
3272 /// Link to the list of goals for this view (profile).
3273 pub href: Option<String>,
3274 /// Value is "analytics#goals".
3275 #[serde(rename = "type")]
3276 pub type_: Option<String>,
3277}
3278
3279impl common::NestedType for ProfileChildLink {}
3280impl common::Part for ProfileChildLink {}
3281
3282/// Parent link for this view (profile). Points to the web property to which this view (profile) belongs.
3283///
3284/// This type is not used in any activity, and only used as *part* of another schema.
3285///
3286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3287#[serde_with::serde_as]
3288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3289pub struct ProfileParentLink {
3290 /// Link to the web property to which this view (profile) belongs.
3291 pub href: Option<String>,
3292 /// Value is "analytics#webproperty".
3293 #[serde(rename = "type")]
3294 pub type_: Option<String>,
3295}
3296
3297impl common::NestedType for ProfileParentLink {}
3298impl common::Part for ProfileParentLink {}
3299
3300/// Permissions the user has for this view (profile).
3301///
3302/// This type is not used in any activity, and only used as *part* of another schema.
3303///
3304#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3305#[serde_with::serde_as]
3306#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3307pub struct ProfilePermissions {
3308 /// 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.
3309 pub effective: Option<Vec<String>>,
3310}
3311
3312impl common::NestedType for ProfilePermissions {}
3313impl common::Part for ProfilePermissions {}
3314
3315/// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
3316///
3317/// This type is not used in any activity, and only used as *part* of another schema.
3318///
3319#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3320#[serde_with::serde_as]
3321#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3322pub struct RealtimeDataColumnHeaders {
3323 /// Column Type. Either DIMENSION or METRIC.
3324 #[serde(rename = "columnType")]
3325 pub column_type: Option<String>,
3326 /// 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.
3327 #[serde(rename = "dataType")]
3328 pub data_type: Option<String>,
3329 /// Column name.
3330 pub name: Option<String>,
3331}
3332
3333impl common::NestedType for RealtimeDataColumnHeaders {}
3334impl common::Part for RealtimeDataColumnHeaders {}
3335
3336/// Information for the view (profile), for which the real time data was requested.
3337///
3338/// This type is not used in any activity, and only used as *part* of another schema.
3339///
3340#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3341#[serde_with::serde_as]
3342#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3343pub struct RealtimeDataProfileInfo {
3344 /// Account ID to which this view (profile) belongs.
3345 #[serde(rename = "accountId")]
3346 pub account_id: Option<String>,
3347 /// Internal ID for the web property to which this view (profile) belongs.
3348 #[serde(rename = "internalWebPropertyId")]
3349 pub internal_web_property_id: Option<String>,
3350 /// View (Profile) ID.
3351 #[serde(rename = "profileId")]
3352 pub profile_id: Option<String>,
3353 /// View (Profile) name.
3354 #[serde(rename = "profileName")]
3355 pub profile_name: Option<String>,
3356 /// Table ID for view (profile).
3357 #[serde(rename = "tableId")]
3358 pub table_id: Option<String>,
3359 /// Web Property ID to which this view (profile) belongs.
3360 #[serde(rename = "webPropertyId")]
3361 pub web_property_id: Option<String>,
3362}
3363
3364impl common::NestedType for RealtimeDataProfileInfo {}
3365impl common::Part for RealtimeDataProfileInfo {}
3366
3367/// Real time data request query parameters.
3368///
3369/// This type is not used in any activity, and only used as *part* of another schema.
3370///
3371#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3372#[serde_with::serde_as]
3373#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3374pub struct RealtimeDataQuery {
3375 /// List of real time dimensions.
3376 pub dimensions: Option<String>,
3377 /// Comma-separated list of dimension or metric filters.
3378 pub filters: Option<String>,
3379 /// Unique table ID.
3380 pub ids: Option<String>,
3381 /// Maximum results per page.
3382 #[serde(rename = "max-results")]
3383 pub max_results: Option<i32>,
3384 /// List of real time metrics.
3385 pub metrics: Option<Vec<String>>,
3386 /// List of dimensions or metrics based on which real time data is sorted.
3387 pub sort: Option<Vec<String>>,
3388}
3389
3390impl common::NestedType for RealtimeDataQuery {}
3391impl common::Part for RealtimeDataQuery {}
3392
3393/// The simple audience definition that will cause a user to be added to an audience.
3394///
3395/// This type is not used in any activity, and only used as *part* of another schema.
3396///
3397#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3398#[serde_with::serde_as]
3399#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3400pub struct RemarketingAudienceAudienceDefinition {
3401 /// Defines the conditions to include users to the audience.
3402 #[serde(rename = "includeConditions")]
3403 pub include_conditions: Option<IncludeConditions>,
3404}
3405
3406impl common::NestedType for RemarketingAudienceAudienceDefinition {}
3407impl common::Part for RemarketingAudienceAudienceDefinition {}
3408
3409/// A state based audience definition that will cause a user to be added or removed from an audience.
3410///
3411/// This type is not used in any activity, and only used as *part* of another schema.
3412///
3413#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3414#[serde_with::serde_as]
3415#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3416pub struct RemarketingAudienceStateBasedAudienceDefinition {
3417 /// Defines the conditions to exclude users from the audience.
3418 #[serde(rename = "excludeConditions")]
3419 pub exclude_conditions:
3420 Option<RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions>,
3421 /// Defines the conditions to include users to the audience.
3422 #[serde(rename = "includeConditions")]
3423 pub include_conditions: Option<IncludeConditions>,
3424}
3425
3426impl common::NestedType for RemarketingAudienceStateBasedAudienceDefinition {}
3427impl common::Part for RemarketingAudienceStateBasedAudienceDefinition {}
3428
3429/// Defines the conditions to exclude users from the audience.
3430///
3431/// This type is not used in any activity, and only used as *part* of another schema.
3432///
3433#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3434#[serde_with::serde_as]
3435#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3436pub struct RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions {
3437 /// Whether to make the exclusion TEMPORARY or PERMANENT.
3438 #[serde(rename = "exclusionDuration")]
3439 pub exclusion_duration: Option<String>,
3440 /// The segment condition that will cause a user to be removed from an audience.
3441 pub segment: Option<String>,
3442}
3443
3444impl common::NestedType for RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions {}
3445impl common::Part for RemarketingAudienceStateBasedAudienceDefinitionExcludeConditions {}
3446
3447/// Download details for a file stored in Google Cloud Storage.
3448///
3449/// This type is not used in any activity, and only used as *part* of another schema.
3450///
3451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3452#[serde_with::serde_as]
3453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3454pub struct UnsampledReportCloudStorageDownloadDetails {
3455 /// Id of the bucket the file object is stored in.
3456 #[serde(rename = "bucketId")]
3457 pub bucket_id: Option<String>,
3458 /// Id of the file object containing the report data.
3459 #[serde(rename = "objectId")]
3460 pub object_id: Option<String>,
3461}
3462
3463impl common::NestedType for UnsampledReportCloudStorageDownloadDetails {}
3464impl common::Part for UnsampledReportCloudStorageDownloadDetails {}
3465
3466/// Download details for a file stored in Google Drive.
3467///
3468/// This type is not used in any activity, and only used as *part* of another schema.
3469///
3470#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3471#[serde_with::serde_as]
3472#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3473pub struct UnsampledReportDriveDownloadDetails {
3474 /// Id of the document/file containing the report data.
3475 #[serde(rename = "documentId")]
3476 pub document_id: Option<String>,
3477}
3478
3479impl common::NestedType for UnsampledReportDriveDownloadDetails {}
3480impl common::Part for UnsampledReportDriveDownloadDetails {}
3481
3482/// User ID.
3483///
3484/// This type is not used in any activity, and only used as *part* of another schema.
3485///
3486#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3487#[serde_with::serde_as]
3488#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3489pub struct UserDeletionRequestId {
3490 /// Type of user
3491 #[serde(rename = "type")]
3492 pub type_: Option<String>,
3493 /// The User's id
3494 #[serde(rename = "userId")]
3495 pub user_id: Option<String>,
3496}
3497
3498impl common::NestedType for UserDeletionRequestId {}
3499impl common::Part for UserDeletionRequestId {}
3500
3501/// Child link for this web property. Points to the list of views (profiles) for this web property.
3502///
3503/// This type is not used in any activity, and only used as *part* of another schema.
3504///
3505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3506#[serde_with::serde_as]
3507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3508pub struct WebpropertyChildLink {
3509 /// Link to the list of views (profiles) for this web property.
3510 pub href: Option<String>,
3511 /// Type of the parent link. Its value is "analytics#profiles".
3512 #[serde(rename = "type")]
3513 pub type_: Option<String>,
3514}
3515
3516impl common::NestedType for WebpropertyChildLink {}
3517impl common::Part for WebpropertyChildLink {}
3518
3519/// Parent link for this web property. Points to the account to which this web property belongs.
3520///
3521/// This type is not used in any activity, and only used as *part* of another schema.
3522///
3523#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3524#[serde_with::serde_as]
3525#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3526pub struct WebpropertyParentLink {
3527 /// Link to the account for this web property.
3528 pub href: Option<String>,
3529 /// Type of the parent link. Its value is "analytics#account".
3530 #[serde(rename = "type")]
3531 pub type_: Option<String>,
3532}
3533
3534impl common::NestedType for WebpropertyParentLink {}
3535impl common::Part for WebpropertyParentLink {}
3536
3537/// Permissions the user has for this web property.
3538///
3539/// This type is not used in any activity, and only used as *part* of another schema.
3540///
3541#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3542#[serde_with::serde_as]
3543#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3544pub struct WebpropertyPermissions {
3545 /// 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.
3546 pub effective: Option<Vec<String>>,
3547}
3548
3549impl common::NestedType for WebpropertyPermissions {}
3550impl common::Part for WebpropertyPermissions {}
3551
3552// ###################
3553// MethodBuilders ###
3554// #################
3555
3556/// A builder providing access to all methods supported on *data* resources.
3557/// It is not used directly, but through the [`Analytics`] hub.
3558///
3559/// # Example
3560///
3561/// Instantiate a resource builder
3562///
3563/// ```test_harness,no_run
3564/// extern crate hyper;
3565/// extern crate hyper_rustls;
3566/// extern crate google_analytics3 as analytics3;
3567///
3568/// # async fn dox() {
3569/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3570///
3571/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3572/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3573/// secret,
3574/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3575/// ).build().await.unwrap();
3576///
3577/// let client = hyper_util::client::legacy::Client::builder(
3578/// hyper_util::rt::TokioExecutor::new()
3579/// )
3580/// .build(
3581/// hyper_rustls::HttpsConnectorBuilder::new()
3582/// .with_native_roots()
3583/// .unwrap()
3584/// .https_or_http()
3585/// .enable_http1()
3586/// .build()
3587/// );
3588/// let mut hub = Analytics::new(client, auth);
3589/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3590/// // like `ga_get(...)`, `mcf_get(...)` and `realtime_get(...)`
3591/// // to build up your call.
3592/// let rb = hub.data();
3593/// # }
3594/// ```
3595pub struct DataMethods<'a, C>
3596where
3597 C: 'a,
3598{
3599 hub: &'a Analytics<C>,
3600}
3601
3602impl<'a, C> common::MethodsBuilder for DataMethods<'a, C> {}
3603
3604impl<'a, C> DataMethods<'a, C> {
3605 /// Create a builder to help you perform the following task:
3606 ///
3607 /// Returns Analytics data for a view (profile).
3608 ///
3609 /// # Arguments
3610 ///
3611 /// * `ids` - Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
3612 /// * `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.
3613 /// * `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.
3614 /// * `metrics` - A comma-separated list of Analytics metrics. E.g., 'ga:sessions,ga:pageviews'. At least one metric must be specified.
3615 pub fn ga_get(
3616 &self,
3617 ids: &str,
3618 start_date: &str,
3619 end_date: &str,
3620 metrics: &str,
3621 ) -> DataGaGetCall<'a, C> {
3622 DataGaGetCall {
3623 hub: self.hub,
3624 _ids: ids.to_string(),
3625 _start_date: start_date.to_string(),
3626 _end_date: end_date.to_string(),
3627 _metrics: metrics.to_string(),
3628 _start_index: Default::default(),
3629 _sort: Default::default(),
3630 _segment: Default::default(),
3631 _sampling_level: Default::default(),
3632 _output: Default::default(),
3633 _max_results: Default::default(),
3634 _include_empty_rows: Default::default(),
3635 _filters: Default::default(),
3636 _dimensions: Default::default(),
3637 _delegate: Default::default(),
3638 _additional_params: Default::default(),
3639 _scopes: Default::default(),
3640 }
3641 }
3642
3643 /// Create a builder to help you perform the following task:
3644 ///
3645 /// Returns Analytics Multi-Channel Funnels data for a view (profile).
3646 ///
3647 /// # Arguments
3648 ///
3649 /// * `ids` - Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
3650 /// * `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.
3651 /// * `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.
3652 /// * `metrics` - A comma-separated list of Multi-Channel Funnels metrics. E.g., 'mcf:totalConversions,mcf:totalConversionValue'. At least one metric must be specified.
3653 pub fn mcf_get(
3654 &self,
3655 ids: &str,
3656 start_date: &str,
3657 end_date: &str,
3658 metrics: &str,
3659 ) -> DataMcfGetCall<'a, C> {
3660 DataMcfGetCall {
3661 hub: self.hub,
3662 _ids: ids.to_string(),
3663 _start_date: start_date.to_string(),
3664 _end_date: end_date.to_string(),
3665 _metrics: metrics.to_string(),
3666 _start_index: Default::default(),
3667 _sort: Default::default(),
3668 _sampling_level: Default::default(),
3669 _max_results: Default::default(),
3670 _filters: Default::default(),
3671 _dimensions: Default::default(),
3672 _delegate: Default::default(),
3673 _additional_params: Default::default(),
3674 _scopes: Default::default(),
3675 }
3676 }
3677
3678 /// Create a builder to help you perform the following task:
3679 ///
3680 /// Returns real time data for a view (profile).
3681 ///
3682 /// # Arguments
3683 ///
3684 /// * `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.
3685 /// * `metrics` - A comma-separated list of real time metrics. E.g., 'rt:activeUsers'. At least one metric must be specified.
3686 pub fn realtime_get(&self, ids: &str, metrics: &str) -> DataRealtimeGetCall<'a, C> {
3687 DataRealtimeGetCall {
3688 hub: self.hub,
3689 _ids: ids.to_string(),
3690 _metrics: metrics.to_string(),
3691 _sort: Default::default(),
3692 _max_results: Default::default(),
3693 _filters: Default::default(),
3694 _dimensions: Default::default(),
3695 _delegate: Default::default(),
3696 _additional_params: Default::default(),
3697 _scopes: Default::default(),
3698 }
3699 }
3700}
3701
3702/// A builder providing access to all methods supported on *management* resources.
3703/// It is not used directly, but through the [`Analytics`] hub.
3704///
3705/// # Example
3706///
3707/// Instantiate a resource builder
3708///
3709/// ```test_harness,no_run
3710/// extern crate hyper;
3711/// extern crate hyper_rustls;
3712/// extern crate google_analytics3 as analytics3;
3713///
3714/// # async fn dox() {
3715/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3716///
3717/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3718/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3719/// secret,
3720/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3721/// ).build().await.unwrap();
3722///
3723/// let client = hyper_util::client::legacy::Client::builder(
3724/// hyper_util::rt::TokioExecutor::new()
3725/// )
3726/// .build(
3727/// hyper_rustls::HttpsConnectorBuilder::new()
3728/// .with_native_roots()
3729/// .unwrap()
3730/// .https_or_http()
3731/// .enable_http1()
3732/// .build()
3733/// );
3734/// let mut hub = Analytics::new(client, auth);
3735/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3736/// // 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(...)`
3737/// // to build up your call.
3738/// let rb = hub.management();
3739/// # }
3740/// ```
3741pub struct ManagementMethods<'a, C>
3742where
3743 C: 'a,
3744{
3745 hub: &'a Analytics<C>,
3746}
3747
3748impl<'a, C> common::MethodsBuilder for ManagementMethods<'a, C> {}
3749
3750impl<'a, C> ManagementMethods<'a, C> {
3751 /// Create a builder to help you perform the following task:
3752 ///
3753 /// Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access.
3754 pub fn account_summaries_list(&self) -> ManagementAccountSummaryListCall<'a, C> {
3755 ManagementAccountSummaryListCall {
3756 hub: self.hub,
3757 _start_index: Default::default(),
3758 _max_results: Default::default(),
3759 _delegate: Default::default(),
3760 _additional_params: Default::default(),
3761 _scopes: Default::default(),
3762 }
3763 }
3764
3765 /// Create a builder to help you perform the following task:
3766 ///
3767 /// Removes a user from the given account.
3768 ///
3769 /// # Arguments
3770 ///
3771 /// * `accountId` - Account ID to delete the user link for.
3772 /// * `linkId` - Link ID to delete the user link for.
3773 pub fn account_user_links_delete(
3774 &self,
3775 account_id: &str,
3776 link_id: &str,
3777 ) -> ManagementAccountUserLinkDeleteCall<'a, C> {
3778 ManagementAccountUserLinkDeleteCall {
3779 hub: self.hub,
3780 _account_id: account_id.to_string(),
3781 _link_id: link_id.to_string(),
3782 _delegate: Default::default(),
3783 _additional_params: Default::default(),
3784 _scopes: Default::default(),
3785 }
3786 }
3787
3788 /// Create a builder to help you perform the following task:
3789 ///
3790 /// Adds a new user to the given account.
3791 ///
3792 /// # Arguments
3793 ///
3794 /// * `request` - No description provided.
3795 /// * `accountId` - Account ID to create the user link for.
3796 pub fn account_user_links_insert(
3797 &self,
3798 request: EntityUserLink,
3799 account_id: &str,
3800 ) -> ManagementAccountUserLinkInsertCall<'a, C> {
3801 ManagementAccountUserLinkInsertCall {
3802 hub: self.hub,
3803 _request: request,
3804 _account_id: account_id.to_string(),
3805 _delegate: Default::default(),
3806 _additional_params: Default::default(),
3807 _scopes: Default::default(),
3808 }
3809 }
3810
3811 /// Create a builder to help you perform the following task:
3812 ///
3813 /// Lists account-user links for a given account.
3814 ///
3815 /// # Arguments
3816 ///
3817 /// * `accountId` - Account ID to retrieve the user links for.
3818 pub fn account_user_links_list(
3819 &self,
3820 account_id: &str,
3821 ) -> ManagementAccountUserLinkListCall<'a, C> {
3822 ManagementAccountUserLinkListCall {
3823 hub: self.hub,
3824 _account_id: account_id.to_string(),
3825 _start_index: Default::default(),
3826 _max_results: Default::default(),
3827 _delegate: Default::default(),
3828 _additional_params: Default::default(),
3829 _scopes: Default::default(),
3830 }
3831 }
3832
3833 /// Create a builder to help you perform the following task:
3834 ///
3835 /// Updates permissions for an existing user on the given account.
3836 ///
3837 /// # Arguments
3838 ///
3839 /// * `request` - No description provided.
3840 /// * `accountId` - Account ID to update the account-user link for.
3841 /// * `linkId` - Link ID to update the account-user link for.
3842 pub fn account_user_links_update(
3843 &self,
3844 request: EntityUserLink,
3845 account_id: &str,
3846 link_id: &str,
3847 ) -> ManagementAccountUserLinkUpdateCall<'a, C> {
3848 ManagementAccountUserLinkUpdateCall {
3849 hub: self.hub,
3850 _request: request,
3851 _account_id: account_id.to_string(),
3852 _link_id: link_id.to_string(),
3853 _delegate: Default::default(),
3854 _additional_params: Default::default(),
3855 _scopes: Default::default(),
3856 }
3857 }
3858
3859 /// Create a builder to help you perform the following task:
3860 ///
3861 /// Lists all accounts to which the user has access.
3862 pub fn accounts_list(&self) -> ManagementAccountListCall<'a, C> {
3863 ManagementAccountListCall {
3864 hub: self.hub,
3865 _start_index: Default::default(),
3866 _max_results: Default::default(),
3867 _delegate: Default::default(),
3868 _additional_params: Default::default(),
3869 _scopes: Default::default(),
3870 }
3871 }
3872
3873 /// Create a builder to help you perform the following task:
3874 ///
3875 /// Hashes the given Client ID.
3876 ///
3877 /// # Arguments
3878 ///
3879 /// * `request` - No description provided.
3880 pub fn client_id_hash_client_id(
3881 &self,
3882 request: HashClientIdRequest,
3883 ) -> ManagementClientIdHashClientIdCall<'a, C> {
3884 ManagementClientIdHashClientIdCall {
3885 hub: self.hub,
3886 _request: request,
3887 _delegate: Default::default(),
3888 _additional_params: Default::default(),
3889 _scopes: Default::default(),
3890 }
3891 }
3892
3893 /// Create a builder to help you perform the following task:
3894 ///
3895 /// List custom data sources to which the user has access.
3896 ///
3897 /// # Arguments
3898 ///
3899 /// * `accountId` - Account Id for the custom data sources to retrieve.
3900 /// * `webPropertyId` - Web property Id for the custom data sources to retrieve.
3901 pub fn custom_data_sources_list(
3902 &self,
3903 account_id: &str,
3904 web_property_id: &str,
3905 ) -> ManagementCustomDataSourceListCall<'a, C> {
3906 ManagementCustomDataSourceListCall {
3907 hub: self.hub,
3908 _account_id: account_id.to_string(),
3909 _web_property_id: web_property_id.to_string(),
3910 _start_index: Default::default(),
3911 _max_results: Default::default(),
3912 _delegate: Default::default(),
3913 _additional_params: Default::default(),
3914 _scopes: Default::default(),
3915 }
3916 }
3917
3918 /// Create a builder to help you perform the following task:
3919 ///
3920 /// Get a custom dimension to which the user has access.
3921 ///
3922 /// # Arguments
3923 ///
3924 /// * `accountId` - Account ID for the custom dimension to retrieve.
3925 /// * `webPropertyId` - Web property ID for the custom dimension to retrieve.
3926 /// * `customDimensionId` - The ID of the custom dimension to retrieve.
3927 pub fn custom_dimensions_get(
3928 &self,
3929 account_id: &str,
3930 web_property_id: &str,
3931 custom_dimension_id: &str,
3932 ) -> ManagementCustomDimensionGetCall<'a, C> {
3933 ManagementCustomDimensionGetCall {
3934 hub: self.hub,
3935 _account_id: account_id.to_string(),
3936 _web_property_id: web_property_id.to_string(),
3937 _custom_dimension_id: custom_dimension_id.to_string(),
3938 _delegate: Default::default(),
3939 _additional_params: Default::default(),
3940 _scopes: Default::default(),
3941 }
3942 }
3943
3944 /// Create a builder to help you perform the following task:
3945 ///
3946 /// Create a new custom dimension.
3947 ///
3948 /// # Arguments
3949 ///
3950 /// * `request` - No description provided.
3951 /// * `accountId` - Account ID for the custom dimension to create.
3952 /// * `webPropertyId` - Web property ID for the custom dimension to create.
3953 pub fn custom_dimensions_insert(
3954 &self,
3955 request: CustomDimension,
3956 account_id: &str,
3957 web_property_id: &str,
3958 ) -> ManagementCustomDimensionInsertCall<'a, C> {
3959 ManagementCustomDimensionInsertCall {
3960 hub: self.hub,
3961 _request: request,
3962 _account_id: account_id.to_string(),
3963 _web_property_id: web_property_id.to_string(),
3964 _delegate: Default::default(),
3965 _additional_params: Default::default(),
3966 _scopes: Default::default(),
3967 }
3968 }
3969
3970 /// Create a builder to help you perform the following task:
3971 ///
3972 /// Lists custom dimensions to which the user has access.
3973 ///
3974 /// # Arguments
3975 ///
3976 /// * `accountId` - Account ID for the custom dimensions to retrieve.
3977 /// * `webPropertyId` - Web property ID for the custom dimensions to retrieve.
3978 pub fn custom_dimensions_list(
3979 &self,
3980 account_id: &str,
3981 web_property_id: &str,
3982 ) -> ManagementCustomDimensionListCall<'a, C> {
3983 ManagementCustomDimensionListCall {
3984 hub: self.hub,
3985 _account_id: account_id.to_string(),
3986 _web_property_id: web_property_id.to_string(),
3987 _start_index: Default::default(),
3988 _max_results: Default::default(),
3989 _delegate: Default::default(),
3990 _additional_params: Default::default(),
3991 _scopes: Default::default(),
3992 }
3993 }
3994
3995 /// Create a builder to help you perform the following task:
3996 ///
3997 /// Updates an existing custom dimension. This method supports patch semantics.
3998 ///
3999 /// # Arguments
4000 ///
4001 /// * `request` - No description provided.
4002 /// * `accountId` - Account ID for the custom dimension to update.
4003 /// * `webPropertyId` - Web property ID for the custom dimension to update.
4004 /// * `customDimensionId` - Custom dimension ID for the custom dimension to update.
4005 pub fn custom_dimensions_patch(
4006 &self,
4007 request: CustomDimension,
4008 account_id: &str,
4009 web_property_id: &str,
4010 custom_dimension_id: &str,
4011 ) -> ManagementCustomDimensionPatchCall<'a, C> {
4012 ManagementCustomDimensionPatchCall {
4013 hub: self.hub,
4014 _request: request,
4015 _account_id: account_id.to_string(),
4016 _web_property_id: web_property_id.to_string(),
4017 _custom_dimension_id: custom_dimension_id.to_string(),
4018 _ignore_custom_data_source_links: Default::default(),
4019 _delegate: Default::default(),
4020 _additional_params: Default::default(),
4021 _scopes: Default::default(),
4022 }
4023 }
4024
4025 /// Create a builder to help you perform the following task:
4026 ///
4027 /// Updates an existing custom dimension.
4028 ///
4029 /// # Arguments
4030 ///
4031 /// * `request` - No description provided.
4032 /// * `accountId` - Account ID for the custom dimension to update.
4033 /// * `webPropertyId` - Web property ID for the custom dimension to update.
4034 /// * `customDimensionId` - Custom dimension ID for the custom dimension to update.
4035 pub fn custom_dimensions_update(
4036 &self,
4037 request: CustomDimension,
4038 account_id: &str,
4039 web_property_id: &str,
4040 custom_dimension_id: &str,
4041 ) -> ManagementCustomDimensionUpdateCall<'a, C> {
4042 ManagementCustomDimensionUpdateCall {
4043 hub: self.hub,
4044 _request: request,
4045 _account_id: account_id.to_string(),
4046 _web_property_id: web_property_id.to_string(),
4047 _custom_dimension_id: custom_dimension_id.to_string(),
4048 _ignore_custom_data_source_links: Default::default(),
4049 _delegate: Default::default(),
4050 _additional_params: Default::default(),
4051 _scopes: Default::default(),
4052 }
4053 }
4054
4055 /// Create a builder to help you perform the following task:
4056 ///
4057 /// Get a custom metric to which the user has access.
4058 ///
4059 /// # Arguments
4060 ///
4061 /// * `accountId` - Account ID for the custom metric to retrieve.
4062 /// * `webPropertyId` - Web property ID for the custom metric to retrieve.
4063 /// * `customMetricId` - The ID of the custom metric to retrieve.
4064 pub fn custom_metrics_get(
4065 &self,
4066 account_id: &str,
4067 web_property_id: &str,
4068 custom_metric_id: &str,
4069 ) -> ManagementCustomMetricGetCall<'a, C> {
4070 ManagementCustomMetricGetCall {
4071 hub: self.hub,
4072 _account_id: account_id.to_string(),
4073 _web_property_id: web_property_id.to_string(),
4074 _custom_metric_id: custom_metric_id.to_string(),
4075 _delegate: Default::default(),
4076 _additional_params: Default::default(),
4077 _scopes: Default::default(),
4078 }
4079 }
4080
4081 /// Create a builder to help you perform the following task:
4082 ///
4083 /// Create a new custom metric.
4084 ///
4085 /// # Arguments
4086 ///
4087 /// * `request` - No description provided.
4088 /// * `accountId` - Account ID for the custom metric to create.
4089 /// * `webPropertyId` - Web property ID for the custom dimension to create.
4090 pub fn custom_metrics_insert(
4091 &self,
4092 request: CustomMetric,
4093 account_id: &str,
4094 web_property_id: &str,
4095 ) -> ManagementCustomMetricInsertCall<'a, C> {
4096 ManagementCustomMetricInsertCall {
4097 hub: self.hub,
4098 _request: request,
4099 _account_id: account_id.to_string(),
4100 _web_property_id: web_property_id.to_string(),
4101 _delegate: Default::default(),
4102 _additional_params: Default::default(),
4103 _scopes: Default::default(),
4104 }
4105 }
4106
4107 /// Create a builder to help you perform the following task:
4108 ///
4109 /// Lists custom metrics to which the user has access.
4110 ///
4111 /// # Arguments
4112 ///
4113 /// * `accountId` - Account ID for the custom metrics to retrieve.
4114 /// * `webPropertyId` - Web property ID for the custom metrics to retrieve.
4115 pub fn custom_metrics_list(
4116 &self,
4117 account_id: &str,
4118 web_property_id: &str,
4119 ) -> ManagementCustomMetricListCall<'a, C> {
4120 ManagementCustomMetricListCall {
4121 hub: self.hub,
4122 _account_id: account_id.to_string(),
4123 _web_property_id: web_property_id.to_string(),
4124 _start_index: Default::default(),
4125 _max_results: Default::default(),
4126 _delegate: Default::default(),
4127 _additional_params: Default::default(),
4128 _scopes: Default::default(),
4129 }
4130 }
4131
4132 /// Create a builder to help you perform the following task:
4133 ///
4134 /// Updates an existing custom metric. This method supports patch semantics.
4135 ///
4136 /// # Arguments
4137 ///
4138 /// * `request` - No description provided.
4139 /// * `accountId` - Account ID for the custom metric to update.
4140 /// * `webPropertyId` - Web property ID for the custom metric to update.
4141 /// * `customMetricId` - Custom metric ID for the custom metric to update.
4142 pub fn custom_metrics_patch(
4143 &self,
4144 request: CustomMetric,
4145 account_id: &str,
4146 web_property_id: &str,
4147 custom_metric_id: &str,
4148 ) -> ManagementCustomMetricPatchCall<'a, C> {
4149 ManagementCustomMetricPatchCall {
4150 hub: self.hub,
4151 _request: request,
4152 _account_id: account_id.to_string(),
4153 _web_property_id: web_property_id.to_string(),
4154 _custom_metric_id: custom_metric_id.to_string(),
4155 _ignore_custom_data_source_links: Default::default(),
4156 _delegate: Default::default(),
4157 _additional_params: Default::default(),
4158 _scopes: Default::default(),
4159 }
4160 }
4161
4162 /// Create a builder to help you perform the following task:
4163 ///
4164 /// Updates an existing custom metric.
4165 ///
4166 /// # Arguments
4167 ///
4168 /// * `request` - No description provided.
4169 /// * `accountId` - Account ID for the custom metric to update.
4170 /// * `webPropertyId` - Web property ID for the custom metric to update.
4171 /// * `customMetricId` - Custom metric ID for the custom metric to update.
4172 pub fn custom_metrics_update(
4173 &self,
4174 request: CustomMetric,
4175 account_id: &str,
4176 web_property_id: &str,
4177 custom_metric_id: &str,
4178 ) -> ManagementCustomMetricUpdateCall<'a, C> {
4179 ManagementCustomMetricUpdateCall {
4180 hub: self.hub,
4181 _request: request,
4182 _account_id: account_id.to_string(),
4183 _web_property_id: web_property_id.to_string(),
4184 _custom_metric_id: custom_metric_id.to_string(),
4185 _ignore_custom_data_source_links: Default::default(),
4186 _delegate: Default::default(),
4187 _additional_params: Default::default(),
4188 _scopes: Default::default(),
4189 }
4190 }
4191
4192 /// Create a builder to help you perform the following task:
4193 ///
4194 /// Delete an experiment.
4195 ///
4196 /// # Arguments
4197 ///
4198 /// * `accountId` - Account ID to which the experiment belongs
4199 /// * `webPropertyId` - Web property ID to which the experiment belongs
4200 /// * `profileId` - View (Profile) ID to which the experiment belongs
4201 /// * `experimentId` - ID of the experiment to delete
4202 pub fn experiments_delete(
4203 &self,
4204 account_id: &str,
4205 web_property_id: &str,
4206 profile_id: &str,
4207 experiment_id: &str,
4208 ) -> ManagementExperimentDeleteCall<'a, C> {
4209 ManagementExperimentDeleteCall {
4210 hub: self.hub,
4211 _account_id: account_id.to_string(),
4212 _web_property_id: web_property_id.to_string(),
4213 _profile_id: profile_id.to_string(),
4214 _experiment_id: experiment_id.to_string(),
4215 _delegate: Default::default(),
4216 _additional_params: Default::default(),
4217 _scopes: Default::default(),
4218 }
4219 }
4220
4221 /// Create a builder to help you perform the following task:
4222 ///
4223 /// Returns an experiment to which the user has access.
4224 ///
4225 /// # Arguments
4226 ///
4227 /// * `accountId` - Account ID to retrieve the experiment for.
4228 /// * `webPropertyId` - Web property ID to retrieve the experiment for.
4229 /// * `profileId` - View (Profile) ID to retrieve the experiment for.
4230 /// * `experimentId` - Experiment ID to retrieve the experiment for.
4231 pub fn experiments_get(
4232 &self,
4233 account_id: &str,
4234 web_property_id: &str,
4235 profile_id: &str,
4236 experiment_id: &str,
4237 ) -> ManagementExperimentGetCall<'a, C> {
4238 ManagementExperimentGetCall {
4239 hub: self.hub,
4240 _account_id: account_id.to_string(),
4241 _web_property_id: web_property_id.to_string(),
4242 _profile_id: profile_id.to_string(),
4243 _experiment_id: experiment_id.to_string(),
4244 _delegate: Default::default(),
4245 _additional_params: Default::default(),
4246 _scopes: Default::default(),
4247 }
4248 }
4249
4250 /// Create a builder to help you perform the following task:
4251 ///
4252 /// Create a new experiment.
4253 ///
4254 /// # Arguments
4255 ///
4256 /// * `request` - No description provided.
4257 /// * `accountId` - Account ID to create the experiment for.
4258 /// * `webPropertyId` - Web property ID to create the experiment for.
4259 /// * `profileId` - View (Profile) ID to create the experiment for.
4260 pub fn experiments_insert(
4261 &self,
4262 request: Experiment,
4263 account_id: &str,
4264 web_property_id: &str,
4265 profile_id: &str,
4266 ) -> ManagementExperimentInsertCall<'a, C> {
4267 ManagementExperimentInsertCall {
4268 hub: self.hub,
4269 _request: request,
4270 _account_id: account_id.to_string(),
4271 _web_property_id: web_property_id.to_string(),
4272 _profile_id: profile_id.to_string(),
4273 _delegate: Default::default(),
4274 _additional_params: Default::default(),
4275 _scopes: Default::default(),
4276 }
4277 }
4278
4279 /// Create a builder to help you perform the following task:
4280 ///
4281 /// Lists experiments to which the user has access.
4282 ///
4283 /// # Arguments
4284 ///
4285 /// * `accountId` - Account ID to retrieve experiments for.
4286 /// * `webPropertyId` - Web property ID to retrieve experiments for.
4287 /// * `profileId` - View (Profile) ID to retrieve experiments for.
4288 pub fn experiments_list(
4289 &self,
4290 account_id: &str,
4291 web_property_id: &str,
4292 profile_id: &str,
4293 ) -> ManagementExperimentListCall<'a, C> {
4294 ManagementExperimentListCall {
4295 hub: self.hub,
4296 _account_id: account_id.to_string(),
4297 _web_property_id: web_property_id.to_string(),
4298 _profile_id: profile_id.to_string(),
4299 _start_index: Default::default(),
4300 _max_results: Default::default(),
4301 _delegate: Default::default(),
4302 _additional_params: Default::default(),
4303 _scopes: Default::default(),
4304 }
4305 }
4306
4307 /// Create a builder to help you perform the following task:
4308 ///
4309 /// Update an existing experiment. This method supports patch semantics.
4310 ///
4311 /// # Arguments
4312 ///
4313 /// * `request` - No description provided.
4314 /// * `accountId` - Account ID of the experiment to update.
4315 /// * `webPropertyId` - Web property ID of the experiment to update.
4316 /// * `profileId` - View (Profile) ID of the experiment to update.
4317 /// * `experimentId` - Experiment ID of the experiment to update.
4318 pub fn experiments_patch(
4319 &self,
4320 request: Experiment,
4321 account_id: &str,
4322 web_property_id: &str,
4323 profile_id: &str,
4324 experiment_id: &str,
4325 ) -> ManagementExperimentPatchCall<'a, C> {
4326 ManagementExperimentPatchCall {
4327 hub: self.hub,
4328 _request: request,
4329 _account_id: account_id.to_string(),
4330 _web_property_id: web_property_id.to_string(),
4331 _profile_id: profile_id.to_string(),
4332 _experiment_id: experiment_id.to_string(),
4333 _delegate: Default::default(),
4334 _additional_params: Default::default(),
4335 _scopes: Default::default(),
4336 }
4337 }
4338
4339 /// Create a builder to help you perform the following task:
4340 ///
4341 /// Update an existing experiment.
4342 ///
4343 /// # Arguments
4344 ///
4345 /// * `request` - No description provided.
4346 /// * `accountId` - Account ID of the experiment to update.
4347 /// * `webPropertyId` - Web property ID of the experiment to update.
4348 /// * `profileId` - View (Profile) ID of the experiment to update.
4349 /// * `experimentId` - Experiment ID of the experiment to update.
4350 pub fn experiments_update(
4351 &self,
4352 request: Experiment,
4353 account_id: &str,
4354 web_property_id: &str,
4355 profile_id: &str,
4356 experiment_id: &str,
4357 ) -> ManagementExperimentUpdateCall<'a, C> {
4358 ManagementExperimentUpdateCall {
4359 hub: self.hub,
4360 _request: request,
4361 _account_id: account_id.to_string(),
4362 _web_property_id: web_property_id.to_string(),
4363 _profile_id: profile_id.to_string(),
4364 _experiment_id: experiment_id.to_string(),
4365 _delegate: Default::default(),
4366 _additional_params: Default::default(),
4367 _scopes: Default::default(),
4368 }
4369 }
4370
4371 /// Create a builder to help you perform the following task:
4372 ///
4373 /// Delete a filter.
4374 ///
4375 /// # Arguments
4376 ///
4377 /// * `accountId` - Account ID to delete the filter for.
4378 /// * `filterId` - ID of the filter to be deleted.
4379 pub fn filters_delete(
4380 &self,
4381 account_id: &str,
4382 filter_id: &str,
4383 ) -> ManagementFilterDeleteCall<'a, C> {
4384 ManagementFilterDeleteCall {
4385 hub: self.hub,
4386 _account_id: account_id.to_string(),
4387 _filter_id: filter_id.to_string(),
4388 _delegate: Default::default(),
4389 _additional_params: Default::default(),
4390 _scopes: Default::default(),
4391 }
4392 }
4393
4394 /// Create a builder to help you perform the following task:
4395 ///
4396 /// Returns filters to which the user has access.
4397 ///
4398 /// # Arguments
4399 ///
4400 /// * `accountId` - Account ID to retrieve filters for.
4401 /// * `filterId` - Filter ID to retrieve filters for.
4402 pub fn filters_get(&self, account_id: &str, filter_id: &str) -> ManagementFilterGetCall<'a, C> {
4403 ManagementFilterGetCall {
4404 hub: self.hub,
4405 _account_id: account_id.to_string(),
4406 _filter_id: filter_id.to_string(),
4407 _delegate: Default::default(),
4408 _additional_params: Default::default(),
4409 _scopes: Default::default(),
4410 }
4411 }
4412
4413 /// Create a builder to help you perform the following task:
4414 ///
4415 /// Create a new filter.
4416 ///
4417 /// # Arguments
4418 ///
4419 /// * `request` - No description provided.
4420 /// * `accountId` - Account ID to create filter for.
4421 pub fn filters_insert(
4422 &self,
4423 request: Filter,
4424 account_id: &str,
4425 ) -> ManagementFilterInsertCall<'a, C> {
4426 ManagementFilterInsertCall {
4427 hub: self.hub,
4428 _request: request,
4429 _account_id: account_id.to_string(),
4430 _delegate: Default::default(),
4431 _additional_params: Default::default(),
4432 _scopes: Default::default(),
4433 }
4434 }
4435
4436 /// Create a builder to help you perform the following task:
4437 ///
4438 /// Lists all filters for an account
4439 ///
4440 /// # Arguments
4441 ///
4442 /// * `accountId` - Account ID to retrieve filters for.
4443 pub fn filters_list(&self, account_id: &str) -> ManagementFilterListCall<'a, C> {
4444 ManagementFilterListCall {
4445 hub: self.hub,
4446 _account_id: account_id.to_string(),
4447 _start_index: Default::default(),
4448 _max_results: Default::default(),
4449 _delegate: Default::default(),
4450 _additional_params: Default::default(),
4451 _scopes: Default::default(),
4452 }
4453 }
4454
4455 /// Create a builder to help you perform the following task:
4456 ///
4457 /// Updates an existing filter. This method supports patch semantics.
4458 ///
4459 /// # Arguments
4460 ///
4461 /// * `request` - No description provided.
4462 /// * `accountId` - Account ID to which the filter belongs.
4463 /// * `filterId` - ID of the filter to be updated.
4464 pub fn filters_patch(
4465 &self,
4466 request: Filter,
4467 account_id: &str,
4468 filter_id: &str,
4469 ) -> ManagementFilterPatchCall<'a, C> {
4470 ManagementFilterPatchCall {
4471 hub: self.hub,
4472 _request: request,
4473 _account_id: account_id.to_string(),
4474 _filter_id: filter_id.to_string(),
4475 _delegate: Default::default(),
4476 _additional_params: Default::default(),
4477 _scopes: Default::default(),
4478 }
4479 }
4480
4481 /// Create a builder to help you perform the following task:
4482 ///
4483 /// Updates an existing filter.
4484 ///
4485 /// # Arguments
4486 ///
4487 /// * `request` - No description provided.
4488 /// * `accountId` - Account ID to which the filter belongs.
4489 /// * `filterId` - ID of the filter to be updated.
4490 pub fn filters_update(
4491 &self,
4492 request: Filter,
4493 account_id: &str,
4494 filter_id: &str,
4495 ) -> ManagementFilterUpdateCall<'a, C> {
4496 ManagementFilterUpdateCall {
4497 hub: self.hub,
4498 _request: request,
4499 _account_id: account_id.to_string(),
4500 _filter_id: filter_id.to_string(),
4501 _delegate: Default::default(),
4502 _additional_params: Default::default(),
4503 _scopes: Default::default(),
4504 }
4505 }
4506
4507 /// Create a builder to help you perform the following task:
4508 ///
4509 /// Gets a goal to which the user has access.
4510 ///
4511 /// # Arguments
4512 ///
4513 /// * `accountId` - Account ID to retrieve the goal for.
4514 /// * `webPropertyId` - Web property ID to retrieve the goal for.
4515 /// * `profileId` - View (Profile) ID to retrieve the goal for.
4516 /// * `goalId` - Goal ID to retrieve the goal for.
4517 pub fn goals_get(
4518 &self,
4519 account_id: &str,
4520 web_property_id: &str,
4521 profile_id: &str,
4522 goal_id: &str,
4523 ) -> ManagementGoalGetCall<'a, C> {
4524 ManagementGoalGetCall {
4525 hub: self.hub,
4526 _account_id: account_id.to_string(),
4527 _web_property_id: web_property_id.to_string(),
4528 _profile_id: profile_id.to_string(),
4529 _goal_id: goal_id.to_string(),
4530 _delegate: Default::default(),
4531 _additional_params: Default::default(),
4532 _scopes: Default::default(),
4533 }
4534 }
4535
4536 /// Create a builder to help you perform the following task:
4537 ///
4538 /// Create a new goal.
4539 ///
4540 /// # Arguments
4541 ///
4542 /// * `request` - No description provided.
4543 /// * `accountId` - Account ID to create the goal for.
4544 /// * `webPropertyId` - Web property ID to create the goal for.
4545 /// * `profileId` - View (Profile) ID to create the goal for.
4546 pub fn goals_insert(
4547 &self,
4548 request: Goal,
4549 account_id: &str,
4550 web_property_id: &str,
4551 profile_id: &str,
4552 ) -> ManagementGoalInsertCall<'a, C> {
4553 ManagementGoalInsertCall {
4554 hub: self.hub,
4555 _request: request,
4556 _account_id: account_id.to_string(),
4557 _web_property_id: web_property_id.to_string(),
4558 _profile_id: profile_id.to_string(),
4559 _delegate: Default::default(),
4560 _additional_params: Default::default(),
4561 _scopes: Default::default(),
4562 }
4563 }
4564
4565 /// Create a builder to help you perform the following task:
4566 ///
4567 /// Lists goals to which the user has access.
4568 ///
4569 /// # Arguments
4570 ///
4571 /// * `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.
4572 /// * `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.
4573 /// * `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.
4574 pub fn goals_list(
4575 &self,
4576 account_id: &str,
4577 web_property_id: &str,
4578 profile_id: &str,
4579 ) -> ManagementGoalListCall<'a, C> {
4580 ManagementGoalListCall {
4581 hub: self.hub,
4582 _account_id: account_id.to_string(),
4583 _web_property_id: web_property_id.to_string(),
4584 _profile_id: profile_id.to_string(),
4585 _start_index: Default::default(),
4586 _max_results: Default::default(),
4587 _delegate: Default::default(),
4588 _additional_params: Default::default(),
4589 _scopes: Default::default(),
4590 }
4591 }
4592
4593 /// Create a builder to help you perform the following task:
4594 ///
4595 /// Updates an existing goal. This method supports patch semantics.
4596 ///
4597 /// # Arguments
4598 ///
4599 /// * `request` - No description provided.
4600 /// * `accountId` - Account ID to update the goal.
4601 /// * `webPropertyId` - Web property ID to update the goal.
4602 /// * `profileId` - View (Profile) ID to update the goal.
4603 /// * `goalId` - Index of the goal to be updated.
4604 pub fn goals_patch(
4605 &self,
4606 request: Goal,
4607 account_id: &str,
4608 web_property_id: &str,
4609 profile_id: &str,
4610 goal_id: &str,
4611 ) -> ManagementGoalPatchCall<'a, C> {
4612 ManagementGoalPatchCall {
4613 hub: self.hub,
4614 _request: request,
4615 _account_id: account_id.to_string(),
4616 _web_property_id: web_property_id.to_string(),
4617 _profile_id: profile_id.to_string(),
4618 _goal_id: goal_id.to_string(),
4619 _delegate: Default::default(),
4620 _additional_params: Default::default(),
4621 _scopes: Default::default(),
4622 }
4623 }
4624
4625 /// Create a builder to help you perform the following task:
4626 ///
4627 /// Updates an existing goal.
4628 ///
4629 /// # Arguments
4630 ///
4631 /// * `request` - No description provided.
4632 /// * `accountId` - Account ID to update the goal.
4633 /// * `webPropertyId` - Web property ID to update the goal.
4634 /// * `profileId` - View (Profile) ID to update the goal.
4635 /// * `goalId` - Index of the goal to be updated.
4636 pub fn goals_update(
4637 &self,
4638 request: Goal,
4639 account_id: &str,
4640 web_property_id: &str,
4641 profile_id: &str,
4642 goal_id: &str,
4643 ) -> ManagementGoalUpdateCall<'a, C> {
4644 ManagementGoalUpdateCall {
4645 hub: self.hub,
4646 _request: request,
4647 _account_id: account_id.to_string(),
4648 _web_property_id: web_property_id.to_string(),
4649 _profile_id: profile_id.to_string(),
4650 _goal_id: goal_id.to_string(),
4651 _delegate: Default::default(),
4652 _additional_params: Default::default(),
4653 _scopes: Default::default(),
4654 }
4655 }
4656
4657 /// Create a builder to help you perform the following task:
4658 ///
4659 /// Delete a profile filter link.
4660 ///
4661 /// # Arguments
4662 ///
4663 /// * `accountId` - Account ID to which the profile filter link belongs.
4664 /// * `webPropertyId` - Web property Id to which the profile filter link belongs.
4665 /// * `profileId` - Profile ID to which the filter link belongs.
4666 /// * `linkId` - ID of the profile filter link to delete.
4667 pub fn profile_filter_links_delete(
4668 &self,
4669 account_id: &str,
4670 web_property_id: &str,
4671 profile_id: &str,
4672 link_id: &str,
4673 ) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
4674 ManagementProfileFilterLinkDeleteCall {
4675 hub: self.hub,
4676 _account_id: account_id.to_string(),
4677 _web_property_id: web_property_id.to_string(),
4678 _profile_id: profile_id.to_string(),
4679 _link_id: link_id.to_string(),
4680 _delegate: Default::default(),
4681 _additional_params: Default::default(),
4682 _scopes: Default::default(),
4683 }
4684 }
4685
4686 /// Create a builder to help you perform the following task:
4687 ///
4688 /// Returns a single profile filter link.
4689 ///
4690 /// # Arguments
4691 ///
4692 /// * `accountId` - Account ID to retrieve profile filter link for.
4693 /// * `webPropertyId` - Web property Id to retrieve profile filter link for.
4694 /// * `profileId` - Profile ID to retrieve filter link for.
4695 /// * `linkId` - ID of the profile filter link.
4696 pub fn profile_filter_links_get(
4697 &self,
4698 account_id: &str,
4699 web_property_id: &str,
4700 profile_id: &str,
4701 link_id: &str,
4702 ) -> ManagementProfileFilterLinkGetCall<'a, C> {
4703 ManagementProfileFilterLinkGetCall {
4704 hub: self.hub,
4705 _account_id: account_id.to_string(),
4706 _web_property_id: web_property_id.to_string(),
4707 _profile_id: profile_id.to_string(),
4708 _link_id: link_id.to_string(),
4709 _delegate: Default::default(),
4710 _additional_params: Default::default(),
4711 _scopes: Default::default(),
4712 }
4713 }
4714
4715 /// Create a builder to help you perform the following task:
4716 ///
4717 /// Create a new profile filter link.
4718 ///
4719 /// # Arguments
4720 ///
4721 /// * `request` - No description provided.
4722 /// * `accountId` - Account ID to create profile filter link for.
4723 /// * `webPropertyId` - Web property Id to create profile filter link for.
4724 /// * `profileId` - Profile ID to create filter link for.
4725 pub fn profile_filter_links_insert(
4726 &self,
4727 request: ProfileFilterLink,
4728 account_id: &str,
4729 web_property_id: &str,
4730 profile_id: &str,
4731 ) -> ManagementProfileFilterLinkInsertCall<'a, C> {
4732 ManagementProfileFilterLinkInsertCall {
4733 hub: self.hub,
4734 _request: request,
4735 _account_id: account_id.to_string(),
4736 _web_property_id: web_property_id.to_string(),
4737 _profile_id: profile_id.to_string(),
4738 _delegate: Default::default(),
4739 _additional_params: Default::default(),
4740 _scopes: Default::default(),
4741 }
4742 }
4743
4744 /// Create a builder to help you perform the following task:
4745 ///
4746 /// Lists all profile filter links for a profile.
4747 ///
4748 /// # Arguments
4749 ///
4750 /// * `accountId` - Account ID to retrieve profile filter links for.
4751 /// * `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.
4752 /// * `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.
4753 pub fn profile_filter_links_list(
4754 &self,
4755 account_id: &str,
4756 web_property_id: &str,
4757 profile_id: &str,
4758 ) -> ManagementProfileFilterLinkListCall<'a, C> {
4759 ManagementProfileFilterLinkListCall {
4760 hub: self.hub,
4761 _account_id: account_id.to_string(),
4762 _web_property_id: web_property_id.to_string(),
4763 _profile_id: profile_id.to_string(),
4764 _start_index: Default::default(),
4765 _max_results: Default::default(),
4766 _delegate: Default::default(),
4767 _additional_params: Default::default(),
4768 _scopes: Default::default(),
4769 }
4770 }
4771
4772 /// Create a builder to help you perform the following task:
4773 ///
4774 /// Update an existing profile filter link. This method supports patch semantics.
4775 ///
4776 /// # Arguments
4777 ///
4778 /// * `request` - No description provided.
4779 /// * `accountId` - Account ID to which profile filter link belongs.
4780 /// * `webPropertyId` - Web property Id to which profile filter link belongs
4781 /// * `profileId` - Profile ID to which filter link belongs
4782 /// * `linkId` - ID of the profile filter link to be updated.
4783 pub fn profile_filter_links_patch(
4784 &self,
4785 request: ProfileFilterLink,
4786 account_id: &str,
4787 web_property_id: &str,
4788 profile_id: &str,
4789 link_id: &str,
4790 ) -> ManagementProfileFilterLinkPatchCall<'a, C> {
4791 ManagementProfileFilterLinkPatchCall {
4792 hub: self.hub,
4793 _request: request,
4794 _account_id: account_id.to_string(),
4795 _web_property_id: web_property_id.to_string(),
4796 _profile_id: profile_id.to_string(),
4797 _link_id: link_id.to_string(),
4798 _delegate: Default::default(),
4799 _additional_params: Default::default(),
4800 _scopes: Default::default(),
4801 }
4802 }
4803
4804 /// Create a builder to help you perform the following task:
4805 ///
4806 /// Update an existing profile filter link.
4807 ///
4808 /// # Arguments
4809 ///
4810 /// * `request` - No description provided.
4811 /// * `accountId` - Account ID to which profile filter link belongs.
4812 /// * `webPropertyId` - Web property Id to which profile filter link belongs
4813 /// * `profileId` - Profile ID to which filter link belongs
4814 /// * `linkId` - ID of the profile filter link to be updated.
4815 pub fn profile_filter_links_update(
4816 &self,
4817 request: ProfileFilterLink,
4818 account_id: &str,
4819 web_property_id: &str,
4820 profile_id: &str,
4821 link_id: &str,
4822 ) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
4823 ManagementProfileFilterLinkUpdateCall {
4824 hub: self.hub,
4825 _request: request,
4826 _account_id: account_id.to_string(),
4827 _web_property_id: web_property_id.to_string(),
4828 _profile_id: profile_id.to_string(),
4829 _link_id: link_id.to_string(),
4830 _delegate: Default::default(),
4831 _additional_params: Default::default(),
4832 _scopes: Default::default(),
4833 }
4834 }
4835
4836 /// Create a builder to help you perform the following task:
4837 ///
4838 /// Removes a user from the given view (profile).
4839 ///
4840 /// # Arguments
4841 ///
4842 /// * `accountId` - Account ID to delete the user link for.
4843 /// * `webPropertyId` - Web Property ID to delete the user link for.
4844 /// * `profileId` - View (Profile) ID to delete the user link for.
4845 /// * `linkId` - Link ID to delete the user link for.
4846 pub fn profile_user_links_delete(
4847 &self,
4848 account_id: &str,
4849 web_property_id: &str,
4850 profile_id: &str,
4851 link_id: &str,
4852 ) -> ManagementProfileUserLinkDeleteCall<'a, C> {
4853 ManagementProfileUserLinkDeleteCall {
4854 hub: self.hub,
4855 _account_id: account_id.to_string(),
4856 _web_property_id: web_property_id.to_string(),
4857 _profile_id: profile_id.to_string(),
4858 _link_id: link_id.to_string(),
4859 _delegate: Default::default(),
4860 _additional_params: Default::default(),
4861 _scopes: Default::default(),
4862 }
4863 }
4864
4865 /// Create a builder to help you perform the following task:
4866 ///
4867 /// Adds a new user to the given view (profile).
4868 ///
4869 /// # Arguments
4870 ///
4871 /// * `request` - No description provided.
4872 /// * `accountId` - Account ID to create the user link for.
4873 /// * `webPropertyId` - Web Property ID to create the user link for.
4874 /// * `profileId` - View (Profile) ID to create the user link for.
4875 pub fn profile_user_links_insert(
4876 &self,
4877 request: EntityUserLink,
4878 account_id: &str,
4879 web_property_id: &str,
4880 profile_id: &str,
4881 ) -> ManagementProfileUserLinkInsertCall<'a, C> {
4882 ManagementProfileUserLinkInsertCall {
4883 hub: self.hub,
4884 _request: request,
4885 _account_id: account_id.to_string(),
4886 _web_property_id: web_property_id.to_string(),
4887 _profile_id: profile_id.to_string(),
4888 _delegate: Default::default(),
4889 _additional_params: Default::default(),
4890 _scopes: Default::default(),
4891 }
4892 }
4893
4894 /// Create a builder to help you perform the following task:
4895 ///
4896 /// Lists profile-user links for a given view (profile).
4897 ///
4898 /// # Arguments
4899 ///
4900 /// * `accountId` - Account ID which the given view (profile) belongs to.
4901 /// * `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.
4902 /// * `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.
4903 pub fn profile_user_links_list(
4904 &self,
4905 account_id: &str,
4906 web_property_id: &str,
4907 profile_id: &str,
4908 ) -> ManagementProfileUserLinkListCall<'a, C> {
4909 ManagementProfileUserLinkListCall {
4910 hub: self.hub,
4911 _account_id: account_id.to_string(),
4912 _web_property_id: web_property_id.to_string(),
4913 _profile_id: profile_id.to_string(),
4914 _start_index: Default::default(),
4915 _max_results: Default::default(),
4916 _delegate: Default::default(),
4917 _additional_params: Default::default(),
4918 _scopes: Default::default(),
4919 }
4920 }
4921
4922 /// Create a builder to help you perform the following task:
4923 ///
4924 /// Updates permissions for an existing user on the given view (profile).
4925 ///
4926 /// # Arguments
4927 ///
4928 /// * `request` - No description provided.
4929 /// * `accountId` - Account ID to update the user link for.
4930 /// * `webPropertyId` - Web Property ID to update the user link for.
4931 /// * `profileId` - View (Profile ID) to update the user link for.
4932 /// * `linkId` - Link ID to update the user link for.
4933 pub fn profile_user_links_update(
4934 &self,
4935 request: EntityUserLink,
4936 account_id: &str,
4937 web_property_id: &str,
4938 profile_id: &str,
4939 link_id: &str,
4940 ) -> ManagementProfileUserLinkUpdateCall<'a, C> {
4941 ManagementProfileUserLinkUpdateCall {
4942 hub: self.hub,
4943 _request: request,
4944 _account_id: account_id.to_string(),
4945 _web_property_id: web_property_id.to_string(),
4946 _profile_id: profile_id.to_string(),
4947 _link_id: link_id.to_string(),
4948 _delegate: Default::default(),
4949 _additional_params: Default::default(),
4950 _scopes: Default::default(),
4951 }
4952 }
4953
4954 /// Create a builder to help you perform the following task:
4955 ///
4956 /// Deletes a view (profile).
4957 ///
4958 /// # Arguments
4959 ///
4960 /// * `accountId` - Account ID to delete the view (profile) for.
4961 /// * `webPropertyId` - Web property ID to delete the view (profile) for.
4962 /// * `profileId` - ID of the view (profile) to be deleted.
4963 pub fn profiles_delete(
4964 &self,
4965 account_id: &str,
4966 web_property_id: &str,
4967 profile_id: &str,
4968 ) -> ManagementProfileDeleteCall<'a, C> {
4969 ManagementProfileDeleteCall {
4970 hub: self.hub,
4971 _account_id: account_id.to_string(),
4972 _web_property_id: web_property_id.to_string(),
4973 _profile_id: profile_id.to_string(),
4974 _delegate: Default::default(),
4975 _additional_params: Default::default(),
4976 _scopes: Default::default(),
4977 }
4978 }
4979
4980 /// Create a builder to help you perform the following task:
4981 ///
4982 /// Gets a view (profile) to which the user has access.
4983 ///
4984 /// # Arguments
4985 ///
4986 /// * `accountId` - Account ID to retrieve the view (profile) for.
4987 /// * `webPropertyId` - Web property ID to retrieve the view (profile) for.
4988 /// * `profileId` - View (Profile) ID to retrieve the view (profile) for.
4989 pub fn profiles_get(
4990 &self,
4991 account_id: &str,
4992 web_property_id: &str,
4993 profile_id: &str,
4994 ) -> ManagementProfileGetCall<'a, C> {
4995 ManagementProfileGetCall {
4996 hub: self.hub,
4997 _account_id: account_id.to_string(),
4998 _web_property_id: web_property_id.to_string(),
4999 _profile_id: profile_id.to_string(),
5000 _delegate: Default::default(),
5001 _additional_params: Default::default(),
5002 _scopes: Default::default(),
5003 }
5004 }
5005
5006 /// Create a builder to help you perform the following task:
5007 ///
5008 /// Create a new view (profile).
5009 ///
5010 /// # Arguments
5011 ///
5012 /// * `request` - No description provided.
5013 /// * `accountId` - Account ID to create the view (profile) for.
5014 /// * `webPropertyId` - Web property ID to create the view (profile) for.
5015 pub fn profiles_insert(
5016 &self,
5017 request: Profile,
5018 account_id: &str,
5019 web_property_id: &str,
5020 ) -> ManagementProfileInsertCall<'a, C> {
5021 ManagementProfileInsertCall {
5022 hub: self.hub,
5023 _request: request,
5024 _account_id: account_id.to_string(),
5025 _web_property_id: web_property_id.to_string(),
5026 _delegate: Default::default(),
5027 _additional_params: Default::default(),
5028 _scopes: Default::default(),
5029 }
5030 }
5031
5032 /// Create a builder to help you perform the following task:
5033 ///
5034 /// Lists views (profiles) to which the user has access.
5035 ///
5036 /// # Arguments
5037 ///
5038 /// * `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.
5039 /// * `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.
5040 pub fn profiles_list(
5041 &self,
5042 account_id: &str,
5043 web_property_id: &str,
5044 ) -> ManagementProfileListCall<'a, C> {
5045 ManagementProfileListCall {
5046 hub: self.hub,
5047 _account_id: account_id.to_string(),
5048 _web_property_id: web_property_id.to_string(),
5049 _start_index: Default::default(),
5050 _max_results: Default::default(),
5051 _delegate: Default::default(),
5052 _additional_params: Default::default(),
5053 _scopes: Default::default(),
5054 }
5055 }
5056
5057 /// Create a builder to help you perform the following task:
5058 ///
5059 /// Updates an existing view (profile). This method supports patch semantics.
5060 ///
5061 /// # Arguments
5062 ///
5063 /// * `request` - No description provided.
5064 /// * `accountId` - Account ID to which the view (profile) belongs
5065 /// * `webPropertyId` - Web property ID to which the view (profile) belongs
5066 /// * `profileId` - ID of the view (profile) to be updated.
5067 pub fn profiles_patch(
5068 &self,
5069 request: Profile,
5070 account_id: &str,
5071 web_property_id: &str,
5072 profile_id: &str,
5073 ) -> ManagementProfilePatchCall<'a, C> {
5074 ManagementProfilePatchCall {
5075 hub: self.hub,
5076 _request: request,
5077 _account_id: account_id.to_string(),
5078 _web_property_id: web_property_id.to_string(),
5079 _profile_id: profile_id.to_string(),
5080 _delegate: Default::default(),
5081 _additional_params: Default::default(),
5082 _scopes: Default::default(),
5083 }
5084 }
5085
5086 /// Create a builder to help you perform the following task:
5087 ///
5088 /// Updates an existing view (profile).
5089 ///
5090 /// # Arguments
5091 ///
5092 /// * `request` - No description provided.
5093 /// * `accountId` - Account ID to which the view (profile) belongs
5094 /// * `webPropertyId` - Web property ID to which the view (profile) belongs
5095 /// * `profileId` - ID of the view (profile) to be updated.
5096 pub fn profiles_update(
5097 &self,
5098 request: Profile,
5099 account_id: &str,
5100 web_property_id: &str,
5101 profile_id: &str,
5102 ) -> ManagementProfileUpdateCall<'a, C> {
5103 ManagementProfileUpdateCall {
5104 hub: self.hub,
5105 _request: request,
5106 _account_id: account_id.to_string(),
5107 _web_property_id: web_property_id.to_string(),
5108 _profile_id: profile_id.to_string(),
5109 _delegate: Default::default(),
5110 _additional_params: Default::default(),
5111 _scopes: Default::default(),
5112 }
5113 }
5114
5115 /// Create a builder to help you perform the following task:
5116 ///
5117 /// Delete a remarketing audience.
5118 ///
5119 /// # Arguments
5120 ///
5121 /// * `accountId` - Account ID to which the remarketing audience belongs.
5122 /// * `webPropertyId` - Web property ID to which the remarketing audience belongs.
5123 /// * `remarketingAudienceId` - The ID of the remarketing audience to delete.
5124 pub fn remarketing_audience_delete(
5125 &self,
5126 account_id: &str,
5127 web_property_id: &str,
5128 remarketing_audience_id: &str,
5129 ) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
5130 ManagementRemarketingAudienceDeleteCall {
5131 hub: self.hub,
5132 _account_id: account_id.to_string(),
5133 _web_property_id: web_property_id.to_string(),
5134 _remarketing_audience_id: remarketing_audience_id.to_string(),
5135 _delegate: Default::default(),
5136 _additional_params: Default::default(),
5137 _scopes: Default::default(),
5138 }
5139 }
5140
5141 /// Create a builder to help you perform the following task:
5142 ///
5143 /// Gets a remarketing audience to which the user has access.
5144 ///
5145 /// # Arguments
5146 ///
5147 /// * `accountId` - The account ID of the remarketing audience to retrieve.
5148 /// * `webPropertyId` - The web property ID of the remarketing audience to retrieve.
5149 /// * `remarketingAudienceId` - The ID of the remarketing audience to retrieve.
5150 pub fn remarketing_audience_get(
5151 &self,
5152 account_id: &str,
5153 web_property_id: &str,
5154 remarketing_audience_id: &str,
5155 ) -> ManagementRemarketingAudienceGetCall<'a, C> {
5156 ManagementRemarketingAudienceGetCall {
5157 hub: self.hub,
5158 _account_id: account_id.to_string(),
5159 _web_property_id: web_property_id.to_string(),
5160 _remarketing_audience_id: remarketing_audience_id.to_string(),
5161 _delegate: Default::default(),
5162 _additional_params: Default::default(),
5163 _scopes: Default::default(),
5164 }
5165 }
5166
5167 /// Create a builder to help you perform the following task:
5168 ///
5169 /// Creates a new remarketing audience.
5170 ///
5171 /// # Arguments
5172 ///
5173 /// * `request` - No description provided.
5174 /// * `accountId` - The account ID for which to create the remarketing audience.
5175 /// * `webPropertyId` - Web property ID for which to create the remarketing audience.
5176 pub fn remarketing_audience_insert(
5177 &self,
5178 request: RemarketingAudience,
5179 account_id: &str,
5180 web_property_id: &str,
5181 ) -> ManagementRemarketingAudienceInsertCall<'a, C> {
5182 ManagementRemarketingAudienceInsertCall {
5183 hub: self.hub,
5184 _request: request,
5185 _account_id: account_id.to_string(),
5186 _web_property_id: web_property_id.to_string(),
5187 _delegate: Default::default(),
5188 _additional_params: Default::default(),
5189 _scopes: Default::default(),
5190 }
5191 }
5192
5193 /// Create a builder to help you perform the following task:
5194 ///
5195 /// Lists remarketing audiences to which the user has access.
5196 ///
5197 /// # Arguments
5198 ///
5199 /// * `accountId` - The account ID of the remarketing audiences to retrieve.
5200 /// * `webPropertyId` - The web property ID of the remarketing audiences to retrieve.
5201 pub fn remarketing_audience_list(
5202 &self,
5203 account_id: &str,
5204 web_property_id: &str,
5205 ) -> ManagementRemarketingAudienceListCall<'a, C> {
5206 ManagementRemarketingAudienceListCall {
5207 hub: self.hub,
5208 _account_id: account_id.to_string(),
5209 _web_property_id: web_property_id.to_string(),
5210 _type_: Default::default(),
5211 _start_index: Default::default(),
5212 _max_results: Default::default(),
5213 _delegate: Default::default(),
5214 _additional_params: Default::default(),
5215 _scopes: Default::default(),
5216 }
5217 }
5218
5219 /// Create a builder to help you perform the following task:
5220 ///
5221 /// Updates an existing remarketing audience. This method supports patch semantics.
5222 ///
5223 /// # Arguments
5224 ///
5225 /// * `request` - No description provided.
5226 /// * `accountId` - The account ID of the remarketing audience to update.
5227 /// * `webPropertyId` - The web property ID of the remarketing audience to update.
5228 /// * `remarketingAudienceId` - The ID of the remarketing audience to update.
5229 pub fn remarketing_audience_patch(
5230 &self,
5231 request: RemarketingAudience,
5232 account_id: &str,
5233 web_property_id: &str,
5234 remarketing_audience_id: &str,
5235 ) -> ManagementRemarketingAudiencePatchCall<'a, C> {
5236 ManagementRemarketingAudiencePatchCall {
5237 hub: self.hub,
5238 _request: request,
5239 _account_id: account_id.to_string(),
5240 _web_property_id: web_property_id.to_string(),
5241 _remarketing_audience_id: remarketing_audience_id.to_string(),
5242 _delegate: Default::default(),
5243 _additional_params: Default::default(),
5244 _scopes: Default::default(),
5245 }
5246 }
5247
5248 /// Create a builder to help you perform the following task:
5249 ///
5250 /// Updates an existing remarketing audience.
5251 ///
5252 /// # Arguments
5253 ///
5254 /// * `request` - No description provided.
5255 /// * `accountId` - The account ID of the remarketing audience to update.
5256 /// * `webPropertyId` - The web property ID of the remarketing audience to update.
5257 /// * `remarketingAudienceId` - The ID of the remarketing audience to update.
5258 pub fn remarketing_audience_update(
5259 &self,
5260 request: RemarketingAudience,
5261 account_id: &str,
5262 web_property_id: &str,
5263 remarketing_audience_id: &str,
5264 ) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
5265 ManagementRemarketingAudienceUpdateCall {
5266 hub: self.hub,
5267 _request: request,
5268 _account_id: account_id.to_string(),
5269 _web_property_id: web_property_id.to_string(),
5270 _remarketing_audience_id: remarketing_audience_id.to_string(),
5271 _delegate: Default::default(),
5272 _additional_params: Default::default(),
5273 _scopes: Default::default(),
5274 }
5275 }
5276
5277 /// Create a builder to help you perform the following task:
5278 ///
5279 /// Lists segments to which the user has access.
5280 pub fn segments_list(&self) -> ManagementSegmentListCall<'a, C> {
5281 ManagementSegmentListCall {
5282 hub: self.hub,
5283 _start_index: Default::default(),
5284 _max_results: Default::default(),
5285 _delegate: Default::default(),
5286 _additional_params: Default::default(),
5287 _scopes: Default::default(),
5288 }
5289 }
5290
5291 /// Create a builder to help you perform the following task:
5292 ///
5293 /// Deletes an unsampled report.
5294 ///
5295 /// # Arguments
5296 ///
5297 /// * `accountId` - Account ID to delete the unsampled report for.
5298 /// * `webPropertyId` - Web property ID to delete the unsampled reports for.
5299 /// * `profileId` - View (Profile) ID to delete the unsampled report for.
5300 /// * `unsampledReportId` - ID of the unsampled report to be deleted.
5301 pub fn unsampled_reports_delete(
5302 &self,
5303 account_id: &str,
5304 web_property_id: &str,
5305 profile_id: &str,
5306 unsampled_report_id: &str,
5307 ) -> ManagementUnsampledReportDeleteCall<'a, C> {
5308 ManagementUnsampledReportDeleteCall {
5309 hub: self.hub,
5310 _account_id: account_id.to_string(),
5311 _web_property_id: web_property_id.to_string(),
5312 _profile_id: profile_id.to_string(),
5313 _unsampled_report_id: unsampled_report_id.to_string(),
5314 _delegate: Default::default(),
5315 _additional_params: Default::default(),
5316 _scopes: Default::default(),
5317 }
5318 }
5319
5320 /// Create a builder to help you perform the following task:
5321 ///
5322 /// Returns a single unsampled report.
5323 ///
5324 /// # Arguments
5325 ///
5326 /// * `accountId` - Account ID to retrieve unsampled report for.
5327 /// * `webPropertyId` - Web property ID to retrieve unsampled reports for.
5328 /// * `profileId` - View (Profile) ID to retrieve unsampled report for.
5329 /// * `unsampledReportId` - ID of the unsampled report to retrieve.
5330 pub fn unsampled_reports_get(
5331 &self,
5332 account_id: &str,
5333 web_property_id: &str,
5334 profile_id: &str,
5335 unsampled_report_id: &str,
5336 ) -> ManagementUnsampledReportGetCall<'a, C> {
5337 ManagementUnsampledReportGetCall {
5338 hub: self.hub,
5339 _account_id: account_id.to_string(),
5340 _web_property_id: web_property_id.to_string(),
5341 _profile_id: profile_id.to_string(),
5342 _unsampled_report_id: unsampled_report_id.to_string(),
5343 _delegate: Default::default(),
5344 _additional_params: Default::default(),
5345 _scopes: Default::default(),
5346 }
5347 }
5348
5349 /// Create a builder to help you perform the following task:
5350 ///
5351 /// Create a new unsampled report.
5352 ///
5353 /// # Arguments
5354 ///
5355 /// * `request` - No description provided.
5356 /// * `accountId` - Account ID to create the unsampled report for.
5357 /// * `webPropertyId` - Web property ID to create the unsampled report for.
5358 /// * `profileId` - View (Profile) ID to create the unsampled report for.
5359 pub fn unsampled_reports_insert(
5360 &self,
5361 request: UnsampledReport,
5362 account_id: &str,
5363 web_property_id: &str,
5364 profile_id: &str,
5365 ) -> ManagementUnsampledReportInsertCall<'a, C> {
5366 ManagementUnsampledReportInsertCall {
5367 hub: self.hub,
5368 _request: request,
5369 _account_id: account_id.to_string(),
5370 _web_property_id: web_property_id.to_string(),
5371 _profile_id: profile_id.to_string(),
5372 _delegate: Default::default(),
5373 _additional_params: Default::default(),
5374 _scopes: Default::default(),
5375 }
5376 }
5377
5378 /// Create a builder to help you perform the following task:
5379 ///
5380 /// Lists unsampled reports to which the user has access.
5381 ///
5382 /// # Arguments
5383 ///
5384 /// * `accountId` - Account ID to retrieve unsampled reports for. Must be a specific account ID, ~all is not supported.
5385 /// * `webPropertyId` - Web property ID to retrieve unsampled reports for. Must be a specific web property ID, ~all is not supported.
5386 /// * `profileId` - View (Profile) ID to retrieve unsampled reports for. Must be a specific view (profile) ID, ~all is not supported.
5387 pub fn unsampled_reports_list(
5388 &self,
5389 account_id: &str,
5390 web_property_id: &str,
5391 profile_id: &str,
5392 ) -> ManagementUnsampledReportListCall<'a, C> {
5393 ManagementUnsampledReportListCall {
5394 hub: self.hub,
5395 _account_id: account_id.to_string(),
5396 _web_property_id: web_property_id.to_string(),
5397 _profile_id: profile_id.to_string(),
5398 _start_index: Default::default(),
5399 _max_results: Default::default(),
5400 _delegate: Default::default(),
5401 _additional_params: Default::default(),
5402 _scopes: Default::default(),
5403 }
5404 }
5405
5406 /// Create a builder to help you perform the following task:
5407 ///
5408 /// Delete data associated with a previous upload.
5409 ///
5410 /// # Arguments
5411 ///
5412 /// * `request` - No description provided.
5413 /// * `accountId` - Account Id for the uploads to be deleted.
5414 /// * `webPropertyId` - Web property Id for the uploads to be deleted.
5415 /// * `customDataSourceId` - Custom data source Id for the uploads to be deleted.
5416 pub fn uploads_delete_upload_data(
5417 &self,
5418 request: AnalyticsDataimportDeleteUploadDataRequest,
5419 account_id: &str,
5420 web_property_id: &str,
5421 custom_data_source_id: &str,
5422 ) -> ManagementUploadDeleteUploadDataCall<'a, C> {
5423 ManagementUploadDeleteUploadDataCall {
5424 hub: self.hub,
5425 _request: request,
5426 _account_id: account_id.to_string(),
5427 _web_property_id: web_property_id.to_string(),
5428 _custom_data_source_id: custom_data_source_id.to_string(),
5429 _delegate: Default::default(),
5430 _additional_params: Default::default(),
5431 _scopes: Default::default(),
5432 }
5433 }
5434
5435 /// Create a builder to help you perform the following task:
5436 ///
5437 /// List uploads to which the user has access.
5438 ///
5439 /// # Arguments
5440 ///
5441 /// * `accountId` - Account Id for the upload to retrieve.
5442 /// * `webPropertyId` - Web property Id for the upload to retrieve.
5443 /// * `customDataSourceId` - Custom data source Id for upload to retrieve.
5444 /// * `uploadId` - Upload Id to retrieve.
5445 pub fn uploads_get(
5446 &self,
5447 account_id: &str,
5448 web_property_id: &str,
5449 custom_data_source_id: &str,
5450 upload_id: &str,
5451 ) -> ManagementUploadGetCall<'a, C> {
5452 ManagementUploadGetCall {
5453 hub: self.hub,
5454 _account_id: account_id.to_string(),
5455 _web_property_id: web_property_id.to_string(),
5456 _custom_data_source_id: custom_data_source_id.to_string(),
5457 _upload_id: upload_id.to_string(),
5458 _delegate: Default::default(),
5459 _additional_params: Default::default(),
5460 _scopes: Default::default(),
5461 }
5462 }
5463
5464 /// Create a builder to help you perform the following task:
5465 ///
5466 /// List uploads to which the user has access.
5467 ///
5468 /// # Arguments
5469 ///
5470 /// * `accountId` - Account Id for the uploads to retrieve.
5471 /// * `webPropertyId` - Web property Id for the uploads to retrieve.
5472 /// * `customDataSourceId` - Custom data source Id for uploads to retrieve.
5473 pub fn uploads_list(
5474 &self,
5475 account_id: &str,
5476 web_property_id: &str,
5477 custom_data_source_id: &str,
5478 ) -> ManagementUploadListCall<'a, C> {
5479 ManagementUploadListCall {
5480 hub: self.hub,
5481 _account_id: account_id.to_string(),
5482 _web_property_id: web_property_id.to_string(),
5483 _custom_data_source_id: custom_data_source_id.to_string(),
5484 _start_index: Default::default(),
5485 _max_results: Default::default(),
5486 _delegate: Default::default(),
5487 _additional_params: Default::default(),
5488 _scopes: Default::default(),
5489 }
5490 }
5491
5492 /// Create a builder to help you perform the following task:
5493 ///
5494 /// Upload data for a custom data source.
5495 ///
5496 /// # Arguments
5497 ///
5498 /// * `accountId` - Account Id associated with the upload.
5499 /// * `webPropertyId` - Web property UA-string associated with the upload.
5500 /// * `customDataSourceId` - Custom data source Id to which the data being uploaded belongs.
5501 pub fn uploads_upload_data(
5502 &self,
5503 account_id: &str,
5504 web_property_id: &str,
5505 custom_data_source_id: &str,
5506 ) -> ManagementUploadUploadDataCall<'a, C> {
5507 ManagementUploadUploadDataCall {
5508 hub: self.hub,
5509 _account_id: account_id.to_string(),
5510 _web_property_id: web_property_id.to_string(),
5511 _custom_data_source_id: custom_data_source_id.to_string(),
5512 _delegate: Default::default(),
5513 _additional_params: Default::default(),
5514 _scopes: Default::default(),
5515 }
5516 }
5517
5518 /// Create a builder to help you perform the following task:
5519 ///
5520 /// Deletes a web property-Google Ads link.
5521 ///
5522 /// # Arguments
5523 ///
5524 /// * `accountId` - ID of the account which the given web property belongs to.
5525 /// * `webPropertyId` - Web property ID to delete the Google Ads link for.
5526 /// * `webPropertyAdWordsLinkId` - Web property Google Ads link ID.
5527 pub fn web_property_ad_words_links_delete(
5528 &self,
5529 account_id: &str,
5530 web_property_id: &str,
5531 web_property_ad_words_link_id: &str,
5532 ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
5533 ManagementWebPropertyAdWordsLinkDeleteCall {
5534 hub: self.hub,
5535 _account_id: account_id.to_string(),
5536 _web_property_id: web_property_id.to_string(),
5537 _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(),
5538 _delegate: Default::default(),
5539 _additional_params: Default::default(),
5540 _scopes: Default::default(),
5541 }
5542 }
5543
5544 /// Create a builder to help you perform the following task:
5545 ///
5546 /// Returns a web property-Google Ads link to which the user has access.
5547 ///
5548 /// # Arguments
5549 ///
5550 /// * `accountId` - ID of the account which the given web property belongs to.
5551 /// * `webPropertyId` - Web property ID to retrieve the Google Ads link for.
5552 /// * `webPropertyAdWordsLinkId` - Web property-Google Ads link ID.
5553 pub fn web_property_ad_words_links_get(
5554 &self,
5555 account_id: &str,
5556 web_property_id: &str,
5557 web_property_ad_words_link_id: &str,
5558 ) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
5559 ManagementWebPropertyAdWordsLinkGetCall {
5560 hub: self.hub,
5561 _account_id: account_id.to_string(),
5562 _web_property_id: web_property_id.to_string(),
5563 _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(),
5564 _delegate: Default::default(),
5565 _additional_params: Default::default(),
5566 _scopes: Default::default(),
5567 }
5568 }
5569
5570 /// Create a builder to help you perform the following task:
5571 ///
5572 /// Creates a webProperty-Google Ads link.
5573 ///
5574 /// # Arguments
5575 ///
5576 /// * `request` - No description provided.
5577 /// * `accountId` - ID of the Google Analytics account to create the link for.
5578 /// * `webPropertyId` - Web property ID to create the link for.
5579 pub fn web_property_ad_words_links_insert(
5580 &self,
5581 request: EntityAdWordsLink,
5582 account_id: &str,
5583 web_property_id: &str,
5584 ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
5585 ManagementWebPropertyAdWordsLinkInsertCall {
5586 hub: self.hub,
5587 _request: request,
5588 _account_id: account_id.to_string(),
5589 _web_property_id: web_property_id.to_string(),
5590 _delegate: Default::default(),
5591 _additional_params: Default::default(),
5592 _scopes: Default::default(),
5593 }
5594 }
5595
5596 /// Create a builder to help you perform the following task:
5597 ///
5598 /// Lists webProperty-Google Ads links for a given web property.
5599 ///
5600 /// # Arguments
5601 ///
5602 /// * `accountId` - ID of the account which the given web property belongs to.
5603 /// * `webPropertyId` - Web property ID to retrieve the Google Ads links for.
5604 pub fn web_property_ad_words_links_list(
5605 &self,
5606 account_id: &str,
5607 web_property_id: &str,
5608 ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
5609 ManagementWebPropertyAdWordsLinkListCall {
5610 hub: self.hub,
5611 _account_id: account_id.to_string(),
5612 _web_property_id: web_property_id.to_string(),
5613 _start_index: Default::default(),
5614 _max_results: Default::default(),
5615 _delegate: Default::default(),
5616 _additional_params: Default::default(),
5617 _scopes: Default::default(),
5618 }
5619 }
5620
5621 /// Create a builder to help you perform the following task:
5622 ///
5623 /// Updates an existing webProperty-Google Ads link. This method supports patch semantics.
5624 ///
5625 /// # Arguments
5626 ///
5627 /// * `request` - No description provided.
5628 /// * `accountId` - ID of the account which the given web property belongs to.
5629 /// * `webPropertyId` - Web property ID to retrieve the Google Ads link for.
5630 /// * `webPropertyAdWordsLinkId` - Web property-Google Ads link ID.
5631 pub fn web_property_ad_words_links_patch(
5632 &self,
5633 request: EntityAdWordsLink,
5634 account_id: &str,
5635 web_property_id: &str,
5636 web_property_ad_words_link_id: &str,
5637 ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
5638 ManagementWebPropertyAdWordsLinkPatchCall {
5639 hub: self.hub,
5640 _request: request,
5641 _account_id: account_id.to_string(),
5642 _web_property_id: web_property_id.to_string(),
5643 _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(),
5644 _delegate: Default::default(),
5645 _additional_params: Default::default(),
5646 _scopes: Default::default(),
5647 }
5648 }
5649
5650 /// Create a builder to help you perform the following task:
5651 ///
5652 /// Updates an existing webProperty-Google Ads link.
5653 ///
5654 /// # Arguments
5655 ///
5656 /// * `request` - No description provided.
5657 /// * `accountId` - ID of the account which the given web property belongs to.
5658 /// * `webPropertyId` - Web property ID to retrieve the Google Ads link for.
5659 /// * `webPropertyAdWordsLinkId` - Web property-Google Ads link ID.
5660 pub fn web_property_ad_words_links_update(
5661 &self,
5662 request: EntityAdWordsLink,
5663 account_id: &str,
5664 web_property_id: &str,
5665 web_property_ad_words_link_id: &str,
5666 ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
5667 ManagementWebPropertyAdWordsLinkUpdateCall {
5668 hub: self.hub,
5669 _request: request,
5670 _account_id: account_id.to_string(),
5671 _web_property_id: web_property_id.to_string(),
5672 _web_property_ad_words_link_id: web_property_ad_words_link_id.to_string(),
5673 _delegate: Default::default(),
5674 _additional_params: Default::default(),
5675 _scopes: Default::default(),
5676 }
5677 }
5678
5679 /// Create a builder to help you perform the following task:
5680 ///
5681 /// Gets a web property to which the user has access.
5682 ///
5683 /// # Arguments
5684 ///
5685 /// * `accountId` - Account ID to retrieve the web property for.
5686 /// * `webPropertyId` - ID to retrieve the web property for.
5687 pub fn webproperties_get(
5688 &self,
5689 account_id: &str,
5690 web_property_id: &str,
5691 ) -> ManagementWebpropertyGetCall<'a, C> {
5692 ManagementWebpropertyGetCall {
5693 hub: self.hub,
5694 _account_id: account_id.to_string(),
5695 _web_property_id: web_property_id.to_string(),
5696 _delegate: Default::default(),
5697 _additional_params: Default::default(),
5698 _scopes: Default::default(),
5699 }
5700 }
5701
5702 /// Create a builder to help you perform the following task:
5703 ///
5704 /// 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.
5705 ///
5706 /// # Arguments
5707 ///
5708 /// * `request` - No description provided.
5709 /// * `accountId` - Account ID to create the web property for.
5710 pub fn webproperties_insert(
5711 &self,
5712 request: Webproperty,
5713 account_id: &str,
5714 ) -> ManagementWebpropertyInsertCall<'a, C> {
5715 ManagementWebpropertyInsertCall {
5716 hub: self.hub,
5717 _request: request,
5718 _account_id: account_id.to_string(),
5719 _delegate: Default::default(),
5720 _additional_params: Default::default(),
5721 _scopes: Default::default(),
5722 }
5723 }
5724
5725 /// Create a builder to help you perform the following task:
5726 ///
5727 /// Lists web properties to which the user has access.
5728 ///
5729 /// # Arguments
5730 ///
5731 /// * `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.
5732 pub fn webproperties_list(&self, account_id: &str) -> ManagementWebpropertyListCall<'a, C> {
5733 ManagementWebpropertyListCall {
5734 hub: self.hub,
5735 _account_id: account_id.to_string(),
5736 _start_index: Default::default(),
5737 _max_results: Default::default(),
5738 _delegate: Default::default(),
5739 _additional_params: Default::default(),
5740 _scopes: Default::default(),
5741 }
5742 }
5743
5744 /// Create a builder to help you perform the following task:
5745 ///
5746 /// Updates an existing web property. This method supports patch semantics.
5747 ///
5748 /// # Arguments
5749 ///
5750 /// * `request` - No description provided.
5751 /// * `accountId` - Account ID to which the web property belongs
5752 /// * `webPropertyId` - Web property ID
5753 pub fn webproperties_patch(
5754 &self,
5755 request: Webproperty,
5756 account_id: &str,
5757 web_property_id: &str,
5758 ) -> ManagementWebpropertyPatchCall<'a, C> {
5759 ManagementWebpropertyPatchCall {
5760 hub: self.hub,
5761 _request: request,
5762 _account_id: account_id.to_string(),
5763 _web_property_id: web_property_id.to_string(),
5764 _delegate: Default::default(),
5765 _additional_params: Default::default(),
5766 _scopes: Default::default(),
5767 }
5768 }
5769
5770 /// Create a builder to help you perform the following task:
5771 ///
5772 /// Updates an existing web property.
5773 ///
5774 /// # Arguments
5775 ///
5776 /// * `request` - No description provided.
5777 /// * `accountId` - Account ID to which the web property belongs
5778 /// * `webPropertyId` - Web property ID
5779 pub fn webproperties_update(
5780 &self,
5781 request: Webproperty,
5782 account_id: &str,
5783 web_property_id: &str,
5784 ) -> ManagementWebpropertyUpdateCall<'a, C> {
5785 ManagementWebpropertyUpdateCall {
5786 hub: self.hub,
5787 _request: request,
5788 _account_id: account_id.to_string(),
5789 _web_property_id: web_property_id.to_string(),
5790 _delegate: Default::default(),
5791 _additional_params: Default::default(),
5792 _scopes: Default::default(),
5793 }
5794 }
5795
5796 /// Create a builder to help you perform the following task:
5797 ///
5798 /// Removes a user from the given web property.
5799 ///
5800 /// # Arguments
5801 ///
5802 /// * `accountId` - Account ID to delete the user link for.
5803 /// * `webPropertyId` - Web Property ID to delete the user link for.
5804 /// * `linkId` - Link ID to delete the user link for.
5805 pub fn webproperty_user_links_delete(
5806 &self,
5807 account_id: &str,
5808 web_property_id: &str,
5809 link_id: &str,
5810 ) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
5811 ManagementWebpropertyUserLinkDeleteCall {
5812 hub: self.hub,
5813 _account_id: account_id.to_string(),
5814 _web_property_id: web_property_id.to_string(),
5815 _link_id: link_id.to_string(),
5816 _delegate: Default::default(),
5817 _additional_params: Default::default(),
5818 _scopes: Default::default(),
5819 }
5820 }
5821
5822 /// Create a builder to help you perform the following task:
5823 ///
5824 /// Adds a new user to the given web property.
5825 ///
5826 /// # Arguments
5827 ///
5828 /// * `request` - No description provided.
5829 /// * `accountId` - Account ID to create the user link for.
5830 /// * `webPropertyId` - Web Property ID to create the user link for.
5831 pub fn webproperty_user_links_insert(
5832 &self,
5833 request: EntityUserLink,
5834 account_id: &str,
5835 web_property_id: &str,
5836 ) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
5837 ManagementWebpropertyUserLinkInsertCall {
5838 hub: self.hub,
5839 _request: request,
5840 _account_id: account_id.to_string(),
5841 _web_property_id: web_property_id.to_string(),
5842 _delegate: Default::default(),
5843 _additional_params: Default::default(),
5844 _scopes: Default::default(),
5845 }
5846 }
5847
5848 /// Create a builder to help you perform the following task:
5849 ///
5850 /// Lists webProperty-user links for a given web property.
5851 ///
5852 /// # Arguments
5853 ///
5854 /// * `accountId` - Account ID which the given web property belongs to.
5855 /// * `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.
5856 pub fn webproperty_user_links_list(
5857 &self,
5858 account_id: &str,
5859 web_property_id: &str,
5860 ) -> ManagementWebpropertyUserLinkListCall<'a, C> {
5861 ManagementWebpropertyUserLinkListCall {
5862 hub: self.hub,
5863 _account_id: account_id.to_string(),
5864 _web_property_id: web_property_id.to_string(),
5865 _start_index: Default::default(),
5866 _max_results: Default::default(),
5867 _delegate: Default::default(),
5868 _additional_params: Default::default(),
5869 _scopes: Default::default(),
5870 }
5871 }
5872
5873 /// Create a builder to help you perform the following task:
5874 ///
5875 /// Updates permissions for an existing user on the given web property.
5876 ///
5877 /// # Arguments
5878 ///
5879 /// * `request` - No description provided.
5880 /// * `accountId` - Account ID to update the account-user link for.
5881 /// * `webPropertyId` - Web property ID to update the account-user link for.
5882 /// * `linkId` - Link ID to update the account-user link for.
5883 pub fn webproperty_user_links_update(
5884 &self,
5885 request: EntityUserLink,
5886 account_id: &str,
5887 web_property_id: &str,
5888 link_id: &str,
5889 ) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
5890 ManagementWebpropertyUserLinkUpdateCall {
5891 hub: self.hub,
5892 _request: request,
5893 _account_id: account_id.to_string(),
5894 _web_property_id: web_property_id.to_string(),
5895 _link_id: link_id.to_string(),
5896 _delegate: Default::default(),
5897 _additional_params: Default::default(),
5898 _scopes: Default::default(),
5899 }
5900 }
5901}
5902
5903/// A builder providing access to all methods supported on *metadata* resources.
5904/// It is not used directly, but through the [`Analytics`] hub.
5905///
5906/// # Example
5907///
5908/// Instantiate a resource builder
5909///
5910/// ```test_harness,no_run
5911/// extern crate hyper;
5912/// extern crate hyper_rustls;
5913/// extern crate google_analytics3 as analytics3;
5914///
5915/// # async fn dox() {
5916/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5917///
5918/// let secret: yup_oauth2::ApplicationSecret = Default::default();
5919/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5920/// secret,
5921/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5922/// ).build().await.unwrap();
5923///
5924/// let client = hyper_util::client::legacy::Client::builder(
5925/// hyper_util::rt::TokioExecutor::new()
5926/// )
5927/// .build(
5928/// hyper_rustls::HttpsConnectorBuilder::new()
5929/// .with_native_roots()
5930/// .unwrap()
5931/// .https_or_http()
5932/// .enable_http1()
5933/// .build()
5934/// );
5935/// let mut hub = Analytics::new(client, auth);
5936/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
5937/// // like `columns_list(...)`
5938/// // to build up your call.
5939/// let rb = hub.metadata();
5940/// # }
5941/// ```
5942pub struct MetadataMethods<'a, C>
5943where
5944 C: 'a,
5945{
5946 hub: &'a Analytics<C>,
5947}
5948
5949impl<'a, C> common::MethodsBuilder for MetadataMethods<'a, C> {}
5950
5951impl<'a, C> MetadataMethods<'a, C> {
5952 /// Create a builder to help you perform the following task:
5953 ///
5954 /// Lists all columns for a report type
5955 ///
5956 /// # Arguments
5957 ///
5958 /// * `reportType` - Report type. Allowed Values: 'ga'. Where 'ga' corresponds to the Core Reporting API
5959 pub fn columns_list(&self, report_type: &str) -> MetadataColumnListCall<'a, C> {
5960 MetadataColumnListCall {
5961 hub: self.hub,
5962 _report_type: report_type.to_string(),
5963 _delegate: Default::default(),
5964 _additional_params: Default::default(),
5965 _scopes: Default::default(),
5966 }
5967 }
5968}
5969
5970/// A builder providing access to all methods supported on *provisioning* resources.
5971/// It is not used directly, but through the [`Analytics`] hub.
5972///
5973/// # Example
5974///
5975/// Instantiate a resource builder
5976///
5977/// ```test_harness,no_run
5978/// extern crate hyper;
5979/// extern crate hyper_rustls;
5980/// extern crate google_analytics3 as analytics3;
5981///
5982/// # async fn dox() {
5983/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5984///
5985/// let secret: yup_oauth2::ApplicationSecret = Default::default();
5986/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5987/// secret,
5988/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5989/// ).build().await.unwrap();
5990///
5991/// let client = hyper_util::client::legacy::Client::builder(
5992/// hyper_util::rt::TokioExecutor::new()
5993/// )
5994/// .build(
5995/// hyper_rustls::HttpsConnectorBuilder::new()
5996/// .with_native_roots()
5997/// .unwrap()
5998/// .https_or_http()
5999/// .enable_http1()
6000/// .build()
6001/// );
6002/// let mut hub = Analytics::new(client, auth);
6003/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
6004/// // like `create_account_ticket(...)` and `create_account_tree(...)`
6005/// // to build up your call.
6006/// let rb = hub.provisioning();
6007/// # }
6008/// ```
6009pub struct ProvisioningMethods<'a, C>
6010where
6011 C: 'a,
6012{
6013 hub: &'a Analytics<C>,
6014}
6015
6016impl<'a, C> common::MethodsBuilder for ProvisioningMethods<'a, C> {}
6017
6018impl<'a, C> ProvisioningMethods<'a, C> {
6019 /// Create a builder to help you perform the following task:
6020 ///
6021 /// Creates an account ticket.
6022 ///
6023 /// # Arguments
6024 ///
6025 /// * `request` - No description provided.
6026 pub fn create_account_ticket(
6027 &self,
6028 request: AccountTicket,
6029 ) -> ProvisioningCreateAccountTicketCall<'a, C> {
6030 ProvisioningCreateAccountTicketCall {
6031 hub: self.hub,
6032 _request: request,
6033 _delegate: Default::default(),
6034 _additional_params: Default::default(),
6035 _scopes: Default::default(),
6036 }
6037 }
6038
6039 /// Create a builder to help you perform the following task:
6040 ///
6041 /// Provision account.
6042 ///
6043 /// # Arguments
6044 ///
6045 /// * `request` - No description provided.
6046 pub fn create_account_tree(
6047 &self,
6048 request: AccountTreeRequest,
6049 ) -> ProvisioningCreateAccountTreeCall<'a, C> {
6050 ProvisioningCreateAccountTreeCall {
6051 hub: self.hub,
6052 _request: request,
6053 _delegate: Default::default(),
6054 _additional_params: Default::default(),
6055 _scopes: Default::default(),
6056 }
6057 }
6058}
6059
6060/// A builder providing access to all methods supported on *userDeletion* resources.
6061/// It is not used directly, but through the [`Analytics`] hub.
6062///
6063/// # Example
6064///
6065/// Instantiate a resource builder
6066///
6067/// ```test_harness,no_run
6068/// extern crate hyper;
6069/// extern crate hyper_rustls;
6070/// extern crate google_analytics3 as analytics3;
6071///
6072/// # async fn dox() {
6073/// use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6074///
6075/// let secret: yup_oauth2::ApplicationSecret = Default::default();
6076/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6077/// secret,
6078/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6079/// ).build().await.unwrap();
6080///
6081/// let client = hyper_util::client::legacy::Client::builder(
6082/// hyper_util::rt::TokioExecutor::new()
6083/// )
6084/// .build(
6085/// hyper_rustls::HttpsConnectorBuilder::new()
6086/// .with_native_roots()
6087/// .unwrap()
6088/// .https_or_http()
6089/// .enable_http1()
6090/// .build()
6091/// );
6092/// let mut hub = Analytics::new(client, auth);
6093/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
6094/// // like `user_deletion_request_upsert(...)`
6095/// // to build up your call.
6096/// let rb = hub.user_deletion();
6097/// # }
6098/// ```
6099pub struct UserDeletionMethods<'a, C>
6100where
6101 C: 'a,
6102{
6103 hub: &'a Analytics<C>,
6104}
6105
6106impl<'a, C> common::MethodsBuilder for UserDeletionMethods<'a, C> {}
6107
6108impl<'a, C> UserDeletionMethods<'a, C> {
6109 /// Create a builder to help you perform the following task:
6110 ///
6111 /// Insert or update a user deletion requests.
6112 ///
6113 /// # Arguments
6114 ///
6115 /// * `request` - No description provided.
6116 pub fn user_deletion_request_upsert(
6117 &self,
6118 request: UserDeletionRequest,
6119 ) -> UserDeletionUserDeletionRequestUpsertCall<'a, C> {
6120 UserDeletionUserDeletionRequestUpsertCall {
6121 hub: self.hub,
6122 _request: request,
6123 _delegate: Default::default(),
6124 _additional_params: Default::default(),
6125 _scopes: Default::default(),
6126 }
6127 }
6128}
6129
6130// ###################
6131// CallBuilders ###
6132// #################
6133
6134/// Returns Analytics data for a view (profile).
6135///
6136/// A builder for the *ga.get* method supported by a *data* resource.
6137/// It is not used directly, but through a [`DataMethods`] instance.
6138///
6139/// # Example
6140///
6141/// Instantiate a resource method builder
6142///
6143/// ```test_harness,no_run
6144/// # extern crate hyper;
6145/// # extern crate hyper_rustls;
6146/// # extern crate google_analytics3 as analytics3;
6147/// # async fn dox() {
6148/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6149///
6150/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6151/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6152/// # secret,
6153/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6154/// # ).build().await.unwrap();
6155///
6156/// # let client = hyper_util::client::legacy::Client::builder(
6157/// # hyper_util::rt::TokioExecutor::new()
6158/// # )
6159/// # .build(
6160/// # hyper_rustls::HttpsConnectorBuilder::new()
6161/// # .with_native_roots()
6162/// # .unwrap()
6163/// # .https_or_http()
6164/// # .enable_http1()
6165/// # .build()
6166/// # );
6167/// # let mut hub = Analytics::new(client, auth);
6168/// // You can configure optional parameters by calling the respective setters at will, and
6169/// // execute the final call using `doit()`.
6170/// // Values shown here are possibly random and not representative !
6171/// let result = hub.data().ga_get("ids", "start-date", "end-date", "metrics")
6172/// .start_index(-75)
6173/// .sort("dolor")
6174/// .segment("ea")
6175/// .sampling_level("ipsum")
6176/// .output("invidunt")
6177/// .max_results(-47)
6178/// .include_empty_rows(true)
6179/// .filters("sed")
6180/// .dimensions("ut")
6181/// .doit().await;
6182/// # }
6183/// ```
6184pub struct DataGaGetCall<'a, C>
6185where
6186 C: 'a,
6187{
6188 hub: &'a Analytics<C>,
6189 _ids: String,
6190 _start_date: String,
6191 _end_date: String,
6192 _metrics: String,
6193 _start_index: Option<i32>,
6194 _sort: Option<String>,
6195 _segment: Option<String>,
6196 _sampling_level: Option<String>,
6197 _output: Option<String>,
6198 _max_results: Option<i32>,
6199 _include_empty_rows: Option<bool>,
6200 _filters: Option<String>,
6201 _dimensions: Option<String>,
6202 _delegate: Option<&'a mut dyn common::Delegate>,
6203 _additional_params: HashMap<String, String>,
6204 _scopes: BTreeSet<String>,
6205}
6206
6207impl<'a, C> common::CallBuilder for DataGaGetCall<'a, C> {}
6208
6209impl<'a, C> DataGaGetCall<'a, C>
6210where
6211 C: common::Connector,
6212{
6213 /// Perform the operation you have build so far.
6214 pub async fn doit(mut self) -> common::Result<(common::Response, GaData)> {
6215 use std::borrow::Cow;
6216 use std::io::{Read, Seek};
6217
6218 use common::{url::Params, ToParts};
6219 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6220
6221 let mut dd = common::DefaultDelegate;
6222 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6223 dlg.begin(common::MethodInfo {
6224 id: "analytics.data.ga.get",
6225 http_method: hyper::Method::GET,
6226 });
6227
6228 for &field in [
6229 "alt",
6230 "ids",
6231 "start-date",
6232 "end-date",
6233 "metrics",
6234 "start-index",
6235 "sort",
6236 "segment",
6237 "samplingLevel",
6238 "output",
6239 "max-results",
6240 "include-empty-rows",
6241 "filters",
6242 "dimensions",
6243 ]
6244 .iter()
6245 {
6246 if self._additional_params.contains_key(field) {
6247 dlg.finished(false);
6248 return Err(common::Error::FieldClash(field));
6249 }
6250 }
6251
6252 let mut params = Params::with_capacity(15 + self._additional_params.len());
6253 params.push("ids", self._ids);
6254 params.push("start-date", self._start_date);
6255 params.push("end-date", self._end_date);
6256 params.push("metrics", self._metrics);
6257 if let Some(value) = self._start_index.as_ref() {
6258 params.push("start-index", value.to_string());
6259 }
6260 if let Some(value) = self._sort.as_ref() {
6261 params.push("sort", value);
6262 }
6263 if let Some(value) = self._segment.as_ref() {
6264 params.push("segment", value);
6265 }
6266 if let Some(value) = self._sampling_level.as_ref() {
6267 params.push("samplingLevel", value);
6268 }
6269 if let Some(value) = self._output.as_ref() {
6270 params.push("output", value);
6271 }
6272 if let Some(value) = self._max_results.as_ref() {
6273 params.push("max-results", value.to_string());
6274 }
6275 if let Some(value) = self._include_empty_rows.as_ref() {
6276 params.push("include-empty-rows", value.to_string());
6277 }
6278 if let Some(value) = self._filters.as_ref() {
6279 params.push("filters", value);
6280 }
6281 if let Some(value) = self._dimensions.as_ref() {
6282 params.push("dimensions", value);
6283 }
6284
6285 params.extend(self._additional_params.iter());
6286
6287 params.push("alt", "json");
6288 let mut url = self.hub._base_url.clone() + "data/ga";
6289 if self._scopes.is_empty() {
6290 self._scopes.insert(Scope::Readonly.as_ref().to_string());
6291 }
6292
6293 let url = params.parse_with_url(&url);
6294
6295 loop {
6296 let token = match self
6297 .hub
6298 .auth
6299 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6300 .await
6301 {
6302 Ok(token) => token,
6303 Err(e) => match dlg.token(e) {
6304 Ok(token) => token,
6305 Err(e) => {
6306 dlg.finished(false);
6307 return Err(common::Error::MissingToken(e));
6308 }
6309 },
6310 };
6311 let mut req_result = {
6312 let client = &self.hub.client;
6313 dlg.pre_request();
6314 let mut req_builder = hyper::Request::builder()
6315 .method(hyper::Method::GET)
6316 .uri(url.as_str())
6317 .header(USER_AGENT, self.hub._user_agent.clone());
6318
6319 if let Some(token) = token.as_ref() {
6320 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6321 }
6322
6323 let request = req_builder
6324 .header(CONTENT_LENGTH, 0_u64)
6325 .body(common::to_body::<String>(None));
6326
6327 client.request(request.unwrap()).await
6328 };
6329
6330 match req_result {
6331 Err(err) => {
6332 if let common::Retry::After(d) = dlg.http_error(&err) {
6333 sleep(d).await;
6334 continue;
6335 }
6336 dlg.finished(false);
6337 return Err(common::Error::HttpError(err));
6338 }
6339 Ok(res) => {
6340 let (mut parts, body) = res.into_parts();
6341 let mut body = common::Body::new(body);
6342 if !parts.status.is_success() {
6343 let bytes = common::to_bytes(body).await.unwrap_or_default();
6344 let error = serde_json::from_str(&common::to_string(&bytes));
6345 let response = common::to_response(parts, bytes.into());
6346
6347 if let common::Retry::After(d) =
6348 dlg.http_failure(&response, error.as_ref().ok())
6349 {
6350 sleep(d).await;
6351 continue;
6352 }
6353
6354 dlg.finished(false);
6355
6356 return Err(match error {
6357 Ok(value) => common::Error::BadRequest(value),
6358 _ => common::Error::Failure(response),
6359 });
6360 }
6361 let response = {
6362 let bytes = common::to_bytes(body).await.unwrap_or_default();
6363 let encoded = common::to_string(&bytes);
6364 match serde_json::from_str(&encoded) {
6365 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6366 Err(error) => {
6367 dlg.response_json_decode_error(&encoded, &error);
6368 return Err(common::Error::JsonDecodeError(
6369 encoded.to_string(),
6370 error,
6371 ));
6372 }
6373 }
6374 };
6375
6376 dlg.finished(true);
6377 return Ok(response);
6378 }
6379 }
6380 }
6381 }
6382
6383 /// Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
6384 ///
6385 /// Sets the *ids* query property to the given value.
6386 ///
6387 /// Even though the property as already been set when instantiating this call,
6388 /// we provide this method for API completeness.
6389 pub fn ids(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6390 self._ids = new_value.to_string();
6391 self
6392 }
6393 /// 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.
6394 ///
6395 /// Sets the *start-date* query property to the given value.
6396 ///
6397 /// Even though the property as already been set when instantiating this call,
6398 /// we provide this method for API completeness.
6399 pub fn start_date(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6400 self._start_date = new_value.to_string();
6401 self
6402 }
6403 /// 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.
6404 ///
6405 /// Sets the *end-date* query property to the given value.
6406 ///
6407 /// Even though the property as already been set when instantiating this call,
6408 /// we provide this method for API completeness.
6409 pub fn end_date(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6410 self._end_date = new_value.to_string();
6411 self
6412 }
6413 /// A comma-separated list of Analytics metrics. E.g., 'ga:sessions,ga:pageviews'. At least one metric must be specified.
6414 ///
6415 /// Sets the *metrics* query property to the given value.
6416 ///
6417 /// Even though the property as already been set when instantiating this call,
6418 /// we provide this method for API completeness.
6419 pub fn metrics(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6420 self._metrics = new_value.to_string();
6421 self
6422 }
6423 /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
6424 ///
6425 /// Sets the *start-index* query property to the given value.
6426 pub fn start_index(mut self, new_value: i32) -> DataGaGetCall<'a, C> {
6427 self._start_index = Some(new_value);
6428 self
6429 }
6430 /// A comma-separated list of dimensions or metrics that determine the sort order for Analytics data.
6431 ///
6432 /// Sets the *sort* query property to the given value.
6433 pub fn sort(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6434 self._sort = Some(new_value.to_string());
6435 self
6436 }
6437 /// An Analytics segment to be applied to data.
6438 ///
6439 /// Sets the *segment* query property to the given value.
6440 pub fn segment(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6441 self._segment = Some(new_value.to_string());
6442 self
6443 }
6444 /// The desired sampling level.
6445 ///
6446 /// Sets the *sampling level* query property to the given value.
6447 pub fn sampling_level(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6448 self._sampling_level = Some(new_value.to_string());
6449 self
6450 }
6451 /// The selected format for the response. Default format is JSON.
6452 ///
6453 /// Sets the *output* query property to the given value.
6454 pub fn output(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6455 self._output = Some(new_value.to_string());
6456 self
6457 }
6458 /// The maximum number of entries to include in this feed.
6459 ///
6460 /// Sets the *max-results* query property to the given value.
6461 pub fn max_results(mut self, new_value: i32) -> DataGaGetCall<'a, C> {
6462 self._max_results = Some(new_value);
6463 self
6464 }
6465 /// The response will include empty rows if this parameter is set to true, the default is true
6466 ///
6467 /// Sets the *include-empty-rows* query property to the given value.
6468 pub fn include_empty_rows(mut self, new_value: bool) -> DataGaGetCall<'a, C> {
6469 self._include_empty_rows = Some(new_value);
6470 self
6471 }
6472 /// A comma-separated list of dimension or metric filters to be applied to Analytics data.
6473 ///
6474 /// Sets the *filters* query property to the given value.
6475 pub fn filters(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6476 self._filters = Some(new_value.to_string());
6477 self
6478 }
6479 /// A comma-separated list of Analytics dimensions. E.g., 'ga:browser,ga:city'.
6480 ///
6481 /// Sets the *dimensions* query property to the given value.
6482 pub fn dimensions(mut self, new_value: &str) -> DataGaGetCall<'a, C> {
6483 self._dimensions = Some(new_value.to_string());
6484 self
6485 }
6486 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6487 /// while executing the actual API request.
6488 ///
6489 /// ````text
6490 /// It should be used to handle progress information, and to implement a certain level of resilience.
6491 /// ````
6492 ///
6493 /// Sets the *delegate* property to the given value.
6494 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DataGaGetCall<'a, C> {
6495 self._delegate = Some(new_value);
6496 self
6497 }
6498
6499 /// Set any additional parameter of the query string used in the request.
6500 /// It should be used to set parameters which are not yet available through their own
6501 /// setters.
6502 ///
6503 /// Please note that this method must not be used to set any of the known parameters
6504 /// which have their own setter method. If done anyway, the request will fail.
6505 ///
6506 /// # Additional Parameters
6507 ///
6508 /// * *alt* (query-string) - Data format for the response.
6509 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6510 /// * *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.
6511 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6512 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6513 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6514 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6515 pub fn param<T>(mut self, name: T, value: T) -> DataGaGetCall<'a, C>
6516 where
6517 T: AsRef<str>,
6518 {
6519 self._additional_params
6520 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6521 self
6522 }
6523
6524 /// Identifies the authorization scope for the method you are building.
6525 ///
6526 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6527 /// [`Scope::Readonly`].
6528 ///
6529 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6530 /// tokens for more than one scope.
6531 ///
6532 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6533 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6534 /// sufficient, a read-write scope will do as well.
6535 pub fn add_scope<St>(mut self, scope: St) -> DataGaGetCall<'a, C>
6536 where
6537 St: AsRef<str>,
6538 {
6539 self._scopes.insert(String::from(scope.as_ref()));
6540 self
6541 }
6542 /// Identifies the authorization scope(s) for the method you are building.
6543 ///
6544 /// See [`Self::add_scope()`] for details.
6545 pub fn add_scopes<I, St>(mut self, scopes: I) -> DataGaGetCall<'a, C>
6546 where
6547 I: IntoIterator<Item = St>,
6548 St: AsRef<str>,
6549 {
6550 self._scopes
6551 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6552 self
6553 }
6554
6555 /// Removes all scopes, and no default scope will be used either.
6556 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6557 /// for details).
6558 pub fn clear_scopes(mut self) -> DataGaGetCall<'a, C> {
6559 self._scopes.clear();
6560 self
6561 }
6562}
6563
6564/// Returns Analytics Multi-Channel Funnels data for a view (profile).
6565///
6566/// A builder for the *mcf.get* method supported by a *data* resource.
6567/// It is not used directly, but through a [`DataMethods`] instance.
6568///
6569/// # Example
6570///
6571/// Instantiate a resource method builder
6572///
6573/// ```test_harness,no_run
6574/// # extern crate hyper;
6575/// # extern crate hyper_rustls;
6576/// # extern crate google_analytics3 as analytics3;
6577/// # async fn dox() {
6578/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6579///
6580/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6581/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6582/// # secret,
6583/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6584/// # ).build().await.unwrap();
6585///
6586/// # let client = hyper_util::client::legacy::Client::builder(
6587/// # hyper_util::rt::TokioExecutor::new()
6588/// # )
6589/// # .build(
6590/// # hyper_rustls::HttpsConnectorBuilder::new()
6591/// # .with_native_roots()
6592/// # .unwrap()
6593/// # .https_or_http()
6594/// # .enable_http1()
6595/// # .build()
6596/// # );
6597/// # let mut hub = Analytics::new(client, auth);
6598/// // You can configure optional parameters by calling the respective setters at will, and
6599/// // execute the final call using `doit()`.
6600/// // Values shown here are possibly random and not representative !
6601/// let result = hub.data().mcf_get("ids", "start-date", "end-date", "metrics")
6602/// .start_index(-50)
6603/// .sort("est")
6604/// .sampling_level("gubergren")
6605/// .max_results(-17)
6606/// .filters("dolor")
6607/// .dimensions("Lorem")
6608/// .doit().await;
6609/// # }
6610/// ```
6611pub struct DataMcfGetCall<'a, C>
6612where
6613 C: 'a,
6614{
6615 hub: &'a Analytics<C>,
6616 _ids: String,
6617 _start_date: String,
6618 _end_date: String,
6619 _metrics: String,
6620 _start_index: Option<i32>,
6621 _sort: Option<String>,
6622 _sampling_level: Option<String>,
6623 _max_results: Option<i32>,
6624 _filters: Option<String>,
6625 _dimensions: Option<String>,
6626 _delegate: Option<&'a mut dyn common::Delegate>,
6627 _additional_params: HashMap<String, String>,
6628 _scopes: BTreeSet<String>,
6629}
6630
6631impl<'a, C> common::CallBuilder for DataMcfGetCall<'a, C> {}
6632
6633impl<'a, C> DataMcfGetCall<'a, C>
6634where
6635 C: common::Connector,
6636{
6637 /// Perform the operation you have build so far.
6638 pub async fn doit(mut self) -> common::Result<(common::Response, McfData)> {
6639 use std::borrow::Cow;
6640 use std::io::{Read, Seek};
6641
6642 use common::{url::Params, ToParts};
6643 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6644
6645 let mut dd = common::DefaultDelegate;
6646 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6647 dlg.begin(common::MethodInfo {
6648 id: "analytics.data.mcf.get",
6649 http_method: hyper::Method::GET,
6650 });
6651
6652 for &field in [
6653 "alt",
6654 "ids",
6655 "start-date",
6656 "end-date",
6657 "metrics",
6658 "start-index",
6659 "sort",
6660 "samplingLevel",
6661 "max-results",
6662 "filters",
6663 "dimensions",
6664 ]
6665 .iter()
6666 {
6667 if self._additional_params.contains_key(field) {
6668 dlg.finished(false);
6669 return Err(common::Error::FieldClash(field));
6670 }
6671 }
6672
6673 let mut params = Params::with_capacity(12 + self._additional_params.len());
6674 params.push("ids", self._ids);
6675 params.push("start-date", self._start_date);
6676 params.push("end-date", self._end_date);
6677 params.push("metrics", self._metrics);
6678 if let Some(value) = self._start_index.as_ref() {
6679 params.push("start-index", value.to_string());
6680 }
6681 if let Some(value) = self._sort.as_ref() {
6682 params.push("sort", value);
6683 }
6684 if let Some(value) = self._sampling_level.as_ref() {
6685 params.push("samplingLevel", value);
6686 }
6687 if let Some(value) = self._max_results.as_ref() {
6688 params.push("max-results", value.to_string());
6689 }
6690 if let Some(value) = self._filters.as_ref() {
6691 params.push("filters", value);
6692 }
6693 if let Some(value) = self._dimensions.as_ref() {
6694 params.push("dimensions", value);
6695 }
6696
6697 params.extend(self._additional_params.iter());
6698
6699 params.push("alt", "json");
6700 let mut url = self.hub._base_url.clone() + "data/mcf";
6701 if self._scopes.is_empty() {
6702 self._scopes.insert(Scope::Readonly.as_ref().to_string());
6703 }
6704
6705 let url = params.parse_with_url(&url);
6706
6707 loop {
6708 let token = match self
6709 .hub
6710 .auth
6711 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6712 .await
6713 {
6714 Ok(token) => token,
6715 Err(e) => match dlg.token(e) {
6716 Ok(token) => token,
6717 Err(e) => {
6718 dlg.finished(false);
6719 return Err(common::Error::MissingToken(e));
6720 }
6721 },
6722 };
6723 let mut req_result = {
6724 let client = &self.hub.client;
6725 dlg.pre_request();
6726 let mut req_builder = hyper::Request::builder()
6727 .method(hyper::Method::GET)
6728 .uri(url.as_str())
6729 .header(USER_AGENT, self.hub._user_agent.clone());
6730
6731 if let Some(token) = token.as_ref() {
6732 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6733 }
6734
6735 let request = req_builder
6736 .header(CONTENT_LENGTH, 0_u64)
6737 .body(common::to_body::<String>(None));
6738
6739 client.request(request.unwrap()).await
6740 };
6741
6742 match req_result {
6743 Err(err) => {
6744 if let common::Retry::After(d) = dlg.http_error(&err) {
6745 sleep(d).await;
6746 continue;
6747 }
6748 dlg.finished(false);
6749 return Err(common::Error::HttpError(err));
6750 }
6751 Ok(res) => {
6752 let (mut parts, body) = res.into_parts();
6753 let mut body = common::Body::new(body);
6754 if !parts.status.is_success() {
6755 let bytes = common::to_bytes(body).await.unwrap_or_default();
6756 let error = serde_json::from_str(&common::to_string(&bytes));
6757 let response = common::to_response(parts, bytes.into());
6758
6759 if let common::Retry::After(d) =
6760 dlg.http_failure(&response, error.as_ref().ok())
6761 {
6762 sleep(d).await;
6763 continue;
6764 }
6765
6766 dlg.finished(false);
6767
6768 return Err(match error {
6769 Ok(value) => common::Error::BadRequest(value),
6770 _ => common::Error::Failure(response),
6771 });
6772 }
6773 let response = {
6774 let bytes = common::to_bytes(body).await.unwrap_or_default();
6775 let encoded = common::to_string(&bytes);
6776 match serde_json::from_str(&encoded) {
6777 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6778 Err(error) => {
6779 dlg.response_json_decode_error(&encoded, &error);
6780 return Err(common::Error::JsonDecodeError(
6781 encoded.to_string(),
6782 error,
6783 ));
6784 }
6785 }
6786 };
6787
6788 dlg.finished(true);
6789 return Ok(response);
6790 }
6791 }
6792 }
6793 }
6794
6795 /// Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
6796 ///
6797 /// Sets the *ids* query property to the given value.
6798 ///
6799 /// Even though the property as already been set when instantiating this call,
6800 /// we provide this method for API completeness.
6801 pub fn ids(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6802 self._ids = new_value.to_string();
6803 self
6804 }
6805 /// 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.
6806 ///
6807 /// Sets the *start-date* query property to the given value.
6808 ///
6809 /// Even though the property as already been set when instantiating this call,
6810 /// we provide this method for API completeness.
6811 pub fn start_date(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6812 self._start_date = new_value.to_string();
6813 self
6814 }
6815 /// 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.
6816 ///
6817 /// Sets the *end-date* query property to the given value.
6818 ///
6819 /// Even though the property as already been set when instantiating this call,
6820 /// we provide this method for API completeness.
6821 pub fn end_date(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6822 self._end_date = new_value.to_string();
6823 self
6824 }
6825 /// A comma-separated list of Multi-Channel Funnels metrics. E.g., 'mcf:totalConversions,mcf:totalConversionValue'. At least one metric must be specified.
6826 ///
6827 /// Sets the *metrics* query property to the given value.
6828 ///
6829 /// Even though the property as already been set when instantiating this call,
6830 /// we provide this method for API completeness.
6831 pub fn metrics(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6832 self._metrics = new_value.to_string();
6833 self
6834 }
6835 /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
6836 ///
6837 /// Sets the *start-index* query property to the given value.
6838 pub fn start_index(mut self, new_value: i32) -> DataMcfGetCall<'a, C> {
6839 self._start_index = Some(new_value);
6840 self
6841 }
6842 /// A comma-separated list of dimensions or metrics that determine the sort order for the Analytics data.
6843 ///
6844 /// Sets the *sort* query property to the given value.
6845 pub fn sort(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6846 self._sort = Some(new_value.to_string());
6847 self
6848 }
6849 /// The desired sampling level.
6850 ///
6851 /// Sets the *sampling level* query property to the given value.
6852 pub fn sampling_level(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6853 self._sampling_level = Some(new_value.to_string());
6854 self
6855 }
6856 /// The maximum number of entries to include in this feed.
6857 ///
6858 /// Sets the *max-results* query property to the given value.
6859 pub fn max_results(mut self, new_value: i32) -> DataMcfGetCall<'a, C> {
6860 self._max_results = Some(new_value);
6861 self
6862 }
6863 /// A comma-separated list of dimension or metric filters to be applied to the Analytics data.
6864 ///
6865 /// Sets the *filters* query property to the given value.
6866 pub fn filters(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6867 self._filters = Some(new_value.to_string());
6868 self
6869 }
6870 /// A comma-separated list of Multi-Channel Funnels dimensions. E.g., 'mcf:source,mcf:medium'.
6871 ///
6872 /// Sets the *dimensions* query property to the given value.
6873 pub fn dimensions(mut self, new_value: &str) -> DataMcfGetCall<'a, C> {
6874 self._dimensions = Some(new_value.to_string());
6875 self
6876 }
6877 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6878 /// while executing the actual API request.
6879 ///
6880 /// ````text
6881 /// It should be used to handle progress information, and to implement a certain level of resilience.
6882 /// ````
6883 ///
6884 /// Sets the *delegate* property to the given value.
6885 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> DataMcfGetCall<'a, C> {
6886 self._delegate = Some(new_value);
6887 self
6888 }
6889
6890 /// Set any additional parameter of the query string used in the request.
6891 /// It should be used to set parameters which are not yet available through their own
6892 /// setters.
6893 ///
6894 /// Please note that this method must not be used to set any of the known parameters
6895 /// which have their own setter method. If done anyway, the request will fail.
6896 ///
6897 /// # Additional Parameters
6898 ///
6899 /// * *alt* (query-string) - Data format for the response.
6900 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6901 /// * *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.
6902 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6903 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6904 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6905 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6906 pub fn param<T>(mut self, name: T, value: T) -> DataMcfGetCall<'a, C>
6907 where
6908 T: AsRef<str>,
6909 {
6910 self._additional_params
6911 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6912 self
6913 }
6914
6915 /// Identifies the authorization scope for the method you are building.
6916 ///
6917 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6918 /// [`Scope::Readonly`].
6919 ///
6920 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6921 /// tokens for more than one scope.
6922 ///
6923 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6924 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6925 /// sufficient, a read-write scope will do as well.
6926 pub fn add_scope<St>(mut self, scope: St) -> DataMcfGetCall<'a, C>
6927 where
6928 St: AsRef<str>,
6929 {
6930 self._scopes.insert(String::from(scope.as_ref()));
6931 self
6932 }
6933 /// Identifies the authorization scope(s) for the method you are building.
6934 ///
6935 /// See [`Self::add_scope()`] for details.
6936 pub fn add_scopes<I, St>(mut self, scopes: I) -> DataMcfGetCall<'a, C>
6937 where
6938 I: IntoIterator<Item = St>,
6939 St: AsRef<str>,
6940 {
6941 self._scopes
6942 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6943 self
6944 }
6945
6946 /// Removes all scopes, and no default scope will be used either.
6947 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6948 /// for details).
6949 pub fn clear_scopes(mut self) -> DataMcfGetCall<'a, C> {
6950 self._scopes.clear();
6951 self
6952 }
6953}
6954
6955/// Returns real time data for a view (profile).
6956///
6957/// A builder for the *realtime.get* method supported by a *data* resource.
6958/// It is not used directly, but through a [`DataMethods`] instance.
6959///
6960/// # Example
6961///
6962/// Instantiate a resource method builder
6963///
6964/// ```test_harness,no_run
6965/// # extern crate hyper;
6966/// # extern crate hyper_rustls;
6967/// # extern crate google_analytics3 as analytics3;
6968/// # async fn dox() {
6969/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6970///
6971/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6972/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6973/// # secret,
6974/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6975/// # ).build().await.unwrap();
6976///
6977/// # let client = hyper_util::client::legacy::Client::builder(
6978/// # hyper_util::rt::TokioExecutor::new()
6979/// # )
6980/// # .build(
6981/// # hyper_rustls::HttpsConnectorBuilder::new()
6982/// # .with_native_roots()
6983/// # .unwrap()
6984/// # .https_or_http()
6985/// # .enable_http1()
6986/// # .build()
6987/// # );
6988/// # let mut hub = Analytics::new(client, auth);
6989/// // You can configure optional parameters by calling the respective setters at will, and
6990/// // execute the final call using `doit()`.
6991/// // Values shown here are possibly random and not representative !
6992/// let result = hub.data().realtime_get("ids", "metrics")
6993/// .sort("sed")
6994/// .max_results(-70)
6995/// .filters("sed")
6996/// .dimensions("no")
6997/// .doit().await;
6998/// # }
6999/// ```
7000pub struct DataRealtimeGetCall<'a, C>
7001where
7002 C: 'a,
7003{
7004 hub: &'a Analytics<C>,
7005 _ids: String,
7006 _metrics: String,
7007 _sort: Option<String>,
7008 _max_results: Option<i32>,
7009 _filters: Option<String>,
7010 _dimensions: Option<String>,
7011 _delegate: Option<&'a mut dyn common::Delegate>,
7012 _additional_params: HashMap<String, String>,
7013 _scopes: BTreeSet<String>,
7014}
7015
7016impl<'a, C> common::CallBuilder for DataRealtimeGetCall<'a, C> {}
7017
7018impl<'a, C> DataRealtimeGetCall<'a, C>
7019where
7020 C: common::Connector,
7021{
7022 /// Perform the operation you have build so far.
7023 pub async fn doit(mut self) -> common::Result<(common::Response, RealtimeData)> {
7024 use std::borrow::Cow;
7025 use std::io::{Read, Seek};
7026
7027 use common::{url::Params, ToParts};
7028 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7029
7030 let mut dd = common::DefaultDelegate;
7031 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7032 dlg.begin(common::MethodInfo {
7033 id: "analytics.data.realtime.get",
7034 http_method: hyper::Method::GET,
7035 });
7036
7037 for &field in [
7038 "alt",
7039 "ids",
7040 "metrics",
7041 "sort",
7042 "max-results",
7043 "filters",
7044 "dimensions",
7045 ]
7046 .iter()
7047 {
7048 if self._additional_params.contains_key(field) {
7049 dlg.finished(false);
7050 return Err(common::Error::FieldClash(field));
7051 }
7052 }
7053
7054 let mut params = Params::with_capacity(8 + self._additional_params.len());
7055 params.push("ids", self._ids);
7056 params.push("metrics", self._metrics);
7057 if let Some(value) = self._sort.as_ref() {
7058 params.push("sort", value);
7059 }
7060 if let Some(value) = self._max_results.as_ref() {
7061 params.push("max-results", value.to_string());
7062 }
7063 if let Some(value) = self._filters.as_ref() {
7064 params.push("filters", value);
7065 }
7066 if let Some(value) = self._dimensions.as_ref() {
7067 params.push("dimensions", value);
7068 }
7069
7070 params.extend(self._additional_params.iter());
7071
7072 params.push("alt", "json");
7073 let mut url = self.hub._base_url.clone() + "data/realtime";
7074 if self._scopes.is_empty() {
7075 self._scopes.insert(Scope::Readonly.as_ref().to_string());
7076 }
7077
7078 let url = params.parse_with_url(&url);
7079
7080 loop {
7081 let token = match self
7082 .hub
7083 .auth
7084 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7085 .await
7086 {
7087 Ok(token) => token,
7088 Err(e) => match dlg.token(e) {
7089 Ok(token) => token,
7090 Err(e) => {
7091 dlg.finished(false);
7092 return Err(common::Error::MissingToken(e));
7093 }
7094 },
7095 };
7096 let mut req_result = {
7097 let client = &self.hub.client;
7098 dlg.pre_request();
7099 let mut req_builder = hyper::Request::builder()
7100 .method(hyper::Method::GET)
7101 .uri(url.as_str())
7102 .header(USER_AGENT, self.hub._user_agent.clone());
7103
7104 if let Some(token) = token.as_ref() {
7105 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7106 }
7107
7108 let request = req_builder
7109 .header(CONTENT_LENGTH, 0_u64)
7110 .body(common::to_body::<String>(None));
7111
7112 client.request(request.unwrap()).await
7113 };
7114
7115 match req_result {
7116 Err(err) => {
7117 if let common::Retry::After(d) = dlg.http_error(&err) {
7118 sleep(d).await;
7119 continue;
7120 }
7121 dlg.finished(false);
7122 return Err(common::Error::HttpError(err));
7123 }
7124 Ok(res) => {
7125 let (mut parts, body) = res.into_parts();
7126 let mut body = common::Body::new(body);
7127 if !parts.status.is_success() {
7128 let bytes = common::to_bytes(body).await.unwrap_or_default();
7129 let error = serde_json::from_str(&common::to_string(&bytes));
7130 let response = common::to_response(parts, bytes.into());
7131
7132 if let common::Retry::After(d) =
7133 dlg.http_failure(&response, error.as_ref().ok())
7134 {
7135 sleep(d).await;
7136 continue;
7137 }
7138
7139 dlg.finished(false);
7140
7141 return Err(match error {
7142 Ok(value) => common::Error::BadRequest(value),
7143 _ => common::Error::Failure(response),
7144 });
7145 }
7146 let response = {
7147 let bytes = common::to_bytes(body).await.unwrap_or_default();
7148 let encoded = common::to_string(&bytes);
7149 match serde_json::from_str(&encoded) {
7150 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7151 Err(error) => {
7152 dlg.response_json_decode_error(&encoded, &error);
7153 return Err(common::Error::JsonDecodeError(
7154 encoded.to_string(),
7155 error,
7156 ));
7157 }
7158 }
7159 };
7160
7161 dlg.finished(true);
7162 return Ok(response);
7163 }
7164 }
7165 }
7166 }
7167
7168 /// Unique table ID for retrieving real time data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
7169 ///
7170 /// Sets the *ids* query property to the given value.
7171 ///
7172 /// Even though the property as already been set when instantiating this call,
7173 /// we provide this method for API completeness.
7174 pub fn ids(mut self, new_value: &str) -> DataRealtimeGetCall<'a, C> {
7175 self._ids = new_value.to_string();
7176 self
7177 }
7178 /// A comma-separated list of real time metrics. E.g., 'rt:activeUsers'. At least one metric must be specified.
7179 ///
7180 /// Sets the *metrics* query property to the given value.
7181 ///
7182 /// Even though the property as already been set when instantiating this call,
7183 /// we provide this method for API completeness.
7184 pub fn metrics(mut self, new_value: &str) -> DataRealtimeGetCall<'a, C> {
7185 self._metrics = new_value.to_string();
7186 self
7187 }
7188 /// A comma-separated list of dimensions or metrics that determine the sort order for real time data.
7189 ///
7190 /// Sets the *sort* query property to the given value.
7191 pub fn sort(mut self, new_value: &str) -> DataRealtimeGetCall<'a, C> {
7192 self._sort = Some(new_value.to_string());
7193 self
7194 }
7195 /// The maximum number of entries to include in this feed.
7196 ///
7197 /// Sets the *max-results* query property to the given value.
7198 pub fn max_results(mut self, new_value: i32) -> DataRealtimeGetCall<'a, C> {
7199 self._max_results = Some(new_value);
7200 self
7201 }
7202 /// A comma-separated list of dimension or metric filters to be applied to real time data.
7203 ///
7204 /// Sets the *filters* query property to the given value.
7205 pub fn filters(mut self, new_value: &str) -> DataRealtimeGetCall<'a, C> {
7206 self._filters = Some(new_value.to_string());
7207 self
7208 }
7209 /// A comma-separated list of real time dimensions. E.g., 'rt:medium,rt:city'.
7210 ///
7211 /// Sets the *dimensions* query property to the given value.
7212 pub fn dimensions(mut self, new_value: &str) -> DataRealtimeGetCall<'a, C> {
7213 self._dimensions = Some(new_value.to_string());
7214 self
7215 }
7216 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7217 /// while executing the actual API request.
7218 ///
7219 /// ````text
7220 /// It should be used to handle progress information, and to implement a certain level of resilience.
7221 /// ````
7222 ///
7223 /// Sets the *delegate* property to the given value.
7224 pub fn delegate(
7225 mut self,
7226 new_value: &'a mut dyn common::Delegate,
7227 ) -> DataRealtimeGetCall<'a, C> {
7228 self._delegate = Some(new_value);
7229 self
7230 }
7231
7232 /// Set any additional parameter of the query string used in the request.
7233 /// It should be used to set parameters which are not yet available through their own
7234 /// setters.
7235 ///
7236 /// Please note that this method must not be used to set any of the known parameters
7237 /// which have their own setter method. If done anyway, the request will fail.
7238 ///
7239 /// # Additional Parameters
7240 ///
7241 /// * *alt* (query-string) - Data format for the response.
7242 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7243 /// * *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.
7244 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7245 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7246 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7247 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7248 pub fn param<T>(mut self, name: T, value: T) -> DataRealtimeGetCall<'a, C>
7249 where
7250 T: AsRef<str>,
7251 {
7252 self._additional_params
7253 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7254 self
7255 }
7256
7257 /// Identifies the authorization scope for the method you are building.
7258 ///
7259 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7260 /// [`Scope::Readonly`].
7261 ///
7262 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7263 /// tokens for more than one scope.
7264 ///
7265 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7266 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7267 /// sufficient, a read-write scope will do as well.
7268 pub fn add_scope<St>(mut self, scope: St) -> DataRealtimeGetCall<'a, C>
7269 where
7270 St: AsRef<str>,
7271 {
7272 self._scopes.insert(String::from(scope.as_ref()));
7273 self
7274 }
7275 /// Identifies the authorization scope(s) for the method you are building.
7276 ///
7277 /// See [`Self::add_scope()`] for details.
7278 pub fn add_scopes<I, St>(mut self, scopes: I) -> DataRealtimeGetCall<'a, C>
7279 where
7280 I: IntoIterator<Item = St>,
7281 St: AsRef<str>,
7282 {
7283 self._scopes
7284 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7285 self
7286 }
7287
7288 /// Removes all scopes, and no default scope will be used either.
7289 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7290 /// for details).
7291 pub fn clear_scopes(mut self) -> DataRealtimeGetCall<'a, C> {
7292 self._scopes.clear();
7293 self
7294 }
7295}
7296
7297/// Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access.
7298///
7299/// A builder for the *accountSummaries.list* method supported by a *management* resource.
7300/// It is not used directly, but through a [`ManagementMethods`] instance.
7301///
7302/// # Example
7303///
7304/// Instantiate a resource method builder
7305///
7306/// ```test_harness,no_run
7307/// # extern crate hyper;
7308/// # extern crate hyper_rustls;
7309/// # extern crate google_analytics3 as analytics3;
7310/// # async fn dox() {
7311/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7312///
7313/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7314/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7315/// # secret,
7316/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7317/// # ).build().await.unwrap();
7318///
7319/// # let client = hyper_util::client::legacy::Client::builder(
7320/// # hyper_util::rt::TokioExecutor::new()
7321/// # )
7322/// # .build(
7323/// # hyper_rustls::HttpsConnectorBuilder::new()
7324/// # .with_native_roots()
7325/// # .unwrap()
7326/// # .https_or_http()
7327/// # .enable_http1()
7328/// # .build()
7329/// # );
7330/// # let mut hub = Analytics::new(client, auth);
7331/// // You can configure optional parameters by calling the respective setters at will, and
7332/// // execute the final call using `doit()`.
7333/// // Values shown here are possibly random and not representative !
7334/// let result = hub.management().account_summaries_list()
7335/// .start_index(-15)
7336/// .max_results(-13)
7337/// .doit().await;
7338/// # }
7339/// ```
7340pub struct ManagementAccountSummaryListCall<'a, C>
7341where
7342 C: 'a,
7343{
7344 hub: &'a Analytics<C>,
7345 _start_index: Option<i32>,
7346 _max_results: Option<i32>,
7347 _delegate: Option<&'a mut dyn common::Delegate>,
7348 _additional_params: HashMap<String, String>,
7349 _scopes: BTreeSet<String>,
7350}
7351
7352impl<'a, C> common::CallBuilder for ManagementAccountSummaryListCall<'a, C> {}
7353
7354impl<'a, C> ManagementAccountSummaryListCall<'a, C>
7355where
7356 C: common::Connector,
7357{
7358 /// Perform the operation you have build so far.
7359 pub async fn doit(mut self) -> common::Result<(common::Response, AccountSummaries)> {
7360 use std::borrow::Cow;
7361 use std::io::{Read, Seek};
7362
7363 use common::{url::Params, ToParts};
7364 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7365
7366 let mut dd = common::DefaultDelegate;
7367 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7368 dlg.begin(common::MethodInfo {
7369 id: "analytics.management.accountSummaries.list",
7370 http_method: hyper::Method::GET,
7371 });
7372
7373 for &field in ["alt", "start-index", "max-results"].iter() {
7374 if self._additional_params.contains_key(field) {
7375 dlg.finished(false);
7376 return Err(common::Error::FieldClash(field));
7377 }
7378 }
7379
7380 let mut params = Params::with_capacity(4 + self._additional_params.len());
7381 if let Some(value) = self._start_index.as_ref() {
7382 params.push("start-index", value.to_string());
7383 }
7384 if let Some(value) = self._max_results.as_ref() {
7385 params.push("max-results", value.to_string());
7386 }
7387
7388 params.extend(self._additional_params.iter());
7389
7390 params.push("alt", "json");
7391 let mut url = self.hub._base_url.clone() + "management/accountSummaries";
7392 if self._scopes.is_empty() {
7393 self._scopes.insert(Scope::Readonly.as_ref().to_string());
7394 }
7395
7396 let url = params.parse_with_url(&url);
7397
7398 loop {
7399 let token = match self
7400 .hub
7401 .auth
7402 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7403 .await
7404 {
7405 Ok(token) => token,
7406 Err(e) => match dlg.token(e) {
7407 Ok(token) => token,
7408 Err(e) => {
7409 dlg.finished(false);
7410 return Err(common::Error::MissingToken(e));
7411 }
7412 },
7413 };
7414 let mut req_result = {
7415 let client = &self.hub.client;
7416 dlg.pre_request();
7417 let mut req_builder = hyper::Request::builder()
7418 .method(hyper::Method::GET)
7419 .uri(url.as_str())
7420 .header(USER_AGENT, self.hub._user_agent.clone());
7421
7422 if let Some(token) = token.as_ref() {
7423 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7424 }
7425
7426 let request = req_builder
7427 .header(CONTENT_LENGTH, 0_u64)
7428 .body(common::to_body::<String>(None));
7429
7430 client.request(request.unwrap()).await
7431 };
7432
7433 match req_result {
7434 Err(err) => {
7435 if let common::Retry::After(d) = dlg.http_error(&err) {
7436 sleep(d).await;
7437 continue;
7438 }
7439 dlg.finished(false);
7440 return Err(common::Error::HttpError(err));
7441 }
7442 Ok(res) => {
7443 let (mut parts, body) = res.into_parts();
7444 let mut body = common::Body::new(body);
7445 if !parts.status.is_success() {
7446 let bytes = common::to_bytes(body).await.unwrap_or_default();
7447 let error = serde_json::from_str(&common::to_string(&bytes));
7448 let response = common::to_response(parts, bytes.into());
7449
7450 if let common::Retry::After(d) =
7451 dlg.http_failure(&response, error.as_ref().ok())
7452 {
7453 sleep(d).await;
7454 continue;
7455 }
7456
7457 dlg.finished(false);
7458
7459 return Err(match error {
7460 Ok(value) => common::Error::BadRequest(value),
7461 _ => common::Error::Failure(response),
7462 });
7463 }
7464 let response = {
7465 let bytes = common::to_bytes(body).await.unwrap_or_default();
7466 let encoded = common::to_string(&bytes);
7467 match serde_json::from_str(&encoded) {
7468 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7469 Err(error) => {
7470 dlg.response_json_decode_error(&encoded, &error);
7471 return Err(common::Error::JsonDecodeError(
7472 encoded.to_string(),
7473 error,
7474 ));
7475 }
7476 }
7477 };
7478
7479 dlg.finished(true);
7480 return Ok(response);
7481 }
7482 }
7483 }
7484 }
7485
7486 /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
7487 ///
7488 /// Sets the *start-index* query property to the given value.
7489 pub fn start_index(mut self, new_value: i32) -> ManagementAccountSummaryListCall<'a, C> {
7490 self._start_index = Some(new_value);
7491 self
7492 }
7493 /// The maximum number of account summaries to include in this response, where the largest acceptable value is 1000.
7494 ///
7495 /// Sets the *max-results* query property to the given value.
7496 pub fn max_results(mut self, new_value: i32) -> ManagementAccountSummaryListCall<'a, C> {
7497 self._max_results = Some(new_value);
7498 self
7499 }
7500 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7501 /// while executing the actual API request.
7502 ///
7503 /// ````text
7504 /// It should be used to handle progress information, and to implement a certain level of resilience.
7505 /// ````
7506 ///
7507 /// Sets the *delegate* property to the given value.
7508 pub fn delegate(
7509 mut self,
7510 new_value: &'a mut dyn common::Delegate,
7511 ) -> ManagementAccountSummaryListCall<'a, C> {
7512 self._delegate = Some(new_value);
7513 self
7514 }
7515
7516 /// Set any additional parameter of the query string used in the request.
7517 /// It should be used to set parameters which are not yet available through their own
7518 /// setters.
7519 ///
7520 /// Please note that this method must not be used to set any of the known parameters
7521 /// which have their own setter method. If done anyway, the request will fail.
7522 ///
7523 /// # Additional Parameters
7524 ///
7525 /// * *alt* (query-string) - Data format for the response.
7526 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7527 /// * *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.
7528 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7529 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7530 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7531 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7532 pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountSummaryListCall<'a, C>
7533 where
7534 T: AsRef<str>,
7535 {
7536 self._additional_params
7537 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7538 self
7539 }
7540
7541 /// Identifies the authorization scope for the method you are building.
7542 ///
7543 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7544 /// [`Scope::Readonly`].
7545 ///
7546 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7547 /// tokens for more than one scope.
7548 ///
7549 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7550 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7551 /// sufficient, a read-write scope will do as well.
7552 pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountSummaryListCall<'a, C>
7553 where
7554 St: AsRef<str>,
7555 {
7556 self._scopes.insert(String::from(scope.as_ref()));
7557 self
7558 }
7559 /// Identifies the authorization scope(s) for the method you are building.
7560 ///
7561 /// See [`Self::add_scope()`] for details.
7562 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountSummaryListCall<'a, C>
7563 where
7564 I: IntoIterator<Item = St>,
7565 St: AsRef<str>,
7566 {
7567 self._scopes
7568 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7569 self
7570 }
7571
7572 /// Removes all scopes, and no default scope will be used either.
7573 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7574 /// for details).
7575 pub fn clear_scopes(mut self) -> ManagementAccountSummaryListCall<'a, C> {
7576 self._scopes.clear();
7577 self
7578 }
7579}
7580
7581/// Removes a user from the given account.
7582///
7583/// A builder for the *accountUserLinks.delete* method supported by a *management* resource.
7584/// It is not used directly, but through a [`ManagementMethods`] instance.
7585///
7586/// # Example
7587///
7588/// Instantiate a resource method builder
7589///
7590/// ```test_harness,no_run
7591/// # extern crate hyper;
7592/// # extern crate hyper_rustls;
7593/// # extern crate google_analytics3 as analytics3;
7594/// # async fn dox() {
7595/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7596///
7597/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7598/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7599/// # secret,
7600/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7601/// # ).build().await.unwrap();
7602///
7603/// # let client = hyper_util::client::legacy::Client::builder(
7604/// # hyper_util::rt::TokioExecutor::new()
7605/// # )
7606/// # .build(
7607/// # hyper_rustls::HttpsConnectorBuilder::new()
7608/// # .with_native_roots()
7609/// # .unwrap()
7610/// # .https_or_http()
7611/// # .enable_http1()
7612/// # .build()
7613/// # );
7614/// # let mut hub = Analytics::new(client, auth);
7615/// // You can configure optional parameters by calling the respective setters at will, and
7616/// // execute the final call using `doit()`.
7617/// // Values shown here are possibly random and not representative !
7618/// let result = hub.management().account_user_links_delete("accountId", "linkId")
7619/// .doit().await;
7620/// # }
7621/// ```
7622pub struct ManagementAccountUserLinkDeleteCall<'a, C>
7623where
7624 C: 'a,
7625{
7626 hub: &'a Analytics<C>,
7627 _account_id: String,
7628 _link_id: String,
7629 _delegate: Option<&'a mut dyn common::Delegate>,
7630 _additional_params: HashMap<String, String>,
7631 _scopes: BTreeSet<String>,
7632}
7633
7634impl<'a, C> common::CallBuilder for ManagementAccountUserLinkDeleteCall<'a, C> {}
7635
7636impl<'a, C> ManagementAccountUserLinkDeleteCall<'a, C>
7637where
7638 C: common::Connector,
7639{
7640 /// Perform the operation you have build so far.
7641 pub async fn doit(mut self) -> common::Result<common::Response> {
7642 use std::borrow::Cow;
7643 use std::io::{Read, Seek};
7644
7645 use common::{url::Params, ToParts};
7646 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7647
7648 let mut dd = common::DefaultDelegate;
7649 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7650 dlg.begin(common::MethodInfo {
7651 id: "analytics.management.accountUserLinks.delete",
7652 http_method: hyper::Method::DELETE,
7653 });
7654
7655 for &field in ["accountId", "linkId"].iter() {
7656 if self._additional_params.contains_key(field) {
7657 dlg.finished(false);
7658 return Err(common::Error::FieldClash(field));
7659 }
7660 }
7661
7662 let mut params = Params::with_capacity(3 + self._additional_params.len());
7663 params.push("accountId", self._account_id);
7664 params.push("linkId", self._link_id);
7665
7666 params.extend(self._additional_params.iter());
7667
7668 let mut url =
7669 self.hub._base_url.clone() + "management/accounts/{accountId}/entityUserLinks/{linkId}";
7670 if self._scopes.is_empty() {
7671 self._scopes.insert(Scope::ManageUser.as_ref().to_string());
7672 }
7673
7674 #[allow(clippy::single_element_loop)]
7675 for &(find_this, param_name) in
7676 [("{accountId}", "accountId"), ("{linkId}", "linkId")].iter()
7677 {
7678 url = params.uri_replacement(url, param_name, find_this, false);
7679 }
7680 {
7681 let to_remove = ["linkId", "accountId"];
7682 params.remove_params(&to_remove);
7683 }
7684
7685 let url = params.parse_with_url(&url);
7686
7687 loop {
7688 let token = match self
7689 .hub
7690 .auth
7691 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7692 .await
7693 {
7694 Ok(token) => token,
7695 Err(e) => match dlg.token(e) {
7696 Ok(token) => token,
7697 Err(e) => {
7698 dlg.finished(false);
7699 return Err(common::Error::MissingToken(e));
7700 }
7701 },
7702 };
7703 let mut req_result = {
7704 let client = &self.hub.client;
7705 dlg.pre_request();
7706 let mut req_builder = hyper::Request::builder()
7707 .method(hyper::Method::DELETE)
7708 .uri(url.as_str())
7709 .header(USER_AGENT, self.hub._user_agent.clone());
7710
7711 if let Some(token) = token.as_ref() {
7712 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7713 }
7714
7715 let request = req_builder
7716 .header(CONTENT_LENGTH, 0_u64)
7717 .body(common::to_body::<String>(None));
7718
7719 client.request(request.unwrap()).await
7720 };
7721
7722 match req_result {
7723 Err(err) => {
7724 if let common::Retry::After(d) = dlg.http_error(&err) {
7725 sleep(d).await;
7726 continue;
7727 }
7728 dlg.finished(false);
7729 return Err(common::Error::HttpError(err));
7730 }
7731 Ok(res) => {
7732 let (mut parts, body) = res.into_parts();
7733 let mut body = common::Body::new(body);
7734 if !parts.status.is_success() {
7735 let bytes = common::to_bytes(body).await.unwrap_or_default();
7736 let error = serde_json::from_str(&common::to_string(&bytes));
7737 let response = common::to_response(parts, bytes.into());
7738
7739 if let common::Retry::After(d) =
7740 dlg.http_failure(&response, error.as_ref().ok())
7741 {
7742 sleep(d).await;
7743 continue;
7744 }
7745
7746 dlg.finished(false);
7747
7748 return Err(match error {
7749 Ok(value) => common::Error::BadRequest(value),
7750 _ => common::Error::Failure(response),
7751 });
7752 }
7753 let response = common::Response::from_parts(parts, body);
7754
7755 dlg.finished(true);
7756 return Ok(response);
7757 }
7758 }
7759 }
7760 }
7761
7762 /// Account ID to delete the user link for.
7763 ///
7764 /// Sets the *account id* path property to the given value.
7765 ///
7766 /// Even though the property as already been set when instantiating this call,
7767 /// we provide this method for API completeness.
7768 pub fn account_id(mut self, new_value: &str) -> ManagementAccountUserLinkDeleteCall<'a, C> {
7769 self._account_id = new_value.to_string();
7770 self
7771 }
7772 /// Link ID to delete the user link for.
7773 ///
7774 /// Sets the *link id* path property to the given value.
7775 ///
7776 /// Even though the property as already been set when instantiating this call,
7777 /// we provide this method for API completeness.
7778 pub fn link_id(mut self, new_value: &str) -> ManagementAccountUserLinkDeleteCall<'a, C> {
7779 self._link_id = new_value.to_string();
7780 self
7781 }
7782 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7783 /// while executing the actual API request.
7784 ///
7785 /// ````text
7786 /// It should be used to handle progress information, and to implement a certain level of resilience.
7787 /// ````
7788 ///
7789 /// Sets the *delegate* property to the given value.
7790 pub fn delegate(
7791 mut self,
7792 new_value: &'a mut dyn common::Delegate,
7793 ) -> ManagementAccountUserLinkDeleteCall<'a, C> {
7794 self._delegate = Some(new_value);
7795 self
7796 }
7797
7798 /// Set any additional parameter of the query string used in the request.
7799 /// It should be used to set parameters which are not yet available through their own
7800 /// setters.
7801 ///
7802 /// Please note that this method must not be used to set any of the known parameters
7803 /// which have their own setter method. If done anyway, the request will fail.
7804 ///
7805 /// # Additional Parameters
7806 ///
7807 /// * *alt* (query-string) - Data format for the response.
7808 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7809 /// * *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.
7810 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7811 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7812 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7813 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7814 pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountUserLinkDeleteCall<'a, C>
7815 where
7816 T: AsRef<str>,
7817 {
7818 self._additional_params
7819 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7820 self
7821 }
7822
7823 /// Identifies the authorization scope for the method you are building.
7824 ///
7825 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7826 /// [`Scope::ManageUser`].
7827 ///
7828 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7829 /// tokens for more than one scope.
7830 ///
7831 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7832 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7833 /// sufficient, a read-write scope will do as well.
7834 pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountUserLinkDeleteCall<'a, C>
7835 where
7836 St: AsRef<str>,
7837 {
7838 self._scopes.insert(String::from(scope.as_ref()));
7839 self
7840 }
7841 /// Identifies the authorization scope(s) for the method you are building.
7842 ///
7843 /// See [`Self::add_scope()`] for details.
7844 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountUserLinkDeleteCall<'a, C>
7845 where
7846 I: IntoIterator<Item = St>,
7847 St: AsRef<str>,
7848 {
7849 self._scopes
7850 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7851 self
7852 }
7853
7854 /// Removes all scopes, and no default scope will be used either.
7855 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7856 /// for details).
7857 pub fn clear_scopes(mut self) -> ManagementAccountUserLinkDeleteCall<'a, C> {
7858 self._scopes.clear();
7859 self
7860 }
7861}
7862
7863/// Adds a new user to the given account.
7864///
7865/// A builder for the *accountUserLinks.insert* method supported by a *management* resource.
7866/// It is not used directly, but through a [`ManagementMethods`] instance.
7867///
7868/// # Example
7869///
7870/// Instantiate a resource method builder
7871///
7872/// ```test_harness,no_run
7873/// # extern crate hyper;
7874/// # extern crate hyper_rustls;
7875/// # extern crate google_analytics3 as analytics3;
7876/// use analytics3::api::EntityUserLink;
7877/// # async fn dox() {
7878/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7879///
7880/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7881/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7882/// # secret,
7883/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7884/// # ).build().await.unwrap();
7885///
7886/// # let client = hyper_util::client::legacy::Client::builder(
7887/// # hyper_util::rt::TokioExecutor::new()
7888/// # )
7889/// # .build(
7890/// # hyper_rustls::HttpsConnectorBuilder::new()
7891/// # .with_native_roots()
7892/// # .unwrap()
7893/// # .https_or_http()
7894/// # .enable_http1()
7895/// # .build()
7896/// # );
7897/// # let mut hub = Analytics::new(client, auth);
7898/// // As the method needs a request, you would usually fill it with the desired information
7899/// // into the respective structure. Some of the parts shown here might not be applicable !
7900/// // Values shown here are possibly random and not representative !
7901/// let mut req = EntityUserLink::default();
7902///
7903/// // You can configure optional parameters by calling the respective setters at will, and
7904/// // execute the final call using `doit()`.
7905/// // Values shown here are possibly random and not representative !
7906/// let result = hub.management().account_user_links_insert(req, "accountId")
7907/// .doit().await;
7908/// # }
7909/// ```
7910pub struct ManagementAccountUserLinkInsertCall<'a, C>
7911where
7912 C: 'a,
7913{
7914 hub: &'a Analytics<C>,
7915 _request: EntityUserLink,
7916 _account_id: String,
7917 _delegate: Option<&'a mut dyn common::Delegate>,
7918 _additional_params: HashMap<String, String>,
7919 _scopes: BTreeSet<String>,
7920}
7921
7922impl<'a, C> common::CallBuilder for ManagementAccountUserLinkInsertCall<'a, C> {}
7923
7924impl<'a, C> ManagementAccountUserLinkInsertCall<'a, C>
7925where
7926 C: common::Connector,
7927{
7928 /// Perform the operation you have build so far.
7929 pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
7930 use std::borrow::Cow;
7931 use std::io::{Read, Seek};
7932
7933 use common::{url::Params, ToParts};
7934 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7935
7936 let mut dd = common::DefaultDelegate;
7937 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7938 dlg.begin(common::MethodInfo {
7939 id: "analytics.management.accountUserLinks.insert",
7940 http_method: hyper::Method::POST,
7941 });
7942
7943 for &field in ["alt", "accountId"].iter() {
7944 if self._additional_params.contains_key(field) {
7945 dlg.finished(false);
7946 return Err(common::Error::FieldClash(field));
7947 }
7948 }
7949
7950 let mut params = Params::with_capacity(4 + self._additional_params.len());
7951 params.push("accountId", self._account_id);
7952
7953 params.extend(self._additional_params.iter());
7954
7955 params.push("alt", "json");
7956 let mut url =
7957 self.hub._base_url.clone() + "management/accounts/{accountId}/entityUserLinks";
7958 if self._scopes.is_empty() {
7959 self._scopes.insert(Scope::ManageUser.as_ref().to_string());
7960 }
7961
7962 #[allow(clippy::single_element_loop)]
7963 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
7964 url = params.uri_replacement(url, param_name, find_this, false);
7965 }
7966 {
7967 let to_remove = ["accountId"];
7968 params.remove_params(&to_remove);
7969 }
7970
7971 let url = params.parse_with_url(&url);
7972
7973 let mut json_mime_type = mime::APPLICATION_JSON;
7974 let mut request_value_reader = {
7975 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7976 common::remove_json_null_values(&mut value);
7977 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7978 serde_json::to_writer(&mut dst, &value).unwrap();
7979 dst
7980 };
7981 let request_size = request_value_reader
7982 .seek(std::io::SeekFrom::End(0))
7983 .unwrap();
7984 request_value_reader
7985 .seek(std::io::SeekFrom::Start(0))
7986 .unwrap();
7987
7988 loop {
7989 let token = match self
7990 .hub
7991 .auth
7992 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7993 .await
7994 {
7995 Ok(token) => token,
7996 Err(e) => match dlg.token(e) {
7997 Ok(token) => token,
7998 Err(e) => {
7999 dlg.finished(false);
8000 return Err(common::Error::MissingToken(e));
8001 }
8002 },
8003 };
8004 request_value_reader
8005 .seek(std::io::SeekFrom::Start(0))
8006 .unwrap();
8007 let mut req_result = {
8008 let client = &self.hub.client;
8009 dlg.pre_request();
8010 let mut req_builder = hyper::Request::builder()
8011 .method(hyper::Method::POST)
8012 .uri(url.as_str())
8013 .header(USER_AGENT, self.hub._user_agent.clone());
8014
8015 if let Some(token) = token.as_ref() {
8016 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8017 }
8018
8019 let request = req_builder
8020 .header(CONTENT_TYPE, json_mime_type.to_string())
8021 .header(CONTENT_LENGTH, request_size as u64)
8022 .body(common::to_body(
8023 request_value_reader.get_ref().clone().into(),
8024 ));
8025
8026 client.request(request.unwrap()).await
8027 };
8028
8029 match req_result {
8030 Err(err) => {
8031 if let common::Retry::After(d) = dlg.http_error(&err) {
8032 sleep(d).await;
8033 continue;
8034 }
8035 dlg.finished(false);
8036 return Err(common::Error::HttpError(err));
8037 }
8038 Ok(res) => {
8039 let (mut parts, body) = res.into_parts();
8040 let mut body = common::Body::new(body);
8041 if !parts.status.is_success() {
8042 let bytes = common::to_bytes(body).await.unwrap_or_default();
8043 let error = serde_json::from_str(&common::to_string(&bytes));
8044 let response = common::to_response(parts, bytes.into());
8045
8046 if let common::Retry::After(d) =
8047 dlg.http_failure(&response, error.as_ref().ok())
8048 {
8049 sleep(d).await;
8050 continue;
8051 }
8052
8053 dlg.finished(false);
8054
8055 return Err(match error {
8056 Ok(value) => common::Error::BadRequest(value),
8057 _ => common::Error::Failure(response),
8058 });
8059 }
8060 let response = {
8061 let bytes = common::to_bytes(body).await.unwrap_or_default();
8062 let encoded = common::to_string(&bytes);
8063 match serde_json::from_str(&encoded) {
8064 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8065 Err(error) => {
8066 dlg.response_json_decode_error(&encoded, &error);
8067 return Err(common::Error::JsonDecodeError(
8068 encoded.to_string(),
8069 error,
8070 ));
8071 }
8072 }
8073 };
8074
8075 dlg.finished(true);
8076 return Ok(response);
8077 }
8078 }
8079 }
8080 }
8081
8082 ///
8083 /// Sets the *request* property to the given value.
8084 ///
8085 /// Even though the property as already been set when instantiating this call,
8086 /// we provide this method for API completeness.
8087 pub fn request(
8088 mut self,
8089 new_value: EntityUserLink,
8090 ) -> ManagementAccountUserLinkInsertCall<'a, C> {
8091 self._request = new_value;
8092 self
8093 }
8094 /// Account ID to create the user link for.
8095 ///
8096 /// Sets the *account id* path property to the given value.
8097 ///
8098 /// Even though the property as already been set when instantiating this call,
8099 /// we provide this method for API completeness.
8100 pub fn account_id(mut self, new_value: &str) -> ManagementAccountUserLinkInsertCall<'a, C> {
8101 self._account_id = new_value.to_string();
8102 self
8103 }
8104 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8105 /// while executing the actual API request.
8106 ///
8107 /// ````text
8108 /// It should be used to handle progress information, and to implement a certain level of resilience.
8109 /// ````
8110 ///
8111 /// Sets the *delegate* property to the given value.
8112 pub fn delegate(
8113 mut self,
8114 new_value: &'a mut dyn common::Delegate,
8115 ) -> ManagementAccountUserLinkInsertCall<'a, C> {
8116 self._delegate = Some(new_value);
8117 self
8118 }
8119
8120 /// Set any additional parameter of the query string used in the request.
8121 /// It should be used to set parameters which are not yet available through their own
8122 /// setters.
8123 ///
8124 /// Please note that this method must not be used to set any of the known parameters
8125 /// which have their own setter method. If done anyway, the request will fail.
8126 ///
8127 /// # Additional Parameters
8128 ///
8129 /// * *alt* (query-string) - Data format for the response.
8130 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8131 /// * *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.
8132 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8133 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8134 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8135 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8136 pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountUserLinkInsertCall<'a, C>
8137 where
8138 T: AsRef<str>,
8139 {
8140 self._additional_params
8141 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8142 self
8143 }
8144
8145 /// Identifies the authorization scope for the method you are building.
8146 ///
8147 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8148 /// [`Scope::ManageUser`].
8149 ///
8150 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8151 /// tokens for more than one scope.
8152 ///
8153 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8154 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8155 /// sufficient, a read-write scope will do as well.
8156 pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountUserLinkInsertCall<'a, C>
8157 where
8158 St: AsRef<str>,
8159 {
8160 self._scopes.insert(String::from(scope.as_ref()));
8161 self
8162 }
8163 /// Identifies the authorization scope(s) for the method you are building.
8164 ///
8165 /// See [`Self::add_scope()`] for details.
8166 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountUserLinkInsertCall<'a, C>
8167 where
8168 I: IntoIterator<Item = St>,
8169 St: AsRef<str>,
8170 {
8171 self._scopes
8172 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8173 self
8174 }
8175
8176 /// Removes all scopes, and no default scope will be used either.
8177 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8178 /// for details).
8179 pub fn clear_scopes(mut self) -> ManagementAccountUserLinkInsertCall<'a, C> {
8180 self._scopes.clear();
8181 self
8182 }
8183}
8184
8185/// Lists account-user links for a given account.
8186///
8187/// A builder for the *accountUserLinks.list* method supported by a *management* resource.
8188/// It is not used directly, but through a [`ManagementMethods`] instance.
8189///
8190/// # Example
8191///
8192/// Instantiate a resource method builder
8193///
8194/// ```test_harness,no_run
8195/// # extern crate hyper;
8196/// # extern crate hyper_rustls;
8197/// # extern crate google_analytics3 as analytics3;
8198/// # async fn dox() {
8199/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8200///
8201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8202/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8203/// # secret,
8204/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8205/// # ).build().await.unwrap();
8206///
8207/// # let client = hyper_util::client::legacy::Client::builder(
8208/// # hyper_util::rt::TokioExecutor::new()
8209/// # )
8210/// # .build(
8211/// # hyper_rustls::HttpsConnectorBuilder::new()
8212/// # .with_native_roots()
8213/// # .unwrap()
8214/// # .https_or_http()
8215/// # .enable_http1()
8216/// # .build()
8217/// # );
8218/// # let mut hub = Analytics::new(client, auth);
8219/// // You can configure optional parameters by calling the respective setters at will, and
8220/// // execute the final call using `doit()`.
8221/// // Values shown here are possibly random and not representative !
8222/// let result = hub.management().account_user_links_list("accountId")
8223/// .start_index(-76)
8224/// .max_results(-31)
8225/// .doit().await;
8226/// # }
8227/// ```
8228pub struct ManagementAccountUserLinkListCall<'a, C>
8229where
8230 C: 'a,
8231{
8232 hub: &'a Analytics<C>,
8233 _account_id: String,
8234 _start_index: Option<i32>,
8235 _max_results: Option<i32>,
8236 _delegate: Option<&'a mut dyn common::Delegate>,
8237 _additional_params: HashMap<String, String>,
8238 _scopes: BTreeSet<String>,
8239}
8240
8241impl<'a, C> common::CallBuilder for ManagementAccountUserLinkListCall<'a, C> {}
8242
8243impl<'a, C> ManagementAccountUserLinkListCall<'a, C>
8244where
8245 C: common::Connector,
8246{
8247 /// Perform the operation you have build so far.
8248 pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLinks)> {
8249 use std::borrow::Cow;
8250 use std::io::{Read, Seek};
8251
8252 use common::{url::Params, ToParts};
8253 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8254
8255 let mut dd = common::DefaultDelegate;
8256 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8257 dlg.begin(common::MethodInfo {
8258 id: "analytics.management.accountUserLinks.list",
8259 http_method: hyper::Method::GET,
8260 });
8261
8262 for &field in ["alt", "accountId", "start-index", "max-results"].iter() {
8263 if self._additional_params.contains_key(field) {
8264 dlg.finished(false);
8265 return Err(common::Error::FieldClash(field));
8266 }
8267 }
8268
8269 let mut params = Params::with_capacity(5 + self._additional_params.len());
8270 params.push("accountId", self._account_id);
8271 if let Some(value) = self._start_index.as_ref() {
8272 params.push("start-index", value.to_string());
8273 }
8274 if let Some(value) = self._max_results.as_ref() {
8275 params.push("max-results", value.to_string());
8276 }
8277
8278 params.extend(self._additional_params.iter());
8279
8280 params.push("alt", "json");
8281 let mut url =
8282 self.hub._base_url.clone() + "management/accounts/{accountId}/entityUserLinks";
8283 if self._scopes.is_empty() {
8284 self._scopes
8285 .insert(Scope::ManageUserReadonly.as_ref().to_string());
8286 }
8287
8288 #[allow(clippy::single_element_loop)]
8289 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
8290 url = params.uri_replacement(url, param_name, find_this, false);
8291 }
8292 {
8293 let to_remove = ["accountId"];
8294 params.remove_params(&to_remove);
8295 }
8296
8297 let url = params.parse_with_url(&url);
8298
8299 loop {
8300 let token = match self
8301 .hub
8302 .auth
8303 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8304 .await
8305 {
8306 Ok(token) => token,
8307 Err(e) => match dlg.token(e) {
8308 Ok(token) => token,
8309 Err(e) => {
8310 dlg.finished(false);
8311 return Err(common::Error::MissingToken(e));
8312 }
8313 },
8314 };
8315 let mut req_result = {
8316 let client = &self.hub.client;
8317 dlg.pre_request();
8318 let mut req_builder = hyper::Request::builder()
8319 .method(hyper::Method::GET)
8320 .uri(url.as_str())
8321 .header(USER_AGENT, self.hub._user_agent.clone());
8322
8323 if let Some(token) = token.as_ref() {
8324 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8325 }
8326
8327 let request = req_builder
8328 .header(CONTENT_LENGTH, 0_u64)
8329 .body(common::to_body::<String>(None));
8330
8331 client.request(request.unwrap()).await
8332 };
8333
8334 match req_result {
8335 Err(err) => {
8336 if let common::Retry::After(d) = dlg.http_error(&err) {
8337 sleep(d).await;
8338 continue;
8339 }
8340 dlg.finished(false);
8341 return Err(common::Error::HttpError(err));
8342 }
8343 Ok(res) => {
8344 let (mut parts, body) = res.into_parts();
8345 let mut body = common::Body::new(body);
8346 if !parts.status.is_success() {
8347 let bytes = common::to_bytes(body).await.unwrap_or_default();
8348 let error = serde_json::from_str(&common::to_string(&bytes));
8349 let response = common::to_response(parts, bytes.into());
8350
8351 if let common::Retry::After(d) =
8352 dlg.http_failure(&response, error.as_ref().ok())
8353 {
8354 sleep(d).await;
8355 continue;
8356 }
8357
8358 dlg.finished(false);
8359
8360 return Err(match error {
8361 Ok(value) => common::Error::BadRequest(value),
8362 _ => common::Error::Failure(response),
8363 });
8364 }
8365 let response = {
8366 let bytes = common::to_bytes(body).await.unwrap_or_default();
8367 let encoded = common::to_string(&bytes);
8368 match serde_json::from_str(&encoded) {
8369 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8370 Err(error) => {
8371 dlg.response_json_decode_error(&encoded, &error);
8372 return Err(common::Error::JsonDecodeError(
8373 encoded.to_string(),
8374 error,
8375 ));
8376 }
8377 }
8378 };
8379
8380 dlg.finished(true);
8381 return Ok(response);
8382 }
8383 }
8384 }
8385 }
8386
8387 /// Account ID to retrieve the user links for.
8388 ///
8389 /// Sets the *account id* path property to the given value.
8390 ///
8391 /// Even though the property as already been set when instantiating this call,
8392 /// we provide this method for API completeness.
8393 pub fn account_id(mut self, new_value: &str) -> ManagementAccountUserLinkListCall<'a, C> {
8394 self._account_id = new_value.to_string();
8395 self
8396 }
8397 /// An index of the first account-user link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
8398 ///
8399 /// Sets the *start-index* query property to the given value.
8400 pub fn start_index(mut self, new_value: i32) -> ManagementAccountUserLinkListCall<'a, C> {
8401 self._start_index = Some(new_value);
8402 self
8403 }
8404 /// The maximum number of account-user links to include in this response.
8405 ///
8406 /// Sets the *max-results* query property to the given value.
8407 pub fn max_results(mut self, new_value: i32) -> ManagementAccountUserLinkListCall<'a, C> {
8408 self._max_results = Some(new_value);
8409 self
8410 }
8411 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8412 /// while executing the actual API request.
8413 ///
8414 /// ````text
8415 /// It should be used to handle progress information, and to implement a certain level of resilience.
8416 /// ````
8417 ///
8418 /// Sets the *delegate* property to the given value.
8419 pub fn delegate(
8420 mut self,
8421 new_value: &'a mut dyn common::Delegate,
8422 ) -> ManagementAccountUserLinkListCall<'a, C> {
8423 self._delegate = Some(new_value);
8424 self
8425 }
8426
8427 /// Set any additional parameter of the query string used in the request.
8428 /// It should be used to set parameters which are not yet available through their own
8429 /// setters.
8430 ///
8431 /// Please note that this method must not be used to set any of the known parameters
8432 /// which have their own setter method. If done anyway, the request will fail.
8433 ///
8434 /// # Additional Parameters
8435 ///
8436 /// * *alt* (query-string) - Data format for the response.
8437 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8438 /// * *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.
8439 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8440 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8441 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8442 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8443 pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountUserLinkListCall<'a, C>
8444 where
8445 T: AsRef<str>,
8446 {
8447 self._additional_params
8448 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8449 self
8450 }
8451
8452 /// Identifies the authorization scope for the method you are building.
8453 ///
8454 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8455 /// [`Scope::ManageUserReadonly`].
8456 ///
8457 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8458 /// tokens for more than one scope.
8459 ///
8460 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8461 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8462 /// sufficient, a read-write scope will do as well.
8463 pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountUserLinkListCall<'a, C>
8464 where
8465 St: AsRef<str>,
8466 {
8467 self._scopes.insert(String::from(scope.as_ref()));
8468 self
8469 }
8470 /// Identifies the authorization scope(s) for the method you are building.
8471 ///
8472 /// See [`Self::add_scope()`] for details.
8473 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountUserLinkListCall<'a, C>
8474 where
8475 I: IntoIterator<Item = St>,
8476 St: AsRef<str>,
8477 {
8478 self._scopes
8479 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8480 self
8481 }
8482
8483 /// Removes all scopes, and no default scope will be used either.
8484 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8485 /// for details).
8486 pub fn clear_scopes(mut self) -> ManagementAccountUserLinkListCall<'a, C> {
8487 self._scopes.clear();
8488 self
8489 }
8490}
8491
8492/// Updates permissions for an existing user on the given account.
8493///
8494/// A builder for the *accountUserLinks.update* method supported by a *management* resource.
8495/// It is not used directly, but through a [`ManagementMethods`] instance.
8496///
8497/// # Example
8498///
8499/// Instantiate a resource method builder
8500///
8501/// ```test_harness,no_run
8502/// # extern crate hyper;
8503/// # extern crate hyper_rustls;
8504/// # extern crate google_analytics3 as analytics3;
8505/// use analytics3::api::EntityUserLink;
8506/// # async fn dox() {
8507/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8508///
8509/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8510/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8511/// # secret,
8512/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8513/// # ).build().await.unwrap();
8514///
8515/// # let client = hyper_util::client::legacy::Client::builder(
8516/// # hyper_util::rt::TokioExecutor::new()
8517/// # )
8518/// # .build(
8519/// # hyper_rustls::HttpsConnectorBuilder::new()
8520/// # .with_native_roots()
8521/// # .unwrap()
8522/// # .https_or_http()
8523/// # .enable_http1()
8524/// # .build()
8525/// # );
8526/// # let mut hub = Analytics::new(client, auth);
8527/// // As the method needs a request, you would usually fill it with the desired information
8528/// // into the respective structure. Some of the parts shown here might not be applicable !
8529/// // Values shown here are possibly random and not representative !
8530/// let mut req = EntityUserLink::default();
8531///
8532/// // You can configure optional parameters by calling the respective setters at will, and
8533/// // execute the final call using `doit()`.
8534/// // Values shown here are possibly random and not representative !
8535/// let result = hub.management().account_user_links_update(req, "accountId", "linkId")
8536/// .doit().await;
8537/// # }
8538/// ```
8539pub struct ManagementAccountUserLinkUpdateCall<'a, C>
8540where
8541 C: 'a,
8542{
8543 hub: &'a Analytics<C>,
8544 _request: EntityUserLink,
8545 _account_id: String,
8546 _link_id: String,
8547 _delegate: Option<&'a mut dyn common::Delegate>,
8548 _additional_params: HashMap<String, String>,
8549 _scopes: BTreeSet<String>,
8550}
8551
8552impl<'a, C> common::CallBuilder for ManagementAccountUserLinkUpdateCall<'a, C> {}
8553
8554impl<'a, C> ManagementAccountUserLinkUpdateCall<'a, C>
8555where
8556 C: common::Connector,
8557{
8558 /// Perform the operation you have build so far.
8559 pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
8560 use std::borrow::Cow;
8561 use std::io::{Read, Seek};
8562
8563 use common::{url::Params, ToParts};
8564 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8565
8566 let mut dd = common::DefaultDelegate;
8567 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8568 dlg.begin(common::MethodInfo {
8569 id: "analytics.management.accountUserLinks.update",
8570 http_method: hyper::Method::PUT,
8571 });
8572
8573 for &field in ["alt", "accountId", "linkId"].iter() {
8574 if self._additional_params.contains_key(field) {
8575 dlg.finished(false);
8576 return Err(common::Error::FieldClash(field));
8577 }
8578 }
8579
8580 let mut params = Params::with_capacity(5 + self._additional_params.len());
8581 params.push("accountId", self._account_id);
8582 params.push("linkId", self._link_id);
8583
8584 params.extend(self._additional_params.iter());
8585
8586 params.push("alt", "json");
8587 let mut url =
8588 self.hub._base_url.clone() + "management/accounts/{accountId}/entityUserLinks/{linkId}";
8589 if self._scopes.is_empty() {
8590 self._scopes.insert(Scope::ManageUser.as_ref().to_string());
8591 }
8592
8593 #[allow(clippy::single_element_loop)]
8594 for &(find_this, param_name) in
8595 [("{accountId}", "accountId"), ("{linkId}", "linkId")].iter()
8596 {
8597 url = params.uri_replacement(url, param_name, find_this, false);
8598 }
8599 {
8600 let to_remove = ["linkId", "accountId"];
8601 params.remove_params(&to_remove);
8602 }
8603
8604 let url = params.parse_with_url(&url);
8605
8606 let mut json_mime_type = mime::APPLICATION_JSON;
8607 let mut request_value_reader = {
8608 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8609 common::remove_json_null_values(&mut value);
8610 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8611 serde_json::to_writer(&mut dst, &value).unwrap();
8612 dst
8613 };
8614 let request_size = request_value_reader
8615 .seek(std::io::SeekFrom::End(0))
8616 .unwrap();
8617 request_value_reader
8618 .seek(std::io::SeekFrom::Start(0))
8619 .unwrap();
8620
8621 loop {
8622 let token = match self
8623 .hub
8624 .auth
8625 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8626 .await
8627 {
8628 Ok(token) => token,
8629 Err(e) => match dlg.token(e) {
8630 Ok(token) => token,
8631 Err(e) => {
8632 dlg.finished(false);
8633 return Err(common::Error::MissingToken(e));
8634 }
8635 },
8636 };
8637 request_value_reader
8638 .seek(std::io::SeekFrom::Start(0))
8639 .unwrap();
8640 let mut req_result = {
8641 let client = &self.hub.client;
8642 dlg.pre_request();
8643 let mut req_builder = hyper::Request::builder()
8644 .method(hyper::Method::PUT)
8645 .uri(url.as_str())
8646 .header(USER_AGENT, self.hub._user_agent.clone());
8647
8648 if let Some(token) = token.as_ref() {
8649 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8650 }
8651
8652 let request = req_builder
8653 .header(CONTENT_TYPE, json_mime_type.to_string())
8654 .header(CONTENT_LENGTH, request_size as u64)
8655 .body(common::to_body(
8656 request_value_reader.get_ref().clone().into(),
8657 ));
8658
8659 client.request(request.unwrap()).await
8660 };
8661
8662 match req_result {
8663 Err(err) => {
8664 if let common::Retry::After(d) = dlg.http_error(&err) {
8665 sleep(d).await;
8666 continue;
8667 }
8668 dlg.finished(false);
8669 return Err(common::Error::HttpError(err));
8670 }
8671 Ok(res) => {
8672 let (mut parts, body) = res.into_parts();
8673 let mut body = common::Body::new(body);
8674 if !parts.status.is_success() {
8675 let bytes = common::to_bytes(body).await.unwrap_or_default();
8676 let error = serde_json::from_str(&common::to_string(&bytes));
8677 let response = common::to_response(parts, bytes.into());
8678
8679 if let common::Retry::After(d) =
8680 dlg.http_failure(&response, error.as_ref().ok())
8681 {
8682 sleep(d).await;
8683 continue;
8684 }
8685
8686 dlg.finished(false);
8687
8688 return Err(match error {
8689 Ok(value) => common::Error::BadRequest(value),
8690 _ => common::Error::Failure(response),
8691 });
8692 }
8693 let response = {
8694 let bytes = common::to_bytes(body).await.unwrap_or_default();
8695 let encoded = common::to_string(&bytes);
8696 match serde_json::from_str(&encoded) {
8697 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8698 Err(error) => {
8699 dlg.response_json_decode_error(&encoded, &error);
8700 return Err(common::Error::JsonDecodeError(
8701 encoded.to_string(),
8702 error,
8703 ));
8704 }
8705 }
8706 };
8707
8708 dlg.finished(true);
8709 return Ok(response);
8710 }
8711 }
8712 }
8713 }
8714
8715 ///
8716 /// Sets the *request* property to the given value.
8717 ///
8718 /// Even though the property as already been set when instantiating this call,
8719 /// we provide this method for API completeness.
8720 pub fn request(
8721 mut self,
8722 new_value: EntityUserLink,
8723 ) -> ManagementAccountUserLinkUpdateCall<'a, C> {
8724 self._request = new_value;
8725 self
8726 }
8727 /// Account ID to update the account-user link for.
8728 ///
8729 /// Sets the *account id* path property to the given value.
8730 ///
8731 /// Even though the property as already been set when instantiating this call,
8732 /// we provide this method for API completeness.
8733 pub fn account_id(mut self, new_value: &str) -> ManagementAccountUserLinkUpdateCall<'a, C> {
8734 self._account_id = new_value.to_string();
8735 self
8736 }
8737 /// Link ID to update the account-user link for.
8738 ///
8739 /// Sets the *link id* path property to the given value.
8740 ///
8741 /// Even though the property as already been set when instantiating this call,
8742 /// we provide this method for API completeness.
8743 pub fn link_id(mut self, new_value: &str) -> ManagementAccountUserLinkUpdateCall<'a, C> {
8744 self._link_id = new_value.to_string();
8745 self
8746 }
8747 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8748 /// while executing the actual API request.
8749 ///
8750 /// ````text
8751 /// It should be used to handle progress information, and to implement a certain level of resilience.
8752 /// ````
8753 ///
8754 /// Sets the *delegate* property to the given value.
8755 pub fn delegate(
8756 mut self,
8757 new_value: &'a mut dyn common::Delegate,
8758 ) -> ManagementAccountUserLinkUpdateCall<'a, C> {
8759 self._delegate = Some(new_value);
8760 self
8761 }
8762
8763 /// Set any additional parameter of the query string used in the request.
8764 /// It should be used to set parameters which are not yet available through their own
8765 /// setters.
8766 ///
8767 /// Please note that this method must not be used to set any of the known parameters
8768 /// which have their own setter method. If done anyway, the request will fail.
8769 ///
8770 /// # Additional Parameters
8771 ///
8772 /// * *alt* (query-string) - Data format for the response.
8773 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8774 /// * *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.
8775 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8776 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8777 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8778 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8779 pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountUserLinkUpdateCall<'a, C>
8780 where
8781 T: AsRef<str>,
8782 {
8783 self._additional_params
8784 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8785 self
8786 }
8787
8788 /// Identifies the authorization scope for the method you are building.
8789 ///
8790 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8791 /// [`Scope::ManageUser`].
8792 ///
8793 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8794 /// tokens for more than one scope.
8795 ///
8796 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8797 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8798 /// sufficient, a read-write scope will do as well.
8799 pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountUserLinkUpdateCall<'a, C>
8800 where
8801 St: AsRef<str>,
8802 {
8803 self._scopes.insert(String::from(scope.as_ref()));
8804 self
8805 }
8806 /// Identifies the authorization scope(s) for the method you are building.
8807 ///
8808 /// See [`Self::add_scope()`] for details.
8809 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountUserLinkUpdateCall<'a, C>
8810 where
8811 I: IntoIterator<Item = St>,
8812 St: AsRef<str>,
8813 {
8814 self._scopes
8815 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8816 self
8817 }
8818
8819 /// Removes all scopes, and no default scope will be used either.
8820 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8821 /// for details).
8822 pub fn clear_scopes(mut self) -> ManagementAccountUserLinkUpdateCall<'a, C> {
8823 self._scopes.clear();
8824 self
8825 }
8826}
8827
8828/// Lists all accounts to which the user has access.
8829///
8830/// A builder for the *accounts.list* method supported by a *management* resource.
8831/// It is not used directly, but through a [`ManagementMethods`] instance.
8832///
8833/// # Example
8834///
8835/// Instantiate a resource method builder
8836///
8837/// ```test_harness,no_run
8838/// # extern crate hyper;
8839/// # extern crate hyper_rustls;
8840/// # extern crate google_analytics3 as analytics3;
8841/// # async fn dox() {
8842/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8843///
8844/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8845/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8846/// # secret,
8847/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8848/// # ).build().await.unwrap();
8849///
8850/// # let client = hyper_util::client::legacy::Client::builder(
8851/// # hyper_util::rt::TokioExecutor::new()
8852/// # )
8853/// # .build(
8854/// # hyper_rustls::HttpsConnectorBuilder::new()
8855/// # .with_native_roots()
8856/// # .unwrap()
8857/// # .https_or_http()
8858/// # .enable_http1()
8859/// # .build()
8860/// # );
8861/// # let mut hub = Analytics::new(client, auth);
8862/// // You can configure optional parameters by calling the respective setters at will, and
8863/// // execute the final call using `doit()`.
8864/// // Values shown here are possibly random and not representative !
8865/// let result = hub.management().accounts_list()
8866/// .start_index(-34)
8867/// .max_results(-22)
8868/// .doit().await;
8869/// # }
8870/// ```
8871pub struct ManagementAccountListCall<'a, C>
8872where
8873 C: 'a,
8874{
8875 hub: &'a Analytics<C>,
8876 _start_index: Option<i32>,
8877 _max_results: Option<i32>,
8878 _delegate: Option<&'a mut dyn common::Delegate>,
8879 _additional_params: HashMap<String, String>,
8880 _scopes: BTreeSet<String>,
8881}
8882
8883impl<'a, C> common::CallBuilder for ManagementAccountListCall<'a, C> {}
8884
8885impl<'a, C> ManagementAccountListCall<'a, C>
8886where
8887 C: common::Connector,
8888{
8889 /// Perform the operation you have build so far.
8890 pub async fn doit(mut self) -> common::Result<(common::Response, Accounts)> {
8891 use std::borrow::Cow;
8892 use std::io::{Read, Seek};
8893
8894 use common::{url::Params, ToParts};
8895 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8896
8897 let mut dd = common::DefaultDelegate;
8898 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8899 dlg.begin(common::MethodInfo {
8900 id: "analytics.management.accounts.list",
8901 http_method: hyper::Method::GET,
8902 });
8903
8904 for &field in ["alt", "start-index", "max-results"].iter() {
8905 if self._additional_params.contains_key(field) {
8906 dlg.finished(false);
8907 return Err(common::Error::FieldClash(field));
8908 }
8909 }
8910
8911 let mut params = Params::with_capacity(4 + self._additional_params.len());
8912 if let Some(value) = self._start_index.as_ref() {
8913 params.push("start-index", value.to_string());
8914 }
8915 if let Some(value) = self._max_results.as_ref() {
8916 params.push("max-results", value.to_string());
8917 }
8918
8919 params.extend(self._additional_params.iter());
8920
8921 params.push("alt", "json");
8922 let mut url = self.hub._base_url.clone() + "management/accounts";
8923 if self._scopes.is_empty() {
8924 self._scopes.insert(Scope::Readonly.as_ref().to_string());
8925 }
8926
8927 let url = params.parse_with_url(&url);
8928
8929 loop {
8930 let token = match self
8931 .hub
8932 .auth
8933 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8934 .await
8935 {
8936 Ok(token) => token,
8937 Err(e) => match dlg.token(e) {
8938 Ok(token) => token,
8939 Err(e) => {
8940 dlg.finished(false);
8941 return Err(common::Error::MissingToken(e));
8942 }
8943 },
8944 };
8945 let mut req_result = {
8946 let client = &self.hub.client;
8947 dlg.pre_request();
8948 let mut req_builder = hyper::Request::builder()
8949 .method(hyper::Method::GET)
8950 .uri(url.as_str())
8951 .header(USER_AGENT, self.hub._user_agent.clone());
8952
8953 if let Some(token) = token.as_ref() {
8954 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8955 }
8956
8957 let request = req_builder
8958 .header(CONTENT_LENGTH, 0_u64)
8959 .body(common::to_body::<String>(None));
8960
8961 client.request(request.unwrap()).await
8962 };
8963
8964 match req_result {
8965 Err(err) => {
8966 if let common::Retry::After(d) = dlg.http_error(&err) {
8967 sleep(d).await;
8968 continue;
8969 }
8970 dlg.finished(false);
8971 return Err(common::Error::HttpError(err));
8972 }
8973 Ok(res) => {
8974 let (mut parts, body) = res.into_parts();
8975 let mut body = common::Body::new(body);
8976 if !parts.status.is_success() {
8977 let bytes = common::to_bytes(body).await.unwrap_or_default();
8978 let error = serde_json::from_str(&common::to_string(&bytes));
8979 let response = common::to_response(parts, bytes.into());
8980
8981 if let common::Retry::After(d) =
8982 dlg.http_failure(&response, error.as_ref().ok())
8983 {
8984 sleep(d).await;
8985 continue;
8986 }
8987
8988 dlg.finished(false);
8989
8990 return Err(match error {
8991 Ok(value) => common::Error::BadRequest(value),
8992 _ => common::Error::Failure(response),
8993 });
8994 }
8995 let response = {
8996 let bytes = common::to_bytes(body).await.unwrap_or_default();
8997 let encoded = common::to_string(&bytes);
8998 match serde_json::from_str(&encoded) {
8999 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9000 Err(error) => {
9001 dlg.response_json_decode_error(&encoded, &error);
9002 return Err(common::Error::JsonDecodeError(
9003 encoded.to_string(),
9004 error,
9005 ));
9006 }
9007 }
9008 };
9009
9010 dlg.finished(true);
9011 return Ok(response);
9012 }
9013 }
9014 }
9015 }
9016
9017 /// An index of the first account to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
9018 ///
9019 /// Sets the *start-index* query property to the given value.
9020 pub fn start_index(mut self, new_value: i32) -> ManagementAccountListCall<'a, C> {
9021 self._start_index = Some(new_value);
9022 self
9023 }
9024 /// The maximum number of accounts to include in this response.
9025 ///
9026 /// Sets the *max-results* query property to the given value.
9027 pub fn max_results(mut self, new_value: i32) -> ManagementAccountListCall<'a, C> {
9028 self._max_results = Some(new_value);
9029 self
9030 }
9031 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9032 /// while executing the actual API request.
9033 ///
9034 /// ````text
9035 /// It should be used to handle progress information, and to implement a certain level of resilience.
9036 /// ````
9037 ///
9038 /// Sets the *delegate* property to the given value.
9039 pub fn delegate(
9040 mut self,
9041 new_value: &'a mut dyn common::Delegate,
9042 ) -> ManagementAccountListCall<'a, C> {
9043 self._delegate = Some(new_value);
9044 self
9045 }
9046
9047 /// Set any additional parameter of the query string used in the request.
9048 /// It should be used to set parameters which are not yet available through their own
9049 /// setters.
9050 ///
9051 /// Please note that this method must not be used to set any of the known parameters
9052 /// which have their own setter method. If done anyway, the request will fail.
9053 ///
9054 /// # Additional Parameters
9055 ///
9056 /// * *alt* (query-string) - Data format for the response.
9057 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9058 /// * *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.
9059 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9060 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9061 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9062 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9063 pub fn param<T>(mut self, name: T, value: T) -> ManagementAccountListCall<'a, C>
9064 where
9065 T: AsRef<str>,
9066 {
9067 self._additional_params
9068 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9069 self
9070 }
9071
9072 /// Identifies the authorization scope for the method you are building.
9073 ///
9074 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9075 /// [`Scope::Readonly`].
9076 ///
9077 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9078 /// tokens for more than one scope.
9079 ///
9080 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9081 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9082 /// sufficient, a read-write scope will do as well.
9083 pub fn add_scope<St>(mut self, scope: St) -> ManagementAccountListCall<'a, C>
9084 where
9085 St: AsRef<str>,
9086 {
9087 self._scopes.insert(String::from(scope.as_ref()));
9088 self
9089 }
9090 /// Identifies the authorization scope(s) for the method you are building.
9091 ///
9092 /// See [`Self::add_scope()`] for details.
9093 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementAccountListCall<'a, C>
9094 where
9095 I: IntoIterator<Item = St>,
9096 St: AsRef<str>,
9097 {
9098 self._scopes
9099 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9100 self
9101 }
9102
9103 /// Removes all scopes, and no default scope will be used either.
9104 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9105 /// for details).
9106 pub fn clear_scopes(mut self) -> ManagementAccountListCall<'a, C> {
9107 self._scopes.clear();
9108 self
9109 }
9110}
9111
9112/// Hashes the given Client ID.
9113///
9114/// A builder for the *clientId.hashClientId* method supported by a *management* resource.
9115/// It is not used directly, but through a [`ManagementMethods`] instance.
9116///
9117/// # Example
9118///
9119/// Instantiate a resource method builder
9120///
9121/// ```test_harness,no_run
9122/// # extern crate hyper;
9123/// # extern crate hyper_rustls;
9124/// # extern crate google_analytics3 as analytics3;
9125/// use analytics3::api::HashClientIdRequest;
9126/// # async fn dox() {
9127/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9128///
9129/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9130/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9131/// # secret,
9132/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9133/// # ).build().await.unwrap();
9134///
9135/// # let client = hyper_util::client::legacy::Client::builder(
9136/// # hyper_util::rt::TokioExecutor::new()
9137/// # )
9138/// # .build(
9139/// # hyper_rustls::HttpsConnectorBuilder::new()
9140/// # .with_native_roots()
9141/// # .unwrap()
9142/// # .https_or_http()
9143/// # .enable_http1()
9144/// # .build()
9145/// # );
9146/// # let mut hub = Analytics::new(client, auth);
9147/// // As the method needs a request, you would usually fill it with the desired information
9148/// // into the respective structure. Some of the parts shown here might not be applicable !
9149/// // Values shown here are possibly random and not representative !
9150/// let mut req = HashClientIdRequest::default();
9151///
9152/// // You can configure optional parameters by calling the respective setters at will, and
9153/// // execute the final call using `doit()`.
9154/// // Values shown here are possibly random and not representative !
9155/// let result = hub.management().client_id_hash_client_id(req)
9156/// .doit().await;
9157/// # }
9158/// ```
9159pub struct ManagementClientIdHashClientIdCall<'a, C>
9160where
9161 C: 'a,
9162{
9163 hub: &'a Analytics<C>,
9164 _request: HashClientIdRequest,
9165 _delegate: Option<&'a mut dyn common::Delegate>,
9166 _additional_params: HashMap<String, String>,
9167 _scopes: BTreeSet<String>,
9168}
9169
9170impl<'a, C> common::CallBuilder for ManagementClientIdHashClientIdCall<'a, C> {}
9171
9172impl<'a, C> ManagementClientIdHashClientIdCall<'a, C>
9173where
9174 C: common::Connector,
9175{
9176 /// Perform the operation you have build so far.
9177 pub async fn doit(mut self) -> common::Result<(common::Response, HashClientIdResponse)> {
9178 use std::borrow::Cow;
9179 use std::io::{Read, Seek};
9180
9181 use common::{url::Params, ToParts};
9182 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9183
9184 let mut dd = common::DefaultDelegate;
9185 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9186 dlg.begin(common::MethodInfo {
9187 id: "analytics.management.clientId.hashClientId",
9188 http_method: hyper::Method::POST,
9189 });
9190
9191 for &field in ["alt"].iter() {
9192 if self._additional_params.contains_key(field) {
9193 dlg.finished(false);
9194 return Err(common::Error::FieldClash(field));
9195 }
9196 }
9197
9198 let mut params = Params::with_capacity(3 + self._additional_params.len());
9199
9200 params.extend(self._additional_params.iter());
9201
9202 params.push("alt", "json");
9203 let mut url = self.hub._base_url.clone() + "management/clientId:hashClientId";
9204 if self._scopes.is_empty() {
9205 self._scopes.insert(Scope::Edit.as_ref().to_string());
9206 }
9207
9208 let url = params.parse_with_url(&url);
9209
9210 let mut json_mime_type = mime::APPLICATION_JSON;
9211 let mut request_value_reader = {
9212 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9213 common::remove_json_null_values(&mut value);
9214 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9215 serde_json::to_writer(&mut dst, &value).unwrap();
9216 dst
9217 };
9218 let request_size = request_value_reader
9219 .seek(std::io::SeekFrom::End(0))
9220 .unwrap();
9221 request_value_reader
9222 .seek(std::io::SeekFrom::Start(0))
9223 .unwrap();
9224
9225 loop {
9226 let token = match self
9227 .hub
9228 .auth
9229 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9230 .await
9231 {
9232 Ok(token) => token,
9233 Err(e) => match dlg.token(e) {
9234 Ok(token) => token,
9235 Err(e) => {
9236 dlg.finished(false);
9237 return Err(common::Error::MissingToken(e));
9238 }
9239 },
9240 };
9241 request_value_reader
9242 .seek(std::io::SeekFrom::Start(0))
9243 .unwrap();
9244 let mut req_result = {
9245 let client = &self.hub.client;
9246 dlg.pre_request();
9247 let mut req_builder = hyper::Request::builder()
9248 .method(hyper::Method::POST)
9249 .uri(url.as_str())
9250 .header(USER_AGENT, self.hub._user_agent.clone());
9251
9252 if let Some(token) = token.as_ref() {
9253 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9254 }
9255
9256 let request = req_builder
9257 .header(CONTENT_TYPE, json_mime_type.to_string())
9258 .header(CONTENT_LENGTH, request_size as u64)
9259 .body(common::to_body(
9260 request_value_reader.get_ref().clone().into(),
9261 ));
9262
9263 client.request(request.unwrap()).await
9264 };
9265
9266 match req_result {
9267 Err(err) => {
9268 if let common::Retry::After(d) = dlg.http_error(&err) {
9269 sleep(d).await;
9270 continue;
9271 }
9272 dlg.finished(false);
9273 return Err(common::Error::HttpError(err));
9274 }
9275 Ok(res) => {
9276 let (mut parts, body) = res.into_parts();
9277 let mut body = common::Body::new(body);
9278 if !parts.status.is_success() {
9279 let bytes = common::to_bytes(body).await.unwrap_or_default();
9280 let error = serde_json::from_str(&common::to_string(&bytes));
9281 let response = common::to_response(parts, bytes.into());
9282
9283 if let common::Retry::After(d) =
9284 dlg.http_failure(&response, error.as_ref().ok())
9285 {
9286 sleep(d).await;
9287 continue;
9288 }
9289
9290 dlg.finished(false);
9291
9292 return Err(match error {
9293 Ok(value) => common::Error::BadRequest(value),
9294 _ => common::Error::Failure(response),
9295 });
9296 }
9297 let response = {
9298 let bytes = common::to_bytes(body).await.unwrap_or_default();
9299 let encoded = common::to_string(&bytes);
9300 match serde_json::from_str(&encoded) {
9301 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9302 Err(error) => {
9303 dlg.response_json_decode_error(&encoded, &error);
9304 return Err(common::Error::JsonDecodeError(
9305 encoded.to_string(),
9306 error,
9307 ));
9308 }
9309 }
9310 };
9311
9312 dlg.finished(true);
9313 return Ok(response);
9314 }
9315 }
9316 }
9317 }
9318
9319 ///
9320 /// Sets the *request* property to the given value.
9321 ///
9322 /// Even though the property as already been set when instantiating this call,
9323 /// we provide this method for API completeness.
9324 pub fn request(
9325 mut self,
9326 new_value: HashClientIdRequest,
9327 ) -> ManagementClientIdHashClientIdCall<'a, C> {
9328 self._request = new_value;
9329 self
9330 }
9331 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9332 /// while executing the actual API request.
9333 ///
9334 /// ````text
9335 /// It should be used to handle progress information, and to implement a certain level of resilience.
9336 /// ````
9337 ///
9338 /// Sets the *delegate* property to the given value.
9339 pub fn delegate(
9340 mut self,
9341 new_value: &'a mut dyn common::Delegate,
9342 ) -> ManagementClientIdHashClientIdCall<'a, C> {
9343 self._delegate = Some(new_value);
9344 self
9345 }
9346
9347 /// Set any additional parameter of the query string used in the request.
9348 /// It should be used to set parameters which are not yet available through their own
9349 /// setters.
9350 ///
9351 /// Please note that this method must not be used to set any of the known parameters
9352 /// which have their own setter method. If done anyway, the request will fail.
9353 ///
9354 /// # Additional Parameters
9355 ///
9356 /// * *alt* (query-string) - Data format for the response.
9357 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9358 /// * *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.
9359 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9360 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9361 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9362 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9363 pub fn param<T>(mut self, name: T, value: T) -> ManagementClientIdHashClientIdCall<'a, C>
9364 where
9365 T: AsRef<str>,
9366 {
9367 self._additional_params
9368 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9369 self
9370 }
9371
9372 /// Identifies the authorization scope for the method you are building.
9373 ///
9374 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9375 /// [`Scope::Edit`].
9376 ///
9377 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9378 /// tokens for more than one scope.
9379 ///
9380 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9381 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9382 /// sufficient, a read-write scope will do as well.
9383 pub fn add_scope<St>(mut self, scope: St) -> ManagementClientIdHashClientIdCall<'a, C>
9384 where
9385 St: AsRef<str>,
9386 {
9387 self._scopes.insert(String::from(scope.as_ref()));
9388 self
9389 }
9390 /// Identifies the authorization scope(s) for the method you are building.
9391 ///
9392 /// See [`Self::add_scope()`] for details.
9393 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementClientIdHashClientIdCall<'a, C>
9394 where
9395 I: IntoIterator<Item = St>,
9396 St: AsRef<str>,
9397 {
9398 self._scopes
9399 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9400 self
9401 }
9402
9403 /// Removes all scopes, and no default scope will be used either.
9404 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9405 /// for details).
9406 pub fn clear_scopes(mut self) -> ManagementClientIdHashClientIdCall<'a, C> {
9407 self._scopes.clear();
9408 self
9409 }
9410}
9411
9412/// List custom data sources to which the user has access.
9413///
9414/// A builder for the *customDataSources.list* method supported by a *management* resource.
9415/// It is not used directly, but through a [`ManagementMethods`] instance.
9416///
9417/// # Example
9418///
9419/// Instantiate a resource method builder
9420///
9421/// ```test_harness,no_run
9422/// # extern crate hyper;
9423/// # extern crate hyper_rustls;
9424/// # extern crate google_analytics3 as analytics3;
9425/// # async fn dox() {
9426/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9427///
9428/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9429/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9430/// # secret,
9431/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9432/// # ).build().await.unwrap();
9433///
9434/// # let client = hyper_util::client::legacy::Client::builder(
9435/// # hyper_util::rt::TokioExecutor::new()
9436/// # )
9437/// # .build(
9438/// # hyper_rustls::HttpsConnectorBuilder::new()
9439/// # .with_native_roots()
9440/// # .unwrap()
9441/// # .https_or_http()
9442/// # .enable_http1()
9443/// # .build()
9444/// # );
9445/// # let mut hub = Analytics::new(client, auth);
9446/// // You can configure optional parameters by calling the respective setters at will, and
9447/// // execute the final call using `doit()`.
9448/// // Values shown here are possibly random and not representative !
9449/// let result = hub.management().custom_data_sources_list("accountId", "webPropertyId")
9450/// .start_index(-96)
9451/// .max_results(-92)
9452/// .doit().await;
9453/// # }
9454/// ```
9455pub struct ManagementCustomDataSourceListCall<'a, C>
9456where
9457 C: 'a,
9458{
9459 hub: &'a Analytics<C>,
9460 _account_id: String,
9461 _web_property_id: String,
9462 _start_index: Option<i32>,
9463 _max_results: Option<i32>,
9464 _delegate: Option<&'a mut dyn common::Delegate>,
9465 _additional_params: HashMap<String, String>,
9466 _scopes: BTreeSet<String>,
9467}
9468
9469impl<'a, C> common::CallBuilder for ManagementCustomDataSourceListCall<'a, C> {}
9470
9471impl<'a, C> ManagementCustomDataSourceListCall<'a, C>
9472where
9473 C: common::Connector,
9474{
9475 /// Perform the operation you have build so far.
9476 pub async fn doit(mut self) -> common::Result<(common::Response, CustomDataSources)> {
9477 use std::borrow::Cow;
9478 use std::io::{Read, Seek};
9479
9480 use common::{url::Params, ToParts};
9481 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9482
9483 let mut dd = common::DefaultDelegate;
9484 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9485 dlg.begin(common::MethodInfo {
9486 id: "analytics.management.customDataSources.list",
9487 http_method: hyper::Method::GET,
9488 });
9489
9490 for &field in [
9491 "alt",
9492 "accountId",
9493 "webPropertyId",
9494 "start-index",
9495 "max-results",
9496 ]
9497 .iter()
9498 {
9499 if self._additional_params.contains_key(field) {
9500 dlg.finished(false);
9501 return Err(common::Error::FieldClash(field));
9502 }
9503 }
9504
9505 let mut params = Params::with_capacity(6 + self._additional_params.len());
9506 params.push("accountId", self._account_id);
9507 params.push("webPropertyId", self._web_property_id);
9508 if let Some(value) = self._start_index.as_ref() {
9509 params.push("start-index", value.to_string());
9510 }
9511 if let Some(value) = self._max_results.as_ref() {
9512 params.push("max-results", value.to_string());
9513 }
9514
9515 params.extend(self._additional_params.iter());
9516
9517 params.push("alt", "json");
9518 let mut url = self.hub._base_url.clone()
9519 + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources";
9520 if self._scopes.is_empty() {
9521 self._scopes.insert(Scope::Readonly.as_ref().to_string());
9522 }
9523
9524 #[allow(clippy::single_element_loop)]
9525 for &(find_this, param_name) in [
9526 ("{accountId}", "accountId"),
9527 ("{webPropertyId}", "webPropertyId"),
9528 ]
9529 .iter()
9530 {
9531 url = params.uri_replacement(url, param_name, find_this, false);
9532 }
9533 {
9534 let to_remove = ["webPropertyId", "accountId"];
9535 params.remove_params(&to_remove);
9536 }
9537
9538 let url = params.parse_with_url(&url);
9539
9540 loop {
9541 let token = match self
9542 .hub
9543 .auth
9544 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9545 .await
9546 {
9547 Ok(token) => token,
9548 Err(e) => match dlg.token(e) {
9549 Ok(token) => token,
9550 Err(e) => {
9551 dlg.finished(false);
9552 return Err(common::Error::MissingToken(e));
9553 }
9554 },
9555 };
9556 let mut req_result = {
9557 let client = &self.hub.client;
9558 dlg.pre_request();
9559 let mut req_builder = hyper::Request::builder()
9560 .method(hyper::Method::GET)
9561 .uri(url.as_str())
9562 .header(USER_AGENT, self.hub._user_agent.clone());
9563
9564 if let Some(token) = token.as_ref() {
9565 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9566 }
9567
9568 let request = req_builder
9569 .header(CONTENT_LENGTH, 0_u64)
9570 .body(common::to_body::<String>(None));
9571
9572 client.request(request.unwrap()).await
9573 };
9574
9575 match req_result {
9576 Err(err) => {
9577 if let common::Retry::After(d) = dlg.http_error(&err) {
9578 sleep(d).await;
9579 continue;
9580 }
9581 dlg.finished(false);
9582 return Err(common::Error::HttpError(err));
9583 }
9584 Ok(res) => {
9585 let (mut parts, body) = res.into_parts();
9586 let mut body = common::Body::new(body);
9587 if !parts.status.is_success() {
9588 let bytes = common::to_bytes(body).await.unwrap_or_default();
9589 let error = serde_json::from_str(&common::to_string(&bytes));
9590 let response = common::to_response(parts, bytes.into());
9591
9592 if let common::Retry::After(d) =
9593 dlg.http_failure(&response, error.as_ref().ok())
9594 {
9595 sleep(d).await;
9596 continue;
9597 }
9598
9599 dlg.finished(false);
9600
9601 return Err(match error {
9602 Ok(value) => common::Error::BadRequest(value),
9603 _ => common::Error::Failure(response),
9604 });
9605 }
9606 let response = {
9607 let bytes = common::to_bytes(body).await.unwrap_or_default();
9608 let encoded = common::to_string(&bytes);
9609 match serde_json::from_str(&encoded) {
9610 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9611 Err(error) => {
9612 dlg.response_json_decode_error(&encoded, &error);
9613 return Err(common::Error::JsonDecodeError(
9614 encoded.to_string(),
9615 error,
9616 ));
9617 }
9618 }
9619 };
9620
9621 dlg.finished(true);
9622 return Ok(response);
9623 }
9624 }
9625 }
9626 }
9627
9628 /// Account Id for the custom data sources to retrieve.
9629 ///
9630 /// Sets the *account id* path property to the given value.
9631 ///
9632 /// Even though the property as already been set when instantiating this call,
9633 /// we provide this method for API completeness.
9634 pub fn account_id(mut self, new_value: &str) -> ManagementCustomDataSourceListCall<'a, C> {
9635 self._account_id = new_value.to_string();
9636 self
9637 }
9638 /// Web property Id for the custom data sources to retrieve.
9639 ///
9640 /// Sets the *web property id* path property to the given value.
9641 ///
9642 /// Even though the property as already been set when instantiating this call,
9643 /// we provide this method for API completeness.
9644 pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomDataSourceListCall<'a, C> {
9645 self._web_property_id = new_value.to_string();
9646 self
9647 }
9648 /// 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.
9649 ///
9650 /// Sets the *start-index* query property to the given value.
9651 pub fn start_index(mut self, new_value: i32) -> ManagementCustomDataSourceListCall<'a, C> {
9652 self._start_index = Some(new_value);
9653 self
9654 }
9655 /// The maximum number of custom data sources to include in this response.
9656 ///
9657 /// Sets the *max-results* query property to the given value.
9658 pub fn max_results(mut self, new_value: i32) -> ManagementCustomDataSourceListCall<'a, C> {
9659 self._max_results = Some(new_value);
9660 self
9661 }
9662 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9663 /// while executing the actual API request.
9664 ///
9665 /// ````text
9666 /// It should be used to handle progress information, and to implement a certain level of resilience.
9667 /// ````
9668 ///
9669 /// Sets the *delegate* property to the given value.
9670 pub fn delegate(
9671 mut self,
9672 new_value: &'a mut dyn common::Delegate,
9673 ) -> ManagementCustomDataSourceListCall<'a, C> {
9674 self._delegate = Some(new_value);
9675 self
9676 }
9677
9678 /// Set any additional parameter of the query string used in the request.
9679 /// It should be used to set parameters which are not yet available through their own
9680 /// setters.
9681 ///
9682 /// Please note that this method must not be used to set any of the known parameters
9683 /// which have their own setter method. If done anyway, the request will fail.
9684 ///
9685 /// # Additional Parameters
9686 ///
9687 /// * *alt* (query-string) - Data format for the response.
9688 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9689 /// * *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.
9690 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9691 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9692 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9693 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9694 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDataSourceListCall<'a, C>
9695 where
9696 T: AsRef<str>,
9697 {
9698 self._additional_params
9699 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9700 self
9701 }
9702
9703 /// Identifies the authorization scope for the method you are building.
9704 ///
9705 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9706 /// [`Scope::Readonly`].
9707 ///
9708 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9709 /// tokens for more than one scope.
9710 ///
9711 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9712 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9713 /// sufficient, a read-write scope will do as well.
9714 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDataSourceListCall<'a, C>
9715 where
9716 St: AsRef<str>,
9717 {
9718 self._scopes.insert(String::from(scope.as_ref()));
9719 self
9720 }
9721 /// Identifies the authorization scope(s) for the method you are building.
9722 ///
9723 /// See [`Self::add_scope()`] for details.
9724 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDataSourceListCall<'a, C>
9725 where
9726 I: IntoIterator<Item = St>,
9727 St: AsRef<str>,
9728 {
9729 self._scopes
9730 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9731 self
9732 }
9733
9734 /// Removes all scopes, and no default scope will be used either.
9735 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9736 /// for details).
9737 pub fn clear_scopes(mut self) -> ManagementCustomDataSourceListCall<'a, C> {
9738 self._scopes.clear();
9739 self
9740 }
9741}
9742
9743/// Get a custom dimension to which the user has access.
9744///
9745/// A builder for the *customDimensions.get* method supported by a *management* resource.
9746/// It is not used directly, but through a [`ManagementMethods`] instance.
9747///
9748/// # Example
9749///
9750/// Instantiate a resource method builder
9751///
9752/// ```test_harness,no_run
9753/// # extern crate hyper;
9754/// # extern crate hyper_rustls;
9755/// # extern crate google_analytics3 as analytics3;
9756/// # async fn dox() {
9757/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9758///
9759/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9760/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9761/// # secret,
9762/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9763/// # ).build().await.unwrap();
9764///
9765/// # let client = hyper_util::client::legacy::Client::builder(
9766/// # hyper_util::rt::TokioExecutor::new()
9767/// # )
9768/// # .build(
9769/// # hyper_rustls::HttpsConnectorBuilder::new()
9770/// # .with_native_roots()
9771/// # .unwrap()
9772/// # .https_or_http()
9773/// # .enable_http1()
9774/// # .build()
9775/// # );
9776/// # let mut hub = Analytics::new(client, auth);
9777/// // You can configure optional parameters by calling the respective setters at will, and
9778/// // execute the final call using `doit()`.
9779/// // Values shown here are possibly random and not representative !
9780/// let result = hub.management().custom_dimensions_get("accountId", "webPropertyId", "customDimensionId")
9781/// .doit().await;
9782/// # }
9783/// ```
9784pub struct ManagementCustomDimensionGetCall<'a, C>
9785where
9786 C: 'a,
9787{
9788 hub: &'a Analytics<C>,
9789 _account_id: String,
9790 _web_property_id: String,
9791 _custom_dimension_id: String,
9792 _delegate: Option<&'a mut dyn common::Delegate>,
9793 _additional_params: HashMap<String, String>,
9794 _scopes: BTreeSet<String>,
9795}
9796
9797impl<'a, C> common::CallBuilder for ManagementCustomDimensionGetCall<'a, C> {}
9798
9799impl<'a, C> ManagementCustomDimensionGetCall<'a, C>
9800where
9801 C: common::Connector,
9802{
9803 /// Perform the operation you have build so far.
9804 pub async fn doit(mut self) -> common::Result<(common::Response, CustomDimension)> {
9805 use std::borrow::Cow;
9806 use std::io::{Read, Seek};
9807
9808 use common::{url::Params, ToParts};
9809 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9810
9811 let mut dd = common::DefaultDelegate;
9812 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9813 dlg.begin(common::MethodInfo {
9814 id: "analytics.management.customDimensions.get",
9815 http_method: hyper::Method::GET,
9816 });
9817
9818 for &field in ["alt", "accountId", "webPropertyId", "customDimensionId"].iter() {
9819 if self._additional_params.contains_key(field) {
9820 dlg.finished(false);
9821 return Err(common::Error::FieldClash(field));
9822 }
9823 }
9824
9825 let mut params = Params::with_capacity(5 + self._additional_params.len());
9826 params.push("accountId", self._account_id);
9827 params.push("webPropertyId", self._web_property_id);
9828 params.push("customDimensionId", self._custom_dimension_id);
9829
9830 params.extend(self._additional_params.iter());
9831
9832 params.push("alt", "json");
9833 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDimensions/{customDimensionId}";
9834 if self._scopes.is_empty() {
9835 self._scopes.insert(Scope::Readonly.as_ref().to_string());
9836 }
9837
9838 #[allow(clippy::single_element_loop)]
9839 for &(find_this, param_name) in [
9840 ("{accountId}", "accountId"),
9841 ("{webPropertyId}", "webPropertyId"),
9842 ("{customDimensionId}", "customDimensionId"),
9843 ]
9844 .iter()
9845 {
9846 url = params.uri_replacement(url, param_name, find_this, false);
9847 }
9848 {
9849 let to_remove = ["customDimensionId", "webPropertyId", "accountId"];
9850 params.remove_params(&to_remove);
9851 }
9852
9853 let url = params.parse_with_url(&url);
9854
9855 loop {
9856 let token = match self
9857 .hub
9858 .auth
9859 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9860 .await
9861 {
9862 Ok(token) => token,
9863 Err(e) => match dlg.token(e) {
9864 Ok(token) => token,
9865 Err(e) => {
9866 dlg.finished(false);
9867 return Err(common::Error::MissingToken(e));
9868 }
9869 },
9870 };
9871 let mut req_result = {
9872 let client = &self.hub.client;
9873 dlg.pre_request();
9874 let mut req_builder = hyper::Request::builder()
9875 .method(hyper::Method::GET)
9876 .uri(url.as_str())
9877 .header(USER_AGENT, self.hub._user_agent.clone());
9878
9879 if let Some(token) = token.as_ref() {
9880 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9881 }
9882
9883 let request = req_builder
9884 .header(CONTENT_LENGTH, 0_u64)
9885 .body(common::to_body::<String>(None));
9886
9887 client.request(request.unwrap()).await
9888 };
9889
9890 match req_result {
9891 Err(err) => {
9892 if let common::Retry::After(d) = dlg.http_error(&err) {
9893 sleep(d).await;
9894 continue;
9895 }
9896 dlg.finished(false);
9897 return Err(common::Error::HttpError(err));
9898 }
9899 Ok(res) => {
9900 let (mut parts, body) = res.into_parts();
9901 let mut body = common::Body::new(body);
9902 if !parts.status.is_success() {
9903 let bytes = common::to_bytes(body).await.unwrap_or_default();
9904 let error = serde_json::from_str(&common::to_string(&bytes));
9905 let response = common::to_response(parts, bytes.into());
9906
9907 if let common::Retry::After(d) =
9908 dlg.http_failure(&response, error.as_ref().ok())
9909 {
9910 sleep(d).await;
9911 continue;
9912 }
9913
9914 dlg.finished(false);
9915
9916 return Err(match error {
9917 Ok(value) => common::Error::BadRequest(value),
9918 _ => common::Error::Failure(response),
9919 });
9920 }
9921 let response = {
9922 let bytes = common::to_bytes(body).await.unwrap_or_default();
9923 let encoded = common::to_string(&bytes);
9924 match serde_json::from_str(&encoded) {
9925 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9926 Err(error) => {
9927 dlg.response_json_decode_error(&encoded, &error);
9928 return Err(common::Error::JsonDecodeError(
9929 encoded.to_string(),
9930 error,
9931 ));
9932 }
9933 }
9934 };
9935
9936 dlg.finished(true);
9937 return Ok(response);
9938 }
9939 }
9940 }
9941 }
9942
9943 /// Account ID for the custom dimension to retrieve.
9944 ///
9945 /// Sets the *account id* path property to the given value.
9946 ///
9947 /// Even though the property as already been set when instantiating this call,
9948 /// we provide this method for API completeness.
9949 pub fn account_id(mut self, new_value: &str) -> ManagementCustomDimensionGetCall<'a, C> {
9950 self._account_id = new_value.to_string();
9951 self
9952 }
9953 /// Web property ID for the custom dimension to retrieve.
9954 ///
9955 /// Sets the *web property id* path property to the given value.
9956 ///
9957 /// Even though the property as already been set when instantiating this call,
9958 /// we provide this method for API completeness.
9959 pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomDimensionGetCall<'a, C> {
9960 self._web_property_id = new_value.to_string();
9961 self
9962 }
9963 /// The ID of the custom dimension to retrieve.
9964 ///
9965 /// Sets the *custom dimension id* path property to the given value.
9966 ///
9967 /// Even though the property as already been set when instantiating this call,
9968 /// we provide this method for API completeness.
9969 pub fn custom_dimension_id(
9970 mut self,
9971 new_value: &str,
9972 ) -> ManagementCustomDimensionGetCall<'a, C> {
9973 self._custom_dimension_id = new_value.to_string();
9974 self
9975 }
9976 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9977 /// while executing the actual API request.
9978 ///
9979 /// ````text
9980 /// It should be used to handle progress information, and to implement a certain level of resilience.
9981 /// ````
9982 ///
9983 /// Sets the *delegate* property to the given value.
9984 pub fn delegate(
9985 mut self,
9986 new_value: &'a mut dyn common::Delegate,
9987 ) -> ManagementCustomDimensionGetCall<'a, C> {
9988 self._delegate = Some(new_value);
9989 self
9990 }
9991
9992 /// Set any additional parameter of the query string used in the request.
9993 /// It should be used to set parameters which are not yet available through their own
9994 /// setters.
9995 ///
9996 /// Please note that this method must not be used to set any of the known parameters
9997 /// which have their own setter method. If done anyway, the request will fail.
9998 ///
9999 /// # Additional Parameters
10000 ///
10001 /// * *alt* (query-string) - Data format for the response.
10002 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10003 /// * *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.
10004 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10005 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10006 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10007 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10008 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDimensionGetCall<'a, C>
10009 where
10010 T: AsRef<str>,
10011 {
10012 self._additional_params
10013 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10014 self
10015 }
10016
10017 /// Identifies the authorization scope for the method you are building.
10018 ///
10019 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10020 /// [`Scope::Readonly`].
10021 ///
10022 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10023 /// tokens for more than one scope.
10024 ///
10025 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10026 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10027 /// sufficient, a read-write scope will do as well.
10028 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDimensionGetCall<'a, C>
10029 where
10030 St: AsRef<str>,
10031 {
10032 self._scopes.insert(String::from(scope.as_ref()));
10033 self
10034 }
10035 /// Identifies the authorization scope(s) for the method you are building.
10036 ///
10037 /// See [`Self::add_scope()`] for details.
10038 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDimensionGetCall<'a, C>
10039 where
10040 I: IntoIterator<Item = St>,
10041 St: AsRef<str>,
10042 {
10043 self._scopes
10044 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10045 self
10046 }
10047
10048 /// Removes all scopes, and no default scope will be used either.
10049 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10050 /// for details).
10051 pub fn clear_scopes(mut self) -> ManagementCustomDimensionGetCall<'a, C> {
10052 self._scopes.clear();
10053 self
10054 }
10055}
10056
10057/// Create a new custom dimension.
10058///
10059/// A builder for the *customDimensions.insert* method supported by a *management* resource.
10060/// It is not used directly, but through a [`ManagementMethods`] instance.
10061///
10062/// # Example
10063///
10064/// Instantiate a resource method builder
10065///
10066/// ```test_harness,no_run
10067/// # extern crate hyper;
10068/// # extern crate hyper_rustls;
10069/// # extern crate google_analytics3 as analytics3;
10070/// use analytics3::api::CustomDimension;
10071/// # async fn dox() {
10072/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10073///
10074/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10076/// # secret,
10077/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10078/// # ).build().await.unwrap();
10079///
10080/// # let client = hyper_util::client::legacy::Client::builder(
10081/// # hyper_util::rt::TokioExecutor::new()
10082/// # )
10083/// # .build(
10084/// # hyper_rustls::HttpsConnectorBuilder::new()
10085/// # .with_native_roots()
10086/// # .unwrap()
10087/// # .https_or_http()
10088/// # .enable_http1()
10089/// # .build()
10090/// # );
10091/// # let mut hub = Analytics::new(client, auth);
10092/// // As the method needs a request, you would usually fill it with the desired information
10093/// // into the respective structure. Some of the parts shown here might not be applicable !
10094/// // Values shown here are possibly random and not representative !
10095/// let mut req = CustomDimension::default();
10096///
10097/// // You can configure optional parameters by calling the respective setters at will, and
10098/// // execute the final call using `doit()`.
10099/// // Values shown here are possibly random and not representative !
10100/// let result = hub.management().custom_dimensions_insert(req, "accountId", "webPropertyId")
10101/// .doit().await;
10102/// # }
10103/// ```
10104pub struct ManagementCustomDimensionInsertCall<'a, C>
10105where
10106 C: 'a,
10107{
10108 hub: &'a Analytics<C>,
10109 _request: CustomDimension,
10110 _account_id: String,
10111 _web_property_id: String,
10112 _delegate: Option<&'a mut dyn common::Delegate>,
10113 _additional_params: HashMap<String, String>,
10114 _scopes: BTreeSet<String>,
10115}
10116
10117impl<'a, C> common::CallBuilder for ManagementCustomDimensionInsertCall<'a, C> {}
10118
10119impl<'a, C> ManagementCustomDimensionInsertCall<'a, C>
10120where
10121 C: common::Connector,
10122{
10123 /// Perform the operation you have build so far.
10124 pub async fn doit(mut self) -> common::Result<(common::Response, CustomDimension)> {
10125 use std::borrow::Cow;
10126 use std::io::{Read, Seek};
10127
10128 use common::{url::Params, ToParts};
10129 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10130
10131 let mut dd = common::DefaultDelegate;
10132 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10133 dlg.begin(common::MethodInfo {
10134 id: "analytics.management.customDimensions.insert",
10135 http_method: hyper::Method::POST,
10136 });
10137
10138 for &field in ["alt", "accountId", "webPropertyId"].iter() {
10139 if self._additional_params.contains_key(field) {
10140 dlg.finished(false);
10141 return Err(common::Error::FieldClash(field));
10142 }
10143 }
10144
10145 let mut params = Params::with_capacity(5 + self._additional_params.len());
10146 params.push("accountId", self._account_id);
10147 params.push("webPropertyId", self._web_property_id);
10148
10149 params.extend(self._additional_params.iter());
10150
10151 params.push("alt", "json");
10152 let mut url = self.hub._base_url.clone()
10153 + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDimensions";
10154 if self._scopes.is_empty() {
10155 self._scopes.insert(Scope::Edit.as_ref().to_string());
10156 }
10157
10158 #[allow(clippy::single_element_loop)]
10159 for &(find_this, param_name) in [
10160 ("{accountId}", "accountId"),
10161 ("{webPropertyId}", "webPropertyId"),
10162 ]
10163 .iter()
10164 {
10165 url = params.uri_replacement(url, param_name, find_this, false);
10166 }
10167 {
10168 let to_remove = ["webPropertyId", "accountId"];
10169 params.remove_params(&to_remove);
10170 }
10171
10172 let url = params.parse_with_url(&url);
10173
10174 let mut json_mime_type = mime::APPLICATION_JSON;
10175 let mut request_value_reader = {
10176 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10177 common::remove_json_null_values(&mut value);
10178 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10179 serde_json::to_writer(&mut dst, &value).unwrap();
10180 dst
10181 };
10182 let request_size = request_value_reader
10183 .seek(std::io::SeekFrom::End(0))
10184 .unwrap();
10185 request_value_reader
10186 .seek(std::io::SeekFrom::Start(0))
10187 .unwrap();
10188
10189 loop {
10190 let token = match self
10191 .hub
10192 .auth
10193 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10194 .await
10195 {
10196 Ok(token) => token,
10197 Err(e) => match dlg.token(e) {
10198 Ok(token) => token,
10199 Err(e) => {
10200 dlg.finished(false);
10201 return Err(common::Error::MissingToken(e));
10202 }
10203 },
10204 };
10205 request_value_reader
10206 .seek(std::io::SeekFrom::Start(0))
10207 .unwrap();
10208 let mut req_result = {
10209 let client = &self.hub.client;
10210 dlg.pre_request();
10211 let mut req_builder = hyper::Request::builder()
10212 .method(hyper::Method::POST)
10213 .uri(url.as_str())
10214 .header(USER_AGENT, self.hub._user_agent.clone());
10215
10216 if let Some(token) = token.as_ref() {
10217 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10218 }
10219
10220 let request = req_builder
10221 .header(CONTENT_TYPE, json_mime_type.to_string())
10222 .header(CONTENT_LENGTH, request_size as u64)
10223 .body(common::to_body(
10224 request_value_reader.get_ref().clone().into(),
10225 ));
10226
10227 client.request(request.unwrap()).await
10228 };
10229
10230 match req_result {
10231 Err(err) => {
10232 if let common::Retry::After(d) = dlg.http_error(&err) {
10233 sleep(d).await;
10234 continue;
10235 }
10236 dlg.finished(false);
10237 return Err(common::Error::HttpError(err));
10238 }
10239 Ok(res) => {
10240 let (mut parts, body) = res.into_parts();
10241 let mut body = common::Body::new(body);
10242 if !parts.status.is_success() {
10243 let bytes = common::to_bytes(body).await.unwrap_or_default();
10244 let error = serde_json::from_str(&common::to_string(&bytes));
10245 let response = common::to_response(parts, bytes.into());
10246
10247 if let common::Retry::After(d) =
10248 dlg.http_failure(&response, error.as_ref().ok())
10249 {
10250 sleep(d).await;
10251 continue;
10252 }
10253
10254 dlg.finished(false);
10255
10256 return Err(match error {
10257 Ok(value) => common::Error::BadRequest(value),
10258 _ => common::Error::Failure(response),
10259 });
10260 }
10261 let response = {
10262 let bytes = common::to_bytes(body).await.unwrap_or_default();
10263 let encoded = common::to_string(&bytes);
10264 match serde_json::from_str(&encoded) {
10265 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10266 Err(error) => {
10267 dlg.response_json_decode_error(&encoded, &error);
10268 return Err(common::Error::JsonDecodeError(
10269 encoded.to_string(),
10270 error,
10271 ));
10272 }
10273 }
10274 };
10275
10276 dlg.finished(true);
10277 return Ok(response);
10278 }
10279 }
10280 }
10281 }
10282
10283 ///
10284 /// Sets the *request* property to the given value.
10285 ///
10286 /// Even though the property as already been set when instantiating this call,
10287 /// we provide this method for API completeness.
10288 pub fn request(
10289 mut self,
10290 new_value: CustomDimension,
10291 ) -> ManagementCustomDimensionInsertCall<'a, C> {
10292 self._request = new_value;
10293 self
10294 }
10295 /// Account ID for the custom dimension to create.
10296 ///
10297 /// Sets the *account id* path property to the given value.
10298 ///
10299 /// Even though the property as already been set when instantiating this call,
10300 /// we provide this method for API completeness.
10301 pub fn account_id(mut self, new_value: &str) -> ManagementCustomDimensionInsertCall<'a, C> {
10302 self._account_id = new_value.to_string();
10303 self
10304 }
10305 /// Web property ID for the custom dimension to create.
10306 ///
10307 /// Sets the *web property id* path property to the given value.
10308 ///
10309 /// Even though the property as already been set when instantiating this call,
10310 /// we provide this method for API completeness.
10311 pub fn web_property_id(
10312 mut self,
10313 new_value: &str,
10314 ) -> ManagementCustomDimensionInsertCall<'a, C> {
10315 self._web_property_id = new_value.to_string();
10316 self
10317 }
10318 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10319 /// while executing the actual API request.
10320 ///
10321 /// ````text
10322 /// It should be used to handle progress information, and to implement a certain level of resilience.
10323 /// ````
10324 ///
10325 /// Sets the *delegate* property to the given value.
10326 pub fn delegate(
10327 mut self,
10328 new_value: &'a mut dyn common::Delegate,
10329 ) -> ManagementCustomDimensionInsertCall<'a, C> {
10330 self._delegate = Some(new_value);
10331 self
10332 }
10333
10334 /// Set any additional parameter of the query string used in the request.
10335 /// It should be used to set parameters which are not yet available through their own
10336 /// setters.
10337 ///
10338 /// Please note that this method must not be used to set any of the known parameters
10339 /// which have their own setter method. If done anyway, the request will fail.
10340 ///
10341 /// # Additional Parameters
10342 ///
10343 /// * *alt* (query-string) - Data format for the response.
10344 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10345 /// * *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.
10346 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10347 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10348 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10349 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10350 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDimensionInsertCall<'a, C>
10351 where
10352 T: AsRef<str>,
10353 {
10354 self._additional_params
10355 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10356 self
10357 }
10358
10359 /// Identifies the authorization scope for the method you are building.
10360 ///
10361 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10362 /// [`Scope::Edit`].
10363 ///
10364 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10365 /// tokens for more than one scope.
10366 ///
10367 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10368 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10369 /// sufficient, a read-write scope will do as well.
10370 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDimensionInsertCall<'a, C>
10371 where
10372 St: AsRef<str>,
10373 {
10374 self._scopes.insert(String::from(scope.as_ref()));
10375 self
10376 }
10377 /// Identifies the authorization scope(s) for the method you are building.
10378 ///
10379 /// See [`Self::add_scope()`] for details.
10380 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDimensionInsertCall<'a, C>
10381 where
10382 I: IntoIterator<Item = St>,
10383 St: AsRef<str>,
10384 {
10385 self._scopes
10386 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10387 self
10388 }
10389
10390 /// Removes all scopes, and no default scope will be used either.
10391 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10392 /// for details).
10393 pub fn clear_scopes(mut self) -> ManagementCustomDimensionInsertCall<'a, C> {
10394 self._scopes.clear();
10395 self
10396 }
10397}
10398
10399/// Lists custom dimensions to which the user has access.
10400///
10401/// A builder for the *customDimensions.list* method supported by a *management* resource.
10402/// It is not used directly, but through a [`ManagementMethods`] instance.
10403///
10404/// # Example
10405///
10406/// Instantiate a resource method builder
10407///
10408/// ```test_harness,no_run
10409/// # extern crate hyper;
10410/// # extern crate hyper_rustls;
10411/// # extern crate google_analytics3 as analytics3;
10412/// # async fn dox() {
10413/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10414///
10415/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10416/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10417/// # secret,
10418/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10419/// # ).build().await.unwrap();
10420///
10421/// # let client = hyper_util::client::legacy::Client::builder(
10422/// # hyper_util::rt::TokioExecutor::new()
10423/// # )
10424/// # .build(
10425/// # hyper_rustls::HttpsConnectorBuilder::new()
10426/// # .with_native_roots()
10427/// # .unwrap()
10428/// # .https_or_http()
10429/// # .enable_http1()
10430/// # .build()
10431/// # );
10432/// # let mut hub = Analytics::new(client, auth);
10433/// // You can configure optional parameters by calling the respective setters at will, and
10434/// // execute the final call using `doit()`.
10435/// // Values shown here are possibly random and not representative !
10436/// let result = hub.management().custom_dimensions_list("accountId", "webPropertyId")
10437/// .start_index(-76)
10438/// .max_results(-76)
10439/// .doit().await;
10440/// # }
10441/// ```
10442pub struct ManagementCustomDimensionListCall<'a, C>
10443where
10444 C: 'a,
10445{
10446 hub: &'a Analytics<C>,
10447 _account_id: String,
10448 _web_property_id: String,
10449 _start_index: Option<i32>,
10450 _max_results: Option<i32>,
10451 _delegate: Option<&'a mut dyn common::Delegate>,
10452 _additional_params: HashMap<String, String>,
10453 _scopes: BTreeSet<String>,
10454}
10455
10456impl<'a, C> common::CallBuilder for ManagementCustomDimensionListCall<'a, C> {}
10457
10458impl<'a, C> ManagementCustomDimensionListCall<'a, C>
10459where
10460 C: common::Connector,
10461{
10462 /// Perform the operation you have build so far.
10463 pub async fn doit(mut self) -> common::Result<(common::Response, CustomDimensions)> {
10464 use std::borrow::Cow;
10465 use std::io::{Read, Seek};
10466
10467 use common::{url::Params, ToParts};
10468 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10469
10470 let mut dd = common::DefaultDelegate;
10471 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10472 dlg.begin(common::MethodInfo {
10473 id: "analytics.management.customDimensions.list",
10474 http_method: hyper::Method::GET,
10475 });
10476
10477 for &field in [
10478 "alt",
10479 "accountId",
10480 "webPropertyId",
10481 "start-index",
10482 "max-results",
10483 ]
10484 .iter()
10485 {
10486 if self._additional_params.contains_key(field) {
10487 dlg.finished(false);
10488 return Err(common::Error::FieldClash(field));
10489 }
10490 }
10491
10492 let mut params = Params::with_capacity(6 + self._additional_params.len());
10493 params.push("accountId", self._account_id);
10494 params.push("webPropertyId", self._web_property_id);
10495 if let Some(value) = self._start_index.as_ref() {
10496 params.push("start-index", value.to_string());
10497 }
10498 if let Some(value) = self._max_results.as_ref() {
10499 params.push("max-results", value.to_string());
10500 }
10501
10502 params.extend(self._additional_params.iter());
10503
10504 params.push("alt", "json");
10505 let mut url = self.hub._base_url.clone()
10506 + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDimensions";
10507 if self._scopes.is_empty() {
10508 self._scopes.insert(Scope::Readonly.as_ref().to_string());
10509 }
10510
10511 #[allow(clippy::single_element_loop)]
10512 for &(find_this, param_name) in [
10513 ("{accountId}", "accountId"),
10514 ("{webPropertyId}", "webPropertyId"),
10515 ]
10516 .iter()
10517 {
10518 url = params.uri_replacement(url, param_name, find_this, false);
10519 }
10520 {
10521 let to_remove = ["webPropertyId", "accountId"];
10522 params.remove_params(&to_remove);
10523 }
10524
10525 let url = params.parse_with_url(&url);
10526
10527 loop {
10528 let token = match self
10529 .hub
10530 .auth
10531 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10532 .await
10533 {
10534 Ok(token) => token,
10535 Err(e) => match dlg.token(e) {
10536 Ok(token) => token,
10537 Err(e) => {
10538 dlg.finished(false);
10539 return Err(common::Error::MissingToken(e));
10540 }
10541 },
10542 };
10543 let mut req_result = {
10544 let client = &self.hub.client;
10545 dlg.pre_request();
10546 let mut req_builder = hyper::Request::builder()
10547 .method(hyper::Method::GET)
10548 .uri(url.as_str())
10549 .header(USER_AGENT, self.hub._user_agent.clone());
10550
10551 if let Some(token) = token.as_ref() {
10552 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10553 }
10554
10555 let request = req_builder
10556 .header(CONTENT_LENGTH, 0_u64)
10557 .body(common::to_body::<String>(None));
10558
10559 client.request(request.unwrap()).await
10560 };
10561
10562 match req_result {
10563 Err(err) => {
10564 if let common::Retry::After(d) = dlg.http_error(&err) {
10565 sleep(d).await;
10566 continue;
10567 }
10568 dlg.finished(false);
10569 return Err(common::Error::HttpError(err));
10570 }
10571 Ok(res) => {
10572 let (mut parts, body) = res.into_parts();
10573 let mut body = common::Body::new(body);
10574 if !parts.status.is_success() {
10575 let bytes = common::to_bytes(body).await.unwrap_or_default();
10576 let error = serde_json::from_str(&common::to_string(&bytes));
10577 let response = common::to_response(parts, bytes.into());
10578
10579 if let common::Retry::After(d) =
10580 dlg.http_failure(&response, error.as_ref().ok())
10581 {
10582 sleep(d).await;
10583 continue;
10584 }
10585
10586 dlg.finished(false);
10587
10588 return Err(match error {
10589 Ok(value) => common::Error::BadRequest(value),
10590 _ => common::Error::Failure(response),
10591 });
10592 }
10593 let response = {
10594 let bytes = common::to_bytes(body).await.unwrap_or_default();
10595 let encoded = common::to_string(&bytes);
10596 match serde_json::from_str(&encoded) {
10597 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10598 Err(error) => {
10599 dlg.response_json_decode_error(&encoded, &error);
10600 return Err(common::Error::JsonDecodeError(
10601 encoded.to_string(),
10602 error,
10603 ));
10604 }
10605 }
10606 };
10607
10608 dlg.finished(true);
10609 return Ok(response);
10610 }
10611 }
10612 }
10613 }
10614
10615 /// Account ID for the custom dimensions to retrieve.
10616 ///
10617 /// Sets the *account id* path property to the given value.
10618 ///
10619 /// Even though the property as already been set when instantiating this call,
10620 /// we provide this method for API completeness.
10621 pub fn account_id(mut self, new_value: &str) -> ManagementCustomDimensionListCall<'a, C> {
10622 self._account_id = new_value.to_string();
10623 self
10624 }
10625 /// Web property ID for the custom dimensions to retrieve.
10626 ///
10627 /// Sets the *web property id* path property to the given value.
10628 ///
10629 /// Even though the property as already been set when instantiating this call,
10630 /// we provide this method for API completeness.
10631 pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomDimensionListCall<'a, C> {
10632 self._web_property_id = new_value.to_string();
10633 self
10634 }
10635 /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
10636 ///
10637 /// Sets the *start-index* query property to the given value.
10638 pub fn start_index(mut self, new_value: i32) -> ManagementCustomDimensionListCall<'a, C> {
10639 self._start_index = Some(new_value);
10640 self
10641 }
10642 /// The maximum number of custom dimensions to include in this response.
10643 ///
10644 /// Sets the *max-results* query property to the given value.
10645 pub fn max_results(mut self, new_value: i32) -> ManagementCustomDimensionListCall<'a, C> {
10646 self._max_results = Some(new_value);
10647 self
10648 }
10649 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10650 /// while executing the actual API request.
10651 ///
10652 /// ````text
10653 /// It should be used to handle progress information, and to implement a certain level of resilience.
10654 /// ````
10655 ///
10656 /// Sets the *delegate* property to the given value.
10657 pub fn delegate(
10658 mut self,
10659 new_value: &'a mut dyn common::Delegate,
10660 ) -> ManagementCustomDimensionListCall<'a, C> {
10661 self._delegate = Some(new_value);
10662 self
10663 }
10664
10665 /// Set any additional parameter of the query string used in the request.
10666 /// It should be used to set parameters which are not yet available through their own
10667 /// setters.
10668 ///
10669 /// Please note that this method must not be used to set any of the known parameters
10670 /// which have their own setter method. If done anyway, the request will fail.
10671 ///
10672 /// # Additional Parameters
10673 ///
10674 /// * *alt* (query-string) - Data format for the response.
10675 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10676 /// * *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.
10677 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10678 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10679 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10680 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10681 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDimensionListCall<'a, C>
10682 where
10683 T: AsRef<str>,
10684 {
10685 self._additional_params
10686 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10687 self
10688 }
10689
10690 /// Identifies the authorization scope for the method you are building.
10691 ///
10692 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10693 /// [`Scope::Readonly`].
10694 ///
10695 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10696 /// tokens for more than one scope.
10697 ///
10698 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10699 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10700 /// sufficient, a read-write scope will do as well.
10701 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDimensionListCall<'a, C>
10702 where
10703 St: AsRef<str>,
10704 {
10705 self._scopes.insert(String::from(scope.as_ref()));
10706 self
10707 }
10708 /// Identifies the authorization scope(s) for the method you are building.
10709 ///
10710 /// See [`Self::add_scope()`] for details.
10711 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDimensionListCall<'a, C>
10712 where
10713 I: IntoIterator<Item = St>,
10714 St: AsRef<str>,
10715 {
10716 self._scopes
10717 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10718 self
10719 }
10720
10721 /// Removes all scopes, and no default scope will be used either.
10722 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10723 /// for details).
10724 pub fn clear_scopes(mut self) -> ManagementCustomDimensionListCall<'a, C> {
10725 self._scopes.clear();
10726 self
10727 }
10728}
10729
10730/// Updates an existing custom dimension. This method supports patch semantics.
10731///
10732/// A builder for the *customDimensions.patch* method supported by a *management* resource.
10733/// It is not used directly, but through a [`ManagementMethods`] instance.
10734///
10735/// # Example
10736///
10737/// Instantiate a resource method builder
10738///
10739/// ```test_harness,no_run
10740/// # extern crate hyper;
10741/// # extern crate hyper_rustls;
10742/// # extern crate google_analytics3 as analytics3;
10743/// use analytics3::api::CustomDimension;
10744/// # async fn dox() {
10745/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10746///
10747/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10748/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10749/// # secret,
10750/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10751/// # ).build().await.unwrap();
10752///
10753/// # let client = hyper_util::client::legacy::Client::builder(
10754/// # hyper_util::rt::TokioExecutor::new()
10755/// # )
10756/// # .build(
10757/// # hyper_rustls::HttpsConnectorBuilder::new()
10758/// # .with_native_roots()
10759/// # .unwrap()
10760/// # .https_or_http()
10761/// # .enable_http1()
10762/// # .build()
10763/// # );
10764/// # let mut hub = Analytics::new(client, auth);
10765/// // As the method needs a request, you would usually fill it with the desired information
10766/// // into the respective structure. Some of the parts shown here might not be applicable !
10767/// // Values shown here are possibly random and not representative !
10768/// let mut req = CustomDimension::default();
10769///
10770/// // You can configure optional parameters by calling the respective setters at will, and
10771/// // execute the final call using `doit()`.
10772/// // Values shown here are possibly random and not representative !
10773/// let result = hub.management().custom_dimensions_patch(req, "accountId", "webPropertyId", "customDimensionId")
10774/// .ignore_custom_data_source_links(true)
10775/// .doit().await;
10776/// # }
10777/// ```
10778pub struct ManagementCustomDimensionPatchCall<'a, C>
10779where
10780 C: 'a,
10781{
10782 hub: &'a Analytics<C>,
10783 _request: CustomDimension,
10784 _account_id: String,
10785 _web_property_id: String,
10786 _custom_dimension_id: String,
10787 _ignore_custom_data_source_links: Option<bool>,
10788 _delegate: Option<&'a mut dyn common::Delegate>,
10789 _additional_params: HashMap<String, String>,
10790 _scopes: BTreeSet<String>,
10791}
10792
10793impl<'a, C> common::CallBuilder for ManagementCustomDimensionPatchCall<'a, C> {}
10794
10795impl<'a, C> ManagementCustomDimensionPatchCall<'a, C>
10796where
10797 C: common::Connector,
10798{
10799 /// Perform the operation you have build so far.
10800 pub async fn doit(mut self) -> common::Result<(common::Response, CustomDimension)> {
10801 use std::borrow::Cow;
10802 use std::io::{Read, Seek};
10803
10804 use common::{url::Params, ToParts};
10805 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10806
10807 let mut dd = common::DefaultDelegate;
10808 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10809 dlg.begin(common::MethodInfo {
10810 id: "analytics.management.customDimensions.patch",
10811 http_method: hyper::Method::PATCH,
10812 });
10813
10814 for &field in [
10815 "alt",
10816 "accountId",
10817 "webPropertyId",
10818 "customDimensionId",
10819 "ignoreCustomDataSourceLinks",
10820 ]
10821 .iter()
10822 {
10823 if self._additional_params.contains_key(field) {
10824 dlg.finished(false);
10825 return Err(common::Error::FieldClash(field));
10826 }
10827 }
10828
10829 let mut params = Params::with_capacity(7 + self._additional_params.len());
10830 params.push("accountId", self._account_id);
10831 params.push("webPropertyId", self._web_property_id);
10832 params.push("customDimensionId", self._custom_dimension_id);
10833 if let Some(value) = self._ignore_custom_data_source_links.as_ref() {
10834 params.push("ignoreCustomDataSourceLinks", value.to_string());
10835 }
10836
10837 params.extend(self._additional_params.iter());
10838
10839 params.push("alt", "json");
10840 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDimensions/{customDimensionId}";
10841 if self._scopes.is_empty() {
10842 self._scopes.insert(Scope::Edit.as_ref().to_string());
10843 }
10844
10845 #[allow(clippy::single_element_loop)]
10846 for &(find_this, param_name) in [
10847 ("{accountId}", "accountId"),
10848 ("{webPropertyId}", "webPropertyId"),
10849 ("{customDimensionId}", "customDimensionId"),
10850 ]
10851 .iter()
10852 {
10853 url = params.uri_replacement(url, param_name, find_this, false);
10854 }
10855 {
10856 let to_remove = ["customDimensionId", "webPropertyId", "accountId"];
10857 params.remove_params(&to_remove);
10858 }
10859
10860 let url = params.parse_with_url(&url);
10861
10862 let mut json_mime_type = mime::APPLICATION_JSON;
10863 let mut request_value_reader = {
10864 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10865 common::remove_json_null_values(&mut value);
10866 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10867 serde_json::to_writer(&mut dst, &value).unwrap();
10868 dst
10869 };
10870 let request_size = request_value_reader
10871 .seek(std::io::SeekFrom::End(0))
10872 .unwrap();
10873 request_value_reader
10874 .seek(std::io::SeekFrom::Start(0))
10875 .unwrap();
10876
10877 loop {
10878 let token = match self
10879 .hub
10880 .auth
10881 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10882 .await
10883 {
10884 Ok(token) => token,
10885 Err(e) => match dlg.token(e) {
10886 Ok(token) => token,
10887 Err(e) => {
10888 dlg.finished(false);
10889 return Err(common::Error::MissingToken(e));
10890 }
10891 },
10892 };
10893 request_value_reader
10894 .seek(std::io::SeekFrom::Start(0))
10895 .unwrap();
10896 let mut req_result = {
10897 let client = &self.hub.client;
10898 dlg.pre_request();
10899 let mut req_builder = hyper::Request::builder()
10900 .method(hyper::Method::PATCH)
10901 .uri(url.as_str())
10902 .header(USER_AGENT, self.hub._user_agent.clone());
10903
10904 if let Some(token) = token.as_ref() {
10905 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10906 }
10907
10908 let request = req_builder
10909 .header(CONTENT_TYPE, json_mime_type.to_string())
10910 .header(CONTENT_LENGTH, request_size as u64)
10911 .body(common::to_body(
10912 request_value_reader.get_ref().clone().into(),
10913 ));
10914
10915 client.request(request.unwrap()).await
10916 };
10917
10918 match req_result {
10919 Err(err) => {
10920 if let common::Retry::After(d) = dlg.http_error(&err) {
10921 sleep(d).await;
10922 continue;
10923 }
10924 dlg.finished(false);
10925 return Err(common::Error::HttpError(err));
10926 }
10927 Ok(res) => {
10928 let (mut parts, body) = res.into_parts();
10929 let mut body = common::Body::new(body);
10930 if !parts.status.is_success() {
10931 let bytes = common::to_bytes(body).await.unwrap_or_default();
10932 let error = serde_json::from_str(&common::to_string(&bytes));
10933 let response = common::to_response(parts, bytes.into());
10934
10935 if let common::Retry::After(d) =
10936 dlg.http_failure(&response, error.as_ref().ok())
10937 {
10938 sleep(d).await;
10939 continue;
10940 }
10941
10942 dlg.finished(false);
10943
10944 return Err(match error {
10945 Ok(value) => common::Error::BadRequest(value),
10946 _ => common::Error::Failure(response),
10947 });
10948 }
10949 let response = {
10950 let bytes = common::to_bytes(body).await.unwrap_or_default();
10951 let encoded = common::to_string(&bytes);
10952 match serde_json::from_str(&encoded) {
10953 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10954 Err(error) => {
10955 dlg.response_json_decode_error(&encoded, &error);
10956 return Err(common::Error::JsonDecodeError(
10957 encoded.to_string(),
10958 error,
10959 ));
10960 }
10961 }
10962 };
10963
10964 dlg.finished(true);
10965 return Ok(response);
10966 }
10967 }
10968 }
10969 }
10970
10971 ///
10972 /// Sets the *request* property to the given value.
10973 ///
10974 /// Even though the property as already been set when instantiating this call,
10975 /// we provide this method for API completeness.
10976 pub fn request(
10977 mut self,
10978 new_value: CustomDimension,
10979 ) -> ManagementCustomDimensionPatchCall<'a, C> {
10980 self._request = new_value;
10981 self
10982 }
10983 /// Account ID for the custom dimension to update.
10984 ///
10985 /// Sets the *account id* path property to the given value.
10986 ///
10987 /// Even though the property as already been set when instantiating this call,
10988 /// we provide this method for API completeness.
10989 pub fn account_id(mut self, new_value: &str) -> ManagementCustomDimensionPatchCall<'a, C> {
10990 self._account_id = new_value.to_string();
10991 self
10992 }
10993 /// Web property ID for the custom dimension to update.
10994 ///
10995 /// Sets the *web property id* path property to the given value.
10996 ///
10997 /// Even though the property as already been set when instantiating this call,
10998 /// we provide this method for API completeness.
10999 pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomDimensionPatchCall<'a, C> {
11000 self._web_property_id = new_value.to_string();
11001 self
11002 }
11003 /// Custom dimension ID for the custom dimension to update.
11004 ///
11005 /// Sets the *custom dimension id* path property to the given value.
11006 ///
11007 /// Even though the property as already been set when instantiating this call,
11008 /// we provide this method for API completeness.
11009 pub fn custom_dimension_id(
11010 mut self,
11011 new_value: &str,
11012 ) -> ManagementCustomDimensionPatchCall<'a, C> {
11013 self._custom_dimension_id = new_value.to_string();
11014 self
11015 }
11016 /// Force the update and ignore any warnings related to the custom dimension being linked to a custom data source / data set.
11017 ///
11018 /// Sets the *ignore custom data source links* query property to the given value.
11019 pub fn ignore_custom_data_source_links(
11020 mut self,
11021 new_value: bool,
11022 ) -> ManagementCustomDimensionPatchCall<'a, C> {
11023 self._ignore_custom_data_source_links = Some(new_value);
11024 self
11025 }
11026 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11027 /// while executing the actual API request.
11028 ///
11029 /// ````text
11030 /// It should be used to handle progress information, and to implement a certain level of resilience.
11031 /// ````
11032 ///
11033 /// Sets the *delegate* property to the given value.
11034 pub fn delegate(
11035 mut self,
11036 new_value: &'a mut dyn common::Delegate,
11037 ) -> ManagementCustomDimensionPatchCall<'a, C> {
11038 self._delegate = Some(new_value);
11039 self
11040 }
11041
11042 /// Set any additional parameter of the query string used in the request.
11043 /// It should be used to set parameters which are not yet available through their own
11044 /// setters.
11045 ///
11046 /// Please note that this method must not be used to set any of the known parameters
11047 /// which have their own setter method. If done anyway, the request will fail.
11048 ///
11049 /// # Additional Parameters
11050 ///
11051 /// * *alt* (query-string) - Data format for the response.
11052 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11053 /// * *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.
11054 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11055 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11056 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11057 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11058 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDimensionPatchCall<'a, C>
11059 where
11060 T: AsRef<str>,
11061 {
11062 self._additional_params
11063 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11064 self
11065 }
11066
11067 /// Identifies the authorization scope for the method you are building.
11068 ///
11069 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11070 /// [`Scope::Edit`].
11071 ///
11072 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11073 /// tokens for more than one scope.
11074 ///
11075 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11076 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11077 /// sufficient, a read-write scope will do as well.
11078 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDimensionPatchCall<'a, C>
11079 where
11080 St: AsRef<str>,
11081 {
11082 self._scopes.insert(String::from(scope.as_ref()));
11083 self
11084 }
11085 /// Identifies the authorization scope(s) for the method you are building.
11086 ///
11087 /// See [`Self::add_scope()`] for details.
11088 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDimensionPatchCall<'a, C>
11089 where
11090 I: IntoIterator<Item = St>,
11091 St: AsRef<str>,
11092 {
11093 self._scopes
11094 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11095 self
11096 }
11097
11098 /// Removes all scopes, and no default scope will be used either.
11099 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11100 /// for details).
11101 pub fn clear_scopes(mut self) -> ManagementCustomDimensionPatchCall<'a, C> {
11102 self._scopes.clear();
11103 self
11104 }
11105}
11106
11107/// Updates an existing custom dimension.
11108///
11109/// A builder for the *customDimensions.update* method supported by a *management* resource.
11110/// It is not used directly, but through a [`ManagementMethods`] instance.
11111///
11112/// # Example
11113///
11114/// Instantiate a resource method builder
11115///
11116/// ```test_harness,no_run
11117/// # extern crate hyper;
11118/// # extern crate hyper_rustls;
11119/// # extern crate google_analytics3 as analytics3;
11120/// use analytics3::api::CustomDimension;
11121/// # async fn dox() {
11122/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11123///
11124/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11125/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11126/// # secret,
11127/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11128/// # ).build().await.unwrap();
11129///
11130/// # let client = hyper_util::client::legacy::Client::builder(
11131/// # hyper_util::rt::TokioExecutor::new()
11132/// # )
11133/// # .build(
11134/// # hyper_rustls::HttpsConnectorBuilder::new()
11135/// # .with_native_roots()
11136/// # .unwrap()
11137/// # .https_or_http()
11138/// # .enable_http1()
11139/// # .build()
11140/// # );
11141/// # let mut hub = Analytics::new(client, auth);
11142/// // As the method needs a request, you would usually fill it with the desired information
11143/// // into the respective structure. Some of the parts shown here might not be applicable !
11144/// // Values shown here are possibly random and not representative !
11145/// let mut req = CustomDimension::default();
11146///
11147/// // You can configure optional parameters by calling the respective setters at will, and
11148/// // execute the final call using `doit()`.
11149/// // Values shown here are possibly random and not representative !
11150/// let result = hub.management().custom_dimensions_update(req, "accountId", "webPropertyId", "customDimensionId")
11151/// .ignore_custom_data_source_links(false)
11152/// .doit().await;
11153/// # }
11154/// ```
11155pub struct ManagementCustomDimensionUpdateCall<'a, C>
11156where
11157 C: 'a,
11158{
11159 hub: &'a Analytics<C>,
11160 _request: CustomDimension,
11161 _account_id: String,
11162 _web_property_id: String,
11163 _custom_dimension_id: String,
11164 _ignore_custom_data_source_links: Option<bool>,
11165 _delegate: Option<&'a mut dyn common::Delegate>,
11166 _additional_params: HashMap<String, String>,
11167 _scopes: BTreeSet<String>,
11168}
11169
11170impl<'a, C> common::CallBuilder for ManagementCustomDimensionUpdateCall<'a, C> {}
11171
11172impl<'a, C> ManagementCustomDimensionUpdateCall<'a, C>
11173where
11174 C: common::Connector,
11175{
11176 /// Perform the operation you have build so far.
11177 pub async fn doit(mut self) -> common::Result<(common::Response, CustomDimension)> {
11178 use std::borrow::Cow;
11179 use std::io::{Read, Seek};
11180
11181 use common::{url::Params, ToParts};
11182 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11183
11184 let mut dd = common::DefaultDelegate;
11185 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11186 dlg.begin(common::MethodInfo {
11187 id: "analytics.management.customDimensions.update",
11188 http_method: hyper::Method::PUT,
11189 });
11190
11191 for &field in [
11192 "alt",
11193 "accountId",
11194 "webPropertyId",
11195 "customDimensionId",
11196 "ignoreCustomDataSourceLinks",
11197 ]
11198 .iter()
11199 {
11200 if self._additional_params.contains_key(field) {
11201 dlg.finished(false);
11202 return Err(common::Error::FieldClash(field));
11203 }
11204 }
11205
11206 let mut params = Params::with_capacity(7 + self._additional_params.len());
11207 params.push("accountId", self._account_id);
11208 params.push("webPropertyId", self._web_property_id);
11209 params.push("customDimensionId", self._custom_dimension_id);
11210 if let Some(value) = self._ignore_custom_data_source_links.as_ref() {
11211 params.push("ignoreCustomDataSourceLinks", value.to_string());
11212 }
11213
11214 params.extend(self._additional_params.iter());
11215
11216 params.push("alt", "json");
11217 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDimensions/{customDimensionId}";
11218 if self._scopes.is_empty() {
11219 self._scopes.insert(Scope::Edit.as_ref().to_string());
11220 }
11221
11222 #[allow(clippy::single_element_loop)]
11223 for &(find_this, param_name) in [
11224 ("{accountId}", "accountId"),
11225 ("{webPropertyId}", "webPropertyId"),
11226 ("{customDimensionId}", "customDimensionId"),
11227 ]
11228 .iter()
11229 {
11230 url = params.uri_replacement(url, param_name, find_this, false);
11231 }
11232 {
11233 let to_remove = ["customDimensionId", "webPropertyId", "accountId"];
11234 params.remove_params(&to_remove);
11235 }
11236
11237 let url = params.parse_with_url(&url);
11238
11239 let mut json_mime_type = mime::APPLICATION_JSON;
11240 let mut request_value_reader = {
11241 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11242 common::remove_json_null_values(&mut value);
11243 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11244 serde_json::to_writer(&mut dst, &value).unwrap();
11245 dst
11246 };
11247 let request_size = request_value_reader
11248 .seek(std::io::SeekFrom::End(0))
11249 .unwrap();
11250 request_value_reader
11251 .seek(std::io::SeekFrom::Start(0))
11252 .unwrap();
11253
11254 loop {
11255 let token = match self
11256 .hub
11257 .auth
11258 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11259 .await
11260 {
11261 Ok(token) => token,
11262 Err(e) => match dlg.token(e) {
11263 Ok(token) => token,
11264 Err(e) => {
11265 dlg.finished(false);
11266 return Err(common::Error::MissingToken(e));
11267 }
11268 },
11269 };
11270 request_value_reader
11271 .seek(std::io::SeekFrom::Start(0))
11272 .unwrap();
11273 let mut req_result = {
11274 let client = &self.hub.client;
11275 dlg.pre_request();
11276 let mut req_builder = hyper::Request::builder()
11277 .method(hyper::Method::PUT)
11278 .uri(url.as_str())
11279 .header(USER_AGENT, self.hub._user_agent.clone());
11280
11281 if let Some(token) = token.as_ref() {
11282 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11283 }
11284
11285 let request = req_builder
11286 .header(CONTENT_TYPE, json_mime_type.to_string())
11287 .header(CONTENT_LENGTH, request_size as u64)
11288 .body(common::to_body(
11289 request_value_reader.get_ref().clone().into(),
11290 ));
11291
11292 client.request(request.unwrap()).await
11293 };
11294
11295 match req_result {
11296 Err(err) => {
11297 if let common::Retry::After(d) = dlg.http_error(&err) {
11298 sleep(d).await;
11299 continue;
11300 }
11301 dlg.finished(false);
11302 return Err(common::Error::HttpError(err));
11303 }
11304 Ok(res) => {
11305 let (mut parts, body) = res.into_parts();
11306 let mut body = common::Body::new(body);
11307 if !parts.status.is_success() {
11308 let bytes = common::to_bytes(body).await.unwrap_or_default();
11309 let error = serde_json::from_str(&common::to_string(&bytes));
11310 let response = common::to_response(parts, bytes.into());
11311
11312 if let common::Retry::After(d) =
11313 dlg.http_failure(&response, error.as_ref().ok())
11314 {
11315 sleep(d).await;
11316 continue;
11317 }
11318
11319 dlg.finished(false);
11320
11321 return Err(match error {
11322 Ok(value) => common::Error::BadRequest(value),
11323 _ => common::Error::Failure(response),
11324 });
11325 }
11326 let response = {
11327 let bytes = common::to_bytes(body).await.unwrap_or_default();
11328 let encoded = common::to_string(&bytes);
11329 match serde_json::from_str(&encoded) {
11330 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11331 Err(error) => {
11332 dlg.response_json_decode_error(&encoded, &error);
11333 return Err(common::Error::JsonDecodeError(
11334 encoded.to_string(),
11335 error,
11336 ));
11337 }
11338 }
11339 };
11340
11341 dlg.finished(true);
11342 return Ok(response);
11343 }
11344 }
11345 }
11346 }
11347
11348 ///
11349 /// Sets the *request* property to the given value.
11350 ///
11351 /// Even though the property as already been set when instantiating this call,
11352 /// we provide this method for API completeness.
11353 pub fn request(
11354 mut self,
11355 new_value: CustomDimension,
11356 ) -> ManagementCustomDimensionUpdateCall<'a, C> {
11357 self._request = new_value;
11358 self
11359 }
11360 /// Account ID for the custom dimension to update.
11361 ///
11362 /// Sets the *account id* path property to the given value.
11363 ///
11364 /// Even though the property as already been set when instantiating this call,
11365 /// we provide this method for API completeness.
11366 pub fn account_id(mut self, new_value: &str) -> ManagementCustomDimensionUpdateCall<'a, C> {
11367 self._account_id = new_value.to_string();
11368 self
11369 }
11370 /// Web property ID for the custom dimension to update.
11371 ///
11372 /// Sets the *web property id* path property to the given value.
11373 ///
11374 /// Even though the property as already been set when instantiating this call,
11375 /// we provide this method for API completeness.
11376 pub fn web_property_id(
11377 mut self,
11378 new_value: &str,
11379 ) -> ManagementCustomDimensionUpdateCall<'a, C> {
11380 self._web_property_id = new_value.to_string();
11381 self
11382 }
11383 /// Custom dimension ID for the custom dimension to update.
11384 ///
11385 /// Sets the *custom dimension id* path property to the given value.
11386 ///
11387 /// Even though the property as already been set when instantiating this call,
11388 /// we provide this method for API completeness.
11389 pub fn custom_dimension_id(
11390 mut self,
11391 new_value: &str,
11392 ) -> ManagementCustomDimensionUpdateCall<'a, C> {
11393 self._custom_dimension_id = new_value.to_string();
11394 self
11395 }
11396 /// Force the update and ignore any warnings related to the custom dimension being linked to a custom data source / data set.
11397 ///
11398 /// Sets the *ignore custom data source links* query property to the given value.
11399 pub fn ignore_custom_data_source_links(
11400 mut self,
11401 new_value: bool,
11402 ) -> ManagementCustomDimensionUpdateCall<'a, C> {
11403 self._ignore_custom_data_source_links = Some(new_value);
11404 self
11405 }
11406 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11407 /// while executing the actual API request.
11408 ///
11409 /// ````text
11410 /// It should be used to handle progress information, and to implement a certain level of resilience.
11411 /// ````
11412 ///
11413 /// Sets the *delegate* property to the given value.
11414 pub fn delegate(
11415 mut self,
11416 new_value: &'a mut dyn common::Delegate,
11417 ) -> ManagementCustomDimensionUpdateCall<'a, C> {
11418 self._delegate = Some(new_value);
11419 self
11420 }
11421
11422 /// Set any additional parameter of the query string used in the request.
11423 /// It should be used to set parameters which are not yet available through their own
11424 /// setters.
11425 ///
11426 /// Please note that this method must not be used to set any of the known parameters
11427 /// which have their own setter method. If done anyway, the request will fail.
11428 ///
11429 /// # Additional Parameters
11430 ///
11431 /// * *alt* (query-string) - Data format for the response.
11432 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11433 /// * *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.
11434 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11435 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11436 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11437 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11438 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomDimensionUpdateCall<'a, C>
11439 where
11440 T: AsRef<str>,
11441 {
11442 self._additional_params
11443 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11444 self
11445 }
11446
11447 /// Identifies the authorization scope for the method you are building.
11448 ///
11449 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11450 /// [`Scope::Edit`].
11451 ///
11452 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11453 /// tokens for more than one scope.
11454 ///
11455 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11456 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11457 /// sufficient, a read-write scope will do as well.
11458 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomDimensionUpdateCall<'a, C>
11459 where
11460 St: AsRef<str>,
11461 {
11462 self._scopes.insert(String::from(scope.as_ref()));
11463 self
11464 }
11465 /// Identifies the authorization scope(s) for the method you are building.
11466 ///
11467 /// See [`Self::add_scope()`] for details.
11468 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomDimensionUpdateCall<'a, C>
11469 where
11470 I: IntoIterator<Item = St>,
11471 St: AsRef<str>,
11472 {
11473 self._scopes
11474 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11475 self
11476 }
11477
11478 /// Removes all scopes, and no default scope will be used either.
11479 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11480 /// for details).
11481 pub fn clear_scopes(mut self) -> ManagementCustomDimensionUpdateCall<'a, C> {
11482 self._scopes.clear();
11483 self
11484 }
11485}
11486
11487/// Get a custom metric to which the user has access.
11488///
11489/// A builder for the *customMetrics.get* method supported by a *management* resource.
11490/// It is not used directly, but through a [`ManagementMethods`] instance.
11491///
11492/// # Example
11493///
11494/// Instantiate a resource method builder
11495///
11496/// ```test_harness,no_run
11497/// # extern crate hyper;
11498/// # extern crate hyper_rustls;
11499/// # extern crate google_analytics3 as analytics3;
11500/// # async fn dox() {
11501/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11502///
11503/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11504/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11505/// # secret,
11506/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11507/// # ).build().await.unwrap();
11508///
11509/// # let client = hyper_util::client::legacy::Client::builder(
11510/// # hyper_util::rt::TokioExecutor::new()
11511/// # )
11512/// # .build(
11513/// # hyper_rustls::HttpsConnectorBuilder::new()
11514/// # .with_native_roots()
11515/// # .unwrap()
11516/// # .https_or_http()
11517/// # .enable_http1()
11518/// # .build()
11519/// # );
11520/// # let mut hub = Analytics::new(client, auth);
11521/// // You can configure optional parameters by calling the respective setters at will, and
11522/// // execute the final call using `doit()`.
11523/// // Values shown here are possibly random and not representative !
11524/// let result = hub.management().custom_metrics_get("accountId", "webPropertyId", "customMetricId")
11525/// .doit().await;
11526/// # }
11527/// ```
11528pub struct ManagementCustomMetricGetCall<'a, C>
11529where
11530 C: 'a,
11531{
11532 hub: &'a Analytics<C>,
11533 _account_id: String,
11534 _web_property_id: String,
11535 _custom_metric_id: String,
11536 _delegate: Option<&'a mut dyn common::Delegate>,
11537 _additional_params: HashMap<String, String>,
11538 _scopes: BTreeSet<String>,
11539}
11540
11541impl<'a, C> common::CallBuilder for ManagementCustomMetricGetCall<'a, C> {}
11542
11543impl<'a, C> ManagementCustomMetricGetCall<'a, C>
11544where
11545 C: common::Connector,
11546{
11547 /// Perform the operation you have build so far.
11548 pub async fn doit(mut self) -> common::Result<(common::Response, CustomMetric)> {
11549 use std::borrow::Cow;
11550 use std::io::{Read, Seek};
11551
11552 use common::{url::Params, ToParts};
11553 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11554
11555 let mut dd = common::DefaultDelegate;
11556 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11557 dlg.begin(common::MethodInfo {
11558 id: "analytics.management.customMetrics.get",
11559 http_method: hyper::Method::GET,
11560 });
11561
11562 for &field in ["alt", "accountId", "webPropertyId", "customMetricId"].iter() {
11563 if self._additional_params.contains_key(field) {
11564 dlg.finished(false);
11565 return Err(common::Error::FieldClash(field));
11566 }
11567 }
11568
11569 let mut params = Params::with_capacity(5 + self._additional_params.len());
11570 params.push("accountId", self._account_id);
11571 params.push("webPropertyId", self._web_property_id);
11572 params.push("customMetricId", self._custom_metric_id);
11573
11574 params.extend(self._additional_params.iter());
11575
11576 params.push("alt", "json");
11577 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics/{customMetricId}";
11578 if self._scopes.is_empty() {
11579 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11580 }
11581
11582 #[allow(clippy::single_element_loop)]
11583 for &(find_this, param_name) in [
11584 ("{accountId}", "accountId"),
11585 ("{webPropertyId}", "webPropertyId"),
11586 ("{customMetricId}", "customMetricId"),
11587 ]
11588 .iter()
11589 {
11590 url = params.uri_replacement(url, param_name, find_this, false);
11591 }
11592 {
11593 let to_remove = ["customMetricId", "webPropertyId", "accountId"];
11594 params.remove_params(&to_remove);
11595 }
11596
11597 let url = params.parse_with_url(&url);
11598
11599 loop {
11600 let token = match self
11601 .hub
11602 .auth
11603 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11604 .await
11605 {
11606 Ok(token) => token,
11607 Err(e) => match dlg.token(e) {
11608 Ok(token) => token,
11609 Err(e) => {
11610 dlg.finished(false);
11611 return Err(common::Error::MissingToken(e));
11612 }
11613 },
11614 };
11615 let mut req_result = {
11616 let client = &self.hub.client;
11617 dlg.pre_request();
11618 let mut req_builder = hyper::Request::builder()
11619 .method(hyper::Method::GET)
11620 .uri(url.as_str())
11621 .header(USER_AGENT, self.hub._user_agent.clone());
11622
11623 if let Some(token) = token.as_ref() {
11624 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11625 }
11626
11627 let request = req_builder
11628 .header(CONTENT_LENGTH, 0_u64)
11629 .body(common::to_body::<String>(None));
11630
11631 client.request(request.unwrap()).await
11632 };
11633
11634 match req_result {
11635 Err(err) => {
11636 if let common::Retry::After(d) = dlg.http_error(&err) {
11637 sleep(d).await;
11638 continue;
11639 }
11640 dlg.finished(false);
11641 return Err(common::Error::HttpError(err));
11642 }
11643 Ok(res) => {
11644 let (mut parts, body) = res.into_parts();
11645 let mut body = common::Body::new(body);
11646 if !parts.status.is_success() {
11647 let bytes = common::to_bytes(body).await.unwrap_or_default();
11648 let error = serde_json::from_str(&common::to_string(&bytes));
11649 let response = common::to_response(parts, bytes.into());
11650
11651 if let common::Retry::After(d) =
11652 dlg.http_failure(&response, error.as_ref().ok())
11653 {
11654 sleep(d).await;
11655 continue;
11656 }
11657
11658 dlg.finished(false);
11659
11660 return Err(match error {
11661 Ok(value) => common::Error::BadRequest(value),
11662 _ => common::Error::Failure(response),
11663 });
11664 }
11665 let response = {
11666 let bytes = common::to_bytes(body).await.unwrap_or_default();
11667 let encoded = common::to_string(&bytes);
11668 match serde_json::from_str(&encoded) {
11669 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11670 Err(error) => {
11671 dlg.response_json_decode_error(&encoded, &error);
11672 return Err(common::Error::JsonDecodeError(
11673 encoded.to_string(),
11674 error,
11675 ));
11676 }
11677 }
11678 };
11679
11680 dlg.finished(true);
11681 return Ok(response);
11682 }
11683 }
11684 }
11685 }
11686
11687 /// Account ID for the custom metric to retrieve.
11688 ///
11689 /// Sets the *account id* path property to the given value.
11690 ///
11691 /// Even though the property as already been set when instantiating this call,
11692 /// we provide this method for API completeness.
11693 pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricGetCall<'a, C> {
11694 self._account_id = new_value.to_string();
11695 self
11696 }
11697 /// Web property ID for the custom metric to retrieve.
11698 ///
11699 /// Sets the *web property id* path property to the given value.
11700 ///
11701 /// Even though the property as already been set when instantiating this call,
11702 /// we provide this method for API completeness.
11703 pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricGetCall<'a, C> {
11704 self._web_property_id = new_value.to_string();
11705 self
11706 }
11707 /// The ID of the custom metric to retrieve.
11708 ///
11709 /// Sets the *custom metric id* path property to the given value.
11710 ///
11711 /// Even though the property as already been set when instantiating this call,
11712 /// we provide this method for API completeness.
11713 pub fn custom_metric_id(mut self, new_value: &str) -> ManagementCustomMetricGetCall<'a, C> {
11714 self._custom_metric_id = new_value.to_string();
11715 self
11716 }
11717 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11718 /// while executing the actual API request.
11719 ///
11720 /// ````text
11721 /// It should be used to handle progress information, and to implement a certain level of resilience.
11722 /// ````
11723 ///
11724 /// Sets the *delegate* property to the given value.
11725 pub fn delegate(
11726 mut self,
11727 new_value: &'a mut dyn common::Delegate,
11728 ) -> ManagementCustomMetricGetCall<'a, C> {
11729 self._delegate = Some(new_value);
11730 self
11731 }
11732
11733 /// Set any additional parameter of the query string used in the request.
11734 /// It should be used to set parameters which are not yet available through their own
11735 /// setters.
11736 ///
11737 /// Please note that this method must not be used to set any of the known parameters
11738 /// which have their own setter method. If done anyway, the request will fail.
11739 ///
11740 /// # Additional Parameters
11741 ///
11742 /// * *alt* (query-string) - Data format for the response.
11743 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11744 /// * *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.
11745 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11746 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11747 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11748 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11749 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomMetricGetCall<'a, C>
11750 where
11751 T: AsRef<str>,
11752 {
11753 self._additional_params
11754 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11755 self
11756 }
11757
11758 /// Identifies the authorization scope for the method you are building.
11759 ///
11760 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11761 /// [`Scope::Readonly`].
11762 ///
11763 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11764 /// tokens for more than one scope.
11765 ///
11766 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11767 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11768 /// sufficient, a read-write scope will do as well.
11769 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomMetricGetCall<'a, C>
11770 where
11771 St: AsRef<str>,
11772 {
11773 self._scopes.insert(String::from(scope.as_ref()));
11774 self
11775 }
11776 /// Identifies the authorization scope(s) for the method you are building.
11777 ///
11778 /// See [`Self::add_scope()`] for details.
11779 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomMetricGetCall<'a, C>
11780 where
11781 I: IntoIterator<Item = St>,
11782 St: AsRef<str>,
11783 {
11784 self._scopes
11785 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11786 self
11787 }
11788
11789 /// Removes all scopes, and no default scope will be used either.
11790 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11791 /// for details).
11792 pub fn clear_scopes(mut self) -> ManagementCustomMetricGetCall<'a, C> {
11793 self._scopes.clear();
11794 self
11795 }
11796}
11797
11798/// Create a new custom metric.
11799///
11800/// A builder for the *customMetrics.insert* method supported by a *management* resource.
11801/// It is not used directly, but through a [`ManagementMethods`] instance.
11802///
11803/// # Example
11804///
11805/// Instantiate a resource method builder
11806///
11807/// ```test_harness,no_run
11808/// # extern crate hyper;
11809/// # extern crate hyper_rustls;
11810/// # extern crate google_analytics3 as analytics3;
11811/// use analytics3::api::CustomMetric;
11812/// # async fn dox() {
11813/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11814///
11815/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11816/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11817/// # secret,
11818/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11819/// # ).build().await.unwrap();
11820///
11821/// # let client = hyper_util::client::legacy::Client::builder(
11822/// # hyper_util::rt::TokioExecutor::new()
11823/// # )
11824/// # .build(
11825/// # hyper_rustls::HttpsConnectorBuilder::new()
11826/// # .with_native_roots()
11827/// # .unwrap()
11828/// # .https_or_http()
11829/// # .enable_http1()
11830/// # .build()
11831/// # );
11832/// # let mut hub = Analytics::new(client, auth);
11833/// // As the method needs a request, you would usually fill it with the desired information
11834/// // into the respective structure. Some of the parts shown here might not be applicable !
11835/// // Values shown here are possibly random and not representative !
11836/// let mut req = CustomMetric::default();
11837///
11838/// // You can configure optional parameters by calling the respective setters at will, and
11839/// // execute the final call using `doit()`.
11840/// // Values shown here are possibly random and not representative !
11841/// let result = hub.management().custom_metrics_insert(req, "accountId", "webPropertyId")
11842/// .doit().await;
11843/// # }
11844/// ```
11845pub struct ManagementCustomMetricInsertCall<'a, C>
11846where
11847 C: 'a,
11848{
11849 hub: &'a Analytics<C>,
11850 _request: CustomMetric,
11851 _account_id: String,
11852 _web_property_id: String,
11853 _delegate: Option<&'a mut dyn common::Delegate>,
11854 _additional_params: HashMap<String, String>,
11855 _scopes: BTreeSet<String>,
11856}
11857
11858impl<'a, C> common::CallBuilder for ManagementCustomMetricInsertCall<'a, C> {}
11859
11860impl<'a, C> ManagementCustomMetricInsertCall<'a, C>
11861where
11862 C: common::Connector,
11863{
11864 /// Perform the operation you have build so far.
11865 pub async fn doit(mut self) -> common::Result<(common::Response, CustomMetric)> {
11866 use std::borrow::Cow;
11867 use std::io::{Read, Seek};
11868
11869 use common::{url::Params, ToParts};
11870 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11871
11872 let mut dd = common::DefaultDelegate;
11873 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11874 dlg.begin(common::MethodInfo {
11875 id: "analytics.management.customMetrics.insert",
11876 http_method: hyper::Method::POST,
11877 });
11878
11879 for &field in ["alt", "accountId", "webPropertyId"].iter() {
11880 if self._additional_params.contains_key(field) {
11881 dlg.finished(false);
11882 return Err(common::Error::FieldClash(field));
11883 }
11884 }
11885
11886 let mut params = Params::with_capacity(5 + self._additional_params.len());
11887 params.push("accountId", self._account_id);
11888 params.push("webPropertyId", self._web_property_id);
11889
11890 params.extend(self._additional_params.iter());
11891
11892 params.push("alt", "json");
11893 let mut url = self.hub._base_url.clone()
11894 + "management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics";
11895 if self._scopes.is_empty() {
11896 self._scopes.insert(Scope::Edit.as_ref().to_string());
11897 }
11898
11899 #[allow(clippy::single_element_loop)]
11900 for &(find_this, param_name) in [
11901 ("{accountId}", "accountId"),
11902 ("{webPropertyId}", "webPropertyId"),
11903 ]
11904 .iter()
11905 {
11906 url = params.uri_replacement(url, param_name, find_this, false);
11907 }
11908 {
11909 let to_remove = ["webPropertyId", "accountId"];
11910 params.remove_params(&to_remove);
11911 }
11912
11913 let url = params.parse_with_url(&url);
11914
11915 let mut json_mime_type = mime::APPLICATION_JSON;
11916 let mut request_value_reader = {
11917 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11918 common::remove_json_null_values(&mut value);
11919 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11920 serde_json::to_writer(&mut dst, &value).unwrap();
11921 dst
11922 };
11923 let request_size = request_value_reader
11924 .seek(std::io::SeekFrom::End(0))
11925 .unwrap();
11926 request_value_reader
11927 .seek(std::io::SeekFrom::Start(0))
11928 .unwrap();
11929
11930 loop {
11931 let token = match self
11932 .hub
11933 .auth
11934 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11935 .await
11936 {
11937 Ok(token) => token,
11938 Err(e) => match dlg.token(e) {
11939 Ok(token) => token,
11940 Err(e) => {
11941 dlg.finished(false);
11942 return Err(common::Error::MissingToken(e));
11943 }
11944 },
11945 };
11946 request_value_reader
11947 .seek(std::io::SeekFrom::Start(0))
11948 .unwrap();
11949 let mut req_result = {
11950 let client = &self.hub.client;
11951 dlg.pre_request();
11952 let mut req_builder = hyper::Request::builder()
11953 .method(hyper::Method::POST)
11954 .uri(url.as_str())
11955 .header(USER_AGENT, self.hub._user_agent.clone());
11956
11957 if let Some(token) = token.as_ref() {
11958 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11959 }
11960
11961 let request = req_builder
11962 .header(CONTENT_TYPE, json_mime_type.to_string())
11963 .header(CONTENT_LENGTH, request_size as u64)
11964 .body(common::to_body(
11965 request_value_reader.get_ref().clone().into(),
11966 ));
11967
11968 client.request(request.unwrap()).await
11969 };
11970
11971 match req_result {
11972 Err(err) => {
11973 if let common::Retry::After(d) = dlg.http_error(&err) {
11974 sleep(d).await;
11975 continue;
11976 }
11977 dlg.finished(false);
11978 return Err(common::Error::HttpError(err));
11979 }
11980 Ok(res) => {
11981 let (mut parts, body) = res.into_parts();
11982 let mut body = common::Body::new(body);
11983 if !parts.status.is_success() {
11984 let bytes = common::to_bytes(body).await.unwrap_or_default();
11985 let error = serde_json::from_str(&common::to_string(&bytes));
11986 let response = common::to_response(parts, bytes.into());
11987
11988 if let common::Retry::After(d) =
11989 dlg.http_failure(&response, error.as_ref().ok())
11990 {
11991 sleep(d).await;
11992 continue;
11993 }
11994
11995 dlg.finished(false);
11996
11997 return Err(match error {
11998 Ok(value) => common::Error::BadRequest(value),
11999 _ => common::Error::Failure(response),
12000 });
12001 }
12002 let response = {
12003 let bytes = common::to_bytes(body).await.unwrap_or_default();
12004 let encoded = common::to_string(&bytes);
12005 match serde_json::from_str(&encoded) {
12006 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12007 Err(error) => {
12008 dlg.response_json_decode_error(&encoded, &error);
12009 return Err(common::Error::JsonDecodeError(
12010 encoded.to_string(),
12011 error,
12012 ));
12013 }
12014 }
12015 };
12016
12017 dlg.finished(true);
12018 return Ok(response);
12019 }
12020 }
12021 }
12022 }
12023
12024 ///
12025 /// Sets the *request* property to the given value.
12026 ///
12027 /// Even though the property as already been set when instantiating this call,
12028 /// we provide this method for API completeness.
12029 pub fn request(mut self, new_value: CustomMetric) -> ManagementCustomMetricInsertCall<'a, C> {
12030 self._request = new_value;
12031 self
12032 }
12033 /// Account ID for the custom metric to create.
12034 ///
12035 /// Sets the *account id* path property to the given value.
12036 ///
12037 /// Even though the property as already been set when instantiating this call,
12038 /// we provide this method for API completeness.
12039 pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricInsertCall<'a, C> {
12040 self._account_id = new_value.to_string();
12041 self
12042 }
12043 /// Web property ID for the custom dimension to create.
12044 ///
12045 /// Sets the *web property id* path property to the given value.
12046 ///
12047 /// Even though the property as already been set when instantiating this call,
12048 /// we provide this method for API completeness.
12049 pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricInsertCall<'a, C> {
12050 self._web_property_id = new_value.to_string();
12051 self
12052 }
12053 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12054 /// while executing the actual API request.
12055 ///
12056 /// ````text
12057 /// It should be used to handle progress information, and to implement a certain level of resilience.
12058 /// ````
12059 ///
12060 /// Sets the *delegate* property to the given value.
12061 pub fn delegate(
12062 mut self,
12063 new_value: &'a mut dyn common::Delegate,
12064 ) -> ManagementCustomMetricInsertCall<'a, C> {
12065 self._delegate = Some(new_value);
12066 self
12067 }
12068
12069 /// Set any additional parameter of the query string used in the request.
12070 /// It should be used to set parameters which are not yet available through their own
12071 /// setters.
12072 ///
12073 /// Please note that this method must not be used to set any of the known parameters
12074 /// which have their own setter method. If done anyway, the request will fail.
12075 ///
12076 /// # Additional Parameters
12077 ///
12078 /// * *alt* (query-string) - Data format for the response.
12079 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12080 /// * *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.
12081 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12082 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12083 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12084 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12085 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomMetricInsertCall<'a, C>
12086 where
12087 T: AsRef<str>,
12088 {
12089 self._additional_params
12090 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12091 self
12092 }
12093
12094 /// Identifies the authorization scope for the method you are building.
12095 ///
12096 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12097 /// [`Scope::Edit`].
12098 ///
12099 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12100 /// tokens for more than one scope.
12101 ///
12102 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12103 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12104 /// sufficient, a read-write scope will do as well.
12105 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomMetricInsertCall<'a, C>
12106 where
12107 St: AsRef<str>,
12108 {
12109 self._scopes.insert(String::from(scope.as_ref()));
12110 self
12111 }
12112 /// Identifies the authorization scope(s) for the method you are building.
12113 ///
12114 /// See [`Self::add_scope()`] for details.
12115 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomMetricInsertCall<'a, C>
12116 where
12117 I: IntoIterator<Item = St>,
12118 St: AsRef<str>,
12119 {
12120 self._scopes
12121 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12122 self
12123 }
12124
12125 /// Removes all scopes, and no default scope will be used either.
12126 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12127 /// for details).
12128 pub fn clear_scopes(mut self) -> ManagementCustomMetricInsertCall<'a, C> {
12129 self._scopes.clear();
12130 self
12131 }
12132}
12133
12134/// Lists custom metrics to which the user has access.
12135///
12136/// A builder for the *customMetrics.list* method supported by a *management* resource.
12137/// It is not used directly, but through a [`ManagementMethods`] instance.
12138///
12139/// # Example
12140///
12141/// Instantiate a resource method builder
12142///
12143/// ```test_harness,no_run
12144/// # extern crate hyper;
12145/// # extern crate hyper_rustls;
12146/// # extern crate google_analytics3 as analytics3;
12147/// # async fn dox() {
12148/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12149///
12150/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12151/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12152/// # secret,
12153/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12154/// # ).build().await.unwrap();
12155///
12156/// # let client = hyper_util::client::legacy::Client::builder(
12157/// # hyper_util::rt::TokioExecutor::new()
12158/// # )
12159/// # .build(
12160/// # hyper_rustls::HttpsConnectorBuilder::new()
12161/// # .with_native_roots()
12162/// # .unwrap()
12163/// # .https_or_http()
12164/// # .enable_http1()
12165/// # .build()
12166/// # );
12167/// # let mut hub = Analytics::new(client, auth);
12168/// // You can configure optional parameters by calling the respective setters at will, and
12169/// // execute the final call using `doit()`.
12170/// // Values shown here are possibly random and not representative !
12171/// let result = hub.management().custom_metrics_list("accountId", "webPropertyId")
12172/// .start_index(-2)
12173/// .max_results(-30)
12174/// .doit().await;
12175/// # }
12176/// ```
12177pub struct ManagementCustomMetricListCall<'a, C>
12178where
12179 C: 'a,
12180{
12181 hub: &'a Analytics<C>,
12182 _account_id: String,
12183 _web_property_id: String,
12184 _start_index: Option<i32>,
12185 _max_results: Option<i32>,
12186 _delegate: Option<&'a mut dyn common::Delegate>,
12187 _additional_params: HashMap<String, String>,
12188 _scopes: BTreeSet<String>,
12189}
12190
12191impl<'a, C> common::CallBuilder for ManagementCustomMetricListCall<'a, C> {}
12192
12193impl<'a, C> ManagementCustomMetricListCall<'a, C>
12194where
12195 C: common::Connector,
12196{
12197 /// Perform the operation you have build so far.
12198 pub async fn doit(mut self) -> common::Result<(common::Response, CustomMetrics)> {
12199 use std::borrow::Cow;
12200 use std::io::{Read, Seek};
12201
12202 use common::{url::Params, ToParts};
12203 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12204
12205 let mut dd = common::DefaultDelegate;
12206 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12207 dlg.begin(common::MethodInfo {
12208 id: "analytics.management.customMetrics.list",
12209 http_method: hyper::Method::GET,
12210 });
12211
12212 for &field in [
12213 "alt",
12214 "accountId",
12215 "webPropertyId",
12216 "start-index",
12217 "max-results",
12218 ]
12219 .iter()
12220 {
12221 if self._additional_params.contains_key(field) {
12222 dlg.finished(false);
12223 return Err(common::Error::FieldClash(field));
12224 }
12225 }
12226
12227 let mut params = Params::with_capacity(6 + self._additional_params.len());
12228 params.push("accountId", self._account_id);
12229 params.push("webPropertyId", self._web_property_id);
12230 if let Some(value) = self._start_index.as_ref() {
12231 params.push("start-index", value.to_string());
12232 }
12233 if let Some(value) = self._max_results.as_ref() {
12234 params.push("max-results", value.to_string());
12235 }
12236
12237 params.extend(self._additional_params.iter());
12238
12239 params.push("alt", "json");
12240 let mut url = self.hub._base_url.clone()
12241 + "management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics";
12242 if self._scopes.is_empty() {
12243 self._scopes.insert(Scope::Readonly.as_ref().to_string());
12244 }
12245
12246 #[allow(clippy::single_element_loop)]
12247 for &(find_this, param_name) in [
12248 ("{accountId}", "accountId"),
12249 ("{webPropertyId}", "webPropertyId"),
12250 ]
12251 .iter()
12252 {
12253 url = params.uri_replacement(url, param_name, find_this, false);
12254 }
12255 {
12256 let to_remove = ["webPropertyId", "accountId"];
12257 params.remove_params(&to_remove);
12258 }
12259
12260 let url = params.parse_with_url(&url);
12261
12262 loop {
12263 let token = match self
12264 .hub
12265 .auth
12266 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12267 .await
12268 {
12269 Ok(token) => token,
12270 Err(e) => match dlg.token(e) {
12271 Ok(token) => token,
12272 Err(e) => {
12273 dlg.finished(false);
12274 return Err(common::Error::MissingToken(e));
12275 }
12276 },
12277 };
12278 let mut req_result = {
12279 let client = &self.hub.client;
12280 dlg.pre_request();
12281 let mut req_builder = hyper::Request::builder()
12282 .method(hyper::Method::GET)
12283 .uri(url.as_str())
12284 .header(USER_AGENT, self.hub._user_agent.clone());
12285
12286 if let Some(token) = token.as_ref() {
12287 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12288 }
12289
12290 let request = req_builder
12291 .header(CONTENT_LENGTH, 0_u64)
12292 .body(common::to_body::<String>(None));
12293
12294 client.request(request.unwrap()).await
12295 };
12296
12297 match req_result {
12298 Err(err) => {
12299 if let common::Retry::After(d) = dlg.http_error(&err) {
12300 sleep(d).await;
12301 continue;
12302 }
12303 dlg.finished(false);
12304 return Err(common::Error::HttpError(err));
12305 }
12306 Ok(res) => {
12307 let (mut parts, body) = res.into_parts();
12308 let mut body = common::Body::new(body);
12309 if !parts.status.is_success() {
12310 let bytes = common::to_bytes(body).await.unwrap_or_default();
12311 let error = serde_json::from_str(&common::to_string(&bytes));
12312 let response = common::to_response(parts, bytes.into());
12313
12314 if let common::Retry::After(d) =
12315 dlg.http_failure(&response, error.as_ref().ok())
12316 {
12317 sleep(d).await;
12318 continue;
12319 }
12320
12321 dlg.finished(false);
12322
12323 return Err(match error {
12324 Ok(value) => common::Error::BadRequest(value),
12325 _ => common::Error::Failure(response),
12326 });
12327 }
12328 let response = {
12329 let bytes = common::to_bytes(body).await.unwrap_or_default();
12330 let encoded = common::to_string(&bytes);
12331 match serde_json::from_str(&encoded) {
12332 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12333 Err(error) => {
12334 dlg.response_json_decode_error(&encoded, &error);
12335 return Err(common::Error::JsonDecodeError(
12336 encoded.to_string(),
12337 error,
12338 ));
12339 }
12340 }
12341 };
12342
12343 dlg.finished(true);
12344 return Ok(response);
12345 }
12346 }
12347 }
12348 }
12349
12350 /// Account ID for the custom metrics to retrieve.
12351 ///
12352 /// Sets the *account id* path property to the given value.
12353 ///
12354 /// Even though the property as already been set when instantiating this call,
12355 /// we provide this method for API completeness.
12356 pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricListCall<'a, C> {
12357 self._account_id = new_value.to_string();
12358 self
12359 }
12360 /// Web property ID for the custom metrics to retrieve.
12361 ///
12362 /// Sets the *web property id* path property to the given value.
12363 ///
12364 /// Even though the property as already been set when instantiating this call,
12365 /// we provide this method for API completeness.
12366 pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricListCall<'a, C> {
12367 self._web_property_id = new_value.to_string();
12368 self
12369 }
12370 /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
12371 ///
12372 /// Sets the *start-index* query property to the given value.
12373 pub fn start_index(mut self, new_value: i32) -> ManagementCustomMetricListCall<'a, C> {
12374 self._start_index = Some(new_value);
12375 self
12376 }
12377 /// The maximum number of custom metrics to include in this response.
12378 ///
12379 /// Sets the *max-results* query property to the given value.
12380 pub fn max_results(mut self, new_value: i32) -> ManagementCustomMetricListCall<'a, C> {
12381 self._max_results = Some(new_value);
12382 self
12383 }
12384 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12385 /// while executing the actual API request.
12386 ///
12387 /// ````text
12388 /// It should be used to handle progress information, and to implement a certain level of resilience.
12389 /// ````
12390 ///
12391 /// Sets the *delegate* property to the given value.
12392 pub fn delegate(
12393 mut self,
12394 new_value: &'a mut dyn common::Delegate,
12395 ) -> ManagementCustomMetricListCall<'a, C> {
12396 self._delegate = Some(new_value);
12397 self
12398 }
12399
12400 /// Set any additional parameter of the query string used in the request.
12401 /// It should be used to set parameters which are not yet available through their own
12402 /// setters.
12403 ///
12404 /// Please note that this method must not be used to set any of the known parameters
12405 /// which have their own setter method. If done anyway, the request will fail.
12406 ///
12407 /// # Additional Parameters
12408 ///
12409 /// * *alt* (query-string) - Data format for the response.
12410 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12411 /// * *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.
12412 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12413 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12414 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12415 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12416 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomMetricListCall<'a, C>
12417 where
12418 T: AsRef<str>,
12419 {
12420 self._additional_params
12421 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12422 self
12423 }
12424
12425 /// Identifies the authorization scope for the method you are building.
12426 ///
12427 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12428 /// [`Scope::Readonly`].
12429 ///
12430 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12431 /// tokens for more than one scope.
12432 ///
12433 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12434 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12435 /// sufficient, a read-write scope will do as well.
12436 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomMetricListCall<'a, C>
12437 where
12438 St: AsRef<str>,
12439 {
12440 self._scopes.insert(String::from(scope.as_ref()));
12441 self
12442 }
12443 /// Identifies the authorization scope(s) for the method you are building.
12444 ///
12445 /// See [`Self::add_scope()`] for details.
12446 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomMetricListCall<'a, C>
12447 where
12448 I: IntoIterator<Item = St>,
12449 St: AsRef<str>,
12450 {
12451 self._scopes
12452 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12453 self
12454 }
12455
12456 /// Removes all scopes, and no default scope will be used either.
12457 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12458 /// for details).
12459 pub fn clear_scopes(mut self) -> ManagementCustomMetricListCall<'a, C> {
12460 self._scopes.clear();
12461 self
12462 }
12463}
12464
12465/// Updates an existing custom metric. This method supports patch semantics.
12466///
12467/// A builder for the *customMetrics.patch* method supported by a *management* resource.
12468/// It is not used directly, but through a [`ManagementMethods`] instance.
12469///
12470/// # Example
12471///
12472/// Instantiate a resource method builder
12473///
12474/// ```test_harness,no_run
12475/// # extern crate hyper;
12476/// # extern crate hyper_rustls;
12477/// # extern crate google_analytics3 as analytics3;
12478/// use analytics3::api::CustomMetric;
12479/// # async fn dox() {
12480/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12481///
12482/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12483/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12484/// # secret,
12485/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12486/// # ).build().await.unwrap();
12487///
12488/// # let client = hyper_util::client::legacy::Client::builder(
12489/// # hyper_util::rt::TokioExecutor::new()
12490/// # )
12491/// # .build(
12492/// # hyper_rustls::HttpsConnectorBuilder::new()
12493/// # .with_native_roots()
12494/// # .unwrap()
12495/// # .https_or_http()
12496/// # .enable_http1()
12497/// # .build()
12498/// # );
12499/// # let mut hub = Analytics::new(client, auth);
12500/// // As the method needs a request, you would usually fill it with the desired information
12501/// // into the respective structure. Some of the parts shown here might not be applicable !
12502/// // Values shown here are possibly random and not representative !
12503/// let mut req = CustomMetric::default();
12504///
12505/// // You can configure optional parameters by calling the respective setters at will, and
12506/// // execute the final call using `doit()`.
12507/// // Values shown here are possibly random and not representative !
12508/// let result = hub.management().custom_metrics_patch(req, "accountId", "webPropertyId", "customMetricId")
12509/// .ignore_custom_data_source_links(false)
12510/// .doit().await;
12511/// # }
12512/// ```
12513pub struct ManagementCustomMetricPatchCall<'a, C>
12514where
12515 C: 'a,
12516{
12517 hub: &'a Analytics<C>,
12518 _request: CustomMetric,
12519 _account_id: String,
12520 _web_property_id: String,
12521 _custom_metric_id: String,
12522 _ignore_custom_data_source_links: Option<bool>,
12523 _delegate: Option<&'a mut dyn common::Delegate>,
12524 _additional_params: HashMap<String, String>,
12525 _scopes: BTreeSet<String>,
12526}
12527
12528impl<'a, C> common::CallBuilder for ManagementCustomMetricPatchCall<'a, C> {}
12529
12530impl<'a, C> ManagementCustomMetricPatchCall<'a, C>
12531where
12532 C: common::Connector,
12533{
12534 /// Perform the operation you have build so far.
12535 pub async fn doit(mut self) -> common::Result<(common::Response, CustomMetric)> {
12536 use std::borrow::Cow;
12537 use std::io::{Read, Seek};
12538
12539 use common::{url::Params, ToParts};
12540 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12541
12542 let mut dd = common::DefaultDelegate;
12543 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12544 dlg.begin(common::MethodInfo {
12545 id: "analytics.management.customMetrics.patch",
12546 http_method: hyper::Method::PATCH,
12547 });
12548
12549 for &field in [
12550 "alt",
12551 "accountId",
12552 "webPropertyId",
12553 "customMetricId",
12554 "ignoreCustomDataSourceLinks",
12555 ]
12556 .iter()
12557 {
12558 if self._additional_params.contains_key(field) {
12559 dlg.finished(false);
12560 return Err(common::Error::FieldClash(field));
12561 }
12562 }
12563
12564 let mut params = Params::with_capacity(7 + self._additional_params.len());
12565 params.push("accountId", self._account_id);
12566 params.push("webPropertyId", self._web_property_id);
12567 params.push("customMetricId", self._custom_metric_id);
12568 if let Some(value) = self._ignore_custom_data_source_links.as_ref() {
12569 params.push("ignoreCustomDataSourceLinks", value.to_string());
12570 }
12571
12572 params.extend(self._additional_params.iter());
12573
12574 params.push("alt", "json");
12575 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics/{customMetricId}";
12576 if self._scopes.is_empty() {
12577 self._scopes.insert(Scope::Edit.as_ref().to_string());
12578 }
12579
12580 #[allow(clippy::single_element_loop)]
12581 for &(find_this, param_name) in [
12582 ("{accountId}", "accountId"),
12583 ("{webPropertyId}", "webPropertyId"),
12584 ("{customMetricId}", "customMetricId"),
12585 ]
12586 .iter()
12587 {
12588 url = params.uri_replacement(url, param_name, find_this, false);
12589 }
12590 {
12591 let to_remove = ["customMetricId", "webPropertyId", "accountId"];
12592 params.remove_params(&to_remove);
12593 }
12594
12595 let url = params.parse_with_url(&url);
12596
12597 let mut json_mime_type = mime::APPLICATION_JSON;
12598 let mut request_value_reader = {
12599 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12600 common::remove_json_null_values(&mut value);
12601 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12602 serde_json::to_writer(&mut dst, &value).unwrap();
12603 dst
12604 };
12605 let request_size = request_value_reader
12606 .seek(std::io::SeekFrom::End(0))
12607 .unwrap();
12608 request_value_reader
12609 .seek(std::io::SeekFrom::Start(0))
12610 .unwrap();
12611
12612 loop {
12613 let token = match self
12614 .hub
12615 .auth
12616 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12617 .await
12618 {
12619 Ok(token) => token,
12620 Err(e) => match dlg.token(e) {
12621 Ok(token) => token,
12622 Err(e) => {
12623 dlg.finished(false);
12624 return Err(common::Error::MissingToken(e));
12625 }
12626 },
12627 };
12628 request_value_reader
12629 .seek(std::io::SeekFrom::Start(0))
12630 .unwrap();
12631 let mut req_result = {
12632 let client = &self.hub.client;
12633 dlg.pre_request();
12634 let mut req_builder = hyper::Request::builder()
12635 .method(hyper::Method::PATCH)
12636 .uri(url.as_str())
12637 .header(USER_AGENT, self.hub._user_agent.clone());
12638
12639 if let Some(token) = token.as_ref() {
12640 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12641 }
12642
12643 let request = req_builder
12644 .header(CONTENT_TYPE, json_mime_type.to_string())
12645 .header(CONTENT_LENGTH, request_size as u64)
12646 .body(common::to_body(
12647 request_value_reader.get_ref().clone().into(),
12648 ));
12649
12650 client.request(request.unwrap()).await
12651 };
12652
12653 match req_result {
12654 Err(err) => {
12655 if let common::Retry::After(d) = dlg.http_error(&err) {
12656 sleep(d).await;
12657 continue;
12658 }
12659 dlg.finished(false);
12660 return Err(common::Error::HttpError(err));
12661 }
12662 Ok(res) => {
12663 let (mut parts, body) = res.into_parts();
12664 let mut body = common::Body::new(body);
12665 if !parts.status.is_success() {
12666 let bytes = common::to_bytes(body).await.unwrap_or_default();
12667 let error = serde_json::from_str(&common::to_string(&bytes));
12668 let response = common::to_response(parts, bytes.into());
12669
12670 if let common::Retry::After(d) =
12671 dlg.http_failure(&response, error.as_ref().ok())
12672 {
12673 sleep(d).await;
12674 continue;
12675 }
12676
12677 dlg.finished(false);
12678
12679 return Err(match error {
12680 Ok(value) => common::Error::BadRequest(value),
12681 _ => common::Error::Failure(response),
12682 });
12683 }
12684 let response = {
12685 let bytes = common::to_bytes(body).await.unwrap_or_default();
12686 let encoded = common::to_string(&bytes);
12687 match serde_json::from_str(&encoded) {
12688 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12689 Err(error) => {
12690 dlg.response_json_decode_error(&encoded, &error);
12691 return Err(common::Error::JsonDecodeError(
12692 encoded.to_string(),
12693 error,
12694 ));
12695 }
12696 }
12697 };
12698
12699 dlg.finished(true);
12700 return Ok(response);
12701 }
12702 }
12703 }
12704 }
12705
12706 ///
12707 /// Sets the *request* property to the given value.
12708 ///
12709 /// Even though the property as already been set when instantiating this call,
12710 /// we provide this method for API completeness.
12711 pub fn request(mut self, new_value: CustomMetric) -> ManagementCustomMetricPatchCall<'a, C> {
12712 self._request = new_value;
12713 self
12714 }
12715 /// Account ID for the custom metric to update.
12716 ///
12717 /// Sets the *account id* path property to the given value.
12718 ///
12719 /// Even though the property as already been set when instantiating this call,
12720 /// we provide this method for API completeness.
12721 pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricPatchCall<'a, C> {
12722 self._account_id = new_value.to_string();
12723 self
12724 }
12725 /// Web property ID for the custom metric to update.
12726 ///
12727 /// Sets the *web property id* path property to the given value.
12728 ///
12729 /// Even though the property as already been set when instantiating this call,
12730 /// we provide this method for API completeness.
12731 pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricPatchCall<'a, C> {
12732 self._web_property_id = new_value.to_string();
12733 self
12734 }
12735 /// Custom metric ID for the custom metric to update.
12736 ///
12737 /// Sets the *custom metric id* path property to the given value.
12738 ///
12739 /// Even though the property as already been set when instantiating this call,
12740 /// we provide this method for API completeness.
12741 pub fn custom_metric_id(mut self, new_value: &str) -> ManagementCustomMetricPatchCall<'a, C> {
12742 self._custom_metric_id = new_value.to_string();
12743 self
12744 }
12745 /// Force the update and ignore any warnings related to the custom metric being linked to a custom data source / data set.
12746 ///
12747 /// Sets the *ignore custom data source links* query property to the given value.
12748 pub fn ignore_custom_data_source_links(
12749 mut self,
12750 new_value: bool,
12751 ) -> ManagementCustomMetricPatchCall<'a, C> {
12752 self._ignore_custom_data_source_links = Some(new_value);
12753 self
12754 }
12755 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12756 /// while executing the actual API request.
12757 ///
12758 /// ````text
12759 /// It should be used to handle progress information, and to implement a certain level of resilience.
12760 /// ````
12761 ///
12762 /// Sets the *delegate* property to the given value.
12763 pub fn delegate(
12764 mut self,
12765 new_value: &'a mut dyn common::Delegate,
12766 ) -> ManagementCustomMetricPatchCall<'a, C> {
12767 self._delegate = Some(new_value);
12768 self
12769 }
12770
12771 /// Set any additional parameter of the query string used in the request.
12772 /// It should be used to set parameters which are not yet available through their own
12773 /// setters.
12774 ///
12775 /// Please note that this method must not be used to set any of the known parameters
12776 /// which have their own setter method. If done anyway, the request will fail.
12777 ///
12778 /// # Additional Parameters
12779 ///
12780 /// * *alt* (query-string) - Data format for the response.
12781 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12782 /// * *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.
12783 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12784 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12785 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12786 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12787 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomMetricPatchCall<'a, C>
12788 where
12789 T: AsRef<str>,
12790 {
12791 self._additional_params
12792 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12793 self
12794 }
12795
12796 /// Identifies the authorization scope for the method you are building.
12797 ///
12798 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12799 /// [`Scope::Edit`].
12800 ///
12801 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12802 /// tokens for more than one scope.
12803 ///
12804 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12805 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12806 /// sufficient, a read-write scope will do as well.
12807 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomMetricPatchCall<'a, C>
12808 where
12809 St: AsRef<str>,
12810 {
12811 self._scopes.insert(String::from(scope.as_ref()));
12812 self
12813 }
12814 /// Identifies the authorization scope(s) for the method you are building.
12815 ///
12816 /// See [`Self::add_scope()`] for details.
12817 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomMetricPatchCall<'a, C>
12818 where
12819 I: IntoIterator<Item = St>,
12820 St: AsRef<str>,
12821 {
12822 self._scopes
12823 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12824 self
12825 }
12826
12827 /// Removes all scopes, and no default scope will be used either.
12828 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12829 /// for details).
12830 pub fn clear_scopes(mut self) -> ManagementCustomMetricPatchCall<'a, C> {
12831 self._scopes.clear();
12832 self
12833 }
12834}
12835
12836/// Updates an existing custom metric.
12837///
12838/// A builder for the *customMetrics.update* method supported by a *management* resource.
12839/// It is not used directly, but through a [`ManagementMethods`] instance.
12840///
12841/// # Example
12842///
12843/// Instantiate a resource method builder
12844///
12845/// ```test_harness,no_run
12846/// # extern crate hyper;
12847/// # extern crate hyper_rustls;
12848/// # extern crate google_analytics3 as analytics3;
12849/// use analytics3::api::CustomMetric;
12850/// # async fn dox() {
12851/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12852///
12853/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12854/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12855/// # secret,
12856/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12857/// # ).build().await.unwrap();
12858///
12859/// # let client = hyper_util::client::legacy::Client::builder(
12860/// # hyper_util::rt::TokioExecutor::new()
12861/// # )
12862/// # .build(
12863/// # hyper_rustls::HttpsConnectorBuilder::new()
12864/// # .with_native_roots()
12865/// # .unwrap()
12866/// # .https_or_http()
12867/// # .enable_http1()
12868/// # .build()
12869/// # );
12870/// # let mut hub = Analytics::new(client, auth);
12871/// // As the method needs a request, you would usually fill it with the desired information
12872/// // into the respective structure. Some of the parts shown here might not be applicable !
12873/// // Values shown here are possibly random and not representative !
12874/// let mut req = CustomMetric::default();
12875///
12876/// // You can configure optional parameters by calling the respective setters at will, and
12877/// // execute the final call using `doit()`.
12878/// // Values shown here are possibly random and not representative !
12879/// let result = hub.management().custom_metrics_update(req, "accountId", "webPropertyId", "customMetricId")
12880/// .ignore_custom_data_source_links(false)
12881/// .doit().await;
12882/// # }
12883/// ```
12884pub struct ManagementCustomMetricUpdateCall<'a, C>
12885where
12886 C: 'a,
12887{
12888 hub: &'a Analytics<C>,
12889 _request: CustomMetric,
12890 _account_id: String,
12891 _web_property_id: String,
12892 _custom_metric_id: String,
12893 _ignore_custom_data_source_links: Option<bool>,
12894 _delegate: Option<&'a mut dyn common::Delegate>,
12895 _additional_params: HashMap<String, String>,
12896 _scopes: BTreeSet<String>,
12897}
12898
12899impl<'a, C> common::CallBuilder for ManagementCustomMetricUpdateCall<'a, C> {}
12900
12901impl<'a, C> ManagementCustomMetricUpdateCall<'a, C>
12902where
12903 C: common::Connector,
12904{
12905 /// Perform the operation you have build so far.
12906 pub async fn doit(mut self) -> common::Result<(common::Response, CustomMetric)> {
12907 use std::borrow::Cow;
12908 use std::io::{Read, Seek};
12909
12910 use common::{url::Params, ToParts};
12911 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12912
12913 let mut dd = common::DefaultDelegate;
12914 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12915 dlg.begin(common::MethodInfo {
12916 id: "analytics.management.customMetrics.update",
12917 http_method: hyper::Method::PUT,
12918 });
12919
12920 for &field in [
12921 "alt",
12922 "accountId",
12923 "webPropertyId",
12924 "customMetricId",
12925 "ignoreCustomDataSourceLinks",
12926 ]
12927 .iter()
12928 {
12929 if self._additional_params.contains_key(field) {
12930 dlg.finished(false);
12931 return Err(common::Error::FieldClash(field));
12932 }
12933 }
12934
12935 let mut params = Params::with_capacity(7 + self._additional_params.len());
12936 params.push("accountId", self._account_id);
12937 params.push("webPropertyId", self._web_property_id);
12938 params.push("customMetricId", self._custom_metric_id);
12939 if let Some(value) = self._ignore_custom_data_source_links.as_ref() {
12940 params.push("ignoreCustomDataSourceLinks", value.to_string());
12941 }
12942
12943 params.extend(self._additional_params.iter());
12944
12945 params.push("alt", "json");
12946 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customMetrics/{customMetricId}";
12947 if self._scopes.is_empty() {
12948 self._scopes.insert(Scope::Edit.as_ref().to_string());
12949 }
12950
12951 #[allow(clippy::single_element_loop)]
12952 for &(find_this, param_name) in [
12953 ("{accountId}", "accountId"),
12954 ("{webPropertyId}", "webPropertyId"),
12955 ("{customMetricId}", "customMetricId"),
12956 ]
12957 .iter()
12958 {
12959 url = params.uri_replacement(url, param_name, find_this, false);
12960 }
12961 {
12962 let to_remove = ["customMetricId", "webPropertyId", "accountId"];
12963 params.remove_params(&to_remove);
12964 }
12965
12966 let url = params.parse_with_url(&url);
12967
12968 let mut json_mime_type = mime::APPLICATION_JSON;
12969 let mut request_value_reader = {
12970 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12971 common::remove_json_null_values(&mut value);
12972 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12973 serde_json::to_writer(&mut dst, &value).unwrap();
12974 dst
12975 };
12976 let request_size = request_value_reader
12977 .seek(std::io::SeekFrom::End(0))
12978 .unwrap();
12979 request_value_reader
12980 .seek(std::io::SeekFrom::Start(0))
12981 .unwrap();
12982
12983 loop {
12984 let token = match self
12985 .hub
12986 .auth
12987 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12988 .await
12989 {
12990 Ok(token) => token,
12991 Err(e) => match dlg.token(e) {
12992 Ok(token) => token,
12993 Err(e) => {
12994 dlg.finished(false);
12995 return Err(common::Error::MissingToken(e));
12996 }
12997 },
12998 };
12999 request_value_reader
13000 .seek(std::io::SeekFrom::Start(0))
13001 .unwrap();
13002 let mut req_result = {
13003 let client = &self.hub.client;
13004 dlg.pre_request();
13005 let mut req_builder = hyper::Request::builder()
13006 .method(hyper::Method::PUT)
13007 .uri(url.as_str())
13008 .header(USER_AGENT, self.hub._user_agent.clone());
13009
13010 if let Some(token) = token.as_ref() {
13011 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13012 }
13013
13014 let request = req_builder
13015 .header(CONTENT_TYPE, json_mime_type.to_string())
13016 .header(CONTENT_LENGTH, request_size as u64)
13017 .body(common::to_body(
13018 request_value_reader.get_ref().clone().into(),
13019 ));
13020
13021 client.request(request.unwrap()).await
13022 };
13023
13024 match req_result {
13025 Err(err) => {
13026 if let common::Retry::After(d) = dlg.http_error(&err) {
13027 sleep(d).await;
13028 continue;
13029 }
13030 dlg.finished(false);
13031 return Err(common::Error::HttpError(err));
13032 }
13033 Ok(res) => {
13034 let (mut parts, body) = res.into_parts();
13035 let mut body = common::Body::new(body);
13036 if !parts.status.is_success() {
13037 let bytes = common::to_bytes(body).await.unwrap_or_default();
13038 let error = serde_json::from_str(&common::to_string(&bytes));
13039 let response = common::to_response(parts, bytes.into());
13040
13041 if let common::Retry::After(d) =
13042 dlg.http_failure(&response, error.as_ref().ok())
13043 {
13044 sleep(d).await;
13045 continue;
13046 }
13047
13048 dlg.finished(false);
13049
13050 return Err(match error {
13051 Ok(value) => common::Error::BadRequest(value),
13052 _ => common::Error::Failure(response),
13053 });
13054 }
13055 let response = {
13056 let bytes = common::to_bytes(body).await.unwrap_or_default();
13057 let encoded = common::to_string(&bytes);
13058 match serde_json::from_str(&encoded) {
13059 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13060 Err(error) => {
13061 dlg.response_json_decode_error(&encoded, &error);
13062 return Err(common::Error::JsonDecodeError(
13063 encoded.to_string(),
13064 error,
13065 ));
13066 }
13067 }
13068 };
13069
13070 dlg.finished(true);
13071 return Ok(response);
13072 }
13073 }
13074 }
13075 }
13076
13077 ///
13078 /// Sets the *request* property to the given value.
13079 ///
13080 /// Even though the property as already been set when instantiating this call,
13081 /// we provide this method for API completeness.
13082 pub fn request(mut self, new_value: CustomMetric) -> ManagementCustomMetricUpdateCall<'a, C> {
13083 self._request = new_value;
13084 self
13085 }
13086 /// Account ID for the custom metric to update.
13087 ///
13088 /// Sets the *account id* path property to the given value.
13089 ///
13090 /// Even though the property as already been set when instantiating this call,
13091 /// we provide this method for API completeness.
13092 pub fn account_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C> {
13093 self._account_id = new_value.to_string();
13094 self
13095 }
13096 /// Web property ID for the custom metric to update.
13097 ///
13098 /// Sets the *web property id* path property to the given value.
13099 ///
13100 /// Even though the property as already been set when instantiating this call,
13101 /// we provide this method for API completeness.
13102 pub fn web_property_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C> {
13103 self._web_property_id = new_value.to_string();
13104 self
13105 }
13106 /// Custom metric ID for the custom metric to update.
13107 ///
13108 /// Sets the *custom metric id* path property to the given value.
13109 ///
13110 /// Even though the property as already been set when instantiating this call,
13111 /// we provide this method for API completeness.
13112 pub fn custom_metric_id(mut self, new_value: &str) -> ManagementCustomMetricUpdateCall<'a, C> {
13113 self._custom_metric_id = new_value.to_string();
13114 self
13115 }
13116 /// Force the update and ignore any warnings related to the custom metric being linked to a custom data source / data set.
13117 ///
13118 /// Sets the *ignore custom data source links* query property to the given value.
13119 pub fn ignore_custom_data_source_links(
13120 mut self,
13121 new_value: bool,
13122 ) -> ManagementCustomMetricUpdateCall<'a, C> {
13123 self._ignore_custom_data_source_links = Some(new_value);
13124 self
13125 }
13126 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13127 /// while executing the actual API request.
13128 ///
13129 /// ````text
13130 /// It should be used to handle progress information, and to implement a certain level of resilience.
13131 /// ````
13132 ///
13133 /// Sets the *delegate* property to the given value.
13134 pub fn delegate(
13135 mut self,
13136 new_value: &'a mut dyn common::Delegate,
13137 ) -> ManagementCustomMetricUpdateCall<'a, C> {
13138 self._delegate = Some(new_value);
13139 self
13140 }
13141
13142 /// Set any additional parameter of the query string used in the request.
13143 /// It should be used to set parameters which are not yet available through their own
13144 /// setters.
13145 ///
13146 /// Please note that this method must not be used to set any of the known parameters
13147 /// which have their own setter method. If done anyway, the request will fail.
13148 ///
13149 /// # Additional Parameters
13150 ///
13151 /// * *alt* (query-string) - Data format for the response.
13152 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13153 /// * *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.
13154 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13155 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13156 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13157 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13158 pub fn param<T>(mut self, name: T, value: T) -> ManagementCustomMetricUpdateCall<'a, C>
13159 where
13160 T: AsRef<str>,
13161 {
13162 self._additional_params
13163 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13164 self
13165 }
13166
13167 /// Identifies the authorization scope for the method you are building.
13168 ///
13169 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13170 /// [`Scope::Edit`].
13171 ///
13172 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13173 /// tokens for more than one scope.
13174 ///
13175 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13176 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13177 /// sufficient, a read-write scope will do as well.
13178 pub fn add_scope<St>(mut self, scope: St) -> ManagementCustomMetricUpdateCall<'a, C>
13179 where
13180 St: AsRef<str>,
13181 {
13182 self._scopes.insert(String::from(scope.as_ref()));
13183 self
13184 }
13185 /// Identifies the authorization scope(s) for the method you are building.
13186 ///
13187 /// See [`Self::add_scope()`] for details.
13188 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementCustomMetricUpdateCall<'a, C>
13189 where
13190 I: IntoIterator<Item = St>,
13191 St: AsRef<str>,
13192 {
13193 self._scopes
13194 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13195 self
13196 }
13197
13198 /// Removes all scopes, and no default scope will be used either.
13199 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13200 /// for details).
13201 pub fn clear_scopes(mut self) -> ManagementCustomMetricUpdateCall<'a, C> {
13202 self._scopes.clear();
13203 self
13204 }
13205}
13206
13207/// Delete an experiment.
13208///
13209/// A builder for the *experiments.delete* method supported by a *management* resource.
13210/// It is not used directly, but through a [`ManagementMethods`] instance.
13211///
13212/// # Example
13213///
13214/// Instantiate a resource method builder
13215///
13216/// ```test_harness,no_run
13217/// # extern crate hyper;
13218/// # extern crate hyper_rustls;
13219/// # extern crate google_analytics3 as analytics3;
13220/// # async fn dox() {
13221/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13222///
13223/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13224/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13225/// # secret,
13226/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13227/// # ).build().await.unwrap();
13228///
13229/// # let client = hyper_util::client::legacy::Client::builder(
13230/// # hyper_util::rt::TokioExecutor::new()
13231/// # )
13232/// # .build(
13233/// # hyper_rustls::HttpsConnectorBuilder::new()
13234/// # .with_native_roots()
13235/// # .unwrap()
13236/// # .https_or_http()
13237/// # .enable_http1()
13238/// # .build()
13239/// # );
13240/// # let mut hub = Analytics::new(client, auth);
13241/// // You can configure optional parameters by calling the respective setters at will, and
13242/// // execute the final call using `doit()`.
13243/// // Values shown here are possibly random and not representative !
13244/// let result = hub.management().experiments_delete("accountId", "webPropertyId", "profileId", "experimentId")
13245/// .doit().await;
13246/// # }
13247/// ```
13248pub struct ManagementExperimentDeleteCall<'a, C>
13249where
13250 C: 'a,
13251{
13252 hub: &'a Analytics<C>,
13253 _account_id: String,
13254 _web_property_id: String,
13255 _profile_id: String,
13256 _experiment_id: String,
13257 _delegate: Option<&'a mut dyn common::Delegate>,
13258 _additional_params: HashMap<String, String>,
13259 _scopes: BTreeSet<String>,
13260}
13261
13262impl<'a, C> common::CallBuilder for ManagementExperimentDeleteCall<'a, C> {}
13263
13264impl<'a, C> ManagementExperimentDeleteCall<'a, C>
13265where
13266 C: common::Connector,
13267{
13268 /// Perform the operation you have build so far.
13269 pub async fn doit(mut self) -> common::Result<common::Response> {
13270 use std::borrow::Cow;
13271 use std::io::{Read, Seek};
13272
13273 use common::{url::Params, ToParts};
13274 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13275
13276 let mut dd = common::DefaultDelegate;
13277 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13278 dlg.begin(common::MethodInfo {
13279 id: "analytics.management.experiments.delete",
13280 http_method: hyper::Method::DELETE,
13281 });
13282
13283 for &field in ["accountId", "webPropertyId", "profileId", "experimentId"].iter() {
13284 if self._additional_params.contains_key(field) {
13285 dlg.finished(false);
13286 return Err(common::Error::FieldClash(field));
13287 }
13288 }
13289
13290 let mut params = Params::with_capacity(5 + self._additional_params.len());
13291 params.push("accountId", self._account_id);
13292 params.push("webPropertyId", self._web_property_id);
13293 params.push("profileId", self._profile_id);
13294 params.push("experimentId", self._experiment_id);
13295
13296 params.extend(self._additional_params.iter());
13297
13298 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}";
13299 if self._scopes.is_empty() {
13300 self._scopes.insert(Scope::Full.as_ref().to_string());
13301 }
13302
13303 #[allow(clippy::single_element_loop)]
13304 for &(find_this, param_name) in [
13305 ("{accountId}", "accountId"),
13306 ("{webPropertyId}", "webPropertyId"),
13307 ("{profileId}", "profileId"),
13308 ("{experimentId}", "experimentId"),
13309 ]
13310 .iter()
13311 {
13312 url = params.uri_replacement(url, param_name, find_this, false);
13313 }
13314 {
13315 let to_remove = ["experimentId", "profileId", "webPropertyId", "accountId"];
13316 params.remove_params(&to_remove);
13317 }
13318
13319 let url = params.parse_with_url(&url);
13320
13321 loop {
13322 let token = match self
13323 .hub
13324 .auth
13325 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13326 .await
13327 {
13328 Ok(token) => token,
13329 Err(e) => match dlg.token(e) {
13330 Ok(token) => token,
13331 Err(e) => {
13332 dlg.finished(false);
13333 return Err(common::Error::MissingToken(e));
13334 }
13335 },
13336 };
13337 let mut req_result = {
13338 let client = &self.hub.client;
13339 dlg.pre_request();
13340 let mut req_builder = hyper::Request::builder()
13341 .method(hyper::Method::DELETE)
13342 .uri(url.as_str())
13343 .header(USER_AGENT, self.hub._user_agent.clone());
13344
13345 if let Some(token) = token.as_ref() {
13346 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13347 }
13348
13349 let request = req_builder
13350 .header(CONTENT_LENGTH, 0_u64)
13351 .body(common::to_body::<String>(None));
13352
13353 client.request(request.unwrap()).await
13354 };
13355
13356 match req_result {
13357 Err(err) => {
13358 if let common::Retry::After(d) = dlg.http_error(&err) {
13359 sleep(d).await;
13360 continue;
13361 }
13362 dlg.finished(false);
13363 return Err(common::Error::HttpError(err));
13364 }
13365 Ok(res) => {
13366 let (mut parts, body) = res.into_parts();
13367 let mut body = common::Body::new(body);
13368 if !parts.status.is_success() {
13369 let bytes = common::to_bytes(body).await.unwrap_or_default();
13370 let error = serde_json::from_str(&common::to_string(&bytes));
13371 let response = common::to_response(parts, bytes.into());
13372
13373 if let common::Retry::After(d) =
13374 dlg.http_failure(&response, error.as_ref().ok())
13375 {
13376 sleep(d).await;
13377 continue;
13378 }
13379
13380 dlg.finished(false);
13381
13382 return Err(match error {
13383 Ok(value) => common::Error::BadRequest(value),
13384 _ => common::Error::Failure(response),
13385 });
13386 }
13387 let response = common::Response::from_parts(parts, body);
13388
13389 dlg.finished(true);
13390 return Ok(response);
13391 }
13392 }
13393 }
13394 }
13395
13396 /// Account ID to which the experiment belongs
13397 ///
13398 /// Sets the *account id* path property to the given value.
13399 ///
13400 /// Even though the property as already been set when instantiating this call,
13401 /// we provide this method for API completeness.
13402 pub fn account_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C> {
13403 self._account_id = new_value.to_string();
13404 self
13405 }
13406 /// Web property ID to which the experiment belongs
13407 ///
13408 /// Sets the *web property id* path property to the given value.
13409 ///
13410 /// Even though the property as already been set when instantiating this call,
13411 /// we provide this method for API completeness.
13412 pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C> {
13413 self._web_property_id = new_value.to_string();
13414 self
13415 }
13416 /// View (Profile) ID to which the experiment belongs
13417 ///
13418 /// Sets the *profile id* path property to the given value.
13419 ///
13420 /// Even though the property as already been set when instantiating this call,
13421 /// we provide this method for API completeness.
13422 pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C> {
13423 self._profile_id = new_value.to_string();
13424 self
13425 }
13426 /// ID of the experiment to delete
13427 ///
13428 /// Sets the *experiment id* path property to the given value.
13429 ///
13430 /// Even though the property as already been set when instantiating this call,
13431 /// we provide this method for API completeness.
13432 pub fn experiment_id(mut self, new_value: &str) -> ManagementExperimentDeleteCall<'a, C> {
13433 self._experiment_id = new_value.to_string();
13434 self
13435 }
13436 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13437 /// while executing the actual API request.
13438 ///
13439 /// ````text
13440 /// It should be used to handle progress information, and to implement a certain level of resilience.
13441 /// ````
13442 ///
13443 /// Sets the *delegate* property to the given value.
13444 pub fn delegate(
13445 mut self,
13446 new_value: &'a mut dyn common::Delegate,
13447 ) -> ManagementExperimentDeleteCall<'a, C> {
13448 self._delegate = Some(new_value);
13449 self
13450 }
13451
13452 /// Set any additional parameter of the query string used in the request.
13453 /// It should be used to set parameters which are not yet available through their own
13454 /// setters.
13455 ///
13456 /// Please note that this method must not be used to set any of the known parameters
13457 /// which have their own setter method. If done anyway, the request will fail.
13458 ///
13459 /// # Additional Parameters
13460 ///
13461 /// * *alt* (query-string) - Data format for the response.
13462 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13463 /// * *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.
13464 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13465 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13466 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13467 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13468 pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentDeleteCall<'a, C>
13469 where
13470 T: AsRef<str>,
13471 {
13472 self._additional_params
13473 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13474 self
13475 }
13476
13477 /// Identifies the authorization scope for the method you are building.
13478 ///
13479 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13480 /// [`Scope::Full`].
13481 ///
13482 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13483 /// tokens for more than one scope.
13484 ///
13485 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13486 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13487 /// sufficient, a read-write scope will do as well.
13488 pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentDeleteCall<'a, C>
13489 where
13490 St: AsRef<str>,
13491 {
13492 self._scopes.insert(String::from(scope.as_ref()));
13493 self
13494 }
13495 /// Identifies the authorization scope(s) for the method you are building.
13496 ///
13497 /// See [`Self::add_scope()`] for details.
13498 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentDeleteCall<'a, C>
13499 where
13500 I: IntoIterator<Item = St>,
13501 St: AsRef<str>,
13502 {
13503 self._scopes
13504 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13505 self
13506 }
13507
13508 /// Removes all scopes, and no default scope will be used either.
13509 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13510 /// for details).
13511 pub fn clear_scopes(mut self) -> ManagementExperimentDeleteCall<'a, C> {
13512 self._scopes.clear();
13513 self
13514 }
13515}
13516
13517/// Returns an experiment to which the user has access.
13518///
13519/// A builder for the *experiments.get* method supported by a *management* resource.
13520/// It is not used directly, but through a [`ManagementMethods`] instance.
13521///
13522/// # Example
13523///
13524/// Instantiate a resource method builder
13525///
13526/// ```test_harness,no_run
13527/// # extern crate hyper;
13528/// # extern crate hyper_rustls;
13529/// # extern crate google_analytics3 as analytics3;
13530/// # async fn dox() {
13531/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13532///
13533/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13534/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13535/// # secret,
13536/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13537/// # ).build().await.unwrap();
13538///
13539/// # let client = hyper_util::client::legacy::Client::builder(
13540/// # hyper_util::rt::TokioExecutor::new()
13541/// # )
13542/// # .build(
13543/// # hyper_rustls::HttpsConnectorBuilder::new()
13544/// # .with_native_roots()
13545/// # .unwrap()
13546/// # .https_or_http()
13547/// # .enable_http1()
13548/// # .build()
13549/// # );
13550/// # let mut hub = Analytics::new(client, auth);
13551/// // You can configure optional parameters by calling the respective setters at will, and
13552/// // execute the final call using `doit()`.
13553/// // Values shown here are possibly random and not representative !
13554/// let result = hub.management().experiments_get("accountId", "webPropertyId", "profileId", "experimentId")
13555/// .doit().await;
13556/// # }
13557/// ```
13558pub struct ManagementExperimentGetCall<'a, C>
13559where
13560 C: 'a,
13561{
13562 hub: &'a Analytics<C>,
13563 _account_id: String,
13564 _web_property_id: String,
13565 _profile_id: String,
13566 _experiment_id: String,
13567 _delegate: Option<&'a mut dyn common::Delegate>,
13568 _additional_params: HashMap<String, String>,
13569 _scopes: BTreeSet<String>,
13570}
13571
13572impl<'a, C> common::CallBuilder for ManagementExperimentGetCall<'a, C> {}
13573
13574impl<'a, C> ManagementExperimentGetCall<'a, C>
13575where
13576 C: common::Connector,
13577{
13578 /// Perform the operation you have build so far.
13579 pub async fn doit(mut self) -> common::Result<(common::Response, Experiment)> {
13580 use std::borrow::Cow;
13581 use std::io::{Read, Seek};
13582
13583 use common::{url::Params, ToParts};
13584 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13585
13586 let mut dd = common::DefaultDelegate;
13587 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13588 dlg.begin(common::MethodInfo {
13589 id: "analytics.management.experiments.get",
13590 http_method: hyper::Method::GET,
13591 });
13592
13593 for &field in [
13594 "alt",
13595 "accountId",
13596 "webPropertyId",
13597 "profileId",
13598 "experimentId",
13599 ]
13600 .iter()
13601 {
13602 if self._additional_params.contains_key(field) {
13603 dlg.finished(false);
13604 return Err(common::Error::FieldClash(field));
13605 }
13606 }
13607
13608 let mut params = Params::with_capacity(6 + self._additional_params.len());
13609 params.push("accountId", self._account_id);
13610 params.push("webPropertyId", self._web_property_id);
13611 params.push("profileId", self._profile_id);
13612 params.push("experimentId", self._experiment_id);
13613
13614 params.extend(self._additional_params.iter());
13615
13616 params.push("alt", "json");
13617 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}";
13618 if self._scopes.is_empty() {
13619 self._scopes.insert(Scope::Readonly.as_ref().to_string());
13620 }
13621
13622 #[allow(clippy::single_element_loop)]
13623 for &(find_this, param_name) in [
13624 ("{accountId}", "accountId"),
13625 ("{webPropertyId}", "webPropertyId"),
13626 ("{profileId}", "profileId"),
13627 ("{experimentId}", "experimentId"),
13628 ]
13629 .iter()
13630 {
13631 url = params.uri_replacement(url, param_name, find_this, false);
13632 }
13633 {
13634 let to_remove = ["experimentId", "profileId", "webPropertyId", "accountId"];
13635 params.remove_params(&to_remove);
13636 }
13637
13638 let url = params.parse_with_url(&url);
13639
13640 loop {
13641 let token = match self
13642 .hub
13643 .auth
13644 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13645 .await
13646 {
13647 Ok(token) => token,
13648 Err(e) => match dlg.token(e) {
13649 Ok(token) => token,
13650 Err(e) => {
13651 dlg.finished(false);
13652 return Err(common::Error::MissingToken(e));
13653 }
13654 },
13655 };
13656 let mut req_result = {
13657 let client = &self.hub.client;
13658 dlg.pre_request();
13659 let mut req_builder = hyper::Request::builder()
13660 .method(hyper::Method::GET)
13661 .uri(url.as_str())
13662 .header(USER_AGENT, self.hub._user_agent.clone());
13663
13664 if let Some(token) = token.as_ref() {
13665 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13666 }
13667
13668 let request = req_builder
13669 .header(CONTENT_LENGTH, 0_u64)
13670 .body(common::to_body::<String>(None));
13671
13672 client.request(request.unwrap()).await
13673 };
13674
13675 match req_result {
13676 Err(err) => {
13677 if let common::Retry::After(d) = dlg.http_error(&err) {
13678 sleep(d).await;
13679 continue;
13680 }
13681 dlg.finished(false);
13682 return Err(common::Error::HttpError(err));
13683 }
13684 Ok(res) => {
13685 let (mut parts, body) = res.into_parts();
13686 let mut body = common::Body::new(body);
13687 if !parts.status.is_success() {
13688 let bytes = common::to_bytes(body).await.unwrap_or_default();
13689 let error = serde_json::from_str(&common::to_string(&bytes));
13690 let response = common::to_response(parts, bytes.into());
13691
13692 if let common::Retry::After(d) =
13693 dlg.http_failure(&response, error.as_ref().ok())
13694 {
13695 sleep(d).await;
13696 continue;
13697 }
13698
13699 dlg.finished(false);
13700
13701 return Err(match error {
13702 Ok(value) => common::Error::BadRequest(value),
13703 _ => common::Error::Failure(response),
13704 });
13705 }
13706 let response = {
13707 let bytes = common::to_bytes(body).await.unwrap_or_default();
13708 let encoded = common::to_string(&bytes);
13709 match serde_json::from_str(&encoded) {
13710 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13711 Err(error) => {
13712 dlg.response_json_decode_error(&encoded, &error);
13713 return Err(common::Error::JsonDecodeError(
13714 encoded.to_string(),
13715 error,
13716 ));
13717 }
13718 }
13719 };
13720
13721 dlg.finished(true);
13722 return Ok(response);
13723 }
13724 }
13725 }
13726 }
13727
13728 /// Account ID to retrieve the experiment for.
13729 ///
13730 /// Sets the *account id* path property to the given value.
13731 ///
13732 /// Even though the property as already been set when instantiating this call,
13733 /// we provide this method for API completeness.
13734 pub fn account_id(mut self, new_value: &str) -> ManagementExperimentGetCall<'a, C> {
13735 self._account_id = new_value.to_string();
13736 self
13737 }
13738 /// Web property ID to retrieve the experiment for.
13739 ///
13740 /// Sets the *web property id* path property to the given value.
13741 ///
13742 /// Even though the property as already been set when instantiating this call,
13743 /// we provide this method for API completeness.
13744 pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentGetCall<'a, C> {
13745 self._web_property_id = new_value.to_string();
13746 self
13747 }
13748 /// View (Profile) ID to retrieve the experiment for.
13749 ///
13750 /// Sets the *profile id* path property to the given value.
13751 ///
13752 /// Even though the property as already been set when instantiating this call,
13753 /// we provide this method for API completeness.
13754 pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentGetCall<'a, C> {
13755 self._profile_id = new_value.to_string();
13756 self
13757 }
13758 /// Experiment ID to retrieve the experiment for.
13759 ///
13760 /// Sets the *experiment id* path property to the given value.
13761 ///
13762 /// Even though the property as already been set when instantiating this call,
13763 /// we provide this method for API completeness.
13764 pub fn experiment_id(mut self, new_value: &str) -> ManagementExperimentGetCall<'a, C> {
13765 self._experiment_id = new_value.to_string();
13766 self
13767 }
13768 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13769 /// while executing the actual API request.
13770 ///
13771 /// ````text
13772 /// It should be used to handle progress information, and to implement a certain level of resilience.
13773 /// ````
13774 ///
13775 /// Sets the *delegate* property to the given value.
13776 pub fn delegate(
13777 mut self,
13778 new_value: &'a mut dyn common::Delegate,
13779 ) -> ManagementExperimentGetCall<'a, C> {
13780 self._delegate = Some(new_value);
13781 self
13782 }
13783
13784 /// Set any additional parameter of the query string used in the request.
13785 /// It should be used to set parameters which are not yet available through their own
13786 /// setters.
13787 ///
13788 /// Please note that this method must not be used to set any of the known parameters
13789 /// which have their own setter method. If done anyway, the request will fail.
13790 ///
13791 /// # Additional Parameters
13792 ///
13793 /// * *alt* (query-string) - Data format for the response.
13794 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13795 /// * *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.
13796 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13797 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13798 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13799 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13800 pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentGetCall<'a, C>
13801 where
13802 T: AsRef<str>,
13803 {
13804 self._additional_params
13805 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13806 self
13807 }
13808
13809 /// Identifies the authorization scope for the method you are building.
13810 ///
13811 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13812 /// [`Scope::Readonly`].
13813 ///
13814 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13815 /// tokens for more than one scope.
13816 ///
13817 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13818 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13819 /// sufficient, a read-write scope will do as well.
13820 pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentGetCall<'a, C>
13821 where
13822 St: AsRef<str>,
13823 {
13824 self._scopes.insert(String::from(scope.as_ref()));
13825 self
13826 }
13827 /// Identifies the authorization scope(s) for the method you are building.
13828 ///
13829 /// See [`Self::add_scope()`] for details.
13830 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentGetCall<'a, C>
13831 where
13832 I: IntoIterator<Item = St>,
13833 St: AsRef<str>,
13834 {
13835 self._scopes
13836 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13837 self
13838 }
13839
13840 /// Removes all scopes, and no default scope will be used either.
13841 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13842 /// for details).
13843 pub fn clear_scopes(mut self) -> ManagementExperimentGetCall<'a, C> {
13844 self._scopes.clear();
13845 self
13846 }
13847}
13848
13849/// Create a new experiment.
13850///
13851/// A builder for the *experiments.insert* method supported by a *management* resource.
13852/// It is not used directly, but through a [`ManagementMethods`] instance.
13853///
13854/// # Example
13855///
13856/// Instantiate a resource method builder
13857///
13858/// ```test_harness,no_run
13859/// # extern crate hyper;
13860/// # extern crate hyper_rustls;
13861/// # extern crate google_analytics3 as analytics3;
13862/// use analytics3::api::Experiment;
13863/// # async fn dox() {
13864/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13865///
13866/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13867/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13868/// # secret,
13869/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13870/// # ).build().await.unwrap();
13871///
13872/// # let client = hyper_util::client::legacy::Client::builder(
13873/// # hyper_util::rt::TokioExecutor::new()
13874/// # )
13875/// # .build(
13876/// # hyper_rustls::HttpsConnectorBuilder::new()
13877/// # .with_native_roots()
13878/// # .unwrap()
13879/// # .https_or_http()
13880/// # .enable_http1()
13881/// # .build()
13882/// # );
13883/// # let mut hub = Analytics::new(client, auth);
13884/// // As the method needs a request, you would usually fill it with the desired information
13885/// // into the respective structure. Some of the parts shown here might not be applicable !
13886/// // Values shown here are possibly random and not representative !
13887/// let mut req = Experiment::default();
13888///
13889/// // You can configure optional parameters by calling the respective setters at will, and
13890/// // execute the final call using `doit()`.
13891/// // Values shown here are possibly random and not representative !
13892/// let result = hub.management().experiments_insert(req, "accountId", "webPropertyId", "profileId")
13893/// .doit().await;
13894/// # }
13895/// ```
13896pub struct ManagementExperimentInsertCall<'a, C>
13897where
13898 C: 'a,
13899{
13900 hub: &'a Analytics<C>,
13901 _request: Experiment,
13902 _account_id: String,
13903 _web_property_id: String,
13904 _profile_id: String,
13905 _delegate: Option<&'a mut dyn common::Delegate>,
13906 _additional_params: HashMap<String, String>,
13907 _scopes: BTreeSet<String>,
13908}
13909
13910impl<'a, C> common::CallBuilder for ManagementExperimentInsertCall<'a, C> {}
13911
13912impl<'a, C> ManagementExperimentInsertCall<'a, C>
13913where
13914 C: common::Connector,
13915{
13916 /// Perform the operation you have build so far.
13917 pub async fn doit(mut self) -> common::Result<(common::Response, Experiment)> {
13918 use std::borrow::Cow;
13919 use std::io::{Read, Seek};
13920
13921 use common::{url::Params, ToParts};
13922 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13923
13924 let mut dd = common::DefaultDelegate;
13925 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13926 dlg.begin(common::MethodInfo {
13927 id: "analytics.management.experiments.insert",
13928 http_method: hyper::Method::POST,
13929 });
13930
13931 for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
13932 if self._additional_params.contains_key(field) {
13933 dlg.finished(false);
13934 return Err(common::Error::FieldClash(field));
13935 }
13936 }
13937
13938 let mut params = Params::with_capacity(6 + self._additional_params.len());
13939 params.push("accountId", self._account_id);
13940 params.push("webPropertyId", self._web_property_id);
13941 params.push("profileId", self._profile_id);
13942
13943 params.extend(self._additional_params.iter());
13944
13945 params.push("alt", "json");
13946 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments";
13947 if self._scopes.is_empty() {
13948 self._scopes.insert(Scope::Full.as_ref().to_string());
13949 }
13950
13951 #[allow(clippy::single_element_loop)]
13952 for &(find_this, param_name) in [
13953 ("{accountId}", "accountId"),
13954 ("{webPropertyId}", "webPropertyId"),
13955 ("{profileId}", "profileId"),
13956 ]
13957 .iter()
13958 {
13959 url = params.uri_replacement(url, param_name, find_this, false);
13960 }
13961 {
13962 let to_remove = ["profileId", "webPropertyId", "accountId"];
13963 params.remove_params(&to_remove);
13964 }
13965
13966 let url = params.parse_with_url(&url);
13967
13968 let mut json_mime_type = mime::APPLICATION_JSON;
13969 let mut request_value_reader = {
13970 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13971 common::remove_json_null_values(&mut value);
13972 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13973 serde_json::to_writer(&mut dst, &value).unwrap();
13974 dst
13975 };
13976 let request_size = request_value_reader
13977 .seek(std::io::SeekFrom::End(0))
13978 .unwrap();
13979 request_value_reader
13980 .seek(std::io::SeekFrom::Start(0))
13981 .unwrap();
13982
13983 loop {
13984 let token = match self
13985 .hub
13986 .auth
13987 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13988 .await
13989 {
13990 Ok(token) => token,
13991 Err(e) => match dlg.token(e) {
13992 Ok(token) => token,
13993 Err(e) => {
13994 dlg.finished(false);
13995 return Err(common::Error::MissingToken(e));
13996 }
13997 },
13998 };
13999 request_value_reader
14000 .seek(std::io::SeekFrom::Start(0))
14001 .unwrap();
14002 let mut req_result = {
14003 let client = &self.hub.client;
14004 dlg.pre_request();
14005 let mut req_builder = hyper::Request::builder()
14006 .method(hyper::Method::POST)
14007 .uri(url.as_str())
14008 .header(USER_AGENT, self.hub._user_agent.clone());
14009
14010 if let Some(token) = token.as_ref() {
14011 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14012 }
14013
14014 let request = req_builder
14015 .header(CONTENT_TYPE, json_mime_type.to_string())
14016 .header(CONTENT_LENGTH, request_size as u64)
14017 .body(common::to_body(
14018 request_value_reader.get_ref().clone().into(),
14019 ));
14020
14021 client.request(request.unwrap()).await
14022 };
14023
14024 match req_result {
14025 Err(err) => {
14026 if let common::Retry::After(d) = dlg.http_error(&err) {
14027 sleep(d).await;
14028 continue;
14029 }
14030 dlg.finished(false);
14031 return Err(common::Error::HttpError(err));
14032 }
14033 Ok(res) => {
14034 let (mut parts, body) = res.into_parts();
14035 let mut body = common::Body::new(body);
14036 if !parts.status.is_success() {
14037 let bytes = common::to_bytes(body).await.unwrap_or_default();
14038 let error = serde_json::from_str(&common::to_string(&bytes));
14039 let response = common::to_response(parts, bytes.into());
14040
14041 if let common::Retry::After(d) =
14042 dlg.http_failure(&response, error.as_ref().ok())
14043 {
14044 sleep(d).await;
14045 continue;
14046 }
14047
14048 dlg.finished(false);
14049
14050 return Err(match error {
14051 Ok(value) => common::Error::BadRequest(value),
14052 _ => common::Error::Failure(response),
14053 });
14054 }
14055 let response = {
14056 let bytes = common::to_bytes(body).await.unwrap_or_default();
14057 let encoded = common::to_string(&bytes);
14058 match serde_json::from_str(&encoded) {
14059 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14060 Err(error) => {
14061 dlg.response_json_decode_error(&encoded, &error);
14062 return Err(common::Error::JsonDecodeError(
14063 encoded.to_string(),
14064 error,
14065 ));
14066 }
14067 }
14068 };
14069
14070 dlg.finished(true);
14071 return Ok(response);
14072 }
14073 }
14074 }
14075 }
14076
14077 ///
14078 /// Sets the *request* property to the given value.
14079 ///
14080 /// Even though the property as already been set when instantiating this call,
14081 /// we provide this method for API completeness.
14082 pub fn request(mut self, new_value: Experiment) -> ManagementExperimentInsertCall<'a, C> {
14083 self._request = new_value;
14084 self
14085 }
14086 /// Account ID to create the experiment for.
14087 ///
14088 /// Sets the *account id* path property to the given value.
14089 ///
14090 /// Even though the property as already been set when instantiating this call,
14091 /// we provide this method for API completeness.
14092 pub fn account_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C> {
14093 self._account_id = new_value.to_string();
14094 self
14095 }
14096 /// Web property ID to create the experiment for.
14097 ///
14098 /// Sets the *web property id* path property to the given value.
14099 ///
14100 /// Even though the property as already been set when instantiating this call,
14101 /// we provide this method for API completeness.
14102 pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C> {
14103 self._web_property_id = new_value.to_string();
14104 self
14105 }
14106 /// View (Profile) ID to create the experiment for.
14107 ///
14108 /// Sets the *profile id* path property to the given value.
14109 ///
14110 /// Even though the property as already been set when instantiating this call,
14111 /// we provide this method for API completeness.
14112 pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentInsertCall<'a, C> {
14113 self._profile_id = new_value.to_string();
14114 self
14115 }
14116 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14117 /// while executing the actual API request.
14118 ///
14119 /// ````text
14120 /// It should be used to handle progress information, and to implement a certain level of resilience.
14121 /// ````
14122 ///
14123 /// Sets the *delegate* property to the given value.
14124 pub fn delegate(
14125 mut self,
14126 new_value: &'a mut dyn common::Delegate,
14127 ) -> ManagementExperimentInsertCall<'a, C> {
14128 self._delegate = Some(new_value);
14129 self
14130 }
14131
14132 /// Set any additional parameter of the query string used in the request.
14133 /// It should be used to set parameters which are not yet available through their own
14134 /// setters.
14135 ///
14136 /// Please note that this method must not be used to set any of the known parameters
14137 /// which have their own setter method. If done anyway, the request will fail.
14138 ///
14139 /// # Additional Parameters
14140 ///
14141 /// * *alt* (query-string) - Data format for the response.
14142 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14143 /// * *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.
14144 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14145 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14146 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14147 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14148 pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentInsertCall<'a, C>
14149 where
14150 T: AsRef<str>,
14151 {
14152 self._additional_params
14153 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14154 self
14155 }
14156
14157 /// Identifies the authorization scope for the method you are building.
14158 ///
14159 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14160 /// [`Scope::Full`].
14161 ///
14162 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14163 /// tokens for more than one scope.
14164 ///
14165 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14166 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14167 /// sufficient, a read-write scope will do as well.
14168 pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentInsertCall<'a, C>
14169 where
14170 St: AsRef<str>,
14171 {
14172 self._scopes.insert(String::from(scope.as_ref()));
14173 self
14174 }
14175 /// Identifies the authorization scope(s) for the method you are building.
14176 ///
14177 /// See [`Self::add_scope()`] for details.
14178 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentInsertCall<'a, C>
14179 where
14180 I: IntoIterator<Item = St>,
14181 St: AsRef<str>,
14182 {
14183 self._scopes
14184 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14185 self
14186 }
14187
14188 /// Removes all scopes, and no default scope will be used either.
14189 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14190 /// for details).
14191 pub fn clear_scopes(mut self) -> ManagementExperimentInsertCall<'a, C> {
14192 self._scopes.clear();
14193 self
14194 }
14195}
14196
14197/// Lists experiments to which the user has access.
14198///
14199/// A builder for the *experiments.list* method supported by a *management* resource.
14200/// It is not used directly, but through a [`ManagementMethods`] instance.
14201///
14202/// # Example
14203///
14204/// Instantiate a resource method builder
14205///
14206/// ```test_harness,no_run
14207/// # extern crate hyper;
14208/// # extern crate hyper_rustls;
14209/// # extern crate google_analytics3 as analytics3;
14210/// # async fn dox() {
14211/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14212///
14213/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14214/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14215/// # secret,
14216/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14217/// # ).build().await.unwrap();
14218///
14219/// # let client = hyper_util::client::legacy::Client::builder(
14220/// # hyper_util::rt::TokioExecutor::new()
14221/// # )
14222/// # .build(
14223/// # hyper_rustls::HttpsConnectorBuilder::new()
14224/// # .with_native_roots()
14225/// # .unwrap()
14226/// # .https_or_http()
14227/// # .enable_http1()
14228/// # .build()
14229/// # );
14230/// # let mut hub = Analytics::new(client, auth);
14231/// // You can configure optional parameters by calling the respective setters at will, and
14232/// // execute the final call using `doit()`.
14233/// // Values shown here are possibly random and not representative !
14234/// let result = hub.management().experiments_list("accountId", "webPropertyId", "profileId")
14235/// .start_index(-18)
14236/// .max_results(-8)
14237/// .doit().await;
14238/// # }
14239/// ```
14240pub struct ManagementExperimentListCall<'a, C>
14241where
14242 C: 'a,
14243{
14244 hub: &'a Analytics<C>,
14245 _account_id: String,
14246 _web_property_id: String,
14247 _profile_id: String,
14248 _start_index: Option<i32>,
14249 _max_results: Option<i32>,
14250 _delegate: Option<&'a mut dyn common::Delegate>,
14251 _additional_params: HashMap<String, String>,
14252 _scopes: BTreeSet<String>,
14253}
14254
14255impl<'a, C> common::CallBuilder for ManagementExperimentListCall<'a, C> {}
14256
14257impl<'a, C> ManagementExperimentListCall<'a, C>
14258where
14259 C: common::Connector,
14260{
14261 /// Perform the operation you have build so far.
14262 pub async fn doit(mut self) -> common::Result<(common::Response, Experiments)> {
14263 use std::borrow::Cow;
14264 use std::io::{Read, Seek};
14265
14266 use common::{url::Params, ToParts};
14267 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14268
14269 let mut dd = common::DefaultDelegate;
14270 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14271 dlg.begin(common::MethodInfo {
14272 id: "analytics.management.experiments.list",
14273 http_method: hyper::Method::GET,
14274 });
14275
14276 for &field in [
14277 "alt",
14278 "accountId",
14279 "webPropertyId",
14280 "profileId",
14281 "start-index",
14282 "max-results",
14283 ]
14284 .iter()
14285 {
14286 if self._additional_params.contains_key(field) {
14287 dlg.finished(false);
14288 return Err(common::Error::FieldClash(field));
14289 }
14290 }
14291
14292 let mut params = Params::with_capacity(7 + self._additional_params.len());
14293 params.push("accountId", self._account_id);
14294 params.push("webPropertyId", self._web_property_id);
14295 params.push("profileId", self._profile_id);
14296 if let Some(value) = self._start_index.as_ref() {
14297 params.push("start-index", value.to_string());
14298 }
14299 if let Some(value) = self._max_results.as_ref() {
14300 params.push("max-results", value.to_string());
14301 }
14302
14303 params.extend(self._additional_params.iter());
14304
14305 params.push("alt", "json");
14306 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments";
14307 if self._scopes.is_empty() {
14308 self._scopes.insert(Scope::Readonly.as_ref().to_string());
14309 }
14310
14311 #[allow(clippy::single_element_loop)]
14312 for &(find_this, param_name) in [
14313 ("{accountId}", "accountId"),
14314 ("{webPropertyId}", "webPropertyId"),
14315 ("{profileId}", "profileId"),
14316 ]
14317 .iter()
14318 {
14319 url = params.uri_replacement(url, param_name, find_this, false);
14320 }
14321 {
14322 let to_remove = ["profileId", "webPropertyId", "accountId"];
14323 params.remove_params(&to_remove);
14324 }
14325
14326 let url = params.parse_with_url(&url);
14327
14328 loop {
14329 let token = match self
14330 .hub
14331 .auth
14332 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14333 .await
14334 {
14335 Ok(token) => token,
14336 Err(e) => match dlg.token(e) {
14337 Ok(token) => token,
14338 Err(e) => {
14339 dlg.finished(false);
14340 return Err(common::Error::MissingToken(e));
14341 }
14342 },
14343 };
14344 let mut req_result = {
14345 let client = &self.hub.client;
14346 dlg.pre_request();
14347 let mut req_builder = hyper::Request::builder()
14348 .method(hyper::Method::GET)
14349 .uri(url.as_str())
14350 .header(USER_AGENT, self.hub._user_agent.clone());
14351
14352 if let Some(token) = token.as_ref() {
14353 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14354 }
14355
14356 let request = req_builder
14357 .header(CONTENT_LENGTH, 0_u64)
14358 .body(common::to_body::<String>(None));
14359
14360 client.request(request.unwrap()).await
14361 };
14362
14363 match req_result {
14364 Err(err) => {
14365 if let common::Retry::After(d) = dlg.http_error(&err) {
14366 sleep(d).await;
14367 continue;
14368 }
14369 dlg.finished(false);
14370 return Err(common::Error::HttpError(err));
14371 }
14372 Ok(res) => {
14373 let (mut parts, body) = res.into_parts();
14374 let mut body = common::Body::new(body);
14375 if !parts.status.is_success() {
14376 let bytes = common::to_bytes(body).await.unwrap_or_default();
14377 let error = serde_json::from_str(&common::to_string(&bytes));
14378 let response = common::to_response(parts, bytes.into());
14379
14380 if let common::Retry::After(d) =
14381 dlg.http_failure(&response, error.as_ref().ok())
14382 {
14383 sleep(d).await;
14384 continue;
14385 }
14386
14387 dlg.finished(false);
14388
14389 return Err(match error {
14390 Ok(value) => common::Error::BadRequest(value),
14391 _ => common::Error::Failure(response),
14392 });
14393 }
14394 let response = {
14395 let bytes = common::to_bytes(body).await.unwrap_or_default();
14396 let encoded = common::to_string(&bytes);
14397 match serde_json::from_str(&encoded) {
14398 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14399 Err(error) => {
14400 dlg.response_json_decode_error(&encoded, &error);
14401 return Err(common::Error::JsonDecodeError(
14402 encoded.to_string(),
14403 error,
14404 ));
14405 }
14406 }
14407 };
14408
14409 dlg.finished(true);
14410 return Ok(response);
14411 }
14412 }
14413 }
14414 }
14415
14416 /// Account ID to retrieve experiments 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) -> ManagementExperimentListCall<'a, C> {
14423 self._account_id = new_value.to_string();
14424 self
14425 }
14426 /// Web property ID to retrieve experiments 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) -> ManagementExperimentListCall<'a, C> {
14433 self._web_property_id = new_value.to_string();
14434 self
14435 }
14436 /// View (Profile) ID to retrieve experiments 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) -> ManagementExperimentListCall<'a, C> {
14443 self._profile_id = new_value.to_string();
14444 self
14445 }
14446 /// An index of the first experiment to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
14447 ///
14448 /// Sets the *start-index* query property to the given value.
14449 pub fn start_index(mut self, new_value: i32) -> ManagementExperimentListCall<'a, C> {
14450 self._start_index = Some(new_value);
14451 self
14452 }
14453 /// The maximum number of experiments to include in this response.
14454 ///
14455 /// Sets the *max-results* query property to the given value.
14456 pub fn max_results(mut self, new_value: i32) -> ManagementExperimentListCall<'a, C> {
14457 self._max_results = Some(new_value);
14458 self
14459 }
14460 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14461 /// while executing the actual API request.
14462 ///
14463 /// ````text
14464 /// It should be used to handle progress information, and to implement a certain level of resilience.
14465 /// ````
14466 ///
14467 /// Sets the *delegate* property to the given value.
14468 pub fn delegate(
14469 mut self,
14470 new_value: &'a mut dyn common::Delegate,
14471 ) -> ManagementExperimentListCall<'a, C> {
14472 self._delegate = Some(new_value);
14473 self
14474 }
14475
14476 /// Set any additional parameter of the query string used in the request.
14477 /// It should be used to set parameters which are not yet available through their own
14478 /// setters.
14479 ///
14480 /// Please note that this method must not be used to set any of the known parameters
14481 /// which have their own setter method. If done anyway, the request will fail.
14482 ///
14483 /// # Additional Parameters
14484 ///
14485 /// * *alt* (query-string) - Data format for the response.
14486 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14487 /// * *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.
14488 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14489 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14490 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14491 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14492 pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentListCall<'a, C>
14493 where
14494 T: AsRef<str>,
14495 {
14496 self._additional_params
14497 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14498 self
14499 }
14500
14501 /// Identifies the authorization scope for the method you are building.
14502 ///
14503 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14504 /// [`Scope::Readonly`].
14505 ///
14506 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14507 /// tokens for more than one scope.
14508 ///
14509 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14510 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14511 /// sufficient, a read-write scope will do as well.
14512 pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentListCall<'a, C>
14513 where
14514 St: AsRef<str>,
14515 {
14516 self._scopes.insert(String::from(scope.as_ref()));
14517 self
14518 }
14519 /// Identifies the authorization scope(s) for the method you are building.
14520 ///
14521 /// See [`Self::add_scope()`] for details.
14522 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentListCall<'a, C>
14523 where
14524 I: IntoIterator<Item = St>,
14525 St: AsRef<str>,
14526 {
14527 self._scopes
14528 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14529 self
14530 }
14531
14532 /// Removes all scopes, and no default scope will be used either.
14533 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14534 /// for details).
14535 pub fn clear_scopes(mut self) -> ManagementExperimentListCall<'a, C> {
14536 self._scopes.clear();
14537 self
14538 }
14539}
14540
14541/// Update an existing experiment. This method supports patch semantics.
14542///
14543/// A builder for the *experiments.patch* method supported by a *management* resource.
14544/// It is not used directly, but through a [`ManagementMethods`] instance.
14545///
14546/// # Example
14547///
14548/// Instantiate a resource method builder
14549///
14550/// ```test_harness,no_run
14551/// # extern crate hyper;
14552/// # extern crate hyper_rustls;
14553/// # extern crate google_analytics3 as analytics3;
14554/// use analytics3::api::Experiment;
14555/// # async fn dox() {
14556/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14557///
14558/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14559/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14560/// # secret,
14561/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14562/// # ).build().await.unwrap();
14563///
14564/// # let client = hyper_util::client::legacy::Client::builder(
14565/// # hyper_util::rt::TokioExecutor::new()
14566/// # )
14567/// # .build(
14568/// # hyper_rustls::HttpsConnectorBuilder::new()
14569/// # .with_native_roots()
14570/// # .unwrap()
14571/// # .https_or_http()
14572/// # .enable_http1()
14573/// # .build()
14574/// # );
14575/// # let mut hub = Analytics::new(client, auth);
14576/// // As the method needs a request, you would usually fill it with the desired information
14577/// // into the respective structure. Some of the parts shown here might not be applicable !
14578/// // Values shown here are possibly random and not representative !
14579/// let mut req = Experiment::default();
14580///
14581/// // You can configure optional parameters by calling the respective setters at will, and
14582/// // execute the final call using `doit()`.
14583/// // Values shown here are possibly random and not representative !
14584/// let result = hub.management().experiments_patch(req, "accountId", "webPropertyId", "profileId", "experimentId")
14585/// .doit().await;
14586/// # }
14587/// ```
14588pub struct ManagementExperimentPatchCall<'a, C>
14589where
14590 C: 'a,
14591{
14592 hub: &'a Analytics<C>,
14593 _request: Experiment,
14594 _account_id: String,
14595 _web_property_id: String,
14596 _profile_id: String,
14597 _experiment_id: String,
14598 _delegate: Option<&'a mut dyn common::Delegate>,
14599 _additional_params: HashMap<String, String>,
14600 _scopes: BTreeSet<String>,
14601}
14602
14603impl<'a, C> common::CallBuilder for ManagementExperimentPatchCall<'a, C> {}
14604
14605impl<'a, C> ManagementExperimentPatchCall<'a, C>
14606where
14607 C: common::Connector,
14608{
14609 /// Perform the operation you have build so far.
14610 pub async fn doit(mut self) -> common::Result<(common::Response, Experiment)> {
14611 use std::borrow::Cow;
14612 use std::io::{Read, Seek};
14613
14614 use common::{url::Params, ToParts};
14615 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14616
14617 let mut dd = common::DefaultDelegate;
14618 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14619 dlg.begin(common::MethodInfo {
14620 id: "analytics.management.experiments.patch",
14621 http_method: hyper::Method::PATCH,
14622 });
14623
14624 for &field in [
14625 "alt",
14626 "accountId",
14627 "webPropertyId",
14628 "profileId",
14629 "experimentId",
14630 ]
14631 .iter()
14632 {
14633 if self._additional_params.contains_key(field) {
14634 dlg.finished(false);
14635 return Err(common::Error::FieldClash(field));
14636 }
14637 }
14638
14639 let mut params = Params::with_capacity(7 + self._additional_params.len());
14640 params.push("accountId", self._account_id);
14641 params.push("webPropertyId", self._web_property_id);
14642 params.push("profileId", self._profile_id);
14643 params.push("experimentId", self._experiment_id);
14644
14645 params.extend(self._additional_params.iter());
14646
14647 params.push("alt", "json");
14648 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}";
14649 if self._scopes.is_empty() {
14650 self._scopes.insert(Scope::Full.as_ref().to_string());
14651 }
14652
14653 #[allow(clippy::single_element_loop)]
14654 for &(find_this, param_name) in [
14655 ("{accountId}", "accountId"),
14656 ("{webPropertyId}", "webPropertyId"),
14657 ("{profileId}", "profileId"),
14658 ("{experimentId}", "experimentId"),
14659 ]
14660 .iter()
14661 {
14662 url = params.uri_replacement(url, param_name, find_this, false);
14663 }
14664 {
14665 let to_remove = ["experimentId", "profileId", "webPropertyId", "accountId"];
14666 params.remove_params(&to_remove);
14667 }
14668
14669 let url = params.parse_with_url(&url);
14670
14671 let mut json_mime_type = mime::APPLICATION_JSON;
14672 let mut request_value_reader = {
14673 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14674 common::remove_json_null_values(&mut value);
14675 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14676 serde_json::to_writer(&mut dst, &value).unwrap();
14677 dst
14678 };
14679 let request_size = request_value_reader
14680 .seek(std::io::SeekFrom::End(0))
14681 .unwrap();
14682 request_value_reader
14683 .seek(std::io::SeekFrom::Start(0))
14684 .unwrap();
14685
14686 loop {
14687 let token = match self
14688 .hub
14689 .auth
14690 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14691 .await
14692 {
14693 Ok(token) => token,
14694 Err(e) => match dlg.token(e) {
14695 Ok(token) => token,
14696 Err(e) => {
14697 dlg.finished(false);
14698 return Err(common::Error::MissingToken(e));
14699 }
14700 },
14701 };
14702 request_value_reader
14703 .seek(std::io::SeekFrom::Start(0))
14704 .unwrap();
14705 let mut req_result = {
14706 let client = &self.hub.client;
14707 dlg.pre_request();
14708 let mut req_builder = hyper::Request::builder()
14709 .method(hyper::Method::PATCH)
14710 .uri(url.as_str())
14711 .header(USER_AGENT, self.hub._user_agent.clone());
14712
14713 if let Some(token) = token.as_ref() {
14714 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14715 }
14716
14717 let request = req_builder
14718 .header(CONTENT_TYPE, json_mime_type.to_string())
14719 .header(CONTENT_LENGTH, request_size as u64)
14720 .body(common::to_body(
14721 request_value_reader.get_ref().clone().into(),
14722 ));
14723
14724 client.request(request.unwrap()).await
14725 };
14726
14727 match req_result {
14728 Err(err) => {
14729 if let common::Retry::After(d) = dlg.http_error(&err) {
14730 sleep(d).await;
14731 continue;
14732 }
14733 dlg.finished(false);
14734 return Err(common::Error::HttpError(err));
14735 }
14736 Ok(res) => {
14737 let (mut parts, body) = res.into_parts();
14738 let mut body = common::Body::new(body);
14739 if !parts.status.is_success() {
14740 let bytes = common::to_bytes(body).await.unwrap_or_default();
14741 let error = serde_json::from_str(&common::to_string(&bytes));
14742 let response = common::to_response(parts, bytes.into());
14743
14744 if let common::Retry::After(d) =
14745 dlg.http_failure(&response, error.as_ref().ok())
14746 {
14747 sleep(d).await;
14748 continue;
14749 }
14750
14751 dlg.finished(false);
14752
14753 return Err(match error {
14754 Ok(value) => common::Error::BadRequest(value),
14755 _ => common::Error::Failure(response),
14756 });
14757 }
14758 let response = {
14759 let bytes = common::to_bytes(body).await.unwrap_or_default();
14760 let encoded = common::to_string(&bytes);
14761 match serde_json::from_str(&encoded) {
14762 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14763 Err(error) => {
14764 dlg.response_json_decode_error(&encoded, &error);
14765 return Err(common::Error::JsonDecodeError(
14766 encoded.to_string(),
14767 error,
14768 ));
14769 }
14770 }
14771 };
14772
14773 dlg.finished(true);
14774 return Ok(response);
14775 }
14776 }
14777 }
14778 }
14779
14780 ///
14781 /// Sets the *request* property to the given value.
14782 ///
14783 /// Even though the property as already been set when instantiating this call,
14784 /// we provide this method for API completeness.
14785 pub fn request(mut self, new_value: Experiment) -> ManagementExperimentPatchCall<'a, C> {
14786 self._request = new_value;
14787 self
14788 }
14789 /// Account ID of the experiment to update.
14790 ///
14791 /// Sets the *account id* path property to the given value.
14792 ///
14793 /// Even though the property as already been set when instantiating this call,
14794 /// we provide this method for API completeness.
14795 pub fn account_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C> {
14796 self._account_id = new_value.to_string();
14797 self
14798 }
14799 /// Web property ID of the experiment to update.
14800 ///
14801 /// Sets the *web property id* path property to the given value.
14802 ///
14803 /// Even though the property as already been set when instantiating this call,
14804 /// we provide this method for API completeness.
14805 pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C> {
14806 self._web_property_id = new_value.to_string();
14807 self
14808 }
14809 /// View (Profile) ID of the experiment to update.
14810 ///
14811 /// Sets the *profile id* path property to the given value.
14812 ///
14813 /// Even though the property as already been set when instantiating this call,
14814 /// we provide this method for API completeness.
14815 pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C> {
14816 self._profile_id = new_value.to_string();
14817 self
14818 }
14819 /// Experiment ID of the experiment to update.
14820 ///
14821 /// Sets the *experiment id* path property to the given value.
14822 ///
14823 /// Even though the property as already been set when instantiating this call,
14824 /// we provide this method for API completeness.
14825 pub fn experiment_id(mut self, new_value: &str) -> ManagementExperimentPatchCall<'a, C> {
14826 self._experiment_id = new_value.to_string();
14827 self
14828 }
14829 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14830 /// while executing the actual API request.
14831 ///
14832 /// ````text
14833 /// It should be used to handle progress information, and to implement a certain level of resilience.
14834 /// ````
14835 ///
14836 /// Sets the *delegate* property to the given value.
14837 pub fn delegate(
14838 mut self,
14839 new_value: &'a mut dyn common::Delegate,
14840 ) -> ManagementExperimentPatchCall<'a, C> {
14841 self._delegate = Some(new_value);
14842 self
14843 }
14844
14845 /// Set any additional parameter of the query string used in the request.
14846 /// It should be used to set parameters which are not yet available through their own
14847 /// setters.
14848 ///
14849 /// Please note that this method must not be used to set any of the known parameters
14850 /// which have their own setter method. If done anyway, the request will fail.
14851 ///
14852 /// # Additional Parameters
14853 ///
14854 /// * *alt* (query-string) - Data format for the response.
14855 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14856 /// * *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.
14857 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14858 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14859 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14860 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14861 pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentPatchCall<'a, C>
14862 where
14863 T: AsRef<str>,
14864 {
14865 self._additional_params
14866 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14867 self
14868 }
14869
14870 /// Identifies the authorization scope for the method you are building.
14871 ///
14872 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14873 /// [`Scope::Full`].
14874 ///
14875 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14876 /// tokens for more than one scope.
14877 ///
14878 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14879 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14880 /// sufficient, a read-write scope will do as well.
14881 pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentPatchCall<'a, C>
14882 where
14883 St: AsRef<str>,
14884 {
14885 self._scopes.insert(String::from(scope.as_ref()));
14886 self
14887 }
14888 /// Identifies the authorization scope(s) for the method you are building.
14889 ///
14890 /// See [`Self::add_scope()`] for details.
14891 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentPatchCall<'a, C>
14892 where
14893 I: IntoIterator<Item = St>,
14894 St: AsRef<str>,
14895 {
14896 self._scopes
14897 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14898 self
14899 }
14900
14901 /// Removes all scopes, and no default scope will be used either.
14902 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14903 /// for details).
14904 pub fn clear_scopes(mut self) -> ManagementExperimentPatchCall<'a, C> {
14905 self._scopes.clear();
14906 self
14907 }
14908}
14909
14910/// Update an existing experiment.
14911///
14912/// A builder for the *experiments.update* method supported by a *management* resource.
14913/// It is not used directly, but through a [`ManagementMethods`] instance.
14914///
14915/// # Example
14916///
14917/// Instantiate a resource method builder
14918///
14919/// ```test_harness,no_run
14920/// # extern crate hyper;
14921/// # extern crate hyper_rustls;
14922/// # extern crate google_analytics3 as analytics3;
14923/// use analytics3::api::Experiment;
14924/// # async fn dox() {
14925/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14926///
14927/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14928/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14929/// # secret,
14930/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14931/// # ).build().await.unwrap();
14932///
14933/// # let client = hyper_util::client::legacy::Client::builder(
14934/// # hyper_util::rt::TokioExecutor::new()
14935/// # )
14936/// # .build(
14937/// # hyper_rustls::HttpsConnectorBuilder::new()
14938/// # .with_native_roots()
14939/// # .unwrap()
14940/// # .https_or_http()
14941/// # .enable_http1()
14942/// # .build()
14943/// # );
14944/// # let mut hub = Analytics::new(client, auth);
14945/// // As the method needs a request, you would usually fill it with the desired information
14946/// // into the respective structure. Some of the parts shown here might not be applicable !
14947/// // Values shown here are possibly random and not representative !
14948/// let mut req = Experiment::default();
14949///
14950/// // You can configure optional parameters by calling the respective setters at will, and
14951/// // execute the final call using `doit()`.
14952/// // Values shown here are possibly random and not representative !
14953/// let result = hub.management().experiments_update(req, "accountId", "webPropertyId", "profileId", "experimentId")
14954/// .doit().await;
14955/// # }
14956/// ```
14957pub struct ManagementExperimentUpdateCall<'a, C>
14958where
14959 C: 'a,
14960{
14961 hub: &'a Analytics<C>,
14962 _request: Experiment,
14963 _account_id: String,
14964 _web_property_id: String,
14965 _profile_id: String,
14966 _experiment_id: String,
14967 _delegate: Option<&'a mut dyn common::Delegate>,
14968 _additional_params: HashMap<String, String>,
14969 _scopes: BTreeSet<String>,
14970}
14971
14972impl<'a, C> common::CallBuilder for ManagementExperimentUpdateCall<'a, C> {}
14973
14974impl<'a, C> ManagementExperimentUpdateCall<'a, C>
14975where
14976 C: common::Connector,
14977{
14978 /// Perform the operation you have build so far.
14979 pub async fn doit(mut self) -> common::Result<(common::Response, Experiment)> {
14980 use std::borrow::Cow;
14981 use std::io::{Read, Seek};
14982
14983 use common::{url::Params, ToParts};
14984 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14985
14986 let mut dd = common::DefaultDelegate;
14987 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14988 dlg.begin(common::MethodInfo {
14989 id: "analytics.management.experiments.update",
14990 http_method: hyper::Method::PUT,
14991 });
14992
14993 for &field in [
14994 "alt",
14995 "accountId",
14996 "webPropertyId",
14997 "profileId",
14998 "experimentId",
14999 ]
15000 .iter()
15001 {
15002 if self._additional_params.contains_key(field) {
15003 dlg.finished(false);
15004 return Err(common::Error::FieldClash(field));
15005 }
15006 }
15007
15008 let mut params = Params::with_capacity(7 + self._additional_params.len());
15009 params.push("accountId", self._account_id);
15010 params.push("webPropertyId", self._web_property_id);
15011 params.push("profileId", self._profile_id);
15012 params.push("experimentId", self._experiment_id);
15013
15014 params.extend(self._additional_params.iter());
15015
15016 params.push("alt", "json");
15017 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}";
15018 if self._scopes.is_empty() {
15019 self._scopes.insert(Scope::Full.as_ref().to_string());
15020 }
15021
15022 #[allow(clippy::single_element_loop)]
15023 for &(find_this, param_name) in [
15024 ("{accountId}", "accountId"),
15025 ("{webPropertyId}", "webPropertyId"),
15026 ("{profileId}", "profileId"),
15027 ("{experimentId}", "experimentId"),
15028 ]
15029 .iter()
15030 {
15031 url = params.uri_replacement(url, param_name, find_this, false);
15032 }
15033 {
15034 let to_remove = ["experimentId", "profileId", "webPropertyId", "accountId"];
15035 params.remove_params(&to_remove);
15036 }
15037
15038 let url = params.parse_with_url(&url);
15039
15040 let mut json_mime_type = mime::APPLICATION_JSON;
15041 let mut request_value_reader = {
15042 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15043 common::remove_json_null_values(&mut value);
15044 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15045 serde_json::to_writer(&mut dst, &value).unwrap();
15046 dst
15047 };
15048 let request_size = request_value_reader
15049 .seek(std::io::SeekFrom::End(0))
15050 .unwrap();
15051 request_value_reader
15052 .seek(std::io::SeekFrom::Start(0))
15053 .unwrap();
15054
15055 loop {
15056 let token = match self
15057 .hub
15058 .auth
15059 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15060 .await
15061 {
15062 Ok(token) => token,
15063 Err(e) => match dlg.token(e) {
15064 Ok(token) => token,
15065 Err(e) => {
15066 dlg.finished(false);
15067 return Err(common::Error::MissingToken(e));
15068 }
15069 },
15070 };
15071 request_value_reader
15072 .seek(std::io::SeekFrom::Start(0))
15073 .unwrap();
15074 let mut req_result = {
15075 let client = &self.hub.client;
15076 dlg.pre_request();
15077 let mut req_builder = hyper::Request::builder()
15078 .method(hyper::Method::PUT)
15079 .uri(url.as_str())
15080 .header(USER_AGENT, self.hub._user_agent.clone());
15081
15082 if let Some(token) = token.as_ref() {
15083 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15084 }
15085
15086 let request = req_builder
15087 .header(CONTENT_TYPE, json_mime_type.to_string())
15088 .header(CONTENT_LENGTH, request_size as u64)
15089 .body(common::to_body(
15090 request_value_reader.get_ref().clone().into(),
15091 ));
15092
15093 client.request(request.unwrap()).await
15094 };
15095
15096 match req_result {
15097 Err(err) => {
15098 if let common::Retry::After(d) = dlg.http_error(&err) {
15099 sleep(d).await;
15100 continue;
15101 }
15102 dlg.finished(false);
15103 return Err(common::Error::HttpError(err));
15104 }
15105 Ok(res) => {
15106 let (mut parts, body) = res.into_parts();
15107 let mut body = common::Body::new(body);
15108 if !parts.status.is_success() {
15109 let bytes = common::to_bytes(body).await.unwrap_or_default();
15110 let error = serde_json::from_str(&common::to_string(&bytes));
15111 let response = common::to_response(parts, bytes.into());
15112
15113 if let common::Retry::After(d) =
15114 dlg.http_failure(&response, error.as_ref().ok())
15115 {
15116 sleep(d).await;
15117 continue;
15118 }
15119
15120 dlg.finished(false);
15121
15122 return Err(match error {
15123 Ok(value) => common::Error::BadRequest(value),
15124 _ => common::Error::Failure(response),
15125 });
15126 }
15127 let response = {
15128 let bytes = common::to_bytes(body).await.unwrap_or_default();
15129 let encoded = common::to_string(&bytes);
15130 match serde_json::from_str(&encoded) {
15131 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15132 Err(error) => {
15133 dlg.response_json_decode_error(&encoded, &error);
15134 return Err(common::Error::JsonDecodeError(
15135 encoded.to_string(),
15136 error,
15137 ));
15138 }
15139 }
15140 };
15141
15142 dlg.finished(true);
15143 return Ok(response);
15144 }
15145 }
15146 }
15147 }
15148
15149 ///
15150 /// Sets the *request* property to the given value.
15151 ///
15152 /// Even though the property as already been set when instantiating this call,
15153 /// we provide this method for API completeness.
15154 pub fn request(mut self, new_value: Experiment) -> ManagementExperimentUpdateCall<'a, C> {
15155 self._request = new_value;
15156 self
15157 }
15158 /// Account ID of the experiment to update.
15159 ///
15160 /// Sets the *account id* path property to the given value.
15161 ///
15162 /// Even though the property as already been set when instantiating this call,
15163 /// we provide this method for API completeness.
15164 pub fn account_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C> {
15165 self._account_id = new_value.to_string();
15166 self
15167 }
15168 /// Web property ID of the experiment to update.
15169 ///
15170 /// Sets the *web property id* path property to the given value.
15171 ///
15172 /// Even though the property as already been set when instantiating this call,
15173 /// we provide this method for API completeness.
15174 pub fn web_property_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C> {
15175 self._web_property_id = new_value.to_string();
15176 self
15177 }
15178 /// View (Profile) ID of the experiment to update.
15179 ///
15180 /// Sets the *profile id* path property to the given value.
15181 ///
15182 /// Even though the property as already been set when instantiating this call,
15183 /// we provide this method for API completeness.
15184 pub fn profile_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C> {
15185 self._profile_id = new_value.to_string();
15186 self
15187 }
15188 /// Experiment ID of the experiment to update.
15189 ///
15190 /// Sets the *experiment id* path property to the given value.
15191 ///
15192 /// Even though the property as already been set when instantiating this call,
15193 /// we provide this method for API completeness.
15194 pub fn experiment_id(mut self, new_value: &str) -> ManagementExperimentUpdateCall<'a, C> {
15195 self._experiment_id = new_value.to_string();
15196 self
15197 }
15198 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15199 /// while executing the actual API request.
15200 ///
15201 /// ````text
15202 /// It should be used to handle progress information, and to implement a certain level of resilience.
15203 /// ````
15204 ///
15205 /// Sets the *delegate* property to the given value.
15206 pub fn delegate(
15207 mut self,
15208 new_value: &'a mut dyn common::Delegate,
15209 ) -> ManagementExperimentUpdateCall<'a, C> {
15210 self._delegate = Some(new_value);
15211 self
15212 }
15213
15214 /// Set any additional parameter of the query string used in the request.
15215 /// It should be used to set parameters which are not yet available through their own
15216 /// setters.
15217 ///
15218 /// Please note that this method must not be used to set any of the known parameters
15219 /// which have their own setter method. If done anyway, the request will fail.
15220 ///
15221 /// # Additional Parameters
15222 ///
15223 /// * *alt* (query-string) - Data format for the response.
15224 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15225 /// * *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.
15226 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15227 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15228 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15229 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15230 pub fn param<T>(mut self, name: T, value: T) -> ManagementExperimentUpdateCall<'a, C>
15231 where
15232 T: AsRef<str>,
15233 {
15234 self._additional_params
15235 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15236 self
15237 }
15238
15239 /// Identifies the authorization scope for the method you are building.
15240 ///
15241 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15242 /// [`Scope::Full`].
15243 ///
15244 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15245 /// tokens for more than one scope.
15246 ///
15247 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15248 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15249 /// sufficient, a read-write scope will do as well.
15250 pub fn add_scope<St>(mut self, scope: St) -> ManagementExperimentUpdateCall<'a, C>
15251 where
15252 St: AsRef<str>,
15253 {
15254 self._scopes.insert(String::from(scope.as_ref()));
15255 self
15256 }
15257 /// Identifies the authorization scope(s) for the method you are building.
15258 ///
15259 /// See [`Self::add_scope()`] for details.
15260 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementExperimentUpdateCall<'a, C>
15261 where
15262 I: IntoIterator<Item = St>,
15263 St: AsRef<str>,
15264 {
15265 self._scopes
15266 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15267 self
15268 }
15269
15270 /// Removes all scopes, and no default scope will be used either.
15271 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15272 /// for details).
15273 pub fn clear_scopes(mut self) -> ManagementExperimentUpdateCall<'a, C> {
15274 self._scopes.clear();
15275 self
15276 }
15277}
15278
15279/// Delete a filter.
15280///
15281/// A builder for the *filters.delete* method supported by a *management* resource.
15282/// It is not used directly, but through a [`ManagementMethods`] instance.
15283///
15284/// # Example
15285///
15286/// Instantiate a resource method builder
15287///
15288/// ```test_harness,no_run
15289/// # extern crate hyper;
15290/// # extern crate hyper_rustls;
15291/// # extern crate google_analytics3 as analytics3;
15292/// # async fn dox() {
15293/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15294///
15295/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15296/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15297/// # secret,
15298/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15299/// # ).build().await.unwrap();
15300///
15301/// # let client = hyper_util::client::legacy::Client::builder(
15302/// # hyper_util::rt::TokioExecutor::new()
15303/// # )
15304/// # .build(
15305/// # hyper_rustls::HttpsConnectorBuilder::new()
15306/// # .with_native_roots()
15307/// # .unwrap()
15308/// # .https_or_http()
15309/// # .enable_http1()
15310/// # .build()
15311/// # );
15312/// # let mut hub = Analytics::new(client, auth);
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().filters_delete("accountId", "filterId")
15317/// .doit().await;
15318/// # }
15319/// ```
15320pub struct ManagementFilterDeleteCall<'a, C>
15321where
15322 C: 'a,
15323{
15324 hub: &'a Analytics<C>,
15325 _account_id: String,
15326 _filter_id: String,
15327 _delegate: Option<&'a mut dyn common::Delegate>,
15328 _additional_params: HashMap<String, String>,
15329 _scopes: BTreeSet<String>,
15330}
15331
15332impl<'a, C> common::CallBuilder for ManagementFilterDeleteCall<'a, C> {}
15333
15334impl<'a, C> ManagementFilterDeleteCall<'a, C>
15335where
15336 C: common::Connector,
15337{
15338 /// Perform the operation you have build so far.
15339 pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
15340 use std::borrow::Cow;
15341 use std::io::{Read, Seek};
15342
15343 use common::{url::Params, ToParts};
15344 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15345
15346 let mut dd = common::DefaultDelegate;
15347 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15348 dlg.begin(common::MethodInfo {
15349 id: "analytics.management.filters.delete",
15350 http_method: hyper::Method::DELETE,
15351 });
15352
15353 for &field in ["alt", "accountId", "filterId"].iter() {
15354 if self._additional_params.contains_key(field) {
15355 dlg.finished(false);
15356 return Err(common::Error::FieldClash(field));
15357 }
15358 }
15359
15360 let mut params = Params::with_capacity(4 + self._additional_params.len());
15361 params.push("accountId", self._account_id);
15362 params.push("filterId", self._filter_id);
15363
15364 params.extend(self._additional_params.iter());
15365
15366 params.push("alt", "json");
15367 let mut url =
15368 self.hub._base_url.clone() + "management/accounts/{accountId}/filters/{filterId}";
15369 if self._scopes.is_empty() {
15370 self._scopes.insert(Scope::Edit.as_ref().to_string());
15371 }
15372
15373 #[allow(clippy::single_element_loop)]
15374 for &(find_this, param_name) in
15375 [("{accountId}", "accountId"), ("{filterId}", "filterId")].iter()
15376 {
15377 url = params.uri_replacement(url, param_name, find_this, false);
15378 }
15379 {
15380 let to_remove = ["filterId", "accountId"];
15381 params.remove_params(&to_remove);
15382 }
15383
15384 let url = params.parse_with_url(&url);
15385
15386 loop {
15387 let token = match self
15388 .hub
15389 .auth
15390 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15391 .await
15392 {
15393 Ok(token) => token,
15394 Err(e) => match dlg.token(e) {
15395 Ok(token) => token,
15396 Err(e) => {
15397 dlg.finished(false);
15398 return Err(common::Error::MissingToken(e));
15399 }
15400 },
15401 };
15402 let mut req_result = {
15403 let client = &self.hub.client;
15404 dlg.pre_request();
15405 let mut req_builder = hyper::Request::builder()
15406 .method(hyper::Method::DELETE)
15407 .uri(url.as_str())
15408 .header(USER_AGENT, self.hub._user_agent.clone());
15409
15410 if let Some(token) = token.as_ref() {
15411 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15412 }
15413
15414 let request = req_builder
15415 .header(CONTENT_LENGTH, 0_u64)
15416 .body(common::to_body::<String>(None));
15417
15418 client.request(request.unwrap()).await
15419 };
15420
15421 match req_result {
15422 Err(err) => {
15423 if let common::Retry::After(d) = dlg.http_error(&err) {
15424 sleep(d).await;
15425 continue;
15426 }
15427 dlg.finished(false);
15428 return Err(common::Error::HttpError(err));
15429 }
15430 Ok(res) => {
15431 let (mut parts, body) = res.into_parts();
15432 let mut body = common::Body::new(body);
15433 if !parts.status.is_success() {
15434 let bytes = common::to_bytes(body).await.unwrap_or_default();
15435 let error = serde_json::from_str(&common::to_string(&bytes));
15436 let response = common::to_response(parts, bytes.into());
15437
15438 if let common::Retry::After(d) =
15439 dlg.http_failure(&response, error.as_ref().ok())
15440 {
15441 sleep(d).await;
15442 continue;
15443 }
15444
15445 dlg.finished(false);
15446
15447 return Err(match error {
15448 Ok(value) => common::Error::BadRequest(value),
15449 _ => common::Error::Failure(response),
15450 });
15451 }
15452 let response = {
15453 let bytes = common::to_bytes(body).await.unwrap_or_default();
15454 let encoded = common::to_string(&bytes);
15455 match serde_json::from_str(&encoded) {
15456 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15457 Err(error) => {
15458 dlg.response_json_decode_error(&encoded, &error);
15459 return Err(common::Error::JsonDecodeError(
15460 encoded.to_string(),
15461 error,
15462 ));
15463 }
15464 }
15465 };
15466
15467 dlg.finished(true);
15468 return Ok(response);
15469 }
15470 }
15471 }
15472 }
15473
15474 /// Account ID to delete the filter for.
15475 ///
15476 /// Sets the *account id* path property to the given value.
15477 ///
15478 /// Even though the property as already been set when instantiating this call,
15479 /// we provide this method for API completeness.
15480 pub fn account_id(mut self, new_value: &str) -> ManagementFilterDeleteCall<'a, C> {
15481 self._account_id = new_value.to_string();
15482 self
15483 }
15484 /// ID of the filter to be deleted.
15485 ///
15486 /// Sets the *filter id* path property to the given value.
15487 ///
15488 /// Even though the property as already been set when instantiating this call,
15489 /// we provide this method for API completeness.
15490 pub fn filter_id(mut self, new_value: &str) -> ManagementFilterDeleteCall<'a, C> {
15491 self._filter_id = new_value.to_string();
15492 self
15493 }
15494 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15495 /// while executing the actual API request.
15496 ///
15497 /// ````text
15498 /// It should be used to handle progress information, and to implement a certain level of resilience.
15499 /// ````
15500 ///
15501 /// Sets the *delegate* property to the given value.
15502 pub fn delegate(
15503 mut self,
15504 new_value: &'a mut dyn common::Delegate,
15505 ) -> ManagementFilterDeleteCall<'a, C> {
15506 self._delegate = Some(new_value);
15507 self
15508 }
15509
15510 /// Set any additional parameter of the query string used in the request.
15511 /// It should be used to set parameters which are not yet available through their own
15512 /// setters.
15513 ///
15514 /// Please note that this method must not be used to set any of the known parameters
15515 /// which have their own setter method. If done anyway, the request will fail.
15516 ///
15517 /// # Additional Parameters
15518 ///
15519 /// * *alt* (query-string) - Data format for the response.
15520 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15521 /// * *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.
15522 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15523 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15524 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15525 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15526 pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterDeleteCall<'a, C>
15527 where
15528 T: AsRef<str>,
15529 {
15530 self._additional_params
15531 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15532 self
15533 }
15534
15535 /// Identifies the authorization scope for the method you are building.
15536 ///
15537 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15538 /// [`Scope::Edit`].
15539 ///
15540 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15541 /// tokens for more than one scope.
15542 ///
15543 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15544 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15545 /// sufficient, a read-write scope will do as well.
15546 pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterDeleteCall<'a, C>
15547 where
15548 St: AsRef<str>,
15549 {
15550 self._scopes.insert(String::from(scope.as_ref()));
15551 self
15552 }
15553 /// Identifies the authorization scope(s) for the method you are building.
15554 ///
15555 /// See [`Self::add_scope()`] for details.
15556 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterDeleteCall<'a, C>
15557 where
15558 I: IntoIterator<Item = St>,
15559 St: AsRef<str>,
15560 {
15561 self._scopes
15562 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15563 self
15564 }
15565
15566 /// Removes all scopes, and no default scope will be used either.
15567 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15568 /// for details).
15569 pub fn clear_scopes(mut self) -> ManagementFilterDeleteCall<'a, C> {
15570 self._scopes.clear();
15571 self
15572 }
15573}
15574
15575/// Returns filters to which the user has access.
15576///
15577/// A builder for the *filters.get* method supported by a *management* resource.
15578/// It is not used directly, but through a [`ManagementMethods`] instance.
15579///
15580/// # Example
15581///
15582/// Instantiate a resource method builder
15583///
15584/// ```test_harness,no_run
15585/// # extern crate hyper;
15586/// # extern crate hyper_rustls;
15587/// # extern crate google_analytics3 as analytics3;
15588/// # async fn dox() {
15589/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15590///
15591/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15592/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15593/// # secret,
15594/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15595/// # ).build().await.unwrap();
15596///
15597/// # let client = hyper_util::client::legacy::Client::builder(
15598/// # hyper_util::rt::TokioExecutor::new()
15599/// # )
15600/// # .build(
15601/// # hyper_rustls::HttpsConnectorBuilder::new()
15602/// # .with_native_roots()
15603/// # .unwrap()
15604/// # .https_or_http()
15605/// # .enable_http1()
15606/// # .build()
15607/// # );
15608/// # let mut hub = Analytics::new(client, auth);
15609/// // You can configure optional parameters by calling the respective setters at will, and
15610/// // execute the final call using `doit()`.
15611/// // Values shown here are possibly random and not representative !
15612/// let result = hub.management().filters_get("accountId", "filterId")
15613/// .doit().await;
15614/// # }
15615/// ```
15616pub struct ManagementFilterGetCall<'a, C>
15617where
15618 C: 'a,
15619{
15620 hub: &'a Analytics<C>,
15621 _account_id: String,
15622 _filter_id: String,
15623 _delegate: Option<&'a mut dyn common::Delegate>,
15624 _additional_params: HashMap<String, String>,
15625 _scopes: BTreeSet<String>,
15626}
15627
15628impl<'a, C> common::CallBuilder for ManagementFilterGetCall<'a, C> {}
15629
15630impl<'a, C> ManagementFilterGetCall<'a, C>
15631where
15632 C: common::Connector,
15633{
15634 /// Perform the operation you have build so far.
15635 pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
15636 use std::borrow::Cow;
15637 use std::io::{Read, Seek};
15638
15639 use common::{url::Params, ToParts};
15640 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15641
15642 let mut dd = common::DefaultDelegate;
15643 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15644 dlg.begin(common::MethodInfo {
15645 id: "analytics.management.filters.get",
15646 http_method: hyper::Method::GET,
15647 });
15648
15649 for &field in ["alt", "accountId", "filterId"].iter() {
15650 if self._additional_params.contains_key(field) {
15651 dlg.finished(false);
15652 return Err(common::Error::FieldClash(field));
15653 }
15654 }
15655
15656 let mut params = Params::with_capacity(4 + self._additional_params.len());
15657 params.push("accountId", self._account_id);
15658 params.push("filterId", self._filter_id);
15659
15660 params.extend(self._additional_params.iter());
15661
15662 params.push("alt", "json");
15663 let mut url =
15664 self.hub._base_url.clone() + "management/accounts/{accountId}/filters/{filterId}";
15665 if self._scopes.is_empty() {
15666 self._scopes.insert(Scope::Readonly.as_ref().to_string());
15667 }
15668
15669 #[allow(clippy::single_element_loop)]
15670 for &(find_this, param_name) in
15671 [("{accountId}", "accountId"), ("{filterId}", "filterId")].iter()
15672 {
15673 url = params.uri_replacement(url, param_name, find_this, false);
15674 }
15675 {
15676 let to_remove = ["filterId", "accountId"];
15677 params.remove_params(&to_remove);
15678 }
15679
15680 let url = params.parse_with_url(&url);
15681
15682 loop {
15683 let token = match self
15684 .hub
15685 .auth
15686 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15687 .await
15688 {
15689 Ok(token) => token,
15690 Err(e) => match dlg.token(e) {
15691 Ok(token) => token,
15692 Err(e) => {
15693 dlg.finished(false);
15694 return Err(common::Error::MissingToken(e));
15695 }
15696 },
15697 };
15698 let mut req_result = {
15699 let client = &self.hub.client;
15700 dlg.pre_request();
15701 let mut req_builder = hyper::Request::builder()
15702 .method(hyper::Method::GET)
15703 .uri(url.as_str())
15704 .header(USER_AGENT, self.hub._user_agent.clone());
15705
15706 if let Some(token) = token.as_ref() {
15707 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15708 }
15709
15710 let request = req_builder
15711 .header(CONTENT_LENGTH, 0_u64)
15712 .body(common::to_body::<String>(None));
15713
15714 client.request(request.unwrap()).await
15715 };
15716
15717 match req_result {
15718 Err(err) => {
15719 if let common::Retry::After(d) = dlg.http_error(&err) {
15720 sleep(d).await;
15721 continue;
15722 }
15723 dlg.finished(false);
15724 return Err(common::Error::HttpError(err));
15725 }
15726 Ok(res) => {
15727 let (mut parts, body) = res.into_parts();
15728 let mut body = common::Body::new(body);
15729 if !parts.status.is_success() {
15730 let bytes = common::to_bytes(body).await.unwrap_or_default();
15731 let error = serde_json::from_str(&common::to_string(&bytes));
15732 let response = common::to_response(parts, bytes.into());
15733
15734 if let common::Retry::After(d) =
15735 dlg.http_failure(&response, error.as_ref().ok())
15736 {
15737 sleep(d).await;
15738 continue;
15739 }
15740
15741 dlg.finished(false);
15742
15743 return Err(match error {
15744 Ok(value) => common::Error::BadRequest(value),
15745 _ => common::Error::Failure(response),
15746 });
15747 }
15748 let response = {
15749 let bytes = common::to_bytes(body).await.unwrap_or_default();
15750 let encoded = common::to_string(&bytes);
15751 match serde_json::from_str(&encoded) {
15752 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15753 Err(error) => {
15754 dlg.response_json_decode_error(&encoded, &error);
15755 return Err(common::Error::JsonDecodeError(
15756 encoded.to_string(),
15757 error,
15758 ));
15759 }
15760 }
15761 };
15762
15763 dlg.finished(true);
15764 return Ok(response);
15765 }
15766 }
15767 }
15768 }
15769
15770 /// Account ID to retrieve filters for.
15771 ///
15772 /// Sets the *account id* path property to the given value.
15773 ///
15774 /// Even though the property as already been set when instantiating this call,
15775 /// we provide this method for API completeness.
15776 pub fn account_id(mut self, new_value: &str) -> ManagementFilterGetCall<'a, C> {
15777 self._account_id = new_value.to_string();
15778 self
15779 }
15780 /// Filter ID to retrieve filters for.
15781 ///
15782 /// Sets the *filter id* path property to the given value.
15783 ///
15784 /// Even though the property as already been set when instantiating this call,
15785 /// we provide this method for API completeness.
15786 pub fn filter_id(mut self, new_value: &str) -> ManagementFilterGetCall<'a, C> {
15787 self._filter_id = new_value.to_string();
15788 self
15789 }
15790 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15791 /// while executing the actual API request.
15792 ///
15793 /// ````text
15794 /// It should be used to handle progress information, and to implement a certain level of resilience.
15795 /// ````
15796 ///
15797 /// Sets the *delegate* property to the given value.
15798 pub fn delegate(
15799 mut self,
15800 new_value: &'a mut dyn common::Delegate,
15801 ) -> ManagementFilterGetCall<'a, C> {
15802 self._delegate = Some(new_value);
15803 self
15804 }
15805
15806 /// Set any additional parameter of the query string used in the request.
15807 /// It should be used to set parameters which are not yet available through their own
15808 /// setters.
15809 ///
15810 /// Please note that this method must not be used to set any of the known parameters
15811 /// which have their own setter method. If done anyway, the request will fail.
15812 ///
15813 /// # Additional Parameters
15814 ///
15815 /// * *alt* (query-string) - Data format for the response.
15816 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15817 /// * *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.
15818 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15819 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15820 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15821 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15822 pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterGetCall<'a, C>
15823 where
15824 T: AsRef<str>,
15825 {
15826 self._additional_params
15827 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15828 self
15829 }
15830
15831 /// Identifies the authorization scope for the method you are building.
15832 ///
15833 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15834 /// [`Scope::Readonly`].
15835 ///
15836 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15837 /// tokens for more than one scope.
15838 ///
15839 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15840 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15841 /// sufficient, a read-write scope will do as well.
15842 pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterGetCall<'a, C>
15843 where
15844 St: AsRef<str>,
15845 {
15846 self._scopes.insert(String::from(scope.as_ref()));
15847 self
15848 }
15849 /// Identifies the authorization scope(s) for the method you are building.
15850 ///
15851 /// See [`Self::add_scope()`] for details.
15852 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterGetCall<'a, C>
15853 where
15854 I: IntoIterator<Item = St>,
15855 St: AsRef<str>,
15856 {
15857 self._scopes
15858 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15859 self
15860 }
15861
15862 /// Removes all scopes, and no default scope will be used either.
15863 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15864 /// for details).
15865 pub fn clear_scopes(mut self) -> ManagementFilterGetCall<'a, C> {
15866 self._scopes.clear();
15867 self
15868 }
15869}
15870
15871/// Create a new filter.
15872///
15873/// A builder for the *filters.insert* method supported by a *management* resource.
15874/// It is not used directly, but through a [`ManagementMethods`] instance.
15875///
15876/// # Example
15877///
15878/// Instantiate a resource method builder
15879///
15880/// ```test_harness,no_run
15881/// # extern crate hyper;
15882/// # extern crate hyper_rustls;
15883/// # extern crate google_analytics3 as analytics3;
15884/// use analytics3::api::Filter;
15885/// # async fn dox() {
15886/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15887///
15888/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15889/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15890/// # secret,
15891/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15892/// # ).build().await.unwrap();
15893///
15894/// # let client = hyper_util::client::legacy::Client::builder(
15895/// # hyper_util::rt::TokioExecutor::new()
15896/// # )
15897/// # .build(
15898/// # hyper_rustls::HttpsConnectorBuilder::new()
15899/// # .with_native_roots()
15900/// # .unwrap()
15901/// # .https_or_http()
15902/// # .enable_http1()
15903/// # .build()
15904/// # );
15905/// # let mut hub = Analytics::new(client, auth);
15906/// // As the method needs a request, you would usually fill it with the desired information
15907/// // into the respective structure. Some of the parts shown here might not be applicable !
15908/// // Values shown here are possibly random and not representative !
15909/// let mut req = Filter::default();
15910///
15911/// // You can configure optional parameters by calling the respective setters at will, and
15912/// // execute the final call using `doit()`.
15913/// // Values shown here are possibly random and not representative !
15914/// let result = hub.management().filters_insert(req, "accountId")
15915/// .doit().await;
15916/// # }
15917/// ```
15918pub struct ManagementFilterInsertCall<'a, C>
15919where
15920 C: 'a,
15921{
15922 hub: &'a Analytics<C>,
15923 _request: Filter,
15924 _account_id: String,
15925 _delegate: Option<&'a mut dyn common::Delegate>,
15926 _additional_params: HashMap<String, String>,
15927 _scopes: BTreeSet<String>,
15928}
15929
15930impl<'a, C> common::CallBuilder for ManagementFilterInsertCall<'a, C> {}
15931
15932impl<'a, C> ManagementFilterInsertCall<'a, C>
15933where
15934 C: common::Connector,
15935{
15936 /// Perform the operation you have build so far.
15937 pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
15938 use std::borrow::Cow;
15939 use std::io::{Read, Seek};
15940
15941 use common::{url::Params, ToParts};
15942 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15943
15944 let mut dd = common::DefaultDelegate;
15945 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15946 dlg.begin(common::MethodInfo {
15947 id: "analytics.management.filters.insert",
15948 http_method: hyper::Method::POST,
15949 });
15950
15951 for &field in ["alt", "accountId"].iter() {
15952 if self._additional_params.contains_key(field) {
15953 dlg.finished(false);
15954 return Err(common::Error::FieldClash(field));
15955 }
15956 }
15957
15958 let mut params = Params::with_capacity(4 + self._additional_params.len());
15959 params.push("accountId", self._account_id);
15960
15961 params.extend(self._additional_params.iter());
15962
15963 params.push("alt", "json");
15964 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/filters";
15965 if self._scopes.is_empty() {
15966 self._scopes.insert(Scope::Edit.as_ref().to_string());
15967 }
15968
15969 #[allow(clippy::single_element_loop)]
15970 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
15971 url = params.uri_replacement(url, param_name, find_this, false);
15972 }
15973 {
15974 let to_remove = ["accountId"];
15975 params.remove_params(&to_remove);
15976 }
15977
15978 let url = params.parse_with_url(&url);
15979
15980 let mut json_mime_type = mime::APPLICATION_JSON;
15981 let mut request_value_reader = {
15982 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15983 common::remove_json_null_values(&mut value);
15984 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15985 serde_json::to_writer(&mut dst, &value).unwrap();
15986 dst
15987 };
15988 let request_size = request_value_reader
15989 .seek(std::io::SeekFrom::End(0))
15990 .unwrap();
15991 request_value_reader
15992 .seek(std::io::SeekFrom::Start(0))
15993 .unwrap();
15994
15995 loop {
15996 let token = match self
15997 .hub
15998 .auth
15999 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16000 .await
16001 {
16002 Ok(token) => token,
16003 Err(e) => match dlg.token(e) {
16004 Ok(token) => token,
16005 Err(e) => {
16006 dlg.finished(false);
16007 return Err(common::Error::MissingToken(e));
16008 }
16009 },
16010 };
16011 request_value_reader
16012 .seek(std::io::SeekFrom::Start(0))
16013 .unwrap();
16014 let mut req_result = {
16015 let client = &self.hub.client;
16016 dlg.pre_request();
16017 let mut req_builder = hyper::Request::builder()
16018 .method(hyper::Method::POST)
16019 .uri(url.as_str())
16020 .header(USER_AGENT, self.hub._user_agent.clone());
16021
16022 if let Some(token) = token.as_ref() {
16023 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16024 }
16025
16026 let request = req_builder
16027 .header(CONTENT_TYPE, json_mime_type.to_string())
16028 .header(CONTENT_LENGTH, request_size as u64)
16029 .body(common::to_body(
16030 request_value_reader.get_ref().clone().into(),
16031 ));
16032
16033 client.request(request.unwrap()).await
16034 };
16035
16036 match req_result {
16037 Err(err) => {
16038 if let common::Retry::After(d) = dlg.http_error(&err) {
16039 sleep(d).await;
16040 continue;
16041 }
16042 dlg.finished(false);
16043 return Err(common::Error::HttpError(err));
16044 }
16045 Ok(res) => {
16046 let (mut parts, body) = res.into_parts();
16047 let mut body = common::Body::new(body);
16048 if !parts.status.is_success() {
16049 let bytes = common::to_bytes(body).await.unwrap_or_default();
16050 let error = serde_json::from_str(&common::to_string(&bytes));
16051 let response = common::to_response(parts, bytes.into());
16052
16053 if let common::Retry::After(d) =
16054 dlg.http_failure(&response, error.as_ref().ok())
16055 {
16056 sleep(d).await;
16057 continue;
16058 }
16059
16060 dlg.finished(false);
16061
16062 return Err(match error {
16063 Ok(value) => common::Error::BadRequest(value),
16064 _ => common::Error::Failure(response),
16065 });
16066 }
16067 let response = {
16068 let bytes = common::to_bytes(body).await.unwrap_or_default();
16069 let encoded = common::to_string(&bytes);
16070 match serde_json::from_str(&encoded) {
16071 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16072 Err(error) => {
16073 dlg.response_json_decode_error(&encoded, &error);
16074 return Err(common::Error::JsonDecodeError(
16075 encoded.to_string(),
16076 error,
16077 ));
16078 }
16079 }
16080 };
16081
16082 dlg.finished(true);
16083 return Ok(response);
16084 }
16085 }
16086 }
16087 }
16088
16089 ///
16090 /// Sets the *request* property to the given value.
16091 ///
16092 /// Even though the property as already been set when instantiating this call,
16093 /// we provide this method for API completeness.
16094 pub fn request(mut self, new_value: Filter) -> ManagementFilterInsertCall<'a, C> {
16095 self._request = new_value;
16096 self
16097 }
16098 /// Account ID to create filter for.
16099 ///
16100 /// Sets the *account id* path property to the given value.
16101 ///
16102 /// Even though the property as already been set when instantiating this call,
16103 /// we provide this method for API completeness.
16104 pub fn account_id(mut self, new_value: &str) -> ManagementFilterInsertCall<'a, C> {
16105 self._account_id = new_value.to_string();
16106 self
16107 }
16108 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16109 /// while executing the actual API request.
16110 ///
16111 /// ````text
16112 /// It should be used to handle progress information, and to implement a certain level of resilience.
16113 /// ````
16114 ///
16115 /// Sets the *delegate* property to the given value.
16116 pub fn delegate(
16117 mut self,
16118 new_value: &'a mut dyn common::Delegate,
16119 ) -> ManagementFilterInsertCall<'a, C> {
16120 self._delegate = Some(new_value);
16121 self
16122 }
16123
16124 /// Set any additional parameter of the query string used in the request.
16125 /// It should be used to set parameters which are not yet available through their own
16126 /// setters.
16127 ///
16128 /// Please note that this method must not be used to set any of the known parameters
16129 /// which have their own setter method. If done anyway, the request will fail.
16130 ///
16131 /// # Additional Parameters
16132 ///
16133 /// * *alt* (query-string) - Data format for the response.
16134 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16135 /// * *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.
16136 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16137 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16138 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16139 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16140 pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterInsertCall<'a, C>
16141 where
16142 T: AsRef<str>,
16143 {
16144 self._additional_params
16145 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16146 self
16147 }
16148
16149 /// Identifies the authorization scope for the method you are building.
16150 ///
16151 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16152 /// [`Scope::Edit`].
16153 ///
16154 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16155 /// tokens for more than one scope.
16156 ///
16157 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16158 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16159 /// sufficient, a read-write scope will do as well.
16160 pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterInsertCall<'a, C>
16161 where
16162 St: AsRef<str>,
16163 {
16164 self._scopes.insert(String::from(scope.as_ref()));
16165 self
16166 }
16167 /// Identifies the authorization scope(s) for the method you are building.
16168 ///
16169 /// See [`Self::add_scope()`] for details.
16170 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterInsertCall<'a, C>
16171 where
16172 I: IntoIterator<Item = St>,
16173 St: AsRef<str>,
16174 {
16175 self._scopes
16176 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16177 self
16178 }
16179
16180 /// Removes all scopes, and no default scope will be used either.
16181 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16182 /// for details).
16183 pub fn clear_scopes(mut self) -> ManagementFilterInsertCall<'a, C> {
16184 self._scopes.clear();
16185 self
16186 }
16187}
16188
16189/// Lists all filters for an account
16190///
16191/// A builder for the *filters.list* method supported by a *management* resource.
16192/// It is not used directly, but through a [`ManagementMethods`] instance.
16193///
16194/// # Example
16195///
16196/// Instantiate a resource method builder
16197///
16198/// ```test_harness,no_run
16199/// # extern crate hyper;
16200/// # extern crate hyper_rustls;
16201/// # extern crate google_analytics3 as analytics3;
16202/// # async fn dox() {
16203/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16204///
16205/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16206/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16207/// # secret,
16208/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16209/// # ).build().await.unwrap();
16210///
16211/// # let client = hyper_util::client::legacy::Client::builder(
16212/// # hyper_util::rt::TokioExecutor::new()
16213/// # )
16214/// # .build(
16215/// # hyper_rustls::HttpsConnectorBuilder::new()
16216/// # .with_native_roots()
16217/// # .unwrap()
16218/// # .https_or_http()
16219/// # .enable_http1()
16220/// # .build()
16221/// # );
16222/// # let mut hub = Analytics::new(client, auth);
16223/// // You can configure optional parameters by calling the respective setters at will, and
16224/// // execute the final call using `doit()`.
16225/// // Values shown here are possibly random and not representative !
16226/// let result = hub.management().filters_list("accountId")
16227/// .start_index(-77)
16228/// .max_results(-45)
16229/// .doit().await;
16230/// # }
16231/// ```
16232pub struct ManagementFilterListCall<'a, C>
16233where
16234 C: 'a,
16235{
16236 hub: &'a Analytics<C>,
16237 _account_id: String,
16238 _start_index: Option<i32>,
16239 _max_results: Option<i32>,
16240 _delegate: Option<&'a mut dyn common::Delegate>,
16241 _additional_params: HashMap<String, String>,
16242 _scopes: BTreeSet<String>,
16243}
16244
16245impl<'a, C> common::CallBuilder for ManagementFilterListCall<'a, C> {}
16246
16247impl<'a, C> ManagementFilterListCall<'a, C>
16248where
16249 C: common::Connector,
16250{
16251 /// Perform the operation you have build so far.
16252 pub async fn doit(mut self) -> common::Result<(common::Response, Filters)> {
16253 use std::borrow::Cow;
16254 use std::io::{Read, Seek};
16255
16256 use common::{url::Params, ToParts};
16257 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16258
16259 let mut dd = common::DefaultDelegate;
16260 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16261 dlg.begin(common::MethodInfo {
16262 id: "analytics.management.filters.list",
16263 http_method: hyper::Method::GET,
16264 });
16265
16266 for &field in ["alt", "accountId", "start-index", "max-results"].iter() {
16267 if self._additional_params.contains_key(field) {
16268 dlg.finished(false);
16269 return Err(common::Error::FieldClash(field));
16270 }
16271 }
16272
16273 let mut params = Params::with_capacity(5 + self._additional_params.len());
16274 params.push("accountId", self._account_id);
16275 if let Some(value) = self._start_index.as_ref() {
16276 params.push("start-index", value.to_string());
16277 }
16278 if let Some(value) = self._max_results.as_ref() {
16279 params.push("max-results", value.to_string());
16280 }
16281
16282 params.extend(self._additional_params.iter());
16283
16284 params.push("alt", "json");
16285 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/filters";
16286 if self._scopes.is_empty() {
16287 self._scopes.insert(Scope::Readonly.as_ref().to_string());
16288 }
16289
16290 #[allow(clippy::single_element_loop)]
16291 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
16292 url = params.uri_replacement(url, param_name, find_this, false);
16293 }
16294 {
16295 let to_remove = ["accountId"];
16296 params.remove_params(&to_remove);
16297 }
16298
16299 let url = params.parse_with_url(&url);
16300
16301 loop {
16302 let token = match self
16303 .hub
16304 .auth
16305 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16306 .await
16307 {
16308 Ok(token) => token,
16309 Err(e) => match dlg.token(e) {
16310 Ok(token) => token,
16311 Err(e) => {
16312 dlg.finished(false);
16313 return Err(common::Error::MissingToken(e));
16314 }
16315 },
16316 };
16317 let mut req_result = {
16318 let client = &self.hub.client;
16319 dlg.pre_request();
16320 let mut req_builder = hyper::Request::builder()
16321 .method(hyper::Method::GET)
16322 .uri(url.as_str())
16323 .header(USER_AGENT, self.hub._user_agent.clone());
16324
16325 if let Some(token) = token.as_ref() {
16326 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16327 }
16328
16329 let request = req_builder
16330 .header(CONTENT_LENGTH, 0_u64)
16331 .body(common::to_body::<String>(None));
16332
16333 client.request(request.unwrap()).await
16334 };
16335
16336 match req_result {
16337 Err(err) => {
16338 if let common::Retry::After(d) = dlg.http_error(&err) {
16339 sleep(d).await;
16340 continue;
16341 }
16342 dlg.finished(false);
16343 return Err(common::Error::HttpError(err));
16344 }
16345 Ok(res) => {
16346 let (mut parts, body) = res.into_parts();
16347 let mut body = common::Body::new(body);
16348 if !parts.status.is_success() {
16349 let bytes = common::to_bytes(body).await.unwrap_or_default();
16350 let error = serde_json::from_str(&common::to_string(&bytes));
16351 let response = common::to_response(parts, bytes.into());
16352
16353 if let common::Retry::After(d) =
16354 dlg.http_failure(&response, error.as_ref().ok())
16355 {
16356 sleep(d).await;
16357 continue;
16358 }
16359
16360 dlg.finished(false);
16361
16362 return Err(match error {
16363 Ok(value) => common::Error::BadRequest(value),
16364 _ => common::Error::Failure(response),
16365 });
16366 }
16367 let response = {
16368 let bytes = common::to_bytes(body).await.unwrap_or_default();
16369 let encoded = common::to_string(&bytes);
16370 match serde_json::from_str(&encoded) {
16371 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16372 Err(error) => {
16373 dlg.response_json_decode_error(&encoded, &error);
16374 return Err(common::Error::JsonDecodeError(
16375 encoded.to_string(),
16376 error,
16377 ));
16378 }
16379 }
16380 };
16381
16382 dlg.finished(true);
16383 return Ok(response);
16384 }
16385 }
16386 }
16387 }
16388
16389 /// Account ID to retrieve filters for.
16390 ///
16391 /// Sets the *account id* path property to the given value.
16392 ///
16393 /// Even though the property as already been set when instantiating this call,
16394 /// we provide this method for API completeness.
16395 pub fn account_id(mut self, new_value: &str) -> ManagementFilterListCall<'a, C> {
16396 self._account_id = new_value.to_string();
16397 self
16398 }
16399 /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
16400 ///
16401 /// Sets the *start-index* query property to the given value.
16402 pub fn start_index(mut self, new_value: i32) -> ManagementFilterListCall<'a, C> {
16403 self._start_index = Some(new_value);
16404 self
16405 }
16406 /// The maximum number of filters to include in this response.
16407 ///
16408 /// Sets the *max-results* query property to the given value.
16409 pub fn max_results(mut self, new_value: i32) -> ManagementFilterListCall<'a, C> {
16410 self._max_results = Some(new_value);
16411 self
16412 }
16413 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16414 /// while executing the actual API request.
16415 ///
16416 /// ````text
16417 /// It should be used to handle progress information, and to implement a certain level of resilience.
16418 /// ````
16419 ///
16420 /// Sets the *delegate* property to the given value.
16421 pub fn delegate(
16422 mut self,
16423 new_value: &'a mut dyn common::Delegate,
16424 ) -> ManagementFilterListCall<'a, C> {
16425 self._delegate = Some(new_value);
16426 self
16427 }
16428
16429 /// Set any additional parameter of the query string used in the request.
16430 /// It should be used to set parameters which are not yet available through their own
16431 /// setters.
16432 ///
16433 /// Please note that this method must not be used to set any of the known parameters
16434 /// which have their own setter method. If done anyway, the request will fail.
16435 ///
16436 /// # Additional Parameters
16437 ///
16438 /// * *alt* (query-string) - Data format for the response.
16439 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16440 /// * *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.
16441 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16442 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16443 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16444 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16445 pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterListCall<'a, C>
16446 where
16447 T: AsRef<str>,
16448 {
16449 self._additional_params
16450 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16451 self
16452 }
16453
16454 /// Identifies the authorization scope for the method you are building.
16455 ///
16456 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16457 /// [`Scope::Readonly`].
16458 ///
16459 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16460 /// tokens for more than one scope.
16461 ///
16462 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16463 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16464 /// sufficient, a read-write scope will do as well.
16465 pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterListCall<'a, C>
16466 where
16467 St: AsRef<str>,
16468 {
16469 self._scopes.insert(String::from(scope.as_ref()));
16470 self
16471 }
16472 /// Identifies the authorization scope(s) for the method you are building.
16473 ///
16474 /// See [`Self::add_scope()`] for details.
16475 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterListCall<'a, C>
16476 where
16477 I: IntoIterator<Item = St>,
16478 St: AsRef<str>,
16479 {
16480 self._scopes
16481 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16482 self
16483 }
16484
16485 /// Removes all scopes, and no default scope will be used either.
16486 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16487 /// for details).
16488 pub fn clear_scopes(mut self) -> ManagementFilterListCall<'a, C> {
16489 self._scopes.clear();
16490 self
16491 }
16492}
16493
16494/// Updates an existing filter. This method supports patch semantics.
16495///
16496/// A builder for the *filters.patch* method supported by a *management* resource.
16497/// It is not used directly, but through a [`ManagementMethods`] instance.
16498///
16499/// # Example
16500///
16501/// Instantiate a resource method builder
16502///
16503/// ```test_harness,no_run
16504/// # extern crate hyper;
16505/// # extern crate hyper_rustls;
16506/// # extern crate google_analytics3 as analytics3;
16507/// use analytics3::api::Filter;
16508/// # async fn dox() {
16509/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16510///
16511/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16512/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16513/// # secret,
16514/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16515/// # ).build().await.unwrap();
16516///
16517/// # let client = hyper_util::client::legacy::Client::builder(
16518/// # hyper_util::rt::TokioExecutor::new()
16519/// # )
16520/// # .build(
16521/// # hyper_rustls::HttpsConnectorBuilder::new()
16522/// # .with_native_roots()
16523/// # .unwrap()
16524/// # .https_or_http()
16525/// # .enable_http1()
16526/// # .build()
16527/// # );
16528/// # let mut hub = Analytics::new(client, auth);
16529/// // As the method needs a request, you would usually fill it with the desired information
16530/// // into the respective structure. Some of the parts shown here might not be applicable !
16531/// // Values shown here are possibly random and not representative !
16532/// let mut req = Filter::default();
16533///
16534/// // You can configure optional parameters by calling the respective setters at will, and
16535/// // execute the final call using `doit()`.
16536/// // Values shown here are possibly random and not representative !
16537/// let result = hub.management().filters_patch(req, "accountId", "filterId")
16538/// .doit().await;
16539/// # }
16540/// ```
16541pub struct ManagementFilterPatchCall<'a, C>
16542where
16543 C: 'a,
16544{
16545 hub: &'a Analytics<C>,
16546 _request: Filter,
16547 _account_id: String,
16548 _filter_id: String,
16549 _delegate: Option<&'a mut dyn common::Delegate>,
16550 _additional_params: HashMap<String, String>,
16551 _scopes: BTreeSet<String>,
16552}
16553
16554impl<'a, C> common::CallBuilder for ManagementFilterPatchCall<'a, C> {}
16555
16556impl<'a, C> ManagementFilterPatchCall<'a, C>
16557where
16558 C: common::Connector,
16559{
16560 /// Perform the operation you have build so far.
16561 pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
16562 use std::borrow::Cow;
16563 use std::io::{Read, Seek};
16564
16565 use common::{url::Params, ToParts};
16566 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16567
16568 let mut dd = common::DefaultDelegate;
16569 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16570 dlg.begin(common::MethodInfo {
16571 id: "analytics.management.filters.patch",
16572 http_method: hyper::Method::PATCH,
16573 });
16574
16575 for &field in ["alt", "accountId", "filterId"].iter() {
16576 if self._additional_params.contains_key(field) {
16577 dlg.finished(false);
16578 return Err(common::Error::FieldClash(field));
16579 }
16580 }
16581
16582 let mut params = Params::with_capacity(5 + self._additional_params.len());
16583 params.push("accountId", self._account_id);
16584 params.push("filterId", self._filter_id);
16585
16586 params.extend(self._additional_params.iter());
16587
16588 params.push("alt", "json");
16589 let mut url =
16590 self.hub._base_url.clone() + "management/accounts/{accountId}/filters/{filterId}";
16591 if self._scopes.is_empty() {
16592 self._scopes.insert(Scope::Edit.as_ref().to_string());
16593 }
16594
16595 #[allow(clippy::single_element_loop)]
16596 for &(find_this, param_name) in
16597 [("{accountId}", "accountId"), ("{filterId}", "filterId")].iter()
16598 {
16599 url = params.uri_replacement(url, param_name, find_this, false);
16600 }
16601 {
16602 let to_remove = ["filterId", "accountId"];
16603 params.remove_params(&to_remove);
16604 }
16605
16606 let url = params.parse_with_url(&url);
16607
16608 let mut json_mime_type = mime::APPLICATION_JSON;
16609 let mut request_value_reader = {
16610 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16611 common::remove_json_null_values(&mut value);
16612 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16613 serde_json::to_writer(&mut dst, &value).unwrap();
16614 dst
16615 };
16616 let request_size = request_value_reader
16617 .seek(std::io::SeekFrom::End(0))
16618 .unwrap();
16619 request_value_reader
16620 .seek(std::io::SeekFrom::Start(0))
16621 .unwrap();
16622
16623 loop {
16624 let token = match self
16625 .hub
16626 .auth
16627 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16628 .await
16629 {
16630 Ok(token) => token,
16631 Err(e) => match dlg.token(e) {
16632 Ok(token) => token,
16633 Err(e) => {
16634 dlg.finished(false);
16635 return Err(common::Error::MissingToken(e));
16636 }
16637 },
16638 };
16639 request_value_reader
16640 .seek(std::io::SeekFrom::Start(0))
16641 .unwrap();
16642 let mut req_result = {
16643 let client = &self.hub.client;
16644 dlg.pre_request();
16645 let mut req_builder = hyper::Request::builder()
16646 .method(hyper::Method::PATCH)
16647 .uri(url.as_str())
16648 .header(USER_AGENT, self.hub._user_agent.clone());
16649
16650 if let Some(token) = token.as_ref() {
16651 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16652 }
16653
16654 let request = req_builder
16655 .header(CONTENT_TYPE, json_mime_type.to_string())
16656 .header(CONTENT_LENGTH, request_size as u64)
16657 .body(common::to_body(
16658 request_value_reader.get_ref().clone().into(),
16659 ));
16660
16661 client.request(request.unwrap()).await
16662 };
16663
16664 match req_result {
16665 Err(err) => {
16666 if let common::Retry::After(d) = dlg.http_error(&err) {
16667 sleep(d).await;
16668 continue;
16669 }
16670 dlg.finished(false);
16671 return Err(common::Error::HttpError(err));
16672 }
16673 Ok(res) => {
16674 let (mut parts, body) = res.into_parts();
16675 let mut body = common::Body::new(body);
16676 if !parts.status.is_success() {
16677 let bytes = common::to_bytes(body).await.unwrap_or_default();
16678 let error = serde_json::from_str(&common::to_string(&bytes));
16679 let response = common::to_response(parts, bytes.into());
16680
16681 if let common::Retry::After(d) =
16682 dlg.http_failure(&response, error.as_ref().ok())
16683 {
16684 sleep(d).await;
16685 continue;
16686 }
16687
16688 dlg.finished(false);
16689
16690 return Err(match error {
16691 Ok(value) => common::Error::BadRequest(value),
16692 _ => common::Error::Failure(response),
16693 });
16694 }
16695 let response = {
16696 let bytes = common::to_bytes(body).await.unwrap_or_default();
16697 let encoded = common::to_string(&bytes);
16698 match serde_json::from_str(&encoded) {
16699 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16700 Err(error) => {
16701 dlg.response_json_decode_error(&encoded, &error);
16702 return Err(common::Error::JsonDecodeError(
16703 encoded.to_string(),
16704 error,
16705 ));
16706 }
16707 }
16708 };
16709
16710 dlg.finished(true);
16711 return Ok(response);
16712 }
16713 }
16714 }
16715 }
16716
16717 ///
16718 /// Sets the *request* property to the given value.
16719 ///
16720 /// Even though the property as already been set when instantiating this call,
16721 /// we provide this method for API completeness.
16722 pub fn request(mut self, new_value: Filter) -> ManagementFilterPatchCall<'a, C> {
16723 self._request = new_value;
16724 self
16725 }
16726 /// Account ID to which the filter belongs.
16727 ///
16728 /// Sets the *account id* path property to the given value.
16729 ///
16730 /// Even though the property as already been set when instantiating this call,
16731 /// we provide this method for API completeness.
16732 pub fn account_id(mut self, new_value: &str) -> ManagementFilterPatchCall<'a, C> {
16733 self._account_id = new_value.to_string();
16734 self
16735 }
16736 /// ID of the filter to be updated.
16737 ///
16738 /// Sets the *filter id* path property to the given value.
16739 ///
16740 /// Even though the property as already been set when instantiating this call,
16741 /// we provide this method for API completeness.
16742 pub fn filter_id(mut self, new_value: &str) -> ManagementFilterPatchCall<'a, C> {
16743 self._filter_id = new_value.to_string();
16744 self
16745 }
16746 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16747 /// while executing the actual API request.
16748 ///
16749 /// ````text
16750 /// It should be used to handle progress information, and to implement a certain level of resilience.
16751 /// ````
16752 ///
16753 /// Sets the *delegate* property to the given value.
16754 pub fn delegate(
16755 mut self,
16756 new_value: &'a mut dyn common::Delegate,
16757 ) -> ManagementFilterPatchCall<'a, C> {
16758 self._delegate = Some(new_value);
16759 self
16760 }
16761
16762 /// Set any additional parameter of the query string used in the request.
16763 /// It should be used to set parameters which are not yet available through their own
16764 /// setters.
16765 ///
16766 /// Please note that this method must not be used to set any of the known parameters
16767 /// which have their own setter method. If done anyway, the request will fail.
16768 ///
16769 /// # Additional Parameters
16770 ///
16771 /// * *alt* (query-string) - Data format for the response.
16772 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16773 /// * *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.
16774 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16775 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16776 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16777 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16778 pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterPatchCall<'a, C>
16779 where
16780 T: AsRef<str>,
16781 {
16782 self._additional_params
16783 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16784 self
16785 }
16786
16787 /// Identifies the authorization scope for the method you are building.
16788 ///
16789 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16790 /// [`Scope::Edit`].
16791 ///
16792 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16793 /// tokens for more than one scope.
16794 ///
16795 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16796 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16797 /// sufficient, a read-write scope will do as well.
16798 pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterPatchCall<'a, C>
16799 where
16800 St: AsRef<str>,
16801 {
16802 self._scopes.insert(String::from(scope.as_ref()));
16803 self
16804 }
16805 /// Identifies the authorization scope(s) for the method you are building.
16806 ///
16807 /// See [`Self::add_scope()`] for details.
16808 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterPatchCall<'a, C>
16809 where
16810 I: IntoIterator<Item = St>,
16811 St: AsRef<str>,
16812 {
16813 self._scopes
16814 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16815 self
16816 }
16817
16818 /// Removes all scopes, and no default scope will be used either.
16819 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16820 /// for details).
16821 pub fn clear_scopes(mut self) -> ManagementFilterPatchCall<'a, C> {
16822 self._scopes.clear();
16823 self
16824 }
16825}
16826
16827/// Updates an existing filter.
16828///
16829/// A builder for the *filters.update* method supported by a *management* resource.
16830/// It is not used directly, but through a [`ManagementMethods`] instance.
16831///
16832/// # Example
16833///
16834/// Instantiate a resource method builder
16835///
16836/// ```test_harness,no_run
16837/// # extern crate hyper;
16838/// # extern crate hyper_rustls;
16839/// # extern crate google_analytics3 as analytics3;
16840/// use analytics3::api::Filter;
16841/// # async fn dox() {
16842/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16843///
16844/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16845/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16846/// # secret,
16847/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16848/// # ).build().await.unwrap();
16849///
16850/// # let client = hyper_util::client::legacy::Client::builder(
16851/// # hyper_util::rt::TokioExecutor::new()
16852/// # )
16853/// # .build(
16854/// # hyper_rustls::HttpsConnectorBuilder::new()
16855/// # .with_native_roots()
16856/// # .unwrap()
16857/// # .https_or_http()
16858/// # .enable_http1()
16859/// # .build()
16860/// # );
16861/// # let mut hub = Analytics::new(client, auth);
16862/// // As the method needs a request, you would usually fill it with the desired information
16863/// // into the respective structure. Some of the parts shown here might not be applicable !
16864/// // Values shown here are possibly random and not representative !
16865/// let mut req = Filter::default();
16866///
16867/// // You can configure optional parameters by calling the respective setters at will, and
16868/// // execute the final call using `doit()`.
16869/// // Values shown here are possibly random and not representative !
16870/// let result = hub.management().filters_update(req, "accountId", "filterId")
16871/// .doit().await;
16872/// # }
16873/// ```
16874pub struct ManagementFilterUpdateCall<'a, C>
16875where
16876 C: 'a,
16877{
16878 hub: &'a Analytics<C>,
16879 _request: Filter,
16880 _account_id: String,
16881 _filter_id: String,
16882 _delegate: Option<&'a mut dyn common::Delegate>,
16883 _additional_params: HashMap<String, String>,
16884 _scopes: BTreeSet<String>,
16885}
16886
16887impl<'a, C> common::CallBuilder for ManagementFilterUpdateCall<'a, C> {}
16888
16889impl<'a, C> ManagementFilterUpdateCall<'a, C>
16890where
16891 C: common::Connector,
16892{
16893 /// Perform the operation you have build so far.
16894 pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
16895 use std::borrow::Cow;
16896 use std::io::{Read, Seek};
16897
16898 use common::{url::Params, ToParts};
16899 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16900
16901 let mut dd = common::DefaultDelegate;
16902 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16903 dlg.begin(common::MethodInfo {
16904 id: "analytics.management.filters.update",
16905 http_method: hyper::Method::PUT,
16906 });
16907
16908 for &field in ["alt", "accountId", "filterId"].iter() {
16909 if self._additional_params.contains_key(field) {
16910 dlg.finished(false);
16911 return Err(common::Error::FieldClash(field));
16912 }
16913 }
16914
16915 let mut params = Params::with_capacity(5 + self._additional_params.len());
16916 params.push("accountId", self._account_id);
16917 params.push("filterId", self._filter_id);
16918
16919 params.extend(self._additional_params.iter());
16920
16921 params.push("alt", "json");
16922 let mut url =
16923 self.hub._base_url.clone() + "management/accounts/{accountId}/filters/{filterId}";
16924 if self._scopes.is_empty() {
16925 self._scopes.insert(Scope::Edit.as_ref().to_string());
16926 }
16927
16928 #[allow(clippy::single_element_loop)]
16929 for &(find_this, param_name) in
16930 [("{accountId}", "accountId"), ("{filterId}", "filterId")].iter()
16931 {
16932 url = params.uri_replacement(url, param_name, find_this, false);
16933 }
16934 {
16935 let to_remove = ["filterId", "accountId"];
16936 params.remove_params(&to_remove);
16937 }
16938
16939 let url = params.parse_with_url(&url);
16940
16941 let mut json_mime_type = mime::APPLICATION_JSON;
16942 let mut request_value_reader = {
16943 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16944 common::remove_json_null_values(&mut value);
16945 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16946 serde_json::to_writer(&mut dst, &value).unwrap();
16947 dst
16948 };
16949 let request_size = request_value_reader
16950 .seek(std::io::SeekFrom::End(0))
16951 .unwrap();
16952 request_value_reader
16953 .seek(std::io::SeekFrom::Start(0))
16954 .unwrap();
16955
16956 loop {
16957 let token = match self
16958 .hub
16959 .auth
16960 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16961 .await
16962 {
16963 Ok(token) => token,
16964 Err(e) => match dlg.token(e) {
16965 Ok(token) => token,
16966 Err(e) => {
16967 dlg.finished(false);
16968 return Err(common::Error::MissingToken(e));
16969 }
16970 },
16971 };
16972 request_value_reader
16973 .seek(std::io::SeekFrom::Start(0))
16974 .unwrap();
16975 let mut req_result = {
16976 let client = &self.hub.client;
16977 dlg.pre_request();
16978 let mut req_builder = hyper::Request::builder()
16979 .method(hyper::Method::PUT)
16980 .uri(url.as_str())
16981 .header(USER_AGENT, self.hub._user_agent.clone());
16982
16983 if let Some(token) = token.as_ref() {
16984 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16985 }
16986
16987 let request = req_builder
16988 .header(CONTENT_TYPE, json_mime_type.to_string())
16989 .header(CONTENT_LENGTH, request_size as u64)
16990 .body(common::to_body(
16991 request_value_reader.get_ref().clone().into(),
16992 ));
16993
16994 client.request(request.unwrap()).await
16995 };
16996
16997 match req_result {
16998 Err(err) => {
16999 if let common::Retry::After(d) = dlg.http_error(&err) {
17000 sleep(d).await;
17001 continue;
17002 }
17003 dlg.finished(false);
17004 return Err(common::Error::HttpError(err));
17005 }
17006 Ok(res) => {
17007 let (mut parts, body) = res.into_parts();
17008 let mut body = common::Body::new(body);
17009 if !parts.status.is_success() {
17010 let bytes = common::to_bytes(body).await.unwrap_or_default();
17011 let error = serde_json::from_str(&common::to_string(&bytes));
17012 let response = common::to_response(parts, bytes.into());
17013
17014 if let common::Retry::After(d) =
17015 dlg.http_failure(&response, error.as_ref().ok())
17016 {
17017 sleep(d).await;
17018 continue;
17019 }
17020
17021 dlg.finished(false);
17022
17023 return Err(match error {
17024 Ok(value) => common::Error::BadRequest(value),
17025 _ => common::Error::Failure(response),
17026 });
17027 }
17028 let response = {
17029 let bytes = common::to_bytes(body).await.unwrap_or_default();
17030 let encoded = common::to_string(&bytes);
17031 match serde_json::from_str(&encoded) {
17032 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17033 Err(error) => {
17034 dlg.response_json_decode_error(&encoded, &error);
17035 return Err(common::Error::JsonDecodeError(
17036 encoded.to_string(),
17037 error,
17038 ));
17039 }
17040 }
17041 };
17042
17043 dlg.finished(true);
17044 return Ok(response);
17045 }
17046 }
17047 }
17048 }
17049
17050 ///
17051 /// Sets the *request* property to the given value.
17052 ///
17053 /// Even though the property as already been set when instantiating this call,
17054 /// we provide this method for API completeness.
17055 pub fn request(mut self, new_value: Filter) -> ManagementFilterUpdateCall<'a, C> {
17056 self._request = new_value;
17057 self
17058 }
17059 /// Account ID to which the filter belongs.
17060 ///
17061 /// Sets the *account id* path property to the given value.
17062 ///
17063 /// Even though the property as already been set when instantiating this call,
17064 /// we provide this method for API completeness.
17065 pub fn account_id(mut self, new_value: &str) -> ManagementFilterUpdateCall<'a, C> {
17066 self._account_id = new_value.to_string();
17067 self
17068 }
17069 /// ID of the filter to be updated.
17070 ///
17071 /// Sets the *filter id* path property to the given value.
17072 ///
17073 /// Even though the property as already been set when instantiating this call,
17074 /// we provide this method for API completeness.
17075 pub fn filter_id(mut self, new_value: &str) -> ManagementFilterUpdateCall<'a, C> {
17076 self._filter_id = new_value.to_string();
17077 self
17078 }
17079 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17080 /// while executing the actual API request.
17081 ///
17082 /// ````text
17083 /// It should be used to handle progress information, and to implement a certain level of resilience.
17084 /// ````
17085 ///
17086 /// Sets the *delegate* property to the given value.
17087 pub fn delegate(
17088 mut self,
17089 new_value: &'a mut dyn common::Delegate,
17090 ) -> ManagementFilterUpdateCall<'a, C> {
17091 self._delegate = Some(new_value);
17092 self
17093 }
17094
17095 /// Set any additional parameter of the query string used in the request.
17096 /// It should be used to set parameters which are not yet available through their own
17097 /// setters.
17098 ///
17099 /// Please note that this method must not be used to set any of the known parameters
17100 /// which have their own setter method. If done anyway, the request will fail.
17101 ///
17102 /// # Additional Parameters
17103 ///
17104 /// * *alt* (query-string) - Data format for the response.
17105 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17106 /// * *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.
17107 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17108 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17109 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17110 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17111 pub fn param<T>(mut self, name: T, value: T) -> ManagementFilterUpdateCall<'a, C>
17112 where
17113 T: AsRef<str>,
17114 {
17115 self._additional_params
17116 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17117 self
17118 }
17119
17120 /// Identifies the authorization scope for the method you are building.
17121 ///
17122 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17123 /// [`Scope::Edit`].
17124 ///
17125 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17126 /// tokens for more than one scope.
17127 ///
17128 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17129 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17130 /// sufficient, a read-write scope will do as well.
17131 pub fn add_scope<St>(mut self, scope: St) -> ManagementFilterUpdateCall<'a, C>
17132 where
17133 St: AsRef<str>,
17134 {
17135 self._scopes.insert(String::from(scope.as_ref()));
17136 self
17137 }
17138 /// Identifies the authorization scope(s) for the method you are building.
17139 ///
17140 /// See [`Self::add_scope()`] for details.
17141 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementFilterUpdateCall<'a, C>
17142 where
17143 I: IntoIterator<Item = St>,
17144 St: AsRef<str>,
17145 {
17146 self._scopes
17147 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17148 self
17149 }
17150
17151 /// Removes all scopes, and no default scope will be used either.
17152 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17153 /// for details).
17154 pub fn clear_scopes(mut self) -> ManagementFilterUpdateCall<'a, C> {
17155 self._scopes.clear();
17156 self
17157 }
17158}
17159
17160/// Gets a goal to which the user has access.
17161///
17162/// A builder for the *goals.get* method supported by a *management* resource.
17163/// It is not used directly, but through a [`ManagementMethods`] instance.
17164///
17165/// # Example
17166///
17167/// Instantiate a resource method builder
17168///
17169/// ```test_harness,no_run
17170/// # extern crate hyper;
17171/// # extern crate hyper_rustls;
17172/// # extern crate google_analytics3 as analytics3;
17173/// # async fn dox() {
17174/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17175///
17176/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17177/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17178/// # secret,
17179/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17180/// # ).build().await.unwrap();
17181///
17182/// # let client = hyper_util::client::legacy::Client::builder(
17183/// # hyper_util::rt::TokioExecutor::new()
17184/// # )
17185/// # .build(
17186/// # hyper_rustls::HttpsConnectorBuilder::new()
17187/// # .with_native_roots()
17188/// # .unwrap()
17189/// # .https_or_http()
17190/// # .enable_http1()
17191/// # .build()
17192/// # );
17193/// # let mut hub = Analytics::new(client, auth);
17194/// // You can configure optional parameters by calling the respective setters at will, and
17195/// // execute the final call using `doit()`.
17196/// // Values shown here are possibly random and not representative !
17197/// let result = hub.management().goals_get("accountId", "webPropertyId", "profileId", "goalId")
17198/// .doit().await;
17199/// # }
17200/// ```
17201pub struct ManagementGoalGetCall<'a, C>
17202where
17203 C: 'a,
17204{
17205 hub: &'a Analytics<C>,
17206 _account_id: String,
17207 _web_property_id: String,
17208 _profile_id: String,
17209 _goal_id: String,
17210 _delegate: Option<&'a mut dyn common::Delegate>,
17211 _additional_params: HashMap<String, String>,
17212 _scopes: BTreeSet<String>,
17213}
17214
17215impl<'a, C> common::CallBuilder for ManagementGoalGetCall<'a, C> {}
17216
17217impl<'a, C> ManagementGoalGetCall<'a, C>
17218where
17219 C: common::Connector,
17220{
17221 /// Perform the operation you have build so far.
17222 pub async fn doit(mut self) -> common::Result<(common::Response, Goal)> {
17223 use std::borrow::Cow;
17224 use std::io::{Read, Seek};
17225
17226 use common::{url::Params, ToParts};
17227 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17228
17229 let mut dd = common::DefaultDelegate;
17230 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17231 dlg.begin(common::MethodInfo {
17232 id: "analytics.management.goals.get",
17233 http_method: hyper::Method::GET,
17234 });
17235
17236 for &field in ["alt", "accountId", "webPropertyId", "profileId", "goalId"].iter() {
17237 if self._additional_params.contains_key(field) {
17238 dlg.finished(false);
17239 return Err(common::Error::FieldClash(field));
17240 }
17241 }
17242
17243 let mut params = Params::with_capacity(6 + self._additional_params.len());
17244 params.push("accountId", self._account_id);
17245 params.push("webPropertyId", self._web_property_id);
17246 params.push("profileId", self._profile_id);
17247 params.push("goalId", self._goal_id);
17248
17249 params.extend(self._additional_params.iter());
17250
17251 params.push("alt", "json");
17252 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals/{goalId}";
17253 if self._scopes.is_empty() {
17254 self._scopes.insert(Scope::Readonly.as_ref().to_string());
17255 }
17256
17257 #[allow(clippy::single_element_loop)]
17258 for &(find_this, param_name) in [
17259 ("{accountId}", "accountId"),
17260 ("{webPropertyId}", "webPropertyId"),
17261 ("{profileId}", "profileId"),
17262 ("{goalId}", "goalId"),
17263 ]
17264 .iter()
17265 {
17266 url = params.uri_replacement(url, param_name, find_this, false);
17267 }
17268 {
17269 let to_remove = ["goalId", "profileId", "webPropertyId", "accountId"];
17270 params.remove_params(&to_remove);
17271 }
17272
17273 let url = params.parse_with_url(&url);
17274
17275 loop {
17276 let token = match self
17277 .hub
17278 .auth
17279 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17280 .await
17281 {
17282 Ok(token) => token,
17283 Err(e) => match dlg.token(e) {
17284 Ok(token) => token,
17285 Err(e) => {
17286 dlg.finished(false);
17287 return Err(common::Error::MissingToken(e));
17288 }
17289 },
17290 };
17291 let mut req_result = {
17292 let client = &self.hub.client;
17293 dlg.pre_request();
17294 let mut req_builder = hyper::Request::builder()
17295 .method(hyper::Method::GET)
17296 .uri(url.as_str())
17297 .header(USER_AGENT, self.hub._user_agent.clone());
17298
17299 if let Some(token) = token.as_ref() {
17300 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17301 }
17302
17303 let request = req_builder
17304 .header(CONTENT_LENGTH, 0_u64)
17305 .body(common::to_body::<String>(None));
17306
17307 client.request(request.unwrap()).await
17308 };
17309
17310 match req_result {
17311 Err(err) => {
17312 if let common::Retry::After(d) = dlg.http_error(&err) {
17313 sleep(d).await;
17314 continue;
17315 }
17316 dlg.finished(false);
17317 return Err(common::Error::HttpError(err));
17318 }
17319 Ok(res) => {
17320 let (mut parts, body) = res.into_parts();
17321 let mut body = common::Body::new(body);
17322 if !parts.status.is_success() {
17323 let bytes = common::to_bytes(body).await.unwrap_or_default();
17324 let error = serde_json::from_str(&common::to_string(&bytes));
17325 let response = common::to_response(parts, bytes.into());
17326
17327 if let common::Retry::After(d) =
17328 dlg.http_failure(&response, error.as_ref().ok())
17329 {
17330 sleep(d).await;
17331 continue;
17332 }
17333
17334 dlg.finished(false);
17335
17336 return Err(match error {
17337 Ok(value) => common::Error::BadRequest(value),
17338 _ => common::Error::Failure(response),
17339 });
17340 }
17341 let response = {
17342 let bytes = common::to_bytes(body).await.unwrap_or_default();
17343 let encoded = common::to_string(&bytes);
17344 match serde_json::from_str(&encoded) {
17345 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17346 Err(error) => {
17347 dlg.response_json_decode_error(&encoded, &error);
17348 return Err(common::Error::JsonDecodeError(
17349 encoded.to_string(),
17350 error,
17351 ));
17352 }
17353 }
17354 };
17355
17356 dlg.finished(true);
17357 return Ok(response);
17358 }
17359 }
17360 }
17361 }
17362
17363 /// Account ID to retrieve the goal for.
17364 ///
17365 /// Sets the *account id* path property to the given value.
17366 ///
17367 /// Even though the property as already been set when instantiating this call,
17368 /// we provide this method for API completeness.
17369 pub fn account_id(mut self, new_value: &str) -> ManagementGoalGetCall<'a, C> {
17370 self._account_id = new_value.to_string();
17371 self
17372 }
17373 /// Web property ID to retrieve the goal for.
17374 ///
17375 /// Sets the *web property id* path property to the given value.
17376 ///
17377 /// Even though the property as already been set when instantiating this call,
17378 /// we provide this method for API completeness.
17379 pub fn web_property_id(mut self, new_value: &str) -> ManagementGoalGetCall<'a, C> {
17380 self._web_property_id = new_value.to_string();
17381 self
17382 }
17383 /// View (Profile) ID to retrieve the goal for.
17384 ///
17385 /// Sets the *profile id* path property to the given value.
17386 ///
17387 /// Even though the property as already been set when instantiating this call,
17388 /// we provide this method for API completeness.
17389 pub fn profile_id(mut self, new_value: &str) -> ManagementGoalGetCall<'a, C> {
17390 self._profile_id = new_value.to_string();
17391 self
17392 }
17393 /// Goal ID to retrieve the goal for.
17394 ///
17395 /// Sets the *goal id* path property to the given value.
17396 ///
17397 /// Even though the property as already been set when instantiating this call,
17398 /// we provide this method for API completeness.
17399 pub fn goal_id(mut self, new_value: &str) -> ManagementGoalGetCall<'a, C> {
17400 self._goal_id = new_value.to_string();
17401 self
17402 }
17403 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17404 /// while executing the actual API request.
17405 ///
17406 /// ````text
17407 /// It should be used to handle progress information, and to implement a certain level of resilience.
17408 /// ````
17409 ///
17410 /// Sets the *delegate* property to the given value.
17411 pub fn delegate(
17412 mut self,
17413 new_value: &'a mut dyn common::Delegate,
17414 ) -> ManagementGoalGetCall<'a, C> {
17415 self._delegate = Some(new_value);
17416 self
17417 }
17418
17419 /// Set any additional parameter of the query string used in the request.
17420 /// It should be used to set parameters which are not yet available through their own
17421 /// setters.
17422 ///
17423 /// Please note that this method must not be used to set any of the known parameters
17424 /// which have their own setter method. If done anyway, the request will fail.
17425 ///
17426 /// # Additional Parameters
17427 ///
17428 /// * *alt* (query-string) - Data format for the response.
17429 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17430 /// * *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.
17431 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17432 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17433 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17434 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17435 pub fn param<T>(mut self, name: T, value: T) -> ManagementGoalGetCall<'a, C>
17436 where
17437 T: AsRef<str>,
17438 {
17439 self._additional_params
17440 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17441 self
17442 }
17443
17444 /// Identifies the authorization scope for the method you are building.
17445 ///
17446 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17447 /// [`Scope::Readonly`].
17448 ///
17449 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17450 /// tokens for more than one scope.
17451 ///
17452 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17453 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17454 /// sufficient, a read-write scope will do as well.
17455 pub fn add_scope<St>(mut self, scope: St) -> ManagementGoalGetCall<'a, C>
17456 where
17457 St: AsRef<str>,
17458 {
17459 self._scopes.insert(String::from(scope.as_ref()));
17460 self
17461 }
17462 /// Identifies the authorization scope(s) for the method you are building.
17463 ///
17464 /// See [`Self::add_scope()`] for details.
17465 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementGoalGetCall<'a, C>
17466 where
17467 I: IntoIterator<Item = St>,
17468 St: AsRef<str>,
17469 {
17470 self._scopes
17471 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17472 self
17473 }
17474
17475 /// Removes all scopes, and no default scope will be used either.
17476 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17477 /// for details).
17478 pub fn clear_scopes(mut self) -> ManagementGoalGetCall<'a, C> {
17479 self._scopes.clear();
17480 self
17481 }
17482}
17483
17484/// Create a new goal.
17485///
17486/// A builder for the *goals.insert* method supported by a *management* resource.
17487/// It is not used directly, but through a [`ManagementMethods`] instance.
17488///
17489/// # Example
17490///
17491/// Instantiate a resource method builder
17492///
17493/// ```test_harness,no_run
17494/// # extern crate hyper;
17495/// # extern crate hyper_rustls;
17496/// # extern crate google_analytics3 as analytics3;
17497/// use analytics3::api::Goal;
17498/// # async fn dox() {
17499/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17500///
17501/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17502/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17503/// # secret,
17504/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17505/// # ).build().await.unwrap();
17506///
17507/// # let client = hyper_util::client::legacy::Client::builder(
17508/// # hyper_util::rt::TokioExecutor::new()
17509/// # )
17510/// # .build(
17511/// # hyper_rustls::HttpsConnectorBuilder::new()
17512/// # .with_native_roots()
17513/// # .unwrap()
17514/// # .https_or_http()
17515/// # .enable_http1()
17516/// # .build()
17517/// # );
17518/// # let mut hub = Analytics::new(client, auth);
17519/// // As the method needs a request, you would usually fill it with the desired information
17520/// // into the respective structure. Some of the parts shown here might not be applicable !
17521/// // Values shown here are possibly random and not representative !
17522/// let mut req = Goal::default();
17523///
17524/// // You can configure optional parameters by calling the respective setters at will, and
17525/// // execute the final call using `doit()`.
17526/// // Values shown here are possibly random and not representative !
17527/// let result = hub.management().goals_insert(req, "accountId", "webPropertyId", "profileId")
17528/// .doit().await;
17529/// # }
17530/// ```
17531pub struct ManagementGoalInsertCall<'a, C>
17532where
17533 C: 'a,
17534{
17535 hub: &'a Analytics<C>,
17536 _request: Goal,
17537 _account_id: String,
17538 _web_property_id: String,
17539 _profile_id: String,
17540 _delegate: Option<&'a mut dyn common::Delegate>,
17541 _additional_params: HashMap<String, String>,
17542 _scopes: BTreeSet<String>,
17543}
17544
17545impl<'a, C> common::CallBuilder for ManagementGoalInsertCall<'a, C> {}
17546
17547impl<'a, C> ManagementGoalInsertCall<'a, C>
17548where
17549 C: common::Connector,
17550{
17551 /// Perform the operation you have build so far.
17552 pub async fn doit(mut self) -> common::Result<(common::Response, Goal)> {
17553 use std::borrow::Cow;
17554 use std::io::{Read, Seek};
17555
17556 use common::{url::Params, ToParts};
17557 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17558
17559 let mut dd = common::DefaultDelegate;
17560 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17561 dlg.begin(common::MethodInfo {
17562 id: "analytics.management.goals.insert",
17563 http_method: hyper::Method::POST,
17564 });
17565
17566 for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
17567 if self._additional_params.contains_key(field) {
17568 dlg.finished(false);
17569 return Err(common::Error::FieldClash(field));
17570 }
17571 }
17572
17573 let mut params = Params::with_capacity(6 + self._additional_params.len());
17574 params.push("accountId", self._account_id);
17575 params.push("webPropertyId", self._web_property_id);
17576 params.push("profileId", self._profile_id);
17577
17578 params.extend(self._additional_params.iter());
17579
17580 params.push("alt", "json");
17581 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals";
17582 if self._scopes.is_empty() {
17583 self._scopes.insert(Scope::Edit.as_ref().to_string());
17584 }
17585
17586 #[allow(clippy::single_element_loop)]
17587 for &(find_this, param_name) in [
17588 ("{accountId}", "accountId"),
17589 ("{webPropertyId}", "webPropertyId"),
17590 ("{profileId}", "profileId"),
17591 ]
17592 .iter()
17593 {
17594 url = params.uri_replacement(url, param_name, find_this, false);
17595 }
17596 {
17597 let to_remove = ["profileId", "webPropertyId", "accountId"];
17598 params.remove_params(&to_remove);
17599 }
17600
17601 let url = params.parse_with_url(&url);
17602
17603 let mut json_mime_type = mime::APPLICATION_JSON;
17604 let mut request_value_reader = {
17605 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17606 common::remove_json_null_values(&mut value);
17607 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17608 serde_json::to_writer(&mut dst, &value).unwrap();
17609 dst
17610 };
17611 let request_size = request_value_reader
17612 .seek(std::io::SeekFrom::End(0))
17613 .unwrap();
17614 request_value_reader
17615 .seek(std::io::SeekFrom::Start(0))
17616 .unwrap();
17617
17618 loop {
17619 let token = match self
17620 .hub
17621 .auth
17622 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17623 .await
17624 {
17625 Ok(token) => token,
17626 Err(e) => match dlg.token(e) {
17627 Ok(token) => token,
17628 Err(e) => {
17629 dlg.finished(false);
17630 return Err(common::Error::MissingToken(e));
17631 }
17632 },
17633 };
17634 request_value_reader
17635 .seek(std::io::SeekFrom::Start(0))
17636 .unwrap();
17637 let mut req_result = {
17638 let client = &self.hub.client;
17639 dlg.pre_request();
17640 let mut req_builder = hyper::Request::builder()
17641 .method(hyper::Method::POST)
17642 .uri(url.as_str())
17643 .header(USER_AGENT, self.hub._user_agent.clone());
17644
17645 if let Some(token) = token.as_ref() {
17646 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17647 }
17648
17649 let request = req_builder
17650 .header(CONTENT_TYPE, json_mime_type.to_string())
17651 .header(CONTENT_LENGTH, request_size as u64)
17652 .body(common::to_body(
17653 request_value_reader.get_ref().clone().into(),
17654 ));
17655
17656 client.request(request.unwrap()).await
17657 };
17658
17659 match req_result {
17660 Err(err) => {
17661 if let common::Retry::After(d) = dlg.http_error(&err) {
17662 sleep(d).await;
17663 continue;
17664 }
17665 dlg.finished(false);
17666 return Err(common::Error::HttpError(err));
17667 }
17668 Ok(res) => {
17669 let (mut parts, body) = res.into_parts();
17670 let mut body = common::Body::new(body);
17671 if !parts.status.is_success() {
17672 let bytes = common::to_bytes(body).await.unwrap_or_default();
17673 let error = serde_json::from_str(&common::to_string(&bytes));
17674 let response = common::to_response(parts, bytes.into());
17675
17676 if let common::Retry::After(d) =
17677 dlg.http_failure(&response, error.as_ref().ok())
17678 {
17679 sleep(d).await;
17680 continue;
17681 }
17682
17683 dlg.finished(false);
17684
17685 return Err(match error {
17686 Ok(value) => common::Error::BadRequest(value),
17687 _ => common::Error::Failure(response),
17688 });
17689 }
17690 let response = {
17691 let bytes = common::to_bytes(body).await.unwrap_or_default();
17692 let encoded = common::to_string(&bytes);
17693 match serde_json::from_str(&encoded) {
17694 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17695 Err(error) => {
17696 dlg.response_json_decode_error(&encoded, &error);
17697 return Err(common::Error::JsonDecodeError(
17698 encoded.to_string(),
17699 error,
17700 ));
17701 }
17702 }
17703 };
17704
17705 dlg.finished(true);
17706 return Ok(response);
17707 }
17708 }
17709 }
17710 }
17711
17712 ///
17713 /// Sets the *request* property to the given value.
17714 ///
17715 /// Even though the property as already been set when instantiating this call,
17716 /// we provide this method for API completeness.
17717 pub fn request(mut self, new_value: Goal) -> ManagementGoalInsertCall<'a, C> {
17718 self._request = new_value;
17719 self
17720 }
17721 /// Account ID to create the goal for.
17722 ///
17723 /// Sets the *account id* path property to the given value.
17724 ///
17725 /// Even though the property as already been set when instantiating this call,
17726 /// we provide this method for API completeness.
17727 pub fn account_id(mut self, new_value: &str) -> ManagementGoalInsertCall<'a, C> {
17728 self._account_id = new_value.to_string();
17729 self
17730 }
17731 /// Web property ID to create the goal for.
17732 ///
17733 /// Sets the *web property id* path property to the given value.
17734 ///
17735 /// Even though the property as already been set when instantiating this call,
17736 /// we provide this method for API completeness.
17737 pub fn web_property_id(mut self, new_value: &str) -> ManagementGoalInsertCall<'a, C> {
17738 self._web_property_id = new_value.to_string();
17739 self
17740 }
17741 /// View (Profile) ID to create the goal for.
17742 ///
17743 /// Sets the *profile id* path property to the given value.
17744 ///
17745 /// Even though the property as already been set when instantiating this call,
17746 /// we provide this method for API completeness.
17747 pub fn profile_id(mut self, new_value: &str) -> ManagementGoalInsertCall<'a, C> {
17748 self._profile_id = new_value.to_string();
17749 self
17750 }
17751 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17752 /// while executing the actual API request.
17753 ///
17754 /// ````text
17755 /// It should be used to handle progress information, and to implement a certain level of resilience.
17756 /// ````
17757 ///
17758 /// Sets the *delegate* property to the given value.
17759 pub fn delegate(
17760 mut self,
17761 new_value: &'a mut dyn common::Delegate,
17762 ) -> ManagementGoalInsertCall<'a, C> {
17763 self._delegate = Some(new_value);
17764 self
17765 }
17766
17767 /// Set any additional parameter of the query string used in the request.
17768 /// It should be used to set parameters which are not yet available through their own
17769 /// setters.
17770 ///
17771 /// Please note that this method must not be used to set any of the known parameters
17772 /// which have their own setter method. If done anyway, the request will fail.
17773 ///
17774 /// # Additional Parameters
17775 ///
17776 /// * *alt* (query-string) - Data format for the response.
17777 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17778 /// * *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.
17779 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17780 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17781 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17782 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17783 pub fn param<T>(mut self, name: T, value: T) -> ManagementGoalInsertCall<'a, C>
17784 where
17785 T: AsRef<str>,
17786 {
17787 self._additional_params
17788 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17789 self
17790 }
17791
17792 /// Identifies the authorization scope for the method you are building.
17793 ///
17794 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17795 /// [`Scope::Edit`].
17796 ///
17797 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17798 /// tokens for more than one scope.
17799 ///
17800 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17801 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17802 /// sufficient, a read-write scope will do as well.
17803 pub fn add_scope<St>(mut self, scope: St) -> ManagementGoalInsertCall<'a, C>
17804 where
17805 St: AsRef<str>,
17806 {
17807 self._scopes.insert(String::from(scope.as_ref()));
17808 self
17809 }
17810 /// Identifies the authorization scope(s) for the method you are building.
17811 ///
17812 /// See [`Self::add_scope()`] for details.
17813 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementGoalInsertCall<'a, C>
17814 where
17815 I: IntoIterator<Item = St>,
17816 St: AsRef<str>,
17817 {
17818 self._scopes
17819 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17820 self
17821 }
17822
17823 /// Removes all scopes, and no default scope will be used either.
17824 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17825 /// for details).
17826 pub fn clear_scopes(mut self) -> ManagementGoalInsertCall<'a, C> {
17827 self._scopes.clear();
17828 self
17829 }
17830}
17831
17832/// Lists goals to which the user has access.
17833///
17834/// A builder for the *goals.list* method supported by a *management* resource.
17835/// It is not used directly, but through a [`ManagementMethods`] instance.
17836///
17837/// # Example
17838///
17839/// Instantiate a resource method builder
17840///
17841/// ```test_harness,no_run
17842/// # extern crate hyper;
17843/// # extern crate hyper_rustls;
17844/// # extern crate google_analytics3 as analytics3;
17845/// # async fn dox() {
17846/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17847///
17848/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17849/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17850/// # secret,
17851/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17852/// # ).build().await.unwrap();
17853///
17854/// # let client = hyper_util::client::legacy::Client::builder(
17855/// # hyper_util::rt::TokioExecutor::new()
17856/// # )
17857/// # .build(
17858/// # hyper_rustls::HttpsConnectorBuilder::new()
17859/// # .with_native_roots()
17860/// # .unwrap()
17861/// # .https_or_http()
17862/// # .enable_http1()
17863/// # .build()
17864/// # );
17865/// # let mut hub = Analytics::new(client, auth);
17866/// // You can configure optional parameters by calling the respective setters at will, and
17867/// // execute the final call using `doit()`.
17868/// // Values shown here are possibly random and not representative !
17869/// let result = hub.management().goals_list("accountId", "webPropertyId", "profileId")
17870/// .start_index(-94)
17871/// .max_results(-20)
17872/// .doit().await;
17873/// # }
17874/// ```
17875pub struct ManagementGoalListCall<'a, C>
17876where
17877 C: 'a,
17878{
17879 hub: &'a Analytics<C>,
17880 _account_id: String,
17881 _web_property_id: String,
17882 _profile_id: String,
17883 _start_index: Option<i32>,
17884 _max_results: Option<i32>,
17885 _delegate: Option<&'a mut dyn common::Delegate>,
17886 _additional_params: HashMap<String, String>,
17887 _scopes: BTreeSet<String>,
17888}
17889
17890impl<'a, C> common::CallBuilder for ManagementGoalListCall<'a, C> {}
17891
17892impl<'a, C> ManagementGoalListCall<'a, C>
17893where
17894 C: common::Connector,
17895{
17896 /// Perform the operation you have build so far.
17897 pub async fn doit(mut self) -> common::Result<(common::Response, Goals)> {
17898 use std::borrow::Cow;
17899 use std::io::{Read, Seek};
17900
17901 use common::{url::Params, ToParts};
17902 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17903
17904 let mut dd = common::DefaultDelegate;
17905 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17906 dlg.begin(common::MethodInfo {
17907 id: "analytics.management.goals.list",
17908 http_method: hyper::Method::GET,
17909 });
17910
17911 for &field in [
17912 "alt",
17913 "accountId",
17914 "webPropertyId",
17915 "profileId",
17916 "start-index",
17917 "max-results",
17918 ]
17919 .iter()
17920 {
17921 if self._additional_params.contains_key(field) {
17922 dlg.finished(false);
17923 return Err(common::Error::FieldClash(field));
17924 }
17925 }
17926
17927 let mut params = Params::with_capacity(7 + self._additional_params.len());
17928 params.push("accountId", self._account_id);
17929 params.push("webPropertyId", self._web_property_id);
17930 params.push("profileId", self._profile_id);
17931 if let Some(value) = self._start_index.as_ref() {
17932 params.push("start-index", value.to_string());
17933 }
17934 if let Some(value) = self._max_results.as_ref() {
17935 params.push("max-results", value.to_string());
17936 }
17937
17938 params.extend(self._additional_params.iter());
17939
17940 params.push("alt", "json");
17941 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals";
17942 if self._scopes.is_empty() {
17943 self._scopes.insert(Scope::Readonly.as_ref().to_string());
17944 }
17945
17946 #[allow(clippy::single_element_loop)]
17947 for &(find_this, param_name) in [
17948 ("{accountId}", "accountId"),
17949 ("{webPropertyId}", "webPropertyId"),
17950 ("{profileId}", "profileId"),
17951 ]
17952 .iter()
17953 {
17954 url = params.uri_replacement(url, param_name, find_this, false);
17955 }
17956 {
17957 let to_remove = ["profileId", "webPropertyId", "accountId"];
17958 params.remove_params(&to_remove);
17959 }
17960
17961 let url = params.parse_with_url(&url);
17962
17963 loop {
17964 let token = match self
17965 .hub
17966 .auth
17967 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17968 .await
17969 {
17970 Ok(token) => token,
17971 Err(e) => match dlg.token(e) {
17972 Ok(token) => token,
17973 Err(e) => {
17974 dlg.finished(false);
17975 return Err(common::Error::MissingToken(e));
17976 }
17977 },
17978 };
17979 let mut req_result = {
17980 let client = &self.hub.client;
17981 dlg.pre_request();
17982 let mut req_builder = hyper::Request::builder()
17983 .method(hyper::Method::GET)
17984 .uri(url.as_str())
17985 .header(USER_AGENT, self.hub._user_agent.clone());
17986
17987 if let Some(token) = token.as_ref() {
17988 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17989 }
17990
17991 let request = req_builder
17992 .header(CONTENT_LENGTH, 0_u64)
17993 .body(common::to_body::<String>(None));
17994
17995 client.request(request.unwrap()).await
17996 };
17997
17998 match req_result {
17999 Err(err) => {
18000 if let common::Retry::After(d) = dlg.http_error(&err) {
18001 sleep(d).await;
18002 continue;
18003 }
18004 dlg.finished(false);
18005 return Err(common::Error::HttpError(err));
18006 }
18007 Ok(res) => {
18008 let (mut parts, body) = res.into_parts();
18009 let mut body = common::Body::new(body);
18010 if !parts.status.is_success() {
18011 let bytes = common::to_bytes(body).await.unwrap_or_default();
18012 let error = serde_json::from_str(&common::to_string(&bytes));
18013 let response = common::to_response(parts, bytes.into());
18014
18015 if let common::Retry::After(d) =
18016 dlg.http_failure(&response, error.as_ref().ok())
18017 {
18018 sleep(d).await;
18019 continue;
18020 }
18021
18022 dlg.finished(false);
18023
18024 return Err(match error {
18025 Ok(value) => common::Error::BadRequest(value),
18026 _ => common::Error::Failure(response),
18027 });
18028 }
18029 let response = {
18030 let bytes = common::to_bytes(body).await.unwrap_or_default();
18031 let encoded = common::to_string(&bytes);
18032 match serde_json::from_str(&encoded) {
18033 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18034 Err(error) => {
18035 dlg.response_json_decode_error(&encoded, &error);
18036 return Err(common::Error::JsonDecodeError(
18037 encoded.to_string(),
18038 error,
18039 ));
18040 }
18041 }
18042 };
18043
18044 dlg.finished(true);
18045 return Ok(response);
18046 }
18047 }
18048 }
18049 }
18050
18051 /// 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.
18052 ///
18053 /// Sets the *account id* path property to the given value.
18054 ///
18055 /// Even though the property as already been set when instantiating this call,
18056 /// we provide this method for API completeness.
18057 pub fn account_id(mut self, new_value: &str) -> ManagementGoalListCall<'a, C> {
18058 self._account_id = new_value.to_string();
18059 self
18060 }
18061 /// 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.
18062 ///
18063 /// Sets the *web property id* path property to the given value.
18064 ///
18065 /// Even though the property as already been set when instantiating this call,
18066 /// we provide this method for API completeness.
18067 pub fn web_property_id(mut self, new_value: &str) -> ManagementGoalListCall<'a, C> {
18068 self._web_property_id = new_value.to_string();
18069 self
18070 }
18071 /// 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.
18072 ///
18073 /// Sets the *profile id* path property to the given value.
18074 ///
18075 /// Even though the property as already been set when instantiating this call,
18076 /// we provide this method for API completeness.
18077 pub fn profile_id(mut self, new_value: &str) -> ManagementGoalListCall<'a, C> {
18078 self._profile_id = new_value.to_string();
18079 self
18080 }
18081 /// An index of the first goal to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
18082 ///
18083 /// Sets the *start-index* query property to the given value.
18084 pub fn start_index(mut self, new_value: i32) -> ManagementGoalListCall<'a, C> {
18085 self._start_index = Some(new_value);
18086 self
18087 }
18088 /// The maximum number of goals to include in this response.
18089 ///
18090 /// Sets the *max-results* query property to the given value.
18091 pub fn max_results(mut self, new_value: i32) -> ManagementGoalListCall<'a, C> {
18092 self._max_results = Some(new_value);
18093 self
18094 }
18095 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18096 /// while executing the actual API request.
18097 ///
18098 /// ````text
18099 /// It should be used to handle progress information, and to implement a certain level of resilience.
18100 /// ````
18101 ///
18102 /// Sets the *delegate* property to the given value.
18103 pub fn delegate(
18104 mut self,
18105 new_value: &'a mut dyn common::Delegate,
18106 ) -> ManagementGoalListCall<'a, C> {
18107 self._delegate = Some(new_value);
18108 self
18109 }
18110
18111 /// Set any additional parameter of the query string used in the request.
18112 /// It should be used to set parameters which are not yet available through their own
18113 /// setters.
18114 ///
18115 /// Please note that this method must not be used to set any of the known parameters
18116 /// which have their own setter method. If done anyway, the request will fail.
18117 ///
18118 /// # Additional Parameters
18119 ///
18120 /// * *alt* (query-string) - Data format for the response.
18121 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18122 /// * *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.
18123 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18124 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18125 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18126 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18127 pub fn param<T>(mut self, name: T, value: T) -> ManagementGoalListCall<'a, C>
18128 where
18129 T: AsRef<str>,
18130 {
18131 self._additional_params
18132 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18133 self
18134 }
18135
18136 /// Identifies the authorization scope for the method you are building.
18137 ///
18138 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18139 /// [`Scope::Readonly`].
18140 ///
18141 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18142 /// tokens for more than one scope.
18143 ///
18144 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18145 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18146 /// sufficient, a read-write scope will do as well.
18147 pub fn add_scope<St>(mut self, scope: St) -> ManagementGoalListCall<'a, C>
18148 where
18149 St: AsRef<str>,
18150 {
18151 self._scopes.insert(String::from(scope.as_ref()));
18152 self
18153 }
18154 /// Identifies the authorization scope(s) for the method you are building.
18155 ///
18156 /// See [`Self::add_scope()`] for details.
18157 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementGoalListCall<'a, C>
18158 where
18159 I: IntoIterator<Item = St>,
18160 St: AsRef<str>,
18161 {
18162 self._scopes
18163 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18164 self
18165 }
18166
18167 /// Removes all scopes, and no default scope will be used either.
18168 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18169 /// for details).
18170 pub fn clear_scopes(mut self) -> ManagementGoalListCall<'a, C> {
18171 self._scopes.clear();
18172 self
18173 }
18174}
18175
18176/// Updates an existing goal. This method supports patch semantics.
18177///
18178/// A builder for the *goals.patch* method supported by a *management* resource.
18179/// It is not used directly, but through a [`ManagementMethods`] instance.
18180///
18181/// # Example
18182///
18183/// Instantiate a resource method builder
18184///
18185/// ```test_harness,no_run
18186/// # extern crate hyper;
18187/// # extern crate hyper_rustls;
18188/// # extern crate google_analytics3 as analytics3;
18189/// use analytics3::api::Goal;
18190/// # async fn dox() {
18191/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18192///
18193/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18194/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18195/// # secret,
18196/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18197/// # ).build().await.unwrap();
18198///
18199/// # let client = hyper_util::client::legacy::Client::builder(
18200/// # hyper_util::rt::TokioExecutor::new()
18201/// # )
18202/// # .build(
18203/// # hyper_rustls::HttpsConnectorBuilder::new()
18204/// # .with_native_roots()
18205/// # .unwrap()
18206/// # .https_or_http()
18207/// # .enable_http1()
18208/// # .build()
18209/// # );
18210/// # let mut hub = Analytics::new(client, auth);
18211/// // As the method needs a request, you would usually fill it with the desired information
18212/// // into the respective structure. Some of the parts shown here might not be applicable !
18213/// // Values shown here are possibly random and not representative !
18214/// let mut req = Goal::default();
18215///
18216/// // You can configure optional parameters by calling the respective setters at will, and
18217/// // execute the final call using `doit()`.
18218/// // Values shown here are possibly random and not representative !
18219/// let result = hub.management().goals_patch(req, "accountId", "webPropertyId", "profileId", "goalId")
18220/// .doit().await;
18221/// # }
18222/// ```
18223pub struct ManagementGoalPatchCall<'a, C>
18224where
18225 C: 'a,
18226{
18227 hub: &'a Analytics<C>,
18228 _request: Goal,
18229 _account_id: String,
18230 _web_property_id: String,
18231 _profile_id: String,
18232 _goal_id: String,
18233 _delegate: Option<&'a mut dyn common::Delegate>,
18234 _additional_params: HashMap<String, String>,
18235 _scopes: BTreeSet<String>,
18236}
18237
18238impl<'a, C> common::CallBuilder for ManagementGoalPatchCall<'a, C> {}
18239
18240impl<'a, C> ManagementGoalPatchCall<'a, C>
18241where
18242 C: common::Connector,
18243{
18244 /// Perform the operation you have build so far.
18245 pub async fn doit(mut self) -> common::Result<(common::Response, Goal)> {
18246 use std::borrow::Cow;
18247 use std::io::{Read, Seek};
18248
18249 use common::{url::Params, ToParts};
18250 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18251
18252 let mut dd = common::DefaultDelegate;
18253 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18254 dlg.begin(common::MethodInfo {
18255 id: "analytics.management.goals.patch",
18256 http_method: hyper::Method::PATCH,
18257 });
18258
18259 for &field in ["alt", "accountId", "webPropertyId", "profileId", "goalId"].iter() {
18260 if self._additional_params.contains_key(field) {
18261 dlg.finished(false);
18262 return Err(common::Error::FieldClash(field));
18263 }
18264 }
18265
18266 let mut params = Params::with_capacity(7 + self._additional_params.len());
18267 params.push("accountId", self._account_id);
18268 params.push("webPropertyId", self._web_property_id);
18269 params.push("profileId", self._profile_id);
18270 params.push("goalId", self._goal_id);
18271
18272 params.extend(self._additional_params.iter());
18273
18274 params.push("alt", "json");
18275 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals/{goalId}";
18276 if self._scopes.is_empty() {
18277 self._scopes.insert(Scope::Edit.as_ref().to_string());
18278 }
18279
18280 #[allow(clippy::single_element_loop)]
18281 for &(find_this, param_name) in [
18282 ("{accountId}", "accountId"),
18283 ("{webPropertyId}", "webPropertyId"),
18284 ("{profileId}", "profileId"),
18285 ("{goalId}", "goalId"),
18286 ]
18287 .iter()
18288 {
18289 url = params.uri_replacement(url, param_name, find_this, false);
18290 }
18291 {
18292 let to_remove = ["goalId", "profileId", "webPropertyId", "accountId"];
18293 params.remove_params(&to_remove);
18294 }
18295
18296 let url = params.parse_with_url(&url);
18297
18298 let mut json_mime_type = mime::APPLICATION_JSON;
18299 let mut request_value_reader = {
18300 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18301 common::remove_json_null_values(&mut value);
18302 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18303 serde_json::to_writer(&mut dst, &value).unwrap();
18304 dst
18305 };
18306 let request_size = request_value_reader
18307 .seek(std::io::SeekFrom::End(0))
18308 .unwrap();
18309 request_value_reader
18310 .seek(std::io::SeekFrom::Start(0))
18311 .unwrap();
18312
18313 loop {
18314 let token = match self
18315 .hub
18316 .auth
18317 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18318 .await
18319 {
18320 Ok(token) => token,
18321 Err(e) => match dlg.token(e) {
18322 Ok(token) => token,
18323 Err(e) => {
18324 dlg.finished(false);
18325 return Err(common::Error::MissingToken(e));
18326 }
18327 },
18328 };
18329 request_value_reader
18330 .seek(std::io::SeekFrom::Start(0))
18331 .unwrap();
18332 let mut req_result = {
18333 let client = &self.hub.client;
18334 dlg.pre_request();
18335 let mut req_builder = hyper::Request::builder()
18336 .method(hyper::Method::PATCH)
18337 .uri(url.as_str())
18338 .header(USER_AGENT, self.hub._user_agent.clone());
18339
18340 if let Some(token) = token.as_ref() {
18341 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18342 }
18343
18344 let request = req_builder
18345 .header(CONTENT_TYPE, json_mime_type.to_string())
18346 .header(CONTENT_LENGTH, request_size as u64)
18347 .body(common::to_body(
18348 request_value_reader.get_ref().clone().into(),
18349 ));
18350
18351 client.request(request.unwrap()).await
18352 };
18353
18354 match req_result {
18355 Err(err) => {
18356 if let common::Retry::After(d) = dlg.http_error(&err) {
18357 sleep(d).await;
18358 continue;
18359 }
18360 dlg.finished(false);
18361 return Err(common::Error::HttpError(err));
18362 }
18363 Ok(res) => {
18364 let (mut parts, body) = res.into_parts();
18365 let mut body = common::Body::new(body);
18366 if !parts.status.is_success() {
18367 let bytes = common::to_bytes(body).await.unwrap_or_default();
18368 let error = serde_json::from_str(&common::to_string(&bytes));
18369 let response = common::to_response(parts, bytes.into());
18370
18371 if let common::Retry::After(d) =
18372 dlg.http_failure(&response, error.as_ref().ok())
18373 {
18374 sleep(d).await;
18375 continue;
18376 }
18377
18378 dlg.finished(false);
18379
18380 return Err(match error {
18381 Ok(value) => common::Error::BadRequest(value),
18382 _ => common::Error::Failure(response),
18383 });
18384 }
18385 let response = {
18386 let bytes = common::to_bytes(body).await.unwrap_or_default();
18387 let encoded = common::to_string(&bytes);
18388 match serde_json::from_str(&encoded) {
18389 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18390 Err(error) => {
18391 dlg.response_json_decode_error(&encoded, &error);
18392 return Err(common::Error::JsonDecodeError(
18393 encoded.to_string(),
18394 error,
18395 ));
18396 }
18397 }
18398 };
18399
18400 dlg.finished(true);
18401 return Ok(response);
18402 }
18403 }
18404 }
18405 }
18406
18407 ///
18408 /// Sets the *request* property to the given value.
18409 ///
18410 /// Even though the property as already been set when instantiating this call,
18411 /// we provide this method for API completeness.
18412 pub fn request(mut self, new_value: Goal) -> ManagementGoalPatchCall<'a, C> {
18413 self._request = new_value;
18414 self
18415 }
18416 /// Account ID to update the goal.
18417 ///
18418 /// Sets the *account id* path property to the given value.
18419 ///
18420 /// Even though the property as already been set when instantiating this call,
18421 /// we provide this method for API completeness.
18422 pub fn account_id(mut self, new_value: &str) -> ManagementGoalPatchCall<'a, C> {
18423 self._account_id = new_value.to_string();
18424 self
18425 }
18426 /// Web property ID to update the goal.
18427 ///
18428 /// Sets the *web property id* path property to the given value.
18429 ///
18430 /// Even though the property as already been set when instantiating this call,
18431 /// we provide this method for API completeness.
18432 pub fn web_property_id(mut self, new_value: &str) -> ManagementGoalPatchCall<'a, C> {
18433 self._web_property_id = new_value.to_string();
18434 self
18435 }
18436 /// View (Profile) ID to update the goal.
18437 ///
18438 /// Sets the *profile id* path property to the given value.
18439 ///
18440 /// Even though the property as already been set when instantiating this call,
18441 /// we provide this method for API completeness.
18442 pub fn profile_id(mut self, new_value: &str) -> ManagementGoalPatchCall<'a, C> {
18443 self._profile_id = new_value.to_string();
18444 self
18445 }
18446 /// Index of the goal to be updated.
18447 ///
18448 /// Sets the *goal id* path property to the given value.
18449 ///
18450 /// Even though the property as already been set when instantiating this call,
18451 /// we provide this method for API completeness.
18452 pub fn goal_id(mut self, new_value: &str) -> ManagementGoalPatchCall<'a, C> {
18453 self._goal_id = new_value.to_string();
18454 self
18455 }
18456 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18457 /// while executing the actual API request.
18458 ///
18459 /// ````text
18460 /// It should be used to handle progress information, and to implement a certain level of resilience.
18461 /// ````
18462 ///
18463 /// Sets the *delegate* property to the given value.
18464 pub fn delegate(
18465 mut self,
18466 new_value: &'a mut dyn common::Delegate,
18467 ) -> ManagementGoalPatchCall<'a, C> {
18468 self._delegate = Some(new_value);
18469 self
18470 }
18471
18472 /// Set any additional parameter of the query string used in the request.
18473 /// It should be used to set parameters which are not yet available through their own
18474 /// setters.
18475 ///
18476 /// Please note that this method must not be used to set any of the known parameters
18477 /// which have their own setter method. If done anyway, the request will fail.
18478 ///
18479 /// # Additional Parameters
18480 ///
18481 /// * *alt* (query-string) - Data format for the response.
18482 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18483 /// * *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.
18484 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18485 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18486 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18487 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18488 pub fn param<T>(mut self, name: T, value: T) -> ManagementGoalPatchCall<'a, C>
18489 where
18490 T: AsRef<str>,
18491 {
18492 self._additional_params
18493 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18494 self
18495 }
18496
18497 /// Identifies the authorization scope for the method you are building.
18498 ///
18499 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18500 /// [`Scope::Edit`].
18501 ///
18502 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18503 /// tokens for more than one scope.
18504 ///
18505 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18506 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18507 /// sufficient, a read-write scope will do as well.
18508 pub fn add_scope<St>(mut self, scope: St) -> ManagementGoalPatchCall<'a, C>
18509 where
18510 St: AsRef<str>,
18511 {
18512 self._scopes.insert(String::from(scope.as_ref()));
18513 self
18514 }
18515 /// Identifies the authorization scope(s) for the method you are building.
18516 ///
18517 /// See [`Self::add_scope()`] for details.
18518 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementGoalPatchCall<'a, C>
18519 where
18520 I: IntoIterator<Item = St>,
18521 St: AsRef<str>,
18522 {
18523 self._scopes
18524 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18525 self
18526 }
18527
18528 /// Removes all scopes, and no default scope will be used either.
18529 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18530 /// for details).
18531 pub fn clear_scopes(mut self) -> ManagementGoalPatchCall<'a, C> {
18532 self._scopes.clear();
18533 self
18534 }
18535}
18536
18537/// Updates an existing goal.
18538///
18539/// A builder for the *goals.update* method supported by a *management* resource.
18540/// It is not used directly, but through a [`ManagementMethods`] instance.
18541///
18542/// # Example
18543///
18544/// Instantiate a resource method builder
18545///
18546/// ```test_harness,no_run
18547/// # extern crate hyper;
18548/// # extern crate hyper_rustls;
18549/// # extern crate google_analytics3 as analytics3;
18550/// use analytics3::api::Goal;
18551/// # async fn dox() {
18552/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18553///
18554/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18555/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18556/// # secret,
18557/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18558/// # ).build().await.unwrap();
18559///
18560/// # let client = hyper_util::client::legacy::Client::builder(
18561/// # hyper_util::rt::TokioExecutor::new()
18562/// # )
18563/// # .build(
18564/// # hyper_rustls::HttpsConnectorBuilder::new()
18565/// # .with_native_roots()
18566/// # .unwrap()
18567/// # .https_or_http()
18568/// # .enable_http1()
18569/// # .build()
18570/// # );
18571/// # let mut hub = Analytics::new(client, auth);
18572/// // As the method needs a request, you would usually fill it with the desired information
18573/// // into the respective structure. Some of the parts shown here might not be applicable !
18574/// // Values shown here are possibly random and not representative !
18575/// let mut req = Goal::default();
18576///
18577/// // You can configure optional parameters by calling the respective setters at will, and
18578/// // execute the final call using `doit()`.
18579/// // Values shown here are possibly random and not representative !
18580/// let result = hub.management().goals_update(req, "accountId", "webPropertyId", "profileId", "goalId")
18581/// .doit().await;
18582/// # }
18583/// ```
18584pub struct ManagementGoalUpdateCall<'a, C>
18585where
18586 C: 'a,
18587{
18588 hub: &'a Analytics<C>,
18589 _request: Goal,
18590 _account_id: String,
18591 _web_property_id: String,
18592 _profile_id: String,
18593 _goal_id: String,
18594 _delegate: Option<&'a mut dyn common::Delegate>,
18595 _additional_params: HashMap<String, String>,
18596 _scopes: BTreeSet<String>,
18597}
18598
18599impl<'a, C> common::CallBuilder for ManagementGoalUpdateCall<'a, C> {}
18600
18601impl<'a, C> ManagementGoalUpdateCall<'a, C>
18602where
18603 C: common::Connector,
18604{
18605 /// Perform the operation you have build so far.
18606 pub async fn doit(mut self) -> common::Result<(common::Response, Goal)> {
18607 use std::borrow::Cow;
18608 use std::io::{Read, Seek};
18609
18610 use common::{url::Params, ToParts};
18611 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18612
18613 let mut dd = common::DefaultDelegate;
18614 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18615 dlg.begin(common::MethodInfo {
18616 id: "analytics.management.goals.update",
18617 http_method: hyper::Method::PUT,
18618 });
18619
18620 for &field in ["alt", "accountId", "webPropertyId", "profileId", "goalId"].iter() {
18621 if self._additional_params.contains_key(field) {
18622 dlg.finished(false);
18623 return Err(common::Error::FieldClash(field));
18624 }
18625 }
18626
18627 let mut params = Params::with_capacity(7 + self._additional_params.len());
18628 params.push("accountId", self._account_id);
18629 params.push("webPropertyId", self._web_property_id);
18630 params.push("profileId", self._profile_id);
18631 params.push("goalId", self._goal_id);
18632
18633 params.extend(self._additional_params.iter());
18634
18635 params.push("alt", "json");
18636 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals/{goalId}";
18637 if self._scopes.is_empty() {
18638 self._scopes.insert(Scope::Edit.as_ref().to_string());
18639 }
18640
18641 #[allow(clippy::single_element_loop)]
18642 for &(find_this, param_name) in [
18643 ("{accountId}", "accountId"),
18644 ("{webPropertyId}", "webPropertyId"),
18645 ("{profileId}", "profileId"),
18646 ("{goalId}", "goalId"),
18647 ]
18648 .iter()
18649 {
18650 url = params.uri_replacement(url, param_name, find_this, false);
18651 }
18652 {
18653 let to_remove = ["goalId", "profileId", "webPropertyId", "accountId"];
18654 params.remove_params(&to_remove);
18655 }
18656
18657 let url = params.parse_with_url(&url);
18658
18659 let mut json_mime_type = mime::APPLICATION_JSON;
18660 let mut request_value_reader = {
18661 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18662 common::remove_json_null_values(&mut value);
18663 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18664 serde_json::to_writer(&mut dst, &value).unwrap();
18665 dst
18666 };
18667 let request_size = request_value_reader
18668 .seek(std::io::SeekFrom::End(0))
18669 .unwrap();
18670 request_value_reader
18671 .seek(std::io::SeekFrom::Start(0))
18672 .unwrap();
18673
18674 loop {
18675 let token = match self
18676 .hub
18677 .auth
18678 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18679 .await
18680 {
18681 Ok(token) => token,
18682 Err(e) => match dlg.token(e) {
18683 Ok(token) => token,
18684 Err(e) => {
18685 dlg.finished(false);
18686 return Err(common::Error::MissingToken(e));
18687 }
18688 },
18689 };
18690 request_value_reader
18691 .seek(std::io::SeekFrom::Start(0))
18692 .unwrap();
18693 let mut req_result = {
18694 let client = &self.hub.client;
18695 dlg.pre_request();
18696 let mut req_builder = hyper::Request::builder()
18697 .method(hyper::Method::PUT)
18698 .uri(url.as_str())
18699 .header(USER_AGENT, self.hub._user_agent.clone());
18700
18701 if let Some(token) = token.as_ref() {
18702 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18703 }
18704
18705 let request = req_builder
18706 .header(CONTENT_TYPE, json_mime_type.to_string())
18707 .header(CONTENT_LENGTH, request_size as u64)
18708 .body(common::to_body(
18709 request_value_reader.get_ref().clone().into(),
18710 ));
18711
18712 client.request(request.unwrap()).await
18713 };
18714
18715 match req_result {
18716 Err(err) => {
18717 if let common::Retry::After(d) = dlg.http_error(&err) {
18718 sleep(d).await;
18719 continue;
18720 }
18721 dlg.finished(false);
18722 return Err(common::Error::HttpError(err));
18723 }
18724 Ok(res) => {
18725 let (mut parts, body) = res.into_parts();
18726 let mut body = common::Body::new(body);
18727 if !parts.status.is_success() {
18728 let bytes = common::to_bytes(body).await.unwrap_or_default();
18729 let error = serde_json::from_str(&common::to_string(&bytes));
18730 let response = common::to_response(parts, bytes.into());
18731
18732 if let common::Retry::After(d) =
18733 dlg.http_failure(&response, error.as_ref().ok())
18734 {
18735 sleep(d).await;
18736 continue;
18737 }
18738
18739 dlg.finished(false);
18740
18741 return Err(match error {
18742 Ok(value) => common::Error::BadRequest(value),
18743 _ => common::Error::Failure(response),
18744 });
18745 }
18746 let response = {
18747 let bytes = common::to_bytes(body).await.unwrap_or_default();
18748 let encoded = common::to_string(&bytes);
18749 match serde_json::from_str(&encoded) {
18750 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18751 Err(error) => {
18752 dlg.response_json_decode_error(&encoded, &error);
18753 return Err(common::Error::JsonDecodeError(
18754 encoded.to_string(),
18755 error,
18756 ));
18757 }
18758 }
18759 };
18760
18761 dlg.finished(true);
18762 return Ok(response);
18763 }
18764 }
18765 }
18766 }
18767
18768 ///
18769 /// Sets the *request* property to the given value.
18770 ///
18771 /// Even though the property as already been set when instantiating this call,
18772 /// we provide this method for API completeness.
18773 pub fn request(mut self, new_value: Goal) -> ManagementGoalUpdateCall<'a, C> {
18774 self._request = new_value;
18775 self
18776 }
18777 /// Account ID to update the goal.
18778 ///
18779 /// Sets the *account id* path property to the given value.
18780 ///
18781 /// Even though the property as already been set when instantiating this call,
18782 /// we provide this method for API completeness.
18783 pub fn account_id(mut self, new_value: &str) -> ManagementGoalUpdateCall<'a, C> {
18784 self._account_id = new_value.to_string();
18785 self
18786 }
18787 /// Web property ID to update the goal.
18788 ///
18789 /// Sets the *web property id* path property to the given value.
18790 ///
18791 /// Even though the property as already been set when instantiating this call,
18792 /// we provide this method for API completeness.
18793 pub fn web_property_id(mut self, new_value: &str) -> ManagementGoalUpdateCall<'a, C> {
18794 self._web_property_id = new_value.to_string();
18795 self
18796 }
18797 /// View (Profile) ID to update the goal.
18798 ///
18799 /// Sets the *profile id* path property to the given value.
18800 ///
18801 /// Even though the property as already been set when instantiating this call,
18802 /// we provide this method for API completeness.
18803 pub fn profile_id(mut self, new_value: &str) -> ManagementGoalUpdateCall<'a, C> {
18804 self._profile_id = new_value.to_string();
18805 self
18806 }
18807 /// Index of the goal to be updated.
18808 ///
18809 /// Sets the *goal id* path property to the given value.
18810 ///
18811 /// Even though the property as already been set when instantiating this call,
18812 /// we provide this method for API completeness.
18813 pub fn goal_id(mut self, new_value: &str) -> ManagementGoalUpdateCall<'a, C> {
18814 self._goal_id = new_value.to_string();
18815 self
18816 }
18817 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18818 /// while executing the actual API request.
18819 ///
18820 /// ````text
18821 /// It should be used to handle progress information, and to implement a certain level of resilience.
18822 /// ````
18823 ///
18824 /// Sets the *delegate* property to the given value.
18825 pub fn delegate(
18826 mut self,
18827 new_value: &'a mut dyn common::Delegate,
18828 ) -> ManagementGoalUpdateCall<'a, C> {
18829 self._delegate = Some(new_value);
18830 self
18831 }
18832
18833 /// Set any additional parameter of the query string used in the request.
18834 /// It should be used to set parameters which are not yet available through their own
18835 /// setters.
18836 ///
18837 /// Please note that this method must not be used to set any of the known parameters
18838 /// which have their own setter method. If done anyway, the request will fail.
18839 ///
18840 /// # Additional Parameters
18841 ///
18842 /// * *alt* (query-string) - Data format for the response.
18843 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18844 /// * *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.
18845 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18846 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18847 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18848 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18849 pub fn param<T>(mut self, name: T, value: T) -> ManagementGoalUpdateCall<'a, C>
18850 where
18851 T: AsRef<str>,
18852 {
18853 self._additional_params
18854 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18855 self
18856 }
18857
18858 /// Identifies the authorization scope for the method you are building.
18859 ///
18860 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18861 /// [`Scope::Edit`].
18862 ///
18863 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18864 /// tokens for more than one scope.
18865 ///
18866 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18867 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18868 /// sufficient, a read-write scope will do as well.
18869 pub fn add_scope<St>(mut self, scope: St) -> ManagementGoalUpdateCall<'a, C>
18870 where
18871 St: AsRef<str>,
18872 {
18873 self._scopes.insert(String::from(scope.as_ref()));
18874 self
18875 }
18876 /// Identifies the authorization scope(s) for the method you are building.
18877 ///
18878 /// See [`Self::add_scope()`] for details.
18879 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementGoalUpdateCall<'a, C>
18880 where
18881 I: IntoIterator<Item = St>,
18882 St: AsRef<str>,
18883 {
18884 self._scopes
18885 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18886 self
18887 }
18888
18889 /// Removes all scopes, and no default scope will be used either.
18890 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18891 /// for details).
18892 pub fn clear_scopes(mut self) -> ManagementGoalUpdateCall<'a, C> {
18893 self._scopes.clear();
18894 self
18895 }
18896}
18897
18898/// Delete a profile filter link.
18899///
18900/// A builder for the *profileFilterLinks.delete* method supported by a *management* resource.
18901/// It is not used directly, but through a [`ManagementMethods`] instance.
18902///
18903/// # Example
18904///
18905/// Instantiate a resource method builder
18906///
18907/// ```test_harness,no_run
18908/// # extern crate hyper;
18909/// # extern crate hyper_rustls;
18910/// # extern crate google_analytics3 as analytics3;
18911/// # async fn dox() {
18912/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18913///
18914/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18915/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18916/// # secret,
18917/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18918/// # ).build().await.unwrap();
18919///
18920/// # let client = hyper_util::client::legacy::Client::builder(
18921/// # hyper_util::rt::TokioExecutor::new()
18922/// # )
18923/// # .build(
18924/// # hyper_rustls::HttpsConnectorBuilder::new()
18925/// # .with_native_roots()
18926/// # .unwrap()
18927/// # .https_or_http()
18928/// # .enable_http1()
18929/// # .build()
18930/// # );
18931/// # let mut hub = Analytics::new(client, auth);
18932/// // You can configure optional parameters by calling the respective setters at will, and
18933/// // execute the final call using `doit()`.
18934/// // Values shown here are possibly random and not representative !
18935/// let result = hub.management().profile_filter_links_delete("accountId", "webPropertyId", "profileId", "linkId")
18936/// .doit().await;
18937/// # }
18938/// ```
18939pub struct ManagementProfileFilterLinkDeleteCall<'a, C>
18940where
18941 C: 'a,
18942{
18943 hub: &'a Analytics<C>,
18944 _account_id: String,
18945 _web_property_id: String,
18946 _profile_id: String,
18947 _link_id: String,
18948 _delegate: Option<&'a mut dyn common::Delegate>,
18949 _additional_params: HashMap<String, String>,
18950 _scopes: BTreeSet<String>,
18951}
18952
18953impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkDeleteCall<'a, C> {}
18954
18955impl<'a, C> ManagementProfileFilterLinkDeleteCall<'a, C>
18956where
18957 C: common::Connector,
18958{
18959 /// Perform the operation you have build so far.
18960 pub async fn doit(mut self) -> common::Result<common::Response> {
18961 use std::borrow::Cow;
18962 use std::io::{Read, Seek};
18963
18964 use common::{url::Params, ToParts};
18965 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18966
18967 let mut dd = common::DefaultDelegate;
18968 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18969 dlg.begin(common::MethodInfo {
18970 id: "analytics.management.profileFilterLinks.delete",
18971 http_method: hyper::Method::DELETE,
18972 });
18973
18974 for &field in ["accountId", "webPropertyId", "profileId", "linkId"].iter() {
18975 if self._additional_params.contains_key(field) {
18976 dlg.finished(false);
18977 return Err(common::Error::FieldClash(field));
18978 }
18979 }
18980
18981 let mut params = Params::with_capacity(5 + self._additional_params.len());
18982 params.push("accountId", self._account_id);
18983 params.push("webPropertyId", self._web_property_id);
18984 params.push("profileId", self._profile_id);
18985 params.push("linkId", self._link_id);
18986
18987 params.extend(self._additional_params.iter());
18988
18989 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}";
18990 if self._scopes.is_empty() {
18991 self._scopes.insert(Scope::Edit.as_ref().to_string());
18992 }
18993
18994 #[allow(clippy::single_element_loop)]
18995 for &(find_this, param_name) in [
18996 ("{accountId}", "accountId"),
18997 ("{webPropertyId}", "webPropertyId"),
18998 ("{profileId}", "profileId"),
18999 ("{linkId}", "linkId"),
19000 ]
19001 .iter()
19002 {
19003 url = params.uri_replacement(url, param_name, find_this, false);
19004 }
19005 {
19006 let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
19007 params.remove_params(&to_remove);
19008 }
19009
19010 let url = params.parse_with_url(&url);
19011
19012 loop {
19013 let token = match self
19014 .hub
19015 .auth
19016 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19017 .await
19018 {
19019 Ok(token) => token,
19020 Err(e) => match dlg.token(e) {
19021 Ok(token) => token,
19022 Err(e) => {
19023 dlg.finished(false);
19024 return Err(common::Error::MissingToken(e));
19025 }
19026 },
19027 };
19028 let mut req_result = {
19029 let client = &self.hub.client;
19030 dlg.pre_request();
19031 let mut req_builder = hyper::Request::builder()
19032 .method(hyper::Method::DELETE)
19033 .uri(url.as_str())
19034 .header(USER_AGENT, self.hub._user_agent.clone());
19035
19036 if let Some(token) = token.as_ref() {
19037 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19038 }
19039
19040 let request = req_builder
19041 .header(CONTENT_LENGTH, 0_u64)
19042 .body(common::to_body::<String>(None));
19043
19044 client.request(request.unwrap()).await
19045 };
19046
19047 match req_result {
19048 Err(err) => {
19049 if let common::Retry::After(d) = dlg.http_error(&err) {
19050 sleep(d).await;
19051 continue;
19052 }
19053 dlg.finished(false);
19054 return Err(common::Error::HttpError(err));
19055 }
19056 Ok(res) => {
19057 let (mut parts, body) = res.into_parts();
19058 let mut body = common::Body::new(body);
19059 if !parts.status.is_success() {
19060 let bytes = common::to_bytes(body).await.unwrap_or_default();
19061 let error = serde_json::from_str(&common::to_string(&bytes));
19062 let response = common::to_response(parts, bytes.into());
19063
19064 if let common::Retry::After(d) =
19065 dlg.http_failure(&response, error.as_ref().ok())
19066 {
19067 sleep(d).await;
19068 continue;
19069 }
19070
19071 dlg.finished(false);
19072
19073 return Err(match error {
19074 Ok(value) => common::Error::BadRequest(value),
19075 _ => common::Error::Failure(response),
19076 });
19077 }
19078 let response = common::Response::from_parts(parts, body);
19079
19080 dlg.finished(true);
19081 return Ok(response);
19082 }
19083 }
19084 }
19085 }
19086
19087 /// Account ID to which the profile filter link belongs.
19088 ///
19089 /// Sets the *account id* path property to the given value.
19090 ///
19091 /// Even though the property as already been set when instantiating this call,
19092 /// we provide this method for API completeness.
19093 pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19094 self._account_id = new_value.to_string();
19095 self
19096 }
19097 /// Web property Id to which the profile filter link belongs.
19098 ///
19099 /// Sets the *web property id* path property to the given value.
19100 ///
19101 /// Even though the property as already been set when instantiating this call,
19102 /// we provide this method for API completeness.
19103 pub fn web_property_id(
19104 mut self,
19105 new_value: &str,
19106 ) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19107 self._web_property_id = new_value.to_string();
19108 self
19109 }
19110 /// Profile ID to which the filter link belongs.
19111 ///
19112 /// Sets the *profile id* path property to the given value.
19113 ///
19114 /// Even though the property as already been set when instantiating this call,
19115 /// we provide this method for API completeness.
19116 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19117 self._profile_id = new_value.to_string();
19118 self
19119 }
19120 /// ID of the profile filter link to delete.
19121 ///
19122 /// Sets the *link id* path property to the given value.
19123 ///
19124 /// Even though the property as already been set when instantiating this call,
19125 /// we provide this method for API completeness.
19126 pub fn link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19127 self._link_id = new_value.to_string();
19128 self
19129 }
19130 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19131 /// while executing the actual API request.
19132 ///
19133 /// ````text
19134 /// It should be used to handle progress information, and to implement a certain level of resilience.
19135 /// ````
19136 ///
19137 /// Sets the *delegate* property to the given value.
19138 pub fn delegate(
19139 mut self,
19140 new_value: &'a mut dyn common::Delegate,
19141 ) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19142 self._delegate = Some(new_value);
19143 self
19144 }
19145
19146 /// Set any additional parameter of the query string used in the request.
19147 /// It should be used to set parameters which are not yet available through their own
19148 /// setters.
19149 ///
19150 /// Please note that this method must not be used to set any of the known parameters
19151 /// which have their own setter method. If done anyway, the request will fail.
19152 ///
19153 /// # Additional Parameters
19154 ///
19155 /// * *alt* (query-string) - Data format for the response.
19156 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19157 /// * *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.
19158 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19159 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19160 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19161 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19162 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkDeleteCall<'a, C>
19163 where
19164 T: AsRef<str>,
19165 {
19166 self._additional_params
19167 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19168 self
19169 }
19170
19171 /// Identifies the authorization scope for the method you are building.
19172 ///
19173 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19174 /// [`Scope::Edit`].
19175 ///
19176 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19177 /// tokens for more than one scope.
19178 ///
19179 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19180 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19181 /// sufficient, a read-write scope will do as well.
19182 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkDeleteCall<'a, C>
19183 where
19184 St: AsRef<str>,
19185 {
19186 self._scopes.insert(String::from(scope.as_ref()));
19187 self
19188 }
19189 /// Identifies the authorization scope(s) for the method you are building.
19190 ///
19191 /// See [`Self::add_scope()`] for details.
19192 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkDeleteCall<'a, C>
19193 where
19194 I: IntoIterator<Item = St>,
19195 St: AsRef<str>,
19196 {
19197 self._scopes
19198 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19199 self
19200 }
19201
19202 /// Removes all scopes, and no default scope will be used either.
19203 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19204 /// for details).
19205 pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkDeleteCall<'a, C> {
19206 self._scopes.clear();
19207 self
19208 }
19209}
19210
19211/// Returns a single profile filter link.
19212///
19213/// A builder for the *profileFilterLinks.get* method supported by a *management* resource.
19214/// It is not used directly, but through a [`ManagementMethods`] instance.
19215///
19216/// # Example
19217///
19218/// Instantiate a resource method builder
19219///
19220/// ```test_harness,no_run
19221/// # extern crate hyper;
19222/// # extern crate hyper_rustls;
19223/// # extern crate google_analytics3 as analytics3;
19224/// # async fn dox() {
19225/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19226///
19227/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19228/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19229/// # secret,
19230/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19231/// # ).build().await.unwrap();
19232///
19233/// # let client = hyper_util::client::legacy::Client::builder(
19234/// # hyper_util::rt::TokioExecutor::new()
19235/// # )
19236/// # .build(
19237/// # hyper_rustls::HttpsConnectorBuilder::new()
19238/// # .with_native_roots()
19239/// # .unwrap()
19240/// # .https_or_http()
19241/// # .enable_http1()
19242/// # .build()
19243/// # );
19244/// # let mut hub = Analytics::new(client, auth);
19245/// // You can configure optional parameters by calling the respective setters at will, and
19246/// // execute the final call using `doit()`.
19247/// // Values shown here are possibly random and not representative !
19248/// let result = hub.management().profile_filter_links_get("accountId", "webPropertyId", "profileId", "linkId")
19249/// .doit().await;
19250/// # }
19251/// ```
19252pub struct ManagementProfileFilterLinkGetCall<'a, C>
19253where
19254 C: 'a,
19255{
19256 hub: &'a Analytics<C>,
19257 _account_id: String,
19258 _web_property_id: String,
19259 _profile_id: String,
19260 _link_id: String,
19261 _delegate: Option<&'a mut dyn common::Delegate>,
19262 _additional_params: HashMap<String, String>,
19263 _scopes: BTreeSet<String>,
19264}
19265
19266impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkGetCall<'a, C> {}
19267
19268impl<'a, C> ManagementProfileFilterLinkGetCall<'a, C>
19269where
19270 C: common::Connector,
19271{
19272 /// Perform the operation you have build so far.
19273 pub async fn doit(mut self) -> common::Result<(common::Response, ProfileFilterLink)> {
19274 use std::borrow::Cow;
19275 use std::io::{Read, Seek};
19276
19277 use common::{url::Params, ToParts};
19278 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19279
19280 let mut dd = common::DefaultDelegate;
19281 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19282 dlg.begin(common::MethodInfo {
19283 id: "analytics.management.profileFilterLinks.get",
19284 http_method: hyper::Method::GET,
19285 });
19286
19287 for &field in ["alt", "accountId", "webPropertyId", "profileId", "linkId"].iter() {
19288 if self._additional_params.contains_key(field) {
19289 dlg.finished(false);
19290 return Err(common::Error::FieldClash(field));
19291 }
19292 }
19293
19294 let mut params = Params::with_capacity(6 + self._additional_params.len());
19295 params.push("accountId", self._account_id);
19296 params.push("webPropertyId", self._web_property_id);
19297 params.push("profileId", self._profile_id);
19298 params.push("linkId", self._link_id);
19299
19300 params.extend(self._additional_params.iter());
19301
19302 params.push("alt", "json");
19303 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}";
19304 if self._scopes.is_empty() {
19305 self._scopes.insert(Scope::Readonly.as_ref().to_string());
19306 }
19307
19308 #[allow(clippy::single_element_loop)]
19309 for &(find_this, param_name) in [
19310 ("{accountId}", "accountId"),
19311 ("{webPropertyId}", "webPropertyId"),
19312 ("{profileId}", "profileId"),
19313 ("{linkId}", "linkId"),
19314 ]
19315 .iter()
19316 {
19317 url = params.uri_replacement(url, param_name, find_this, false);
19318 }
19319 {
19320 let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
19321 params.remove_params(&to_remove);
19322 }
19323
19324 let url = params.parse_with_url(&url);
19325
19326 loop {
19327 let token = match self
19328 .hub
19329 .auth
19330 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19331 .await
19332 {
19333 Ok(token) => token,
19334 Err(e) => match dlg.token(e) {
19335 Ok(token) => token,
19336 Err(e) => {
19337 dlg.finished(false);
19338 return Err(common::Error::MissingToken(e));
19339 }
19340 },
19341 };
19342 let mut req_result = {
19343 let client = &self.hub.client;
19344 dlg.pre_request();
19345 let mut req_builder = hyper::Request::builder()
19346 .method(hyper::Method::GET)
19347 .uri(url.as_str())
19348 .header(USER_AGENT, self.hub._user_agent.clone());
19349
19350 if let Some(token) = token.as_ref() {
19351 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19352 }
19353
19354 let request = req_builder
19355 .header(CONTENT_LENGTH, 0_u64)
19356 .body(common::to_body::<String>(None));
19357
19358 client.request(request.unwrap()).await
19359 };
19360
19361 match req_result {
19362 Err(err) => {
19363 if let common::Retry::After(d) = dlg.http_error(&err) {
19364 sleep(d).await;
19365 continue;
19366 }
19367 dlg.finished(false);
19368 return Err(common::Error::HttpError(err));
19369 }
19370 Ok(res) => {
19371 let (mut parts, body) = res.into_parts();
19372 let mut body = common::Body::new(body);
19373 if !parts.status.is_success() {
19374 let bytes = common::to_bytes(body).await.unwrap_or_default();
19375 let error = serde_json::from_str(&common::to_string(&bytes));
19376 let response = common::to_response(parts, bytes.into());
19377
19378 if let common::Retry::After(d) =
19379 dlg.http_failure(&response, error.as_ref().ok())
19380 {
19381 sleep(d).await;
19382 continue;
19383 }
19384
19385 dlg.finished(false);
19386
19387 return Err(match error {
19388 Ok(value) => common::Error::BadRequest(value),
19389 _ => common::Error::Failure(response),
19390 });
19391 }
19392 let response = {
19393 let bytes = common::to_bytes(body).await.unwrap_or_default();
19394 let encoded = common::to_string(&bytes);
19395 match serde_json::from_str(&encoded) {
19396 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19397 Err(error) => {
19398 dlg.response_json_decode_error(&encoded, &error);
19399 return Err(common::Error::JsonDecodeError(
19400 encoded.to_string(),
19401 error,
19402 ));
19403 }
19404 }
19405 };
19406
19407 dlg.finished(true);
19408 return Ok(response);
19409 }
19410 }
19411 }
19412 }
19413
19414 /// Account ID to retrieve profile filter link for.
19415 ///
19416 /// Sets the *account id* path property to the given value.
19417 ///
19418 /// Even though the property as already been set when instantiating this call,
19419 /// we provide this method for API completeness.
19420 pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C> {
19421 self._account_id = new_value.to_string();
19422 self
19423 }
19424 /// Web property Id to retrieve profile filter link for.
19425 ///
19426 /// Sets the *web property id* path property to the given value.
19427 ///
19428 /// Even though the property as already been set when instantiating this call,
19429 /// we provide this method for API completeness.
19430 pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C> {
19431 self._web_property_id = new_value.to_string();
19432 self
19433 }
19434 /// Profile ID to retrieve filter link for.
19435 ///
19436 /// Sets the *profile id* path property to the given value.
19437 ///
19438 /// Even though the property as already been set when instantiating this call,
19439 /// we provide this method for API completeness.
19440 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C> {
19441 self._profile_id = new_value.to_string();
19442 self
19443 }
19444 /// ID of the profile filter link.
19445 ///
19446 /// Sets the *link id* path property to the given value.
19447 ///
19448 /// Even though the property as already been set when instantiating this call,
19449 /// we provide this method for API completeness.
19450 pub fn link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkGetCall<'a, C> {
19451 self._link_id = new_value.to_string();
19452 self
19453 }
19454 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19455 /// while executing the actual API request.
19456 ///
19457 /// ````text
19458 /// It should be used to handle progress information, and to implement a certain level of resilience.
19459 /// ````
19460 ///
19461 /// Sets the *delegate* property to the given value.
19462 pub fn delegate(
19463 mut self,
19464 new_value: &'a mut dyn common::Delegate,
19465 ) -> ManagementProfileFilterLinkGetCall<'a, C> {
19466 self._delegate = Some(new_value);
19467 self
19468 }
19469
19470 /// Set any additional parameter of the query string used in the request.
19471 /// It should be used to set parameters which are not yet available through their own
19472 /// setters.
19473 ///
19474 /// Please note that this method must not be used to set any of the known parameters
19475 /// which have their own setter method. If done anyway, the request will fail.
19476 ///
19477 /// # Additional Parameters
19478 ///
19479 /// * *alt* (query-string) - Data format for the response.
19480 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19481 /// * *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.
19482 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19483 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19484 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19485 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19486 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkGetCall<'a, C>
19487 where
19488 T: AsRef<str>,
19489 {
19490 self._additional_params
19491 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19492 self
19493 }
19494
19495 /// Identifies the authorization scope for the method you are building.
19496 ///
19497 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19498 /// [`Scope::Readonly`].
19499 ///
19500 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19501 /// tokens for more than one scope.
19502 ///
19503 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19504 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19505 /// sufficient, a read-write scope will do as well.
19506 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkGetCall<'a, C>
19507 where
19508 St: AsRef<str>,
19509 {
19510 self._scopes.insert(String::from(scope.as_ref()));
19511 self
19512 }
19513 /// Identifies the authorization scope(s) for the method you are building.
19514 ///
19515 /// See [`Self::add_scope()`] for details.
19516 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkGetCall<'a, C>
19517 where
19518 I: IntoIterator<Item = St>,
19519 St: AsRef<str>,
19520 {
19521 self._scopes
19522 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19523 self
19524 }
19525
19526 /// Removes all scopes, and no default scope will be used either.
19527 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19528 /// for details).
19529 pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkGetCall<'a, C> {
19530 self._scopes.clear();
19531 self
19532 }
19533}
19534
19535/// Create a new profile filter link.
19536///
19537/// A builder for the *profileFilterLinks.insert* method supported by a *management* resource.
19538/// It is not used directly, but through a [`ManagementMethods`] instance.
19539///
19540/// # Example
19541///
19542/// Instantiate a resource method builder
19543///
19544/// ```test_harness,no_run
19545/// # extern crate hyper;
19546/// # extern crate hyper_rustls;
19547/// # extern crate google_analytics3 as analytics3;
19548/// use analytics3::api::ProfileFilterLink;
19549/// # async fn dox() {
19550/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19551///
19552/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19553/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19554/// # secret,
19555/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19556/// # ).build().await.unwrap();
19557///
19558/// # let client = hyper_util::client::legacy::Client::builder(
19559/// # hyper_util::rt::TokioExecutor::new()
19560/// # )
19561/// # .build(
19562/// # hyper_rustls::HttpsConnectorBuilder::new()
19563/// # .with_native_roots()
19564/// # .unwrap()
19565/// # .https_or_http()
19566/// # .enable_http1()
19567/// # .build()
19568/// # );
19569/// # let mut hub = Analytics::new(client, auth);
19570/// // As the method needs a request, you would usually fill it with the desired information
19571/// // into the respective structure. Some of the parts shown here might not be applicable !
19572/// // Values shown here are possibly random and not representative !
19573/// let mut req = ProfileFilterLink::default();
19574///
19575/// // You can configure optional parameters by calling the respective setters at will, and
19576/// // execute the final call using `doit()`.
19577/// // Values shown here are possibly random and not representative !
19578/// let result = hub.management().profile_filter_links_insert(req, "accountId", "webPropertyId", "profileId")
19579/// .doit().await;
19580/// # }
19581/// ```
19582pub struct ManagementProfileFilterLinkInsertCall<'a, C>
19583where
19584 C: 'a,
19585{
19586 hub: &'a Analytics<C>,
19587 _request: ProfileFilterLink,
19588 _account_id: String,
19589 _web_property_id: String,
19590 _profile_id: String,
19591 _delegate: Option<&'a mut dyn common::Delegate>,
19592 _additional_params: HashMap<String, String>,
19593 _scopes: BTreeSet<String>,
19594}
19595
19596impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkInsertCall<'a, C> {}
19597
19598impl<'a, C> ManagementProfileFilterLinkInsertCall<'a, C>
19599where
19600 C: common::Connector,
19601{
19602 /// Perform the operation you have build so far.
19603 pub async fn doit(mut self) -> common::Result<(common::Response, ProfileFilterLink)> {
19604 use std::borrow::Cow;
19605 use std::io::{Read, Seek};
19606
19607 use common::{url::Params, ToParts};
19608 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19609
19610 let mut dd = common::DefaultDelegate;
19611 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19612 dlg.begin(common::MethodInfo {
19613 id: "analytics.management.profileFilterLinks.insert",
19614 http_method: hyper::Method::POST,
19615 });
19616
19617 for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
19618 if self._additional_params.contains_key(field) {
19619 dlg.finished(false);
19620 return Err(common::Error::FieldClash(field));
19621 }
19622 }
19623
19624 let mut params = Params::with_capacity(6 + self._additional_params.len());
19625 params.push("accountId", self._account_id);
19626 params.push("webPropertyId", self._web_property_id);
19627 params.push("profileId", self._profile_id);
19628
19629 params.extend(self._additional_params.iter());
19630
19631 params.push("alt", "json");
19632 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks";
19633 if self._scopes.is_empty() {
19634 self._scopes.insert(Scope::Edit.as_ref().to_string());
19635 }
19636
19637 #[allow(clippy::single_element_loop)]
19638 for &(find_this, param_name) in [
19639 ("{accountId}", "accountId"),
19640 ("{webPropertyId}", "webPropertyId"),
19641 ("{profileId}", "profileId"),
19642 ]
19643 .iter()
19644 {
19645 url = params.uri_replacement(url, param_name, find_this, false);
19646 }
19647 {
19648 let to_remove = ["profileId", "webPropertyId", "accountId"];
19649 params.remove_params(&to_remove);
19650 }
19651
19652 let url = params.parse_with_url(&url);
19653
19654 let mut json_mime_type = mime::APPLICATION_JSON;
19655 let mut request_value_reader = {
19656 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19657 common::remove_json_null_values(&mut value);
19658 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19659 serde_json::to_writer(&mut dst, &value).unwrap();
19660 dst
19661 };
19662 let request_size = request_value_reader
19663 .seek(std::io::SeekFrom::End(0))
19664 .unwrap();
19665 request_value_reader
19666 .seek(std::io::SeekFrom::Start(0))
19667 .unwrap();
19668
19669 loop {
19670 let token = match self
19671 .hub
19672 .auth
19673 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19674 .await
19675 {
19676 Ok(token) => token,
19677 Err(e) => match dlg.token(e) {
19678 Ok(token) => token,
19679 Err(e) => {
19680 dlg.finished(false);
19681 return Err(common::Error::MissingToken(e));
19682 }
19683 },
19684 };
19685 request_value_reader
19686 .seek(std::io::SeekFrom::Start(0))
19687 .unwrap();
19688 let mut req_result = {
19689 let client = &self.hub.client;
19690 dlg.pre_request();
19691 let mut req_builder = hyper::Request::builder()
19692 .method(hyper::Method::POST)
19693 .uri(url.as_str())
19694 .header(USER_AGENT, self.hub._user_agent.clone());
19695
19696 if let Some(token) = token.as_ref() {
19697 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19698 }
19699
19700 let request = req_builder
19701 .header(CONTENT_TYPE, json_mime_type.to_string())
19702 .header(CONTENT_LENGTH, request_size as u64)
19703 .body(common::to_body(
19704 request_value_reader.get_ref().clone().into(),
19705 ));
19706
19707 client.request(request.unwrap()).await
19708 };
19709
19710 match req_result {
19711 Err(err) => {
19712 if let common::Retry::After(d) = dlg.http_error(&err) {
19713 sleep(d).await;
19714 continue;
19715 }
19716 dlg.finished(false);
19717 return Err(common::Error::HttpError(err));
19718 }
19719 Ok(res) => {
19720 let (mut parts, body) = res.into_parts();
19721 let mut body = common::Body::new(body);
19722 if !parts.status.is_success() {
19723 let bytes = common::to_bytes(body).await.unwrap_or_default();
19724 let error = serde_json::from_str(&common::to_string(&bytes));
19725 let response = common::to_response(parts, bytes.into());
19726
19727 if let common::Retry::After(d) =
19728 dlg.http_failure(&response, error.as_ref().ok())
19729 {
19730 sleep(d).await;
19731 continue;
19732 }
19733
19734 dlg.finished(false);
19735
19736 return Err(match error {
19737 Ok(value) => common::Error::BadRequest(value),
19738 _ => common::Error::Failure(response),
19739 });
19740 }
19741 let response = {
19742 let bytes = common::to_bytes(body).await.unwrap_or_default();
19743 let encoded = common::to_string(&bytes);
19744 match serde_json::from_str(&encoded) {
19745 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19746 Err(error) => {
19747 dlg.response_json_decode_error(&encoded, &error);
19748 return Err(common::Error::JsonDecodeError(
19749 encoded.to_string(),
19750 error,
19751 ));
19752 }
19753 }
19754 };
19755
19756 dlg.finished(true);
19757 return Ok(response);
19758 }
19759 }
19760 }
19761 }
19762
19763 ///
19764 /// Sets the *request* property to the given value.
19765 ///
19766 /// Even though the property as already been set when instantiating this call,
19767 /// we provide this method for API completeness.
19768 pub fn request(
19769 mut self,
19770 new_value: ProfileFilterLink,
19771 ) -> ManagementProfileFilterLinkInsertCall<'a, C> {
19772 self._request = new_value;
19773 self
19774 }
19775 /// Account ID to create profile filter link for.
19776 ///
19777 /// Sets the *account id* path property to the given value.
19778 ///
19779 /// Even though the property as already been set when instantiating this call,
19780 /// we provide this method for API completeness.
19781 pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkInsertCall<'a, C> {
19782 self._account_id = new_value.to_string();
19783 self
19784 }
19785 /// Web property Id to create profile filter link for.
19786 ///
19787 /// Sets the *web property id* path property to the given value.
19788 ///
19789 /// Even though the property as already been set when instantiating this call,
19790 /// we provide this method for API completeness.
19791 pub fn web_property_id(
19792 mut self,
19793 new_value: &str,
19794 ) -> ManagementProfileFilterLinkInsertCall<'a, C> {
19795 self._web_property_id = new_value.to_string();
19796 self
19797 }
19798 /// Profile ID to create filter link for.
19799 ///
19800 /// Sets the *profile id* path property to the given value.
19801 ///
19802 /// Even though the property as already been set when instantiating this call,
19803 /// we provide this method for API completeness.
19804 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkInsertCall<'a, C> {
19805 self._profile_id = new_value.to_string();
19806 self
19807 }
19808 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19809 /// while executing the actual API request.
19810 ///
19811 /// ````text
19812 /// It should be used to handle progress information, and to implement a certain level of resilience.
19813 /// ````
19814 ///
19815 /// Sets the *delegate* property to the given value.
19816 pub fn delegate(
19817 mut self,
19818 new_value: &'a mut dyn common::Delegate,
19819 ) -> ManagementProfileFilterLinkInsertCall<'a, C> {
19820 self._delegate = Some(new_value);
19821 self
19822 }
19823
19824 /// Set any additional parameter of the query string used in the request.
19825 /// It should be used to set parameters which are not yet available through their own
19826 /// setters.
19827 ///
19828 /// Please note that this method must not be used to set any of the known parameters
19829 /// which have their own setter method. If done anyway, the request will fail.
19830 ///
19831 /// # Additional Parameters
19832 ///
19833 /// * *alt* (query-string) - Data format for the response.
19834 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19835 /// * *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.
19836 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19837 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19838 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19839 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19840 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkInsertCall<'a, C>
19841 where
19842 T: AsRef<str>,
19843 {
19844 self._additional_params
19845 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19846 self
19847 }
19848
19849 /// Identifies the authorization scope for the method you are building.
19850 ///
19851 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19852 /// [`Scope::Edit`].
19853 ///
19854 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19855 /// tokens for more than one scope.
19856 ///
19857 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19858 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19859 /// sufficient, a read-write scope will do as well.
19860 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkInsertCall<'a, C>
19861 where
19862 St: AsRef<str>,
19863 {
19864 self._scopes.insert(String::from(scope.as_ref()));
19865 self
19866 }
19867 /// Identifies the authorization scope(s) for the method you are building.
19868 ///
19869 /// See [`Self::add_scope()`] for details.
19870 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkInsertCall<'a, C>
19871 where
19872 I: IntoIterator<Item = St>,
19873 St: AsRef<str>,
19874 {
19875 self._scopes
19876 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19877 self
19878 }
19879
19880 /// Removes all scopes, and no default scope will be used either.
19881 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19882 /// for details).
19883 pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkInsertCall<'a, C> {
19884 self._scopes.clear();
19885 self
19886 }
19887}
19888
19889/// Lists all profile filter links for a profile.
19890///
19891/// A builder for the *profileFilterLinks.list* method supported by a *management* resource.
19892/// It is not used directly, but through a [`ManagementMethods`] instance.
19893///
19894/// # Example
19895///
19896/// Instantiate a resource method builder
19897///
19898/// ```test_harness,no_run
19899/// # extern crate hyper;
19900/// # extern crate hyper_rustls;
19901/// # extern crate google_analytics3 as analytics3;
19902/// # async fn dox() {
19903/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19904///
19905/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19906/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19907/// # secret,
19908/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19909/// # ).build().await.unwrap();
19910///
19911/// # let client = hyper_util::client::legacy::Client::builder(
19912/// # hyper_util::rt::TokioExecutor::new()
19913/// # )
19914/// # .build(
19915/// # hyper_rustls::HttpsConnectorBuilder::new()
19916/// # .with_native_roots()
19917/// # .unwrap()
19918/// # .https_or_http()
19919/// # .enable_http1()
19920/// # .build()
19921/// # );
19922/// # let mut hub = Analytics::new(client, auth);
19923/// // You can configure optional parameters by calling the respective setters at will, and
19924/// // execute the final call using `doit()`.
19925/// // Values shown here are possibly random and not representative !
19926/// let result = hub.management().profile_filter_links_list("accountId", "webPropertyId", "profileId")
19927/// .start_index(-73)
19928/// .max_results(-10)
19929/// .doit().await;
19930/// # }
19931/// ```
19932pub struct ManagementProfileFilterLinkListCall<'a, C>
19933where
19934 C: 'a,
19935{
19936 hub: &'a Analytics<C>,
19937 _account_id: String,
19938 _web_property_id: String,
19939 _profile_id: String,
19940 _start_index: Option<i32>,
19941 _max_results: Option<i32>,
19942 _delegate: Option<&'a mut dyn common::Delegate>,
19943 _additional_params: HashMap<String, String>,
19944 _scopes: BTreeSet<String>,
19945}
19946
19947impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkListCall<'a, C> {}
19948
19949impl<'a, C> ManagementProfileFilterLinkListCall<'a, C>
19950where
19951 C: common::Connector,
19952{
19953 /// Perform the operation you have build so far.
19954 pub async fn doit(mut self) -> common::Result<(common::Response, ProfileFilterLinks)> {
19955 use std::borrow::Cow;
19956 use std::io::{Read, Seek};
19957
19958 use common::{url::Params, ToParts};
19959 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19960
19961 let mut dd = common::DefaultDelegate;
19962 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19963 dlg.begin(common::MethodInfo {
19964 id: "analytics.management.profileFilterLinks.list",
19965 http_method: hyper::Method::GET,
19966 });
19967
19968 for &field in [
19969 "alt",
19970 "accountId",
19971 "webPropertyId",
19972 "profileId",
19973 "start-index",
19974 "max-results",
19975 ]
19976 .iter()
19977 {
19978 if self._additional_params.contains_key(field) {
19979 dlg.finished(false);
19980 return Err(common::Error::FieldClash(field));
19981 }
19982 }
19983
19984 let mut params = Params::with_capacity(7 + self._additional_params.len());
19985 params.push("accountId", self._account_id);
19986 params.push("webPropertyId", self._web_property_id);
19987 params.push("profileId", self._profile_id);
19988 if let Some(value) = self._start_index.as_ref() {
19989 params.push("start-index", value.to_string());
19990 }
19991 if let Some(value) = self._max_results.as_ref() {
19992 params.push("max-results", value.to_string());
19993 }
19994
19995 params.extend(self._additional_params.iter());
19996
19997 params.push("alt", "json");
19998 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks";
19999 if self._scopes.is_empty() {
20000 self._scopes.insert(Scope::Readonly.as_ref().to_string());
20001 }
20002
20003 #[allow(clippy::single_element_loop)]
20004 for &(find_this, param_name) in [
20005 ("{accountId}", "accountId"),
20006 ("{webPropertyId}", "webPropertyId"),
20007 ("{profileId}", "profileId"),
20008 ]
20009 .iter()
20010 {
20011 url = params.uri_replacement(url, param_name, find_this, false);
20012 }
20013 {
20014 let to_remove = ["profileId", "webPropertyId", "accountId"];
20015 params.remove_params(&to_remove);
20016 }
20017
20018 let url = params.parse_with_url(&url);
20019
20020 loop {
20021 let token = match self
20022 .hub
20023 .auth
20024 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20025 .await
20026 {
20027 Ok(token) => token,
20028 Err(e) => match dlg.token(e) {
20029 Ok(token) => token,
20030 Err(e) => {
20031 dlg.finished(false);
20032 return Err(common::Error::MissingToken(e));
20033 }
20034 },
20035 };
20036 let mut req_result = {
20037 let client = &self.hub.client;
20038 dlg.pre_request();
20039 let mut req_builder = hyper::Request::builder()
20040 .method(hyper::Method::GET)
20041 .uri(url.as_str())
20042 .header(USER_AGENT, self.hub._user_agent.clone());
20043
20044 if let Some(token) = token.as_ref() {
20045 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20046 }
20047
20048 let request = req_builder
20049 .header(CONTENT_LENGTH, 0_u64)
20050 .body(common::to_body::<String>(None));
20051
20052 client.request(request.unwrap()).await
20053 };
20054
20055 match req_result {
20056 Err(err) => {
20057 if let common::Retry::After(d) = dlg.http_error(&err) {
20058 sleep(d).await;
20059 continue;
20060 }
20061 dlg.finished(false);
20062 return Err(common::Error::HttpError(err));
20063 }
20064 Ok(res) => {
20065 let (mut parts, body) = res.into_parts();
20066 let mut body = common::Body::new(body);
20067 if !parts.status.is_success() {
20068 let bytes = common::to_bytes(body).await.unwrap_or_default();
20069 let error = serde_json::from_str(&common::to_string(&bytes));
20070 let response = common::to_response(parts, bytes.into());
20071
20072 if let common::Retry::After(d) =
20073 dlg.http_failure(&response, error.as_ref().ok())
20074 {
20075 sleep(d).await;
20076 continue;
20077 }
20078
20079 dlg.finished(false);
20080
20081 return Err(match error {
20082 Ok(value) => common::Error::BadRequest(value),
20083 _ => common::Error::Failure(response),
20084 });
20085 }
20086 let response = {
20087 let bytes = common::to_bytes(body).await.unwrap_or_default();
20088 let encoded = common::to_string(&bytes);
20089 match serde_json::from_str(&encoded) {
20090 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20091 Err(error) => {
20092 dlg.response_json_decode_error(&encoded, &error);
20093 return Err(common::Error::JsonDecodeError(
20094 encoded.to_string(),
20095 error,
20096 ));
20097 }
20098 }
20099 };
20100
20101 dlg.finished(true);
20102 return Ok(response);
20103 }
20104 }
20105 }
20106 }
20107
20108 /// Account ID to retrieve profile filter links for.
20109 ///
20110 /// Sets the *account id* path property to the given value.
20111 ///
20112 /// Even though the property as already been set when instantiating this call,
20113 /// we provide this method for API completeness.
20114 pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkListCall<'a, C> {
20115 self._account_id = new_value.to_string();
20116 self
20117 }
20118 /// 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.
20119 ///
20120 /// Sets the *web property id* path property to the given value.
20121 ///
20122 /// Even though the property as already been set when instantiating this call,
20123 /// we provide this method for API completeness.
20124 pub fn web_property_id(
20125 mut self,
20126 new_value: &str,
20127 ) -> ManagementProfileFilterLinkListCall<'a, C> {
20128 self._web_property_id = new_value.to_string();
20129 self
20130 }
20131 /// 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.
20132 ///
20133 /// Sets the *profile id* path property to the given value.
20134 ///
20135 /// Even though the property as already been set when instantiating this call,
20136 /// we provide this method for API completeness.
20137 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkListCall<'a, C> {
20138 self._profile_id = new_value.to_string();
20139 self
20140 }
20141 /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
20142 ///
20143 /// Sets the *start-index* query property to the given value.
20144 pub fn start_index(mut self, new_value: i32) -> ManagementProfileFilterLinkListCall<'a, C> {
20145 self._start_index = Some(new_value);
20146 self
20147 }
20148 /// The maximum number of profile filter links to include in this response.
20149 ///
20150 /// Sets the *max-results* query property to the given value.
20151 pub fn max_results(mut self, new_value: i32) -> ManagementProfileFilterLinkListCall<'a, C> {
20152 self._max_results = Some(new_value);
20153 self
20154 }
20155 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20156 /// while executing the actual API request.
20157 ///
20158 /// ````text
20159 /// It should be used to handle progress information, and to implement a certain level of resilience.
20160 /// ````
20161 ///
20162 /// Sets the *delegate* property to the given value.
20163 pub fn delegate(
20164 mut self,
20165 new_value: &'a mut dyn common::Delegate,
20166 ) -> ManagementProfileFilterLinkListCall<'a, C> {
20167 self._delegate = Some(new_value);
20168 self
20169 }
20170
20171 /// Set any additional parameter of the query string used in the request.
20172 /// It should be used to set parameters which are not yet available through their own
20173 /// setters.
20174 ///
20175 /// Please note that this method must not be used to set any of the known parameters
20176 /// which have their own setter method. If done anyway, the request will fail.
20177 ///
20178 /// # Additional Parameters
20179 ///
20180 /// * *alt* (query-string) - Data format for the response.
20181 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20182 /// * *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.
20183 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20184 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20185 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20186 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20187 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkListCall<'a, C>
20188 where
20189 T: AsRef<str>,
20190 {
20191 self._additional_params
20192 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20193 self
20194 }
20195
20196 /// Identifies the authorization scope for the method you are building.
20197 ///
20198 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20199 /// [`Scope::Readonly`].
20200 ///
20201 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20202 /// tokens for more than one scope.
20203 ///
20204 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20205 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20206 /// sufficient, a read-write scope will do as well.
20207 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkListCall<'a, C>
20208 where
20209 St: AsRef<str>,
20210 {
20211 self._scopes.insert(String::from(scope.as_ref()));
20212 self
20213 }
20214 /// Identifies the authorization scope(s) for the method you are building.
20215 ///
20216 /// See [`Self::add_scope()`] for details.
20217 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkListCall<'a, C>
20218 where
20219 I: IntoIterator<Item = St>,
20220 St: AsRef<str>,
20221 {
20222 self._scopes
20223 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20224 self
20225 }
20226
20227 /// Removes all scopes, and no default scope will be used either.
20228 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20229 /// for details).
20230 pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkListCall<'a, C> {
20231 self._scopes.clear();
20232 self
20233 }
20234}
20235
20236/// Update an existing profile filter link. This method supports patch semantics.
20237///
20238/// A builder for the *profileFilterLinks.patch* method supported by a *management* resource.
20239/// It is not used directly, but through a [`ManagementMethods`] instance.
20240///
20241/// # Example
20242///
20243/// Instantiate a resource method builder
20244///
20245/// ```test_harness,no_run
20246/// # extern crate hyper;
20247/// # extern crate hyper_rustls;
20248/// # extern crate google_analytics3 as analytics3;
20249/// use analytics3::api::ProfileFilterLink;
20250/// # async fn dox() {
20251/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20252///
20253/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20254/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20255/// # secret,
20256/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20257/// # ).build().await.unwrap();
20258///
20259/// # let client = hyper_util::client::legacy::Client::builder(
20260/// # hyper_util::rt::TokioExecutor::new()
20261/// # )
20262/// # .build(
20263/// # hyper_rustls::HttpsConnectorBuilder::new()
20264/// # .with_native_roots()
20265/// # .unwrap()
20266/// # .https_or_http()
20267/// # .enable_http1()
20268/// # .build()
20269/// # );
20270/// # let mut hub = Analytics::new(client, auth);
20271/// // As the method needs a request, you would usually fill it with the desired information
20272/// // into the respective structure. Some of the parts shown here might not be applicable !
20273/// // Values shown here are possibly random and not representative !
20274/// let mut req = ProfileFilterLink::default();
20275///
20276/// // You can configure optional parameters by calling the respective setters at will, and
20277/// // execute the final call using `doit()`.
20278/// // Values shown here are possibly random and not representative !
20279/// let result = hub.management().profile_filter_links_patch(req, "accountId", "webPropertyId", "profileId", "linkId")
20280/// .doit().await;
20281/// # }
20282/// ```
20283pub struct ManagementProfileFilterLinkPatchCall<'a, C>
20284where
20285 C: 'a,
20286{
20287 hub: &'a Analytics<C>,
20288 _request: ProfileFilterLink,
20289 _account_id: String,
20290 _web_property_id: String,
20291 _profile_id: String,
20292 _link_id: String,
20293 _delegate: Option<&'a mut dyn common::Delegate>,
20294 _additional_params: HashMap<String, String>,
20295 _scopes: BTreeSet<String>,
20296}
20297
20298impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkPatchCall<'a, C> {}
20299
20300impl<'a, C> ManagementProfileFilterLinkPatchCall<'a, C>
20301where
20302 C: common::Connector,
20303{
20304 /// Perform the operation you have build so far.
20305 pub async fn doit(mut self) -> common::Result<(common::Response, ProfileFilterLink)> {
20306 use std::borrow::Cow;
20307 use std::io::{Read, Seek};
20308
20309 use common::{url::Params, ToParts};
20310 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20311
20312 let mut dd = common::DefaultDelegate;
20313 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20314 dlg.begin(common::MethodInfo {
20315 id: "analytics.management.profileFilterLinks.patch",
20316 http_method: hyper::Method::PATCH,
20317 });
20318
20319 for &field in ["alt", "accountId", "webPropertyId", "profileId", "linkId"].iter() {
20320 if self._additional_params.contains_key(field) {
20321 dlg.finished(false);
20322 return Err(common::Error::FieldClash(field));
20323 }
20324 }
20325
20326 let mut params = Params::with_capacity(7 + self._additional_params.len());
20327 params.push("accountId", self._account_id);
20328 params.push("webPropertyId", self._web_property_id);
20329 params.push("profileId", self._profile_id);
20330 params.push("linkId", self._link_id);
20331
20332 params.extend(self._additional_params.iter());
20333
20334 params.push("alt", "json");
20335 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}";
20336 if self._scopes.is_empty() {
20337 self._scopes.insert(Scope::Edit.as_ref().to_string());
20338 }
20339
20340 #[allow(clippy::single_element_loop)]
20341 for &(find_this, param_name) in [
20342 ("{accountId}", "accountId"),
20343 ("{webPropertyId}", "webPropertyId"),
20344 ("{profileId}", "profileId"),
20345 ("{linkId}", "linkId"),
20346 ]
20347 .iter()
20348 {
20349 url = params.uri_replacement(url, param_name, find_this, false);
20350 }
20351 {
20352 let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
20353 params.remove_params(&to_remove);
20354 }
20355
20356 let url = params.parse_with_url(&url);
20357
20358 let mut json_mime_type = mime::APPLICATION_JSON;
20359 let mut request_value_reader = {
20360 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20361 common::remove_json_null_values(&mut value);
20362 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20363 serde_json::to_writer(&mut dst, &value).unwrap();
20364 dst
20365 };
20366 let request_size = request_value_reader
20367 .seek(std::io::SeekFrom::End(0))
20368 .unwrap();
20369 request_value_reader
20370 .seek(std::io::SeekFrom::Start(0))
20371 .unwrap();
20372
20373 loop {
20374 let token = match self
20375 .hub
20376 .auth
20377 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20378 .await
20379 {
20380 Ok(token) => token,
20381 Err(e) => match dlg.token(e) {
20382 Ok(token) => token,
20383 Err(e) => {
20384 dlg.finished(false);
20385 return Err(common::Error::MissingToken(e));
20386 }
20387 },
20388 };
20389 request_value_reader
20390 .seek(std::io::SeekFrom::Start(0))
20391 .unwrap();
20392 let mut req_result = {
20393 let client = &self.hub.client;
20394 dlg.pre_request();
20395 let mut req_builder = hyper::Request::builder()
20396 .method(hyper::Method::PATCH)
20397 .uri(url.as_str())
20398 .header(USER_AGENT, self.hub._user_agent.clone());
20399
20400 if let Some(token) = token.as_ref() {
20401 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20402 }
20403
20404 let request = req_builder
20405 .header(CONTENT_TYPE, json_mime_type.to_string())
20406 .header(CONTENT_LENGTH, request_size as u64)
20407 .body(common::to_body(
20408 request_value_reader.get_ref().clone().into(),
20409 ));
20410
20411 client.request(request.unwrap()).await
20412 };
20413
20414 match req_result {
20415 Err(err) => {
20416 if let common::Retry::After(d) = dlg.http_error(&err) {
20417 sleep(d).await;
20418 continue;
20419 }
20420 dlg.finished(false);
20421 return Err(common::Error::HttpError(err));
20422 }
20423 Ok(res) => {
20424 let (mut parts, body) = res.into_parts();
20425 let mut body = common::Body::new(body);
20426 if !parts.status.is_success() {
20427 let bytes = common::to_bytes(body).await.unwrap_or_default();
20428 let error = serde_json::from_str(&common::to_string(&bytes));
20429 let response = common::to_response(parts, bytes.into());
20430
20431 if let common::Retry::After(d) =
20432 dlg.http_failure(&response, error.as_ref().ok())
20433 {
20434 sleep(d).await;
20435 continue;
20436 }
20437
20438 dlg.finished(false);
20439
20440 return Err(match error {
20441 Ok(value) => common::Error::BadRequest(value),
20442 _ => common::Error::Failure(response),
20443 });
20444 }
20445 let response = {
20446 let bytes = common::to_bytes(body).await.unwrap_or_default();
20447 let encoded = common::to_string(&bytes);
20448 match serde_json::from_str(&encoded) {
20449 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20450 Err(error) => {
20451 dlg.response_json_decode_error(&encoded, &error);
20452 return Err(common::Error::JsonDecodeError(
20453 encoded.to_string(),
20454 error,
20455 ));
20456 }
20457 }
20458 };
20459
20460 dlg.finished(true);
20461 return Ok(response);
20462 }
20463 }
20464 }
20465 }
20466
20467 ///
20468 /// Sets the *request* property to the given value.
20469 ///
20470 /// Even though the property as already been set when instantiating this call,
20471 /// we provide this method for API completeness.
20472 pub fn request(
20473 mut self,
20474 new_value: ProfileFilterLink,
20475 ) -> ManagementProfileFilterLinkPatchCall<'a, C> {
20476 self._request = new_value;
20477 self
20478 }
20479 /// Account ID to which profile filter link belongs.
20480 ///
20481 /// Sets the *account id* path property to the given value.
20482 ///
20483 /// Even though the property as already been set when instantiating this call,
20484 /// we provide this method for API completeness.
20485 pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkPatchCall<'a, C> {
20486 self._account_id = new_value.to_string();
20487 self
20488 }
20489 /// Web property Id to which profile filter link belongs
20490 ///
20491 /// Sets the *web property id* path property to the given value.
20492 ///
20493 /// Even though the property as already been set when instantiating this call,
20494 /// we provide this method for API completeness.
20495 pub fn web_property_id(
20496 mut self,
20497 new_value: &str,
20498 ) -> ManagementProfileFilterLinkPatchCall<'a, C> {
20499 self._web_property_id = new_value.to_string();
20500 self
20501 }
20502 /// Profile ID to which filter link belongs
20503 ///
20504 /// Sets the *profile id* path property to the given value.
20505 ///
20506 /// Even though the property as already been set when instantiating this call,
20507 /// we provide this method for API completeness.
20508 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkPatchCall<'a, C> {
20509 self._profile_id = new_value.to_string();
20510 self
20511 }
20512 /// ID of the profile filter link to be updated.
20513 ///
20514 /// Sets the *link id* path property to the given value.
20515 ///
20516 /// Even though the property as already been set when instantiating this call,
20517 /// we provide this method for API completeness.
20518 pub fn link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkPatchCall<'a, C> {
20519 self._link_id = new_value.to_string();
20520 self
20521 }
20522 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20523 /// while executing the actual API request.
20524 ///
20525 /// ````text
20526 /// It should be used to handle progress information, and to implement a certain level of resilience.
20527 /// ````
20528 ///
20529 /// Sets the *delegate* property to the given value.
20530 pub fn delegate(
20531 mut self,
20532 new_value: &'a mut dyn common::Delegate,
20533 ) -> ManagementProfileFilterLinkPatchCall<'a, C> {
20534 self._delegate = Some(new_value);
20535 self
20536 }
20537
20538 /// Set any additional parameter of the query string used in the request.
20539 /// It should be used to set parameters which are not yet available through their own
20540 /// setters.
20541 ///
20542 /// Please note that this method must not be used to set any of the known parameters
20543 /// which have their own setter method. If done anyway, the request will fail.
20544 ///
20545 /// # Additional Parameters
20546 ///
20547 /// * *alt* (query-string) - Data format for the response.
20548 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20549 /// * *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.
20550 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20551 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20552 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20553 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20554 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkPatchCall<'a, C>
20555 where
20556 T: AsRef<str>,
20557 {
20558 self._additional_params
20559 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20560 self
20561 }
20562
20563 /// Identifies the authorization scope for the method you are building.
20564 ///
20565 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20566 /// [`Scope::Edit`].
20567 ///
20568 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20569 /// tokens for more than one scope.
20570 ///
20571 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20572 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20573 /// sufficient, a read-write scope will do as well.
20574 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkPatchCall<'a, C>
20575 where
20576 St: AsRef<str>,
20577 {
20578 self._scopes.insert(String::from(scope.as_ref()));
20579 self
20580 }
20581 /// Identifies the authorization scope(s) for the method you are building.
20582 ///
20583 /// See [`Self::add_scope()`] for details.
20584 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkPatchCall<'a, C>
20585 where
20586 I: IntoIterator<Item = St>,
20587 St: AsRef<str>,
20588 {
20589 self._scopes
20590 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20591 self
20592 }
20593
20594 /// Removes all scopes, and no default scope will be used either.
20595 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20596 /// for details).
20597 pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkPatchCall<'a, C> {
20598 self._scopes.clear();
20599 self
20600 }
20601}
20602
20603/// Update an existing profile filter link.
20604///
20605/// A builder for the *profileFilterLinks.update* method supported by a *management* resource.
20606/// It is not used directly, but through a [`ManagementMethods`] instance.
20607///
20608/// # Example
20609///
20610/// Instantiate a resource method builder
20611///
20612/// ```test_harness,no_run
20613/// # extern crate hyper;
20614/// # extern crate hyper_rustls;
20615/// # extern crate google_analytics3 as analytics3;
20616/// use analytics3::api::ProfileFilterLink;
20617/// # async fn dox() {
20618/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20619///
20620/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20621/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20622/// # secret,
20623/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20624/// # ).build().await.unwrap();
20625///
20626/// # let client = hyper_util::client::legacy::Client::builder(
20627/// # hyper_util::rt::TokioExecutor::new()
20628/// # )
20629/// # .build(
20630/// # hyper_rustls::HttpsConnectorBuilder::new()
20631/// # .with_native_roots()
20632/// # .unwrap()
20633/// # .https_or_http()
20634/// # .enable_http1()
20635/// # .build()
20636/// # );
20637/// # let mut hub = Analytics::new(client, auth);
20638/// // As the method needs a request, you would usually fill it with the desired information
20639/// // into the respective structure. Some of the parts shown here might not be applicable !
20640/// // Values shown here are possibly random and not representative !
20641/// let mut req = ProfileFilterLink::default();
20642///
20643/// // You can configure optional parameters by calling the respective setters at will, and
20644/// // execute the final call using `doit()`.
20645/// // Values shown here are possibly random and not representative !
20646/// let result = hub.management().profile_filter_links_update(req, "accountId", "webPropertyId", "profileId", "linkId")
20647/// .doit().await;
20648/// # }
20649/// ```
20650pub struct ManagementProfileFilterLinkUpdateCall<'a, C>
20651where
20652 C: 'a,
20653{
20654 hub: &'a Analytics<C>,
20655 _request: ProfileFilterLink,
20656 _account_id: String,
20657 _web_property_id: String,
20658 _profile_id: String,
20659 _link_id: String,
20660 _delegate: Option<&'a mut dyn common::Delegate>,
20661 _additional_params: HashMap<String, String>,
20662 _scopes: BTreeSet<String>,
20663}
20664
20665impl<'a, C> common::CallBuilder for ManagementProfileFilterLinkUpdateCall<'a, C> {}
20666
20667impl<'a, C> ManagementProfileFilterLinkUpdateCall<'a, C>
20668where
20669 C: common::Connector,
20670{
20671 /// Perform the operation you have build so far.
20672 pub async fn doit(mut self) -> common::Result<(common::Response, ProfileFilterLink)> {
20673 use std::borrow::Cow;
20674 use std::io::{Read, Seek};
20675
20676 use common::{url::Params, ToParts};
20677 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20678
20679 let mut dd = common::DefaultDelegate;
20680 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20681 dlg.begin(common::MethodInfo {
20682 id: "analytics.management.profileFilterLinks.update",
20683 http_method: hyper::Method::PUT,
20684 });
20685
20686 for &field in ["alt", "accountId", "webPropertyId", "profileId", "linkId"].iter() {
20687 if self._additional_params.contains_key(field) {
20688 dlg.finished(false);
20689 return Err(common::Error::FieldClash(field));
20690 }
20691 }
20692
20693 let mut params = Params::with_capacity(7 + self._additional_params.len());
20694 params.push("accountId", self._account_id);
20695 params.push("webPropertyId", self._web_property_id);
20696 params.push("profileId", self._profile_id);
20697 params.push("linkId", self._link_id);
20698
20699 params.extend(self._additional_params.iter());
20700
20701 params.push("alt", "json");
20702 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}";
20703 if self._scopes.is_empty() {
20704 self._scopes.insert(Scope::Edit.as_ref().to_string());
20705 }
20706
20707 #[allow(clippy::single_element_loop)]
20708 for &(find_this, param_name) in [
20709 ("{accountId}", "accountId"),
20710 ("{webPropertyId}", "webPropertyId"),
20711 ("{profileId}", "profileId"),
20712 ("{linkId}", "linkId"),
20713 ]
20714 .iter()
20715 {
20716 url = params.uri_replacement(url, param_name, find_this, false);
20717 }
20718 {
20719 let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
20720 params.remove_params(&to_remove);
20721 }
20722
20723 let url = params.parse_with_url(&url);
20724
20725 let mut json_mime_type = mime::APPLICATION_JSON;
20726 let mut request_value_reader = {
20727 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20728 common::remove_json_null_values(&mut value);
20729 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20730 serde_json::to_writer(&mut dst, &value).unwrap();
20731 dst
20732 };
20733 let request_size = request_value_reader
20734 .seek(std::io::SeekFrom::End(0))
20735 .unwrap();
20736 request_value_reader
20737 .seek(std::io::SeekFrom::Start(0))
20738 .unwrap();
20739
20740 loop {
20741 let token = match self
20742 .hub
20743 .auth
20744 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20745 .await
20746 {
20747 Ok(token) => token,
20748 Err(e) => match dlg.token(e) {
20749 Ok(token) => token,
20750 Err(e) => {
20751 dlg.finished(false);
20752 return Err(common::Error::MissingToken(e));
20753 }
20754 },
20755 };
20756 request_value_reader
20757 .seek(std::io::SeekFrom::Start(0))
20758 .unwrap();
20759 let mut req_result = {
20760 let client = &self.hub.client;
20761 dlg.pre_request();
20762 let mut req_builder = hyper::Request::builder()
20763 .method(hyper::Method::PUT)
20764 .uri(url.as_str())
20765 .header(USER_AGENT, self.hub._user_agent.clone());
20766
20767 if let Some(token) = token.as_ref() {
20768 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20769 }
20770
20771 let request = req_builder
20772 .header(CONTENT_TYPE, json_mime_type.to_string())
20773 .header(CONTENT_LENGTH, request_size as u64)
20774 .body(common::to_body(
20775 request_value_reader.get_ref().clone().into(),
20776 ));
20777
20778 client.request(request.unwrap()).await
20779 };
20780
20781 match req_result {
20782 Err(err) => {
20783 if let common::Retry::After(d) = dlg.http_error(&err) {
20784 sleep(d).await;
20785 continue;
20786 }
20787 dlg.finished(false);
20788 return Err(common::Error::HttpError(err));
20789 }
20790 Ok(res) => {
20791 let (mut parts, body) = res.into_parts();
20792 let mut body = common::Body::new(body);
20793 if !parts.status.is_success() {
20794 let bytes = common::to_bytes(body).await.unwrap_or_default();
20795 let error = serde_json::from_str(&common::to_string(&bytes));
20796 let response = common::to_response(parts, bytes.into());
20797
20798 if let common::Retry::After(d) =
20799 dlg.http_failure(&response, error.as_ref().ok())
20800 {
20801 sleep(d).await;
20802 continue;
20803 }
20804
20805 dlg.finished(false);
20806
20807 return Err(match error {
20808 Ok(value) => common::Error::BadRequest(value),
20809 _ => common::Error::Failure(response),
20810 });
20811 }
20812 let response = {
20813 let bytes = common::to_bytes(body).await.unwrap_or_default();
20814 let encoded = common::to_string(&bytes);
20815 match serde_json::from_str(&encoded) {
20816 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20817 Err(error) => {
20818 dlg.response_json_decode_error(&encoded, &error);
20819 return Err(common::Error::JsonDecodeError(
20820 encoded.to_string(),
20821 error,
20822 ));
20823 }
20824 }
20825 };
20826
20827 dlg.finished(true);
20828 return Ok(response);
20829 }
20830 }
20831 }
20832 }
20833
20834 ///
20835 /// Sets the *request* property to the given value.
20836 ///
20837 /// Even though the property as already been set when instantiating this call,
20838 /// we provide this method for API completeness.
20839 pub fn request(
20840 mut self,
20841 new_value: ProfileFilterLink,
20842 ) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
20843 self._request = new_value;
20844 self
20845 }
20846 /// Account ID to which profile filter link belongs.
20847 ///
20848 /// Sets the *account id* path property to the given value.
20849 ///
20850 /// Even though the property as already been set when instantiating this call,
20851 /// we provide this method for API completeness.
20852 pub fn account_id(mut self, new_value: &str) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
20853 self._account_id = new_value.to_string();
20854 self
20855 }
20856 /// Web property Id to which profile filter link belongs
20857 ///
20858 /// Sets the *web property id* path property to the given value.
20859 ///
20860 /// Even though the property as already been set when instantiating this call,
20861 /// we provide this method for API completeness.
20862 pub fn web_property_id(
20863 mut self,
20864 new_value: &str,
20865 ) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
20866 self._web_property_id = new_value.to_string();
20867 self
20868 }
20869 /// Profile ID to which filter link belongs
20870 ///
20871 /// Sets the *profile id* path property to the given value.
20872 ///
20873 /// Even though the property as already been set when instantiating this call,
20874 /// we provide this method for API completeness.
20875 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
20876 self._profile_id = new_value.to_string();
20877 self
20878 }
20879 /// ID of the profile filter link to be updated.
20880 ///
20881 /// Sets the *link id* path property to the given value.
20882 ///
20883 /// Even though the property as already been set when instantiating this call,
20884 /// we provide this method for API completeness.
20885 pub fn link_id(mut self, new_value: &str) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
20886 self._link_id = new_value.to_string();
20887 self
20888 }
20889 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20890 /// while executing the actual API request.
20891 ///
20892 /// ````text
20893 /// It should be used to handle progress information, and to implement a certain level of resilience.
20894 /// ````
20895 ///
20896 /// Sets the *delegate* property to the given value.
20897 pub fn delegate(
20898 mut self,
20899 new_value: &'a mut dyn common::Delegate,
20900 ) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
20901 self._delegate = Some(new_value);
20902 self
20903 }
20904
20905 /// Set any additional parameter of the query string used in the request.
20906 /// It should be used to set parameters which are not yet available through their own
20907 /// setters.
20908 ///
20909 /// Please note that this method must not be used to set any of the known parameters
20910 /// which have their own setter method. If done anyway, the request will fail.
20911 ///
20912 /// # Additional Parameters
20913 ///
20914 /// * *alt* (query-string) - Data format for the response.
20915 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20916 /// * *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.
20917 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20918 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20919 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20920 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20921 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileFilterLinkUpdateCall<'a, C>
20922 where
20923 T: AsRef<str>,
20924 {
20925 self._additional_params
20926 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20927 self
20928 }
20929
20930 /// Identifies the authorization scope for the method you are building.
20931 ///
20932 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20933 /// [`Scope::Edit`].
20934 ///
20935 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20936 /// tokens for more than one scope.
20937 ///
20938 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20939 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20940 /// sufficient, a read-write scope will do as well.
20941 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileFilterLinkUpdateCall<'a, C>
20942 where
20943 St: AsRef<str>,
20944 {
20945 self._scopes.insert(String::from(scope.as_ref()));
20946 self
20947 }
20948 /// Identifies the authorization scope(s) for the method you are building.
20949 ///
20950 /// See [`Self::add_scope()`] for details.
20951 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileFilterLinkUpdateCall<'a, C>
20952 where
20953 I: IntoIterator<Item = St>,
20954 St: AsRef<str>,
20955 {
20956 self._scopes
20957 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20958 self
20959 }
20960
20961 /// Removes all scopes, and no default scope will be used either.
20962 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20963 /// for details).
20964 pub fn clear_scopes(mut self) -> ManagementProfileFilterLinkUpdateCall<'a, C> {
20965 self._scopes.clear();
20966 self
20967 }
20968}
20969
20970/// Removes a user from the given view (profile).
20971///
20972/// A builder for the *profileUserLinks.delete* method supported by a *management* resource.
20973/// It is not used directly, but through a [`ManagementMethods`] instance.
20974///
20975/// # Example
20976///
20977/// Instantiate a resource method builder
20978///
20979/// ```test_harness,no_run
20980/// # extern crate hyper;
20981/// # extern crate hyper_rustls;
20982/// # extern crate google_analytics3 as analytics3;
20983/// # async fn dox() {
20984/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20985///
20986/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20987/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20988/// # secret,
20989/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20990/// # ).build().await.unwrap();
20991///
20992/// # let client = hyper_util::client::legacy::Client::builder(
20993/// # hyper_util::rt::TokioExecutor::new()
20994/// # )
20995/// # .build(
20996/// # hyper_rustls::HttpsConnectorBuilder::new()
20997/// # .with_native_roots()
20998/// # .unwrap()
20999/// # .https_or_http()
21000/// # .enable_http1()
21001/// # .build()
21002/// # );
21003/// # let mut hub = Analytics::new(client, auth);
21004/// // You can configure optional parameters by calling the respective setters at will, and
21005/// // execute the final call using `doit()`.
21006/// // Values shown here are possibly random and not representative !
21007/// let result = hub.management().profile_user_links_delete("accountId", "webPropertyId", "profileId", "linkId")
21008/// .doit().await;
21009/// # }
21010/// ```
21011pub struct ManagementProfileUserLinkDeleteCall<'a, C>
21012where
21013 C: 'a,
21014{
21015 hub: &'a Analytics<C>,
21016 _account_id: String,
21017 _web_property_id: String,
21018 _profile_id: String,
21019 _link_id: String,
21020 _delegate: Option<&'a mut dyn common::Delegate>,
21021 _additional_params: HashMap<String, String>,
21022 _scopes: BTreeSet<String>,
21023}
21024
21025impl<'a, C> common::CallBuilder for ManagementProfileUserLinkDeleteCall<'a, C> {}
21026
21027impl<'a, C> ManagementProfileUserLinkDeleteCall<'a, C>
21028where
21029 C: common::Connector,
21030{
21031 /// Perform the operation you have build so far.
21032 pub async fn doit(mut self) -> common::Result<common::Response> {
21033 use std::borrow::Cow;
21034 use std::io::{Read, Seek};
21035
21036 use common::{url::Params, ToParts};
21037 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21038
21039 let mut dd = common::DefaultDelegate;
21040 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21041 dlg.begin(common::MethodInfo {
21042 id: "analytics.management.profileUserLinks.delete",
21043 http_method: hyper::Method::DELETE,
21044 });
21045
21046 for &field in ["accountId", "webPropertyId", "profileId", "linkId"].iter() {
21047 if self._additional_params.contains_key(field) {
21048 dlg.finished(false);
21049 return Err(common::Error::FieldClash(field));
21050 }
21051 }
21052
21053 let mut params = Params::with_capacity(5 + self._additional_params.len());
21054 params.push("accountId", self._account_id);
21055 params.push("webPropertyId", self._web_property_id);
21056 params.push("profileId", self._profile_id);
21057 params.push("linkId", self._link_id);
21058
21059 params.extend(self._additional_params.iter());
21060
21061 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks/{linkId}";
21062 if self._scopes.is_empty() {
21063 self._scopes.insert(Scope::ManageUser.as_ref().to_string());
21064 }
21065
21066 #[allow(clippy::single_element_loop)]
21067 for &(find_this, param_name) in [
21068 ("{accountId}", "accountId"),
21069 ("{webPropertyId}", "webPropertyId"),
21070 ("{profileId}", "profileId"),
21071 ("{linkId}", "linkId"),
21072 ]
21073 .iter()
21074 {
21075 url = params.uri_replacement(url, param_name, find_this, false);
21076 }
21077 {
21078 let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
21079 params.remove_params(&to_remove);
21080 }
21081
21082 let url = params.parse_with_url(&url);
21083
21084 loop {
21085 let token = match self
21086 .hub
21087 .auth
21088 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21089 .await
21090 {
21091 Ok(token) => token,
21092 Err(e) => match dlg.token(e) {
21093 Ok(token) => token,
21094 Err(e) => {
21095 dlg.finished(false);
21096 return Err(common::Error::MissingToken(e));
21097 }
21098 },
21099 };
21100 let mut req_result = {
21101 let client = &self.hub.client;
21102 dlg.pre_request();
21103 let mut req_builder = hyper::Request::builder()
21104 .method(hyper::Method::DELETE)
21105 .uri(url.as_str())
21106 .header(USER_AGENT, self.hub._user_agent.clone());
21107
21108 if let Some(token) = token.as_ref() {
21109 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21110 }
21111
21112 let request = req_builder
21113 .header(CONTENT_LENGTH, 0_u64)
21114 .body(common::to_body::<String>(None));
21115
21116 client.request(request.unwrap()).await
21117 };
21118
21119 match req_result {
21120 Err(err) => {
21121 if let common::Retry::After(d) = dlg.http_error(&err) {
21122 sleep(d).await;
21123 continue;
21124 }
21125 dlg.finished(false);
21126 return Err(common::Error::HttpError(err));
21127 }
21128 Ok(res) => {
21129 let (mut parts, body) = res.into_parts();
21130 let mut body = common::Body::new(body);
21131 if !parts.status.is_success() {
21132 let bytes = common::to_bytes(body).await.unwrap_or_default();
21133 let error = serde_json::from_str(&common::to_string(&bytes));
21134 let response = common::to_response(parts, bytes.into());
21135
21136 if let common::Retry::After(d) =
21137 dlg.http_failure(&response, error.as_ref().ok())
21138 {
21139 sleep(d).await;
21140 continue;
21141 }
21142
21143 dlg.finished(false);
21144
21145 return Err(match error {
21146 Ok(value) => common::Error::BadRequest(value),
21147 _ => common::Error::Failure(response),
21148 });
21149 }
21150 let response = common::Response::from_parts(parts, body);
21151
21152 dlg.finished(true);
21153 return Ok(response);
21154 }
21155 }
21156 }
21157 }
21158
21159 /// Account ID to delete the user link for.
21160 ///
21161 /// Sets the *account id* path property to the given value.
21162 ///
21163 /// Even though the property as already been set when instantiating this call,
21164 /// we provide this method for API completeness.
21165 pub fn account_id(mut self, new_value: &str) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21166 self._account_id = new_value.to_string();
21167 self
21168 }
21169 /// Web Property ID to delete the user link for.
21170 ///
21171 /// Sets the *web property id* path property to the given value.
21172 ///
21173 /// Even though the property as already been set when instantiating this call,
21174 /// we provide this method for API completeness.
21175 pub fn web_property_id(
21176 mut self,
21177 new_value: &str,
21178 ) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21179 self._web_property_id = new_value.to_string();
21180 self
21181 }
21182 /// View (Profile) ID to delete the user link for.
21183 ///
21184 /// Sets the *profile id* path property to the given value.
21185 ///
21186 /// Even though the property as already been set when instantiating this call,
21187 /// we provide this method for API completeness.
21188 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21189 self._profile_id = new_value.to_string();
21190 self
21191 }
21192 /// Link ID to delete the user link for.
21193 ///
21194 /// Sets the *link id* path property to the given value.
21195 ///
21196 /// Even though the property as already been set when instantiating this call,
21197 /// we provide this method for API completeness.
21198 pub fn link_id(mut self, new_value: &str) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21199 self._link_id = new_value.to_string();
21200 self
21201 }
21202 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21203 /// while executing the actual API request.
21204 ///
21205 /// ````text
21206 /// It should be used to handle progress information, and to implement a certain level of resilience.
21207 /// ````
21208 ///
21209 /// Sets the *delegate* property to the given value.
21210 pub fn delegate(
21211 mut self,
21212 new_value: &'a mut dyn common::Delegate,
21213 ) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21214 self._delegate = Some(new_value);
21215 self
21216 }
21217
21218 /// Set any additional parameter of the query string used in the request.
21219 /// It should be used to set parameters which are not yet available through their own
21220 /// setters.
21221 ///
21222 /// Please note that this method must not be used to set any of the known parameters
21223 /// which have their own setter method. If done anyway, the request will fail.
21224 ///
21225 /// # Additional Parameters
21226 ///
21227 /// * *alt* (query-string) - Data format for the response.
21228 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21229 /// * *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.
21230 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21231 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21232 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21233 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21234 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileUserLinkDeleteCall<'a, C>
21235 where
21236 T: AsRef<str>,
21237 {
21238 self._additional_params
21239 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21240 self
21241 }
21242
21243 /// Identifies the authorization scope for the method you are building.
21244 ///
21245 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21246 /// [`Scope::ManageUser`].
21247 ///
21248 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21249 /// tokens for more than one scope.
21250 ///
21251 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21252 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21253 /// sufficient, a read-write scope will do as well.
21254 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileUserLinkDeleteCall<'a, C>
21255 where
21256 St: AsRef<str>,
21257 {
21258 self._scopes.insert(String::from(scope.as_ref()));
21259 self
21260 }
21261 /// Identifies the authorization scope(s) for the method you are building.
21262 ///
21263 /// See [`Self::add_scope()`] for details.
21264 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileUserLinkDeleteCall<'a, C>
21265 where
21266 I: IntoIterator<Item = St>,
21267 St: AsRef<str>,
21268 {
21269 self._scopes
21270 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21271 self
21272 }
21273
21274 /// Removes all scopes, and no default scope will be used either.
21275 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21276 /// for details).
21277 pub fn clear_scopes(mut self) -> ManagementProfileUserLinkDeleteCall<'a, C> {
21278 self._scopes.clear();
21279 self
21280 }
21281}
21282
21283/// Adds a new user to the given view (profile).
21284///
21285/// A builder for the *profileUserLinks.insert* method supported by a *management* resource.
21286/// It is not used directly, but through a [`ManagementMethods`] instance.
21287///
21288/// # Example
21289///
21290/// Instantiate a resource method builder
21291///
21292/// ```test_harness,no_run
21293/// # extern crate hyper;
21294/// # extern crate hyper_rustls;
21295/// # extern crate google_analytics3 as analytics3;
21296/// use analytics3::api::EntityUserLink;
21297/// # async fn dox() {
21298/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21299///
21300/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21301/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21302/// # secret,
21303/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21304/// # ).build().await.unwrap();
21305///
21306/// # let client = hyper_util::client::legacy::Client::builder(
21307/// # hyper_util::rt::TokioExecutor::new()
21308/// # )
21309/// # .build(
21310/// # hyper_rustls::HttpsConnectorBuilder::new()
21311/// # .with_native_roots()
21312/// # .unwrap()
21313/// # .https_or_http()
21314/// # .enable_http1()
21315/// # .build()
21316/// # );
21317/// # let mut hub = Analytics::new(client, auth);
21318/// // As the method needs a request, you would usually fill it with the desired information
21319/// // into the respective structure. Some of the parts shown here might not be applicable !
21320/// // Values shown here are possibly random and not representative !
21321/// let mut req = EntityUserLink::default();
21322///
21323/// // You can configure optional parameters by calling the respective setters at will, and
21324/// // execute the final call using `doit()`.
21325/// // Values shown here are possibly random and not representative !
21326/// let result = hub.management().profile_user_links_insert(req, "accountId", "webPropertyId", "profileId")
21327/// .doit().await;
21328/// # }
21329/// ```
21330pub struct ManagementProfileUserLinkInsertCall<'a, C>
21331where
21332 C: 'a,
21333{
21334 hub: &'a Analytics<C>,
21335 _request: EntityUserLink,
21336 _account_id: String,
21337 _web_property_id: String,
21338 _profile_id: String,
21339 _delegate: Option<&'a mut dyn common::Delegate>,
21340 _additional_params: HashMap<String, String>,
21341 _scopes: BTreeSet<String>,
21342}
21343
21344impl<'a, C> common::CallBuilder for ManagementProfileUserLinkInsertCall<'a, C> {}
21345
21346impl<'a, C> ManagementProfileUserLinkInsertCall<'a, C>
21347where
21348 C: common::Connector,
21349{
21350 /// Perform the operation you have build so far.
21351 pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
21352 use std::borrow::Cow;
21353 use std::io::{Read, Seek};
21354
21355 use common::{url::Params, ToParts};
21356 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21357
21358 let mut dd = common::DefaultDelegate;
21359 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21360 dlg.begin(common::MethodInfo {
21361 id: "analytics.management.profileUserLinks.insert",
21362 http_method: hyper::Method::POST,
21363 });
21364
21365 for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
21366 if self._additional_params.contains_key(field) {
21367 dlg.finished(false);
21368 return Err(common::Error::FieldClash(field));
21369 }
21370 }
21371
21372 let mut params = Params::with_capacity(6 + self._additional_params.len());
21373 params.push("accountId", self._account_id);
21374 params.push("webPropertyId", self._web_property_id);
21375 params.push("profileId", self._profile_id);
21376
21377 params.extend(self._additional_params.iter());
21378
21379 params.push("alt", "json");
21380 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks";
21381 if self._scopes.is_empty() {
21382 self._scopes.insert(Scope::ManageUser.as_ref().to_string());
21383 }
21384
21385 #[allow(clippy::single_element_loop)]
21386 for &(find_this, param_name) in [
21387 ("{accountId}", "accountId"),
21388 ("{webPropertyId}", "webPropertyId"),
21389 ("{profileId}", "profileId"),
21390 ]
21391 .iter()
21392 {
21393 url = params.uri_replacement(url, param_name, find_this, false);
21394 }
21395 {
21396 let to_remove = ["profileId", "webPropertyId", "accountId"];
21397 params.remove_params(&to_remove);
21398 }
21399
21400 let url = params.parse_with_url(&url);
21401
21402 let mut json_mime_type = mime::APPLICATION_JSON;
21403 let mut request_value_reader = {
21404 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21405 common::remove_json_null_values(&mut value);
21406 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21407 serde_json::to_writer(&mut dst, &value).unwrap();
21408 dst
21409 };
21410 let request_size = request_value_reader
21411 .seek(std::io::SeekFrom::End(0))
21412 .unwrap();
21413 request_value_reader
21414 .seek(std::io::SeekFrom::Start(0))
21415 .unwrap();
21416
21417 loop {
21418 let token = match self
21419 .hub
21420 .auth
21421 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21422 .await
21423 {
21424 Ok(token) => token,
21425 Err(e) => match dlg.token(e) {
21426 Ok(token) => token,
21427 Err(e) => {
21428 dlg.finished(false);
21429 return Err(common::Error::MissingToken(e));
21430 }
21431 },
21432 };
21433 request_value_reader
21434 .seek(std::io::SeekFrom::Start(0))
21435 .unwrap();
21436 let mut req_result = {
21437 let client = &self.hub.client;
21438 dlg.pre_request();
21439 let mut req_builder = hyper::Request::builder()
21440 .method(hyper::Method::POST)
21441 .uri(url.as_str())
21442 .header(USER_AGENT, self.hub._user_agent.clone());
21443
21444 if let Some(token) = token.as_ref() {
21445 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21446 }
21447
21448 let request = req_builder
21449 .header(CONTENT_TYPE, json_mime_type.to_string())
21450 .header(CONTENT_LENGTH, request_size as u64)
21451 .body(common::to_body(
21452 request_value_reader.get_ref().clone().into(),
21453 ));
21454
21455 client.request(request.unwrap()).await
21456 };
21457
21458 match req_result {
21459 Err(err) => {
21460 if let common::Retry::After(d) = dlg.http_error(&err) {
21461 sleep(d).await;
21462 continue;
21463 }
21464 dlg.finished(false);
21465 return Err(common::Error::HttpError(err));
21466 }
21467 Ok(res) => {
21468 let (mut parts, body) = res.into_parts();
21469 let mut body = common::Body::new(body);
21470 if !parts.status.is_success() {
21471 let bytes = common::to_bytes(body).await.unwrap_or_default();
21472 let error = serde_json::from_str(&common::to_string(&bytes));
21473 let response = common::to_response(parts, bytes.into());
21474
21475 if let common::Retry::After(d) =
21476 dlg.http_failure(&response, error.as_ref().ok())
21477 {
21478 sleep(d).await;
21479 continue;
21480 }
21481
21482 dlg.finished(false);
21483
21484 return Err(match error {
21485 Ok(value) => common::Error::BadRequest(value),
21486 _ => common::Error::Failure(response),
21487 });
21488 }
21489 let response = {
21490 let bytes = common::to_bytes(body).await.unwrap_or_default();
21491 let encoded = common::to_string(&bytes);
21492 match serde_json::from_str(&encoded) {
21493 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21494 Err(error) => {
21495 dlg.response_json_decode_error(&encoded, &error);
21496 return Err(common::Error::JsonDecodeError(
21497 encoded.to_string(),
21498 error,
21499 ));
21500 }
21501 }
21502 };
21503
21504 dlg.finished(true);
21505 return Ok(response);
21506 }
21507 }
21508 }
21509 }
21510
21511 ///
21512 /// Sets the *request* property to the given value.
21513 ///
21514 /// Even though the property as already been set when instantiating this call,
21515 /// we provide this method for API completeness.
21516 pub fn request(
21517 mut self,
21518 new_value: EntityUserLink,
21519 ) -> ManagementProfileUserLinkInsertCall<'a, C> {
21520 self._request = new_value;
21521 self
21522 }
21523 /// Account ID to create the user link for.
21524 ///
21525 /// Sets the *account id* path property to the given value.
21526 ///
21527 /// Even though the property as already been set when instantiating this call,
21528 /// we provide this method for API completeness.
21529 pub fn account_id(mut self, new_value: &str) -> ManagementProfileUserLinkInsertCall<'a, C> {
21530 self._account_id = new_value.to_string();
21531 self
21532 }
21533 /// Web Property ID to create the user link for.
21534 ///
21535 /// Sets the *web property id* path property to the given value.
21536 ///
21537 /// Even though the property as already been set when instantiating this call,
21538 /// we provide this method for API completeness.
21539 pub fn web_property_id(
21540 mut self,
21541 new_value: &str,
21542 ) -> ManagementProfileUserLinkInsertCall<'a, C> {
21543 self._web_property_id = new_value.to_string();
21544 self
21545 }
21546 /// View (Profile) ID to create the user link for.
21547 ///
21548 /// Sets the *profile id* path property to the given value.
21549 ///
21550 /// Even though the property as already been set when instantiating this call,
21551 /// we provide this method for API completeness.
21552 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUserLinkInsertCall<'a, C> {
21553 self._profile_id = new_value.to_string();
21554 self
21555 }
21556 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21557 /// while executing the actual API request.
21558 ///
21559 /// ````text
21560 /// It should be used to handle progress information, and to implement a certain level of resilience.
21561 /// ````
21562 ///
21563 /// Sets the *delegate* property to the given value.
21564 pub fn delegate(
21565 mut self,
21566 new_value: &'a mut dyn common::Delegate,
21567 ) -> ManagementProfileUserLinkInsertCall<'a, C> {
21568 self._delegate = Some(new_value);
21569 self
21570 }
21571
21572 /// Set any additional parameter of the query string used in the request.
21573 /// It should be used to set parameters which are not yet available through their own
21574 /// setters.
21575 ///
21576 /// Please note that this method must not be used to set any of the known parameters
21577 /// which have their own setter method. If done anyway, the request will fail.
21578 ///
21579 /// # Additional Parameters
21580 ///
21581 /// * *alt* (query-string) - Data format for the response.
21582 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21583 /// * *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.
21584 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21585 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21586 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21587 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21588 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileUserLinkInsertCall<'a, C>
21589 where
21590 T: AsRef<str>,
21591 {
21592 self._additional_params
21593 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21594 self
21595 }
21596
21597 /// Identifies the authorization scope for the method you are building.
21598 ///
21599 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21600 /// [`Scope::ManageUser`].
21601 ///
21602 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21603 /// tokens for more than one scope.
21604 ///
21605 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21606 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21607 /// sufficient, a read-write scope will do as well.
21608 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileUserLinkInsertCall<'a, C>
21609 where
21610 St: AsRef<str>,
21611 {
21612 self._scopes.insert(String::from(scope.as_ref()));
21613 self
21614 }
21615 /// Identifies the authorization scope(s) for the method you are building.
21616 ///
21617 /// See [`Self::add_scope()`] for details.
21618 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileUserLinkInsertCall<'a, C>
21619 where
21620 I: IntoIterator<Item = St>,
21621 St: AsRef<str>,
21622 {
21623 self._scopes
21624 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21625 self
21626 }
21627
21628 /// Removes all scopes, and no default scope will be used either.
21629 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21630 /// for details).
21631 pub fn clear_scopes(mut self) -> ManagementProfileUserLinkInsertCall<'a, C> {
21632 self._scopes.clear();
21633 self
21634 }
21635}
21636
21637/// Lists profile-user links for a given view (profile).
21638///
21639/// A builder for the *profileUserLinks.list* method supported by a *management* resource.
21640/// It is not used directly, but through a [`ManagementMethods`] instance.
21641///
21642/// # Example
21643///
21644/// Instantiate a resource method builder
21645///
21646/// ```test_harness,no_run
21647/// # extern crate hyper;
21648/// # extern crate hyper_rustls;
21649/// # extern crate google_analytics3 as analytics3;
21650/// # async fn dox() {
21651/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21652///
21653/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21654/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21655/// # secret,
21656/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21657/// # ).build().await.unwrap();
21658///
21659/// # let client = hyper_util::client::legacy::Client::builder(
21660/// # hyper_util::rt::TokioExecutor::new()
21661/// # )
21662/// # .build(
21663/// # hyper_rustls::HttpsConnectorBuilder::new()
21664/// # .with_native_roots()
21665/// # .unwrap()
21666/// # .https_or_http()
21667/// # .enable_http1()
21668/// # .build()
21669/// # );
21670/// # let mut hub = Analytics::new(client, auth);
21671/// // You can configure optional parameters by calling the respective setters at will, and
21672/// // execute the final call using `doit()`.
21673/// // Values shown here are possibly random and not representative !
21674/// let result = hub.management().profile_user_links_list("accountId", "webPropertyId", "profileId")
21675/// .start_index(-77)
21676/// .max_results(-19)
21677/// .doit().await;
21678/// # }
21679/// ```
21680pub struct ManagementProfileUserLinkListCall<'a, C>
21681where
21682 C: 'a,
21683{
21684 hub: &'a Analytics<C>,
21685 _account_id: String,
21686 _web_property_id: String,
21687 _profile_id: String,
21688 _start_index: Option<i32>,
21689 _max_results: Option<i32>,
21690 _delegate: Option<&'a mut dyn common::Delegate>,
21691 _additional_params: HashMap<String, String>,
21692 _scopes: BTreeSet<String>,
21693}
21694
21695impl<'a, C> common::CallBuilder for ManagementProfileUserLinkListCall<'a, C> {}
21696
21697impl<'a, C> ManagementProfileUserLinkListCall<'a, C>
21698where
21699 C: common::Connector,
21700{
21701 /// Perform the operation you have build so far.
21702 pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLinks)> {
21703 use std::borrow::Cow;
21704 use std::io::{Read, Seek};
21705
21706 use common::{url::Params, ToParts};
21707 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21708
21709 let mut dd = common::DefaultDelegate;
21710 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21711 dlg.begin(common::MethodInfo {
21712 id: "analytics.management.profileUserLinks.list",
21713 http_method: hyper::Method::GET,
21714 });
21715
21716 for &field in [
21717 "alt",
21718 "accountId",
21719 "webPropertyId",
21720 "profileId",
21721 "start-index",
21722 "max-results",
21723 ]
21724 .iter()
21725 {
21726 if self._additional_params.contains_key(field) {
21727 dlg.finished(false);
21728 return Err(common::Error::FieldClash(field));
21729 }
21730 }
21731
21732 let mut params = Params::with_capacity(7 + self._additional_params.len());
21733 params.push("accountId", self._account_id);
21734 params.push("webPropertyId", self._web_property_id);
21735 params.push("profileId", self._profile_id);
21736 if let Some(value) = self._start_index.as_ref() {
21737 params.push("start-index", value.to_string());
21738 }
21739 if let Some(value) = self._max_results.as_ref() {
21740 params.push("max-results", value.to_string());
21741 }
21742
21743 params.extend(self._additional_params.iter());
21744
21745 params.push("alt", "json");
21746 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks";
21747 if self._scopes.is_empty() {
21748 self._scopes
21749 .insert(Scope::ManageUserReadonly.as_ref().to_string());
21750 }
21751
21752 #[allow(clippy::single_element_loop)]
21753 for &(find_this, param_name) in [
21754 ("{accountId}", "accountId"),
21755 ("{webPropertyId}", "webPropertyId"),
21756 ("{profileId}", "profileId"),
21757 ]
21758 .iter()
21759 {
21760 url = params.uri_replacement(url, param_name, find_this, false);
21761 }
21762 {
21763 let to_remove = ["profileId", "webPropertyId", "accountId"];
21764 params.remove_params(&to_remove);
21765 }
21766
21767 let url = params.parse_with_url(&url);
21768
21769 loop {
21770 let token = match self
21771 .hub
21772 .auth
21773 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21774 .await
21775 {
21776 Ok(token) => token,
21777 Err(e) => match dlg.token(e) {
21778 Ok(token) => token,
21779 Err(e) => {
21780 dlg.finished(false);
21781 return Err(common::Error::MissingToken(e));
21782 }
21783 },
21784 };
21785 let mut req_result = {
21786 let client = &self.hub.client;
21787 dlg.pre_request();
21788 let mut req_builder = hyper::Request::builder()
21789 .method(hyper::Method::GET)
21790 .uri(url.as_str())
21791 .header(USER_AGENT, self.hub._user_agent.clone());
21792
21793 if let Some(token) = token.as_ref() {
21794 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21795 }
21796
21797 let request = req_builder
21798 .header(CONTENT_LENGTH, 0_u64)
21799 .body(common::to_body::<String>(None));
21800
21801 client.request(request.unwrap()).await
21802 };
21803
21804 match req_result {
21805 Err(err) => {
21806 if let common::Retry::After(d) = dlg.http_error(&err) {
21807 sleep(d).await;
21808 continue;
21809 }
21810 dlg.finished(false);
21811 return Err(common::Error::HttpError(err));
21812 }
21813 Ok(res) => {
21814 let (mut parts, body) = res.into_parts();
21815 let mut body = common::Body::new(body);
21816 if !parts.status.is_success() {
21817 let bytes = common::to_bytes(body).await.unwrap_or_default();
21818 let error = serde_json::from_str(&common::to_string(&bytes));
21819 let response = common::to_response(parts, bytes.into());
21820
21821 if let common::Retry::After(d) =
21822 dlg.http_failure(&response, error.as_ref().ok())
21823 {
21824 sleep(d).await;
21825 continue;
21826 }
21827
21828 dlg.finished(false);
21829
21830 return Err(match error {
21831 Ok(value) => common::Error::BadRequest(value),
21832 _ => common::Error::Failure(response),
21833 });
21834 }
21835 let response = {
21836 let bytes = common::to_bytes(body).await.unwrap_or_default();
21837 let encoded = common::to_string(&bytes);
21838 match serde_json::from_str(&encoded) {
21839 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21840 Err(error) => {
21841 dlg.response_json_decode_error(&encoded, &error);
21842 return Err(common::Error::JsonDecodeError(
21843 encoded.to_string(),
21844 error,
21845 ));
21846 }
21847 }
21848 };
21849
21850 dlg.finished(true);
21851 return Ok(response);
21852 }
21853 }
21854 }
21855 }
21856
21857 /// Account ID which the given view (profile) belongs to.
21858 ///
21859 /// Sets the *account id* path property to the given value.
21860 ///
21861 /// Even though the property as already been set when instantiating this call,
21862 /// we provide this method for API completeness.
21863 pub fn account_id(mut self, new_value: &str) -> ManagementProfileUserLinkListCall<'a, C> {
21864 self._account_id = new_value.to_string();
21865 self
21866 }
21867 /// 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.
21868 ///
21869 /// Sets the *web property id* path property to the given value.
21870 ///
21871 /// Even though the property as already been set when instantiating this call,
21872 /// we provide this method for API completeness.
21873 pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileUserLinkListCall<'a, C> {
21874 self._web_property_id = new_value.to_string();
21875 self
21876 }
21877 /// 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.
21878 ///
21879 /// Sets the *profile id* path property to the given value.
21880 ///
21881 /// Even though the property as already been set when instantiating this call,
21882 /// we provide this method for API completeness.
21883 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUserLinkListCall<'a, C> {
21884 self._profile_id = new_value.to_string();
21885 self
21886 }
21887 /// An index of the first profile-user link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
21888 ///
21889 /// Sets the *start-index* query property to the given value.
21890 pub fn start_index(mut self, new_value: i32) -> ManagementProfileUserLinkListCall<'a, C> {
21891 self._start_index = Some(new_value);
21892 self
21893 }
21894 /// The maximum number of profile-user links to include in this response.
21895 ///
21896 /// Sets the *max-results* query property to the given value.
21897 pub fn max_results(mut self, new_value: i32) -> ManagementProfileUserLinkListCall<'a, C> {
21898 self._max_results = Some(new_value);
21899 self
21900 }
21901 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21902 /// while executing the actual API request.
21903 ///
21904 /// ````text
21905 /// It should be used to handle progress information, and to implement a certain level of resilience.
21906 /// ````
21907 ///
21908 /// Sets the *delegate* property to the given value.
21909 pub fn delegate(
21910 mut self,
21911 new_value: &'a mut dyn common::Delegate,
21912 ) -> ManagementProfileUserLinkListCall<'a, C> {
21913 self._delegate = Some(new_value);
21914 self
21915 }
21916
21917 /// Set any additional parameter of the query string used in the request.
21918 /// It should be used to set parameters which are not yet available through their own
21919 /// setters.
21920 ///
21921 /// Please note that this method must not be used to set any of the known parameters
21922 /// which have their own setter method. If done anyway, the request will fail.
21923 ///
21924 /// # Additional Parameters
21925 ///
21926 /// * *alt* (query-string) - Data format for the response.
21927 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21928 /// * *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.
21929 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21930 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21931 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21932 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21933 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileUserLinkListCall<'a, C>
21934 where
21935 T: AsRef<str>,
21936 {
21937 self._additional_params
21938 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21939 self
21940 }
21941
21942 /// Identifies the authorization scope for the method you are building.
21943 ///
21944 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21945 /// [`Scope::ManageUserReadonly`].
21946 ///
21947 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21948 /// tokens for more than one scope.
21949 ///
21950 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21951 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21952 /// sufficient, a read-write scope will do as well.
21953 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileUserLinkListCall<'a, C>
21954 where
21955 St: AsRef<str>,
21956 {
21957 self._scopes.insert(String::from(scope.as_ref()));
21958 self
21959 }
21960 /// Identifies the authorization scope(s) for the method you are building.
21961 ///
21962 /// See [`Self::add_scope()`] for details.
21963 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileUserLinkListCall<'a, C>
21964 where
21965 I: IntoIterator<Item = St>,
21966 St: AsRef<str>,
21967 {
21968 self._scopes
21969 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21970 self
21971 }
21972
21973 /// Removes all scopes, and no default scope will be used either.
21974 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21975 /// for details).
21976 pub fn clear_scopes(mut self) -> ManagementProfileUserLinkListCall<'a, C> {
21977 self._scopes.clear();
21978 self
21979 }
21980}
21981
21982/// Updates permissions for an existing user on the given view (profile).
21983///
21984/// A builder for the *profileUserLinks.update* method supported by a *management* resource.
21985/// It is not used directly, but through a [`ManagementMethods`] instance.
21986///
21987/// # Example
21988///
21989/// Instantiate a resource method builder
21990///
21991/// ```test_harness,no_run
21992/// # extern crate hyper;
21993/// # extern crate hyper_rustls;
21994/// # extern crate google_analytics3 as analytics3;
21995/// use analytics3::api::EntityUserLink;
21996/// # async fn dox() {
21997/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21998///
21999/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22000/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22001/// # secret,
22002/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22003/// # ).build().await.unwrap();
22004///
22005/// # let client = hyper_util::client::legacy::Client::builder(
22006/// # hyper_util::rt::TokioExecutor::new()
22007/// # )
22008/// # .build(
22009/// # hyper_rustls::HttpsConnectorBuilder::new()
22010/// # .with_native_roots()
22011/// # .unwrap()
22012/// # .https_or_http()
22013/// # .enable_http1()
22014/// # .build()
22015/// # );
22016/// # let mut hub = Analytics::new(client, auth);
22017/// // As the method needs a request, you would usually fill it with the desired information
22018/// // into the respective structure. Some of the parts shown here might not be applicable !
22019/// // Values shown here are possibly random and not representative !
22020/// let mut req = EntityUserLink::default();
22021///
22022/// // You can configure optional parameters by calling the respective setters at will, and
22023/// // execute the final call using `doit()`.
22024/// // Values shown here are possibly random and not representative !
22025/// let result = hub.management().profile_user_links_update(req, "accountId", "webPropertyId", "profileId", "linkId")
22026/// .doit().await;
22027/// # }
22028/// ```
22029pub struct ManagementProfileUserLinkUpdateCall<'a, C>
22030where
22031 C: 'a,
22032{
22033 hub: &'a Analytics<C>,
22034 _request: EntityUserLink,
22035 _account_id: String,
22036 _web_property_id: String,
22037 _profile_id: String,
22038 _link_id: String,
22039 _delegate: Option<&'a mut dyn common::Delegate>,
22040 _additional_params: HashMap<String, String>,
22041 _scopes: BTreeSet<String>,
22042}
22043
22044impl<'a, C> common::CallBuilder for ManagementProfileUserLinkUpdateCall<'a, C> {}
22045
22046impl<'a, C> ManagementProfileUserLinkUpdateCall<'a, C>
22047where
22048 C: common::Connector,
22049{
22050 /// Perform the operation you have build so far.
22051 pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
22052 use std::borrow::Cow;
22053 use std::io::{Read, Seek};
22054
22055 use common::{url::Params, ToParts};
22056 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22057
22058 let mut dd = common::DefaultDelegate;
22059 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22060 dlg.begin(common::MethodInfo {
22061 id: "analytics.management.profileUserLinks.update",
22062 http_method: hyper::Method::PUT,
22063 });
22064
22065 for &field in ["alt", "accountId", "webPropertyId", "profileId", "linkId"].iter() {
22066 if self._additional_params.contains_key(field) {
22067 dlg.finished(false);
22068 return Err(common::Error::FieldClash(field));
22069 }
22070 }
22071
22072 let mut params = Params::with_capacity(7 + self._additional_params.len());
22073 params.push("accountId", self._account_id);
22074 params.push("webPropertyId", self._web_property_id);
22075 params.push("profileId", self._profile_id);
22076 params.push("linkId", self._link_id);
22077
22078 params.extend(self._additional_params.iter());
22079
22080 params.push("alt", "json");
22081 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks/{linkId}";
22082 if self._scopes.is_empty() {
22083 self._scopes.insert(Scope::ManageUser.as_ref().to_string());
22084 }
22085
22086 #[allow(clippy::single_element_loop)]
22087 for &(find_this, param_name) in [
22088 ("{accountId}", "accountId"),
22089 ("{webPropertyId}", "webPropertyId"),
22090 ("{profileId}", "profileId"),
22091 ("{linkId}", "linkId"),
22092 ]
22093 .iter()
22094 {
22095 url = params.uri_replacement(url, param_name, find_this, false);
22096 }
22097 {
22098 let to_remove = ["linkId", "profileId", "webPropertyId", "accountId"];
22099 params.remove_params(&to_remove);
22100 }
22101
22102 let url = params.parse_with_url(&url);
22103
22104 let mut json_mime_type = mime::APPLICATION_JSON;
22105 let mut request_value_reader = {
22106 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22107 common::remove_json_null_values(&mut value);
22108 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22109 serde_json::to_writer(&mut dst, &value).unwrap();
22110 dst
22111 };
22112 let request_size = request_value_reader
22113 .seek(std::io::SeekFrom::End(0))
22114 .unwrap();
22115 request_value_reader
22116 .seek(std::io::SeekFrom::Start(0))
22117 .unwrap();
22118
22119 loop {
22120 let token = match self
22121 .hub
22122 .auth
22123 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22124 .await
22125 {
22126 Ok(token) => token,
22127 Err(e) => match dlg.token(e) {
22128 Ok(token) => token,
22129 Err(e) => {
22130 dlg.finished(false);
22131 return Err(common::Error::MissingToken(e));
22132 }
22133 },
22134 };
22135 request_value_reader
22136 .seek(std::io::SeekFrom::Start(0))
22137 .unwrap();
22138 let mut req_result = {
22139 let client = &self.hub.client;
22140 dlg.pre_request();
22141 let mut req_builder = hyper::Request::builder()
22142 .method(hyper::Method::PUT)
22143 .uri(url.as_str())
22144 .header(USER_AGENT, self.hub._user_agent.clone());
22145
22146 if let Some(token) = token.as_ref() {
22147 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22148 }
22149
22150 let request = req_builder
22151 .header(CONTENT_TYPE, json_mime_type.to_string())
22152 .header(CONTENT_LENGTH, request_size as u64)
22153 .body(common::to_body(
22154 request_value_reader.get_ref().clone().into(),
22155 ));
22156
22157 client.request(request.unwrap()).await
22158 };
22159
22160 match req_result {
22161 Err(err) => {
22162 if let common::Retry::After(d) = dlg.http_error(&err) {
22163 sleep(d).await;
22164 continue;
22165 }
22166 dlg.finished(false);
22167 return Err(common::Error::HttpError(err));
22168 }
22169 Ok(res) => {
22170 let (mut parts, body) = res.into_parts();
22171 let mut body = common::Body::new(body);
22172 if !parts.status.is_success() {
22173 let bytes = common::to_bytes(body).await.unwrap_or_default();
22174 let error = serde_json::from_str(&common::to_string(&bytes));
22175 let response = common::to_response(parts, bytes.into());
22176
22177 if let common::Retry::After(d) =
22178 dlg.http_failure(&response, error.as_ref().ok())
22179 {
22180 sleep(d).await;
22181 continue;
22182 }
22183
22184 dlg.finished(false);
22185
22186 return Err(match error {
22187 Ok(value) => common::Error::BadRequest(value),
22188 _ => common::Error::Failure(response),
22189 });
22190 }
22191 let response = {
22192 let bytes = common::to_bytes(body).await.unwrap_or_default();
22193 let encoded = common::to_string(&bytes);
22194 match serde_json::from_str(&encoded) {
22195 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22196 Err(error) => {
22197 dlg.response_json_decode_error(&encoded, &error);
22198 return Err(common::Error::JsonDecodeError(
22199 encoded.to_string(),
22200 error,
22201 ));
22202 }
22203 }
22204 };
22205
22206 dlg.finished(true);
22207 return Ok(response);
22208 }
22209 }
22210 }
22211 }
22212
22213 ///
22214 /// Sets the *request* property to the given value.
22215 ///
22216 /// Even though the property as already been set when instantiating this call,
22217 /// we provide this method for API completeness.
22218 pub fn request(
22219 mut self,
22220 new_value: EntityUserLink,
22221 ) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22222 self._request = new_value;
22223 self
22224 }
22225 /// Account ID to update the user link for.
22226 ///
22227 /// Sets the *account id* path property to the given value.
22228 ///
22229 /// Even though the property as already been set when instantiating this call,
22230 /// we provide this method for API completeness.
22231 pub fn account_id(mut self, new_value: &str) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22232 self._account_id = new_value.to_string();
22233 self
22234 }
22235 /// Web Property ID to update the user link for.
22236 ///
22237 /// Sets the *web property id* path property to the given value.
22238 ///
22239 /// Even though the property as already been set when instantiating this call,
22240 /// we provide this method for API completeness.
22241 pub fn web_property_id(
22242 mut self,
22243 new_value: &str,
22244 ) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22245 self._web_property_id = new_value.to_string();
22246 self
22247 }
22248 /// View (Profile ID) to update the user link for.
22249 ///
22250 /// Sets the *profile id* path property to the given value.
22251 ///
22252 /// Even though the property as already been set when instantiating this call,
22253 /// we provide this method for API completeness.
22254 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22255 self._profile_id = new_value.to_string();
22256 self
22257 }
22258 /// Link ID to update the user link for.
22259 ///
22260 /// Sets the *link id* path property to the given value.
22261 ///
22262 /// Even though the property as already been set when instantiating this call,
22263 /// we provide this method for API completeness.
22264 pub fn link_id(mut self, new_value: &str) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22265 self._link_id = new_value.to_string();
22266 self
22267 }
22268 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22269 /// while executing the actual API request.
22270 ///
22271 /// ````text
22272 /// It should be used to handle progress information, and to implement a certain level of resilience.
22273 /// ````
22274 ///
22275 /// Sets the *delegate* property to the given value.
22276 pub fn delegate(
22277 mut self,
22278 new_value: &'a mut dyn common::Delegate,
22279 ) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22280 self._delegate = Some(new_value);
22281 self
22282 }
22283
22284 /// Set any additional parameter of the query string used in the request.
22285 /// It should be used to set parameters which are not yet available through their own
22286 /// setters.
22287 ///
22288 /// Please note that this method must not be used to set any of the known parameters
22289 /// which have their own setter method. If done anyway, the request will fail.
22290 ///
22291 /// # Additional Parameters
22292 ///
22293 /// * *alt* (query-string) - Data format for the response.
22294 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22295 /// * *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.
22296 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22297 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22298 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22299 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22300 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileUserLinkUpdateCall<'a, C>
22301 where
22302 T: AsRef<str>,
22303 {
22304 self._additional_params
22305 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22306 self
22307 }
22308
22309 /// Identifies the authorization scope for the method you are building.
22310 ///
22311 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22312 /// [`Scope::ManageUser`].
22313 ///
22314 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22315 /// tokens for more than one scope.
22316 ///
22317 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22318 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22319 /// sufficient, a read-write scope will do as well.
22320 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileUserLinkUpdateCall<'a, C>
22321 where
22322 St: AsRef<str>,
22323 {
22324 self._scopes.insert(String::from(scope.as_ref()));
22325 self
22326 }
22327 /// Identifies the authorization scope(s) for the method you are building.
22328 ///
22329 /// See [`Self::add_scope()`] for details.
22330 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileUserLinkUpdateCall<'a, C>
22331 where
22332 I: IntoIterator<Item = St>,
22333 St: AsRef<str>,
22334 {
22335 self._scopes
22336 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22337 self
22338 }
22339
22340 /// Removes all scopes, and no default scope will be used either.
22341 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22342 /// for details).
22343 pub fn clear_scopes(mut self) -> ManagementProfileUserLinkUpdateCall<'a, C> {
22344 self._scopes.clear();
22345 self
22346 }
22347}
22348
22349/// Deletes a view (profile).
22350///
22351/// A builder for the *profiles.delete* method supported by a *management* resource.
22352/// It is not used directly, but through a [`ManagementMethods`] instance.
22353///
22354/// # Example
22355///
22356/// Instantiate a resource method builder
22357///
22358/// ```test_harness,no_run
22359/// # extern crate hyper;
22360/// # extern crate hyper_rustls;
22361/// # extern crate google_analytics3 as analytics3;
22362/// # async fn dox() {
22363/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22364///
22365/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22366/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22367/// # secret,
22368/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22369/// # ).build().await.unwrap();
22370///
22371/// # let client = hyper_util::client::legacy::Client::builder(
22372/// # hyper_util::rt::TokioExecutor::new()
22373/// # )
22374/// # .build(
22375/// # hyper_rustls::HttpsConnectorBuilder::new()
22376/// # .with_native_roots()
22377/// # .unwrap()
22378/// # .https_or_http()
22379/// # .enable_http1()
22380/// # .build()
22381/// # );
22382/// # let mut hub = Analytics::new(client, auth);
22383/// // You can configure optional parameters by calling the respective setters at will, and
22384/// // execute the final call using `doit()`.
22385/// // Values shown here are possibly random and not representative !
22386/// let result = hub.management().profiles_delete("accountId", "webPropertyId", "profileId")
22387/// .doit().await;
22388/// # }
22389/// ```
22390pub struct ManagementProfileDeleteCall<'a, C>
22391where
22392 C: 'a,
22393{
22394 hub: &'a Analytics<C>,
22395 _account_id: String,
22396 _web_property_id: String,
22397 _profile_id: String,
22398 _delegate: Option<&'a mut dyn common::Delegate>,
22399 _additional_params: HashMap<String, String>,
22400 _scopes: BTreeSet<String>,
22401}
22402
22403impl<'a, C> common::CallBuilder for ManagementProfileDeleteCall<'a, C> {}
22404
22405impl<'a, C> ManagementProfileDeleteCall<'a, C>
22406where
22407 C: common::Connector,
22408{
22409 /// Perform the operation you have build so far.
22410 pub async fn doit(mut self) -> common::Result<common::Response> {
22411 use std::borrow::Cow;
22412 use std::io::{Read, Seek};
22413
22414 use common::{url::Params, ToParts};
22415 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22416
22417 let mut dd = common::DefaultDelegate;
22418 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22419 dlg.begin(common::MethodInfo {
22420 id: "analytics.management.profiles.delete",
22421 http_method: hyper::Method::DELETE,
22422 });
22423
22424 for &field in ["accountId", "webPropertyId", "profileId"].iter() {
22425 if self._additional_params.contains_key(field) {
22426 dlg.finished(false);
22427 return Err(common::Error::FieldClash(field));
22428 }
22429 }
22430
22431 let mut params = Params::with_capacity(4 + self._additional_params.len());
22432 params.push("accountId", self._account_id);
22433 params.push("webPropertyId", self._web_property_id);
22434 params.push("profileId", self._profile_id);
22435
22436 params.extend(self._additional_params.iter());
22437
22438 let mut url = self.hub._base_url.clone()
22439 + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}";
22440 if self._scopes.is_empty() {
22441 self._scopes.insert(Scope::Edit.as_ref().to_string());
22442 }
22443
22444 #[allow(clippy::single_element_loop)]
22445 for &(find_this, param_name) in [
22446 ("{accountId}", "accountId"),
22447 ("{webPropertyId}", "webPropertyId"),
22448 ("{profileId}", "profileId"),
22449 ]
22450 .iter()
22451 {
22452 url = params.uri_replacement(url, param_name, find_this, false);
22453 }
22454 {
22455 let to_remove = ["profileId", "webPropertyId", "accountId"];
22456 params.remove_params(&to_remove);
22457 }
22458
22459 let url = params.parse_with_url(&url);
22460
22461 loop {
22462 let token = match self
22463 .hub
22464 .auth
22465 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22466 .await
22467 {
22468 Ok(token) => token,
22469 Err(e) => match dlg.token(e) {
22470 Ok(token) => token,
22471 Err(e) => {
22472 dlg.finished(false);
22473 return Err(common::Error::MissingToken(e));
22474 }
22475 },
22476 };
22477 let mut req_result = {
22478 let client = &self.hub.client;
22479 dlg.pre_request();
22480 let mut req_builder = hyper::Request::builder()
22481 .method(hyper::Method::DELETE)
22482 .uri(url.as_str())
22483 .header(USER_AGENT, self.hub._user_agent.clone());
22484
22485 if let Some(token) = token.as_ref() {
22486 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22487 }
22488
22489 let request = req_builder
22490 .header(CONTENT_LENGTH, 0_u64)
22491 .body(common::to_body::<String>(None));
22492
22493 client.request(request.unwrap()).await
22494 };
22495
22496 match req_result {
22497 Err(err) => {
22498 if let common::Retry::After(d) = dlg.http_error(&err) {
22499 sleep(d).await;
22500 continue;
22501 }
22502 dlg.finished(false);
22503 return Err(common::Error::HttpError(err));
22504 }
22505 Ok(res) => {
22506 let (mut parts, body) = res.into_parts();
22507 let mut body = common::Body::new(body);
22508 if !parts.status.is_success() {
22509 let bytes = common::to_bytes(body).await.unwrap_or_default();
22510 let error = serde_json::from_str(&common::to_string(&bytes));
22511 let response = common::to_response(parts, bytes.into());
22512
22513 if let common::Retry::After(d) =
22514 dlg.http_failure(&response, error.as_ref().ok())
22515 {
22516 sleep(d).await;
22517 continue;
22518 }
22519
22520 dlg.finished(false);
22521
22522 return Err(match error {
22523 Ok(value) => common::Error::BadRequest(value),
22524 _ => common::Error::Failure(response),
22525 });
22526 }
22527 let response = common::Response::from_parts(parts, body);
22528
22529 dlg.finished(true);
22530 return Ok(response);
22531 }
22532 }
22533 }
22534 }
22535
22536 /// Account ID to delete the view (profile) for.
22537 ///
22538 /// Sets the *account id* path property to the given value.
22539 ///
22540 /// Even though the property as already been set when instantiating this call,
22541 /// we provide this method for API completeness.
22542 pub fn account_id(mut self, new_value: &str) -> ManagementProfileDeleteCall<'a, C> {
22543 self._account_id = new_value.to_string();
22544 self
22545 }
22546 /// Web property ID to delete the view (profile) for.
22547 ///
22548 /// Sets the *web property id* path property to the given value.
22549 ///
22550 /// Even though the property as already been set when instantiating this call,
22551 /// we provide this method for API completeness.
22552 pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileDeleteCall<'a, C> {
22553 self._web_property_id = new_value.to_string();
22554 self
22555 }
22556 /// ID of the view (profile) to be deleted.
22557 ///
22558 /// Sets the *profile id* path property to the given value.
22559 ///
22560 /// Even though the property as already been set when instantiating this call,
22561 /// we provide this method for API completeness.
22562 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileDeleteCall<'a, C> {
22563 self._profile_id = new_value.to_string();
22564 self
22565 }
22566 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22567 /// while executing the actual API request.
22568 ///
22569 /// ````text
22570 /// It should be used to handle progress information, and to implement a certain level of resilience.
22571 /// ````
22572 ///
22573 /// Sets the *delegate* property to the given value.
22574 pub fn delegate(
22575 mut self,
22576 new_value: &'a mut dyn common::Delegate,
22577 ) -> ManagementProfileDeleteCall<'a, C> {
22578 self._delegate = Some(new_value);
22579 self
22580 }
22581
22582 /// Set any additional parameter of the query string used in the request.
22583 /// It should be used to set parameters which are not yet available through their own
22584 /// setters.
22585 ///
22586 /// Please note that this method must not be used to set any of the known parameters
22587 /// which have their own setter method. If done anyway, the request will fail.
22588 ///
22589 /// # Additional Parameters
22590 ///
22591 /// * *alt* (query-string) - Data format for the response.
22592 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22593 /// * *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.
22594 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22595 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22596 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22597 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22598 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileDeleteCall<'a, C>
22599 where
22600 T: AsRef<str>,
22601 {
22602 self._additional_params
22603 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22604 self
22605 }
22606
22607 /// Identifies the authorization scope for the method you are building.
22608 ///
22609 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22610 /// [`Scope::Edit`].
22611 ///
22612 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22613 /// tokens for more than one scope.
22614 ///
22615 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22616 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22617 /// sufficient, a read-write scope will do as well.
22618 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileDeleteCall<'a, C>
22619 where
22620 St: AsRef<str>,
22621 {
22622 self._scopes.insert(String::from(scope.as_ref()));
22623 self
22624 }
22625 /// Identifies the authorization scope(s) for the method you are building.
22626 ///
22627 /// See [`Self::add_scope()`] for details.
22628 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileDeleteCall<'a, C>
22629 where
22630 I: IntoIterator<Item = St>,
22631 St: AsRef<str>,
22632 {
22633 self._scopes
22634 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22635 self
22636 }
22637
22638 /// Removes all scopes, and no default scope will be used either.
22639 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22640 /// for details).
22641 pub fn clear_scopes(mut self) -> ManagementProfileDeleteCall<'a, C> {
22642 self._scopes.clear();
22643 self
22644 }
22645}
22646
22647/// Gets a view (profile) to which the user has access.
22648///
22649/// A builder for the *profiles.get* method supported by a *management* resource.
22650/// It is not used directly, but through a [`ManagementMethods`] instance.
22651///
22652/// # Example
22653///
22654/// Instantiate a resource method builder
22655///
22656/// ```test_harness,no_run
22657/// # extern crate hyper;
22658/// # extern crate hyper_rustls;
22659/// # extern crate google_analytics3 as analytics3;
22660/// # async fn dox() {
22661/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22662///
22663/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22664/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22665/// # secret,
22666/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22667/// # ).build().await.unwrap();
22668///
22669/// # let client = hyper_util::client::legacy::Client::builder(
22670/// # hyper_util::rt::TokioExecutor::new()
22671/// # )
22672/// # .build(
22673/// # hyper_rustls::HttpsConnectorBuilder::new()
22674/// # .with_native_roots()
22675/// # .unwrap()
22676/// # .https_or_http()
22677/// # .enable_http1()
22678/// # .build()
22679/// # );
22680/// # let mut hub = Analytics::new(client, auth);
22681/// // You can configure optional parameters by calling the respective setters at will, and
22682/// // execute the final call using `doit()`.
22683/// // Values shown here are possibly random and not representative !
22684/// let result = hub.management().profiles_get("accountId", "webPropertyId", "profileId")
22685/// .doit().await;
22686/// # }
22687/// ```
22688pub struct ManagementProfileGetCall<'a, C>
22689where
22690 C: 'a,
22691{
22692 hub: &'a Analytics<C>,
22693 _account_id: String,
22694 _web_property_id: String,
22695 _profile_id: String,
22696 _delegate: Option<&'a mut dyn common::Delegate>,
22697 _additional_params: HashMap<String, String>,
22698 _scopes: BTreeSet<String>,
22699}
22700
22701impl<'a, C> common::CallBuilder for ManagementProfileGetCall<'a, C> {}
22702
22703impl<'a, C> ManagementProfileGetCall<'a, C>
22704where
22705 C: common::Connector,
22706{
22707 /// Perform the operation you have build so far.
22708 pub async fn doit(mut self) -> common::Result<(common::Response, Profile)> {
22709 use std::borrow::Cow;
22710 use std::io::{Read, Seek};
22711
22712 use common::{url::Params, ToParts};
22713 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22714
22715 let mut dd = common::DefaultDelegate;
22716 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22717 dlg.begin(common::MethodInfo {
22718 id: "analytics.management.profiles.get",
22719 http_method: hyper::Method::GET,
22720 });
22721
22722 for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
22723 if self._additional_params.contains_key(field) {
22724 dlg.finished(false);
22725 return Err(common::Error::FieldClash(field));
22726 }
22727 }
22728
22729 let mut params = Params::with_capacity(5 + self._additional_params.len());
22730 params.push("accountId", self._account_id);
22731 params.push("webPropertyId", self._web_property_id);
22732 params.push("profileId", self._profile_id);
22733
22734 params.extend(self._additional_params.iter());
22735
22736 params.push("alt", "json");
22737 let mut url = self.hub._base_url.clone()
22738 + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}";
22739 if self._scopes.is_empty() {
22740 self._scopes.insert(Scope::Readonly.as_ref().to_string());
22741 }
22742
22743 #[allow(clippy::single_element_loop)]
22744 for &(find_this, param_name) in [
22745 ("{accountId}", "accountId"),
22746 ("{webPropertyId}", "webPropertyId"),
22747 ("{profileId}", "profileId"),
22748 ]
22749 .iter()
22750 {
22751 url = params.uri_replacement(url, param_name, find_this, false);
22752 }
22753 {
22754 let to_remove = ["profileId", "webPropertyId", "accountId"];
22755 params.remove_params(&to_remove);
22756 }
22757
22758 let url = params.parse_with_url(&url);
22759
22760 loop {
22761 let token = match self
22762 .hub
22763 .auth
22764 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22765 .await
22766 {
22767 Ok(token) => token,
22768 Err(e) => match dlg.token(e) {
22769 Ok(token) => token,
22770 Err(e) => {
22771 dlg.finished(false);
22772 return Err(common::Error::MissingToken(e));
22773 }
22774 },
22775 };
22776 let mut req_result = {
22777 let client = &self.hub.client;
22778 dlg.pre_request();
22779 let mut req_builder = hyper::Request::builder()
22780 .method(hyper::Method::GET)
22781 .uri(url.as_str())
22782 .header(USER_AGENT, self.hub._user_agent.clone());
22783
22784 if let Some(token) = token.as_ref() {
22785 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22786 }
22787
22788 let request = req_builder
22789 .header(CONTENT_LENGTH, 0_u64)
22790 .body(common::to_body::<String>(None));
22791
22792 client.request(request.unwrap()).await
22793 };
22794
22795 match req_result {
22796 Err(err) => {
22797 if let common::Retry::After(d) = dlg.http_error(&err) {
22798 sleep(d).await;
22799 continue;
22800 }
22801 dlg.finished(false);
22802 return Err(common::Error::HttpError(err));
22803 }
22804 Ok(res) => {
22805 let (mut parts, body) = res.into_parts();
22806 let mut body = common::Body::new(body);
22807 if !parts.status.is_success() {
22808 let bytes = common::to_bytes(body).await.unwrap_or_default();
22809 let error = serde_json::from_str(&common::to_string(&bytes));
22810 let response = common::to_response(parts, bytes.into());
22811
22812 if let common::Retry::After(d) =
22813 dlg.http_failure(&response, error.as_ref().ok())
22814 {
22815 sleep(d).await;
22816 continue;
22817 }
22818
22819 dlg.finished(false);
22820
22821 return Err(match error {
22822 Ok(value) => common::Error::BadRequest(value),
22823 _ => common::Error::Failure(response),
22824 });
22825 }
22826 let response = {
22827 let bytes = common::to_bytes(body).await.unwrap_or_default();
22828 let encoded = common::to_string(&bytes);
22829 match serde_json::from_str(&encoded) {
22830 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22831 Err(error) => {
22832 dlg.response_json_decode_error(&encoded, &error);
22833 return Err(common::Error::JsonDecodeError(
22834 encoded.to_string(),
22835 error,
22836 ));
22837 }
22838 }
22839 };
22840
22841 dlg.finished(true);
22842 return Ok(response);
22843 }
22844 }
22845 }
22846 }
22847
22848 /// Account ID to retrieve the view (profile) for.
22849 ///
22850 /// Sets the *account id* path property to the given value.
22851 ///
22852 /// Even though the property as already been set when instantiating this call,
22853 /// we provide this method for API completeness.
22854 pub fn account_id(mut self, new_value: &str) -> ManagementProfileGetCall<'a, C> {
22855 self._account_id = new_value.to_string();
22856 self
22857 }
22858 /// Web property ID to retrieve the view (profile) for.
22859 ///
22860 /// Sets the *web property id* path property to the given value.
22861 ///
22862 /// Even though the property as already been set when instantiating this call,
22863 /// we provide this method for API completeness.
22864 pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileGetCall<'a, C> {
22865 self._web_property_id = new_value.to_string();
22866 self
22867 }
22868 /// View (Profile) ID to retrieve the view (profile) for.
22869 ///
22870 /// Sets the *profile id* path property to the given value.
22871 ///
22872 /// Even though the property as already been set when instantiating this call,
22873 /// we provide this method for API completeness.
22874 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileGetCall<'a, C> {
22875 self._profile_id = new_value.to_string();
22876 self
22877 }
22878 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22879 /// while executing the actual API request.
22880 ///
22881 /// ````text
22882 /// It should be used to handle progress information, and to implement a certain level of resilience.
22883 /// ````
22884 ///
22885 /// Sets the *delegate* property to the given value.
22886 pub fn delegate(
22887 mut self,
22888 new_value: &'a mut dyn common::Delegate,
22889 ) -> ManagementProfileGetCall<'a, C> {
22890 self._delegate = Some(new_value);
22891 self
22892 }
22893
22894 /// Set any additional parameter of the query string used in the request.
22895 /// It should be used to set parameters which are not yet available through their own
22896 /// setters.
22897 ///
22898 /// Please note that this method must not be used to set any of the known parameters
22899 /// which have their own setter method. If done anyway, the request will fail.
22900 ///
22901 /// # Additional Parameters
22902 ///
22903 /// * *alt* (query-string) - Data format for the response.
22904 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22905 /// * *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.
22906 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22907 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22908 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22909 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22910 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileGetCall<'a, C>
22911 where
22912 T: AsRef<str>,
22913 {
22914 self._additional_params
22915 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22916 self
22917 }
22918
22919 /// Identifies the authorization scope for the method you are building.
22920 ///
22921 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22922 /// [`Scope::Readonly`].
22923 ///
22924 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22925 /// tokens for more than one scope.
22926 ///
22927 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22928 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22929 /// sufficient, a read-write scope will do as well.
22930 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileGetCall<'a, C>
22931 where
22932 St: AsRef<str>,
22933 {
22934 self._scopes.insert(String::from(scope.as_ref()));
22935 self
22936 }
22937 /// Identifies the authorization scope(s) for the method you are building.
22938 ///
22939 /// See [`Self::add_scope()`] for details.
22940 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileGetCall<'a, C>
22941 where
22942 I: IntoIterator<Item = St>,
22943 St: AsRef<str>,
22944 {
22945 self._scopes
22946 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22947 self
22948 }
22949
22950 /// Removes all scopes, and no default scope will be used either.
22951 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22952 /// for details).
22953 pub fn clear_scopes(mut self) -> ManagementProfileGetCall<'a, C> {
22954 self._scopes.clear();
22955 self
22956 }
22957}
22958
22959/// Create a new view (profile).
22960///
22961/// A builder for the *profiles.insert* method supported by a *management* resource.
22962/// It is not used directly, but through a [`ManagementMethods`] instance.
22963///
22964/// # Example
22965///
22966/// Instantiate a resource method builder
22967///
22968/// ```test_harness,no_run
22969/// # extern crate hyper;
22970/// # extern crate hyper_rustls;
22971/// # extern crate google_analytics3 as analytics3;
22972/// use analytics3::api::Profile;
22973/// # async fn dox() {
22974/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22975///
22976/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22977/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22978/// # secret,
22979/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22980/// # ).build().await.unwrap();
22981///
22982/// # let client = hyper_util::client::legacy::Client::builder(
22983/// # hyper_util::rt::TokioExecutor::new()
22984/// # )
22985/// # .build(
22986/// # hyper_rustls::HttpsConnectorBuilder::new()
22987/// # .with_native_roots()
22988/// # .unwrap()
22989/// # .https_or_http()
22990/// # .enable_http1()
22991/// # .build()
22992/// # );
22993/// # let mut hub = Analytics::new(client, auth);
22994/// // As the method needs a request, you would usually fill it with the desired information
22995/// // into the respective structure. Some of the parts shown here might not be applicable !
22996/// // Values shown here are possibly random and not representative !
22997/// let mut req = Profile::default();
22998///
22999/// // You can configure optional parameters by calling the respective setters at will, and
23000/// // execute the final call using `doit()`.
23001/// // Values shown here are possibly random and not representative !
23002/// let result = hub.management().profiles_insert(req, "accountId", "webPropertyId")
23003/// .doit().await;
23004/// # }
23005/// ```
23006pub struct ManagementProfileInsertCall<'a, C>
23007where
23008 C: 'a,
23009{
23010 hub: &'a Analytics<C>,
23011 _request: Profile,
23012 _account_id: String,
23013 _web_property_id: String,
23014 _delegate: Option<&'a mut dyn common::Delegate>,
23015 _additional_params: HashMap<String, String>,
23016 _scopes: BTreeSet<String>,
23017}
23018
23019impl<'a, C> common::CallBuilder for ManagementProfileInsertCall<'a, C> {}
23020
23021impl<'a, C> ManagementProfileInsertCall<'a, C>
23022where
23023 C: common::Connector,
23024{
23025 /// Perform the operation you have build so far.
23026 pub async fn doit(mut self) -> common::Result<(common::Response, Profile)> {
23027 use std::borrow::Cow;
23028 use std::io::{Read, Seek};
23029
23030 use common::{url::Params, ToParts};
23031 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23032
23033 let mut dd = common::DefaultDelegate;
23034 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23035 dlg.begin(common::MethodInfo {
23036 id: "analytics.management.profiles.insert",
23037 http_method: hyper::Method::POST,
23038 });
23039
23040 for &field in ["alt", "accountId", "webPropertyId"].iter() {
23041 if self._additional_params.contains_key(field) {
23042 dlg.finished(false);
23043 return Err(common::Error::FieldClash(field));
23044 }
23045 }
23046
23047 let mut params = Params::with_capacity(5 + self._additional_params.len());
23048 params.push("accountId", self._account_id);
23049 params.push("webPropertyId", self._web_property_id);
23050
23051 params.extend(self._additional_params.iter());
23052
23053 params.push("alt", "json");
23054 let mut url = self.hub._base_url.clone()
23055 + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles";
23056 if self._scopes.is_empty() {
23057 self._scopes.insert(Scope::Edit.as_ref().to_string());
23058 }
23059
23060 #[allow(clippy::single_element_loop)]
23061 for &(find_this, param_name) in [
23062 ("{accountId}", "accountId"),
23063 ("{webPropertyId}", "webPropertyId"),
23064 ]
23065 .iter()
23066 {
23067 url = params.uri_replacement(url, param_name, find_this, false);
23068 }
23069 {
23070 let to_remove = ["webPropertyId", "accountId"];
23071 params.remove_params(&to_remove);
23072 }
23073
23074 let url = params.parse_with_url(&url);
23075
23076 let mut json_mime_type = mime::APPLICATION_JSON;
23077 let mut request_value_reader = {
23078 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23079 common::remove_json_null_values(&mut value);
23080 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23081 serde_json::to_writer(&mut dst, &value).unwrap();
23082 dst
23083 };
23084 let request_size = request_value_reader
23085 .seek(std::io::SeekFrom::End(0))
23086 .unwrap();
23087 request_value_reader
23088 .seek(std::io::SeekFrom::Start(0))
23089 .unwrap();
23090
23091 loop {
23092 let token = match self
23093 .hub
23094 .auth
23095 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23096 .await
23097 {
23098 Ok(token) => token,
23099 Err(e) => match dlg.token(e) {
23100 Ok(token) => token,
23101 Err(e) => {
23102 dlg.finished(false);
23103 return Err(common::Error::MissingToken(e));
23104 }
23105 },
23106 };
23107 request_value_reader
23108 .seek(std::io::SeekFrom::Start(0))
23109 .unwrap();
23110 let mut req_result = {
23111 let client = &self.hub.client;
23112 dlg.pre_request();
23113 let mut req_builder = hyper::Request::builder()
23114 .method(hyper::Method::POST)
23115 .uri(url.as_str())
23116 .header(USER_AGENT, self.hub._user_agent.clone());
23117
23118 if let Some(token) = token.as_ref() {
23119 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23120 }
23121
23122 let request = req_builder
23123 .header(CONTENT_TYPE, json_mime_type.to_string())
23124 .header(CONTENT_LENGTH, request_size as u64)
23125 .body(common::to_body(
23126 request_value_reader.get_ref().clone().into(),
23127 ));
23128
23129 client.request(request.unwrap()).await
23130 };
23131
23132 match req_result {
23133 Err(err) => {
23134 if let common::Retry::After(d) = dlg.http_error(&err) {
23135 sleep(d).await;
23136 continue;
23137 }
23138 dlg.finished(false);
23139 return Err(common::Error::HttpError(err));
23140 }
23141 Ok(res) => {
23142 let (mut parts, body) = res.into_parts();
23143 let mut body = common::Body::new(body);
23144 if !parts.status.is_success() {
23145 let bytes = common::to_bytes(body).await.unwrap_or_default();
23146 let error = serde_json::from_str(&common::to_string(&bytes));
23147 let response = common::to_response(parts, bytes.into());
23148
23149 if let common::Retry::After(d) =
23150 dlg.http_failure(&response, error.as_ref().ok())
23151 {
23152 sleep(d).await;
23153 continue;
23154 }
23155
23156 dlg.finished(false);
23157
23158 return Err(match error {
23159 Ok(value) => common::Error::BadRequest(value),
23160 _ => common::Error::Failure(response),
23161 });
23162 }
23163 let response = {
23164 let bytes = common::to_bytes(body).await.unwrap_or_default();
23165 let encoded = common::to_string(&bytes);
23166 match serde_json::from_str(&encoded) {
23167 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23168 Err(error) => {
23169 dlg.response_json_decode_error(&encoded, &error);
23170 return Err(common::Error::JsonDecodeError(
23171 encoded.to_string(),
23172 error,
23173 ));
23174 }
23175 }
23176 };
23177
23178 dlg.finished(true);
23179 return Ok(response);
23180 }
23181 }
23182 }
23183 }
23184
23185 ///
23186 /// Sets the *request* property to the given value.
23187 ///
23188 /// Even though the property as already been set when instantiating this call,
23189 /// we provide this method for API completeness.
23190 pub fn request(mut self, new_value: Profile) -> ManagementProfileInsertCall<'a, C> {
23191 self._request = new_value;
23192 self
23193 }
23194 /// Account ID to create the view (profile) for.
23195 ///
23196 /// Sets the *account id* path property to the given value.
23197 ///
23198 /// Even though the property as already been set when instantiating this call,
23199 /// we provide this method for API completeness.
23200 pub fn account_id(mut self, new_value: &str) -> ManagementProfileInsertCall<'a, C> {
23201 self._account_id = new_value.to_string();
23202 self
23203 }
23204 /// Web property ID to create the view (profile) for.
23205 ///
23206 /// Sets the *web property id* path property to the given value.
23207 ///
23208 /// Even though the property as already been set when instantiating this call,
23209 /// we provide this method for API completeness.
23210 pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileInsertCall<'a, C> {
23211 self._web_property_id = new_value.to_string();
23212 self
23213 }
23214 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23215 /// while executing the actual API request.
23216 ///
23217 /// ````text
23218 /// It should be used to handle progress information, and to implement a certain level of resilience.
23219 /// ````
23220 ///
23221 /// Sets the *delegate* property to the given value.
23222 pub fn delegate(
23223 mut self,
23224 new_value: &'a mut dyn common::Delegate,
23225 ) -> ManagementProfileInsertCall<'a, C> {
23226 self._delegate = Some(new_value);
23227 self
23228 }
23229
23230 /// Set any additional parameter of the query string used in the request.
23231 /// It should be used to set parameters which are not yet available through their own
23232 /// setters.
23233 ///
23234 /// Please note that this method must not be used to set any of the known parameters
23235 /// which have their own setter method. If done anyway, the request will fail.
23236 ///
23237 /// # Additional Parameters
23238 ///
23239 /// * *alt* (query-string) - Data format for the response.
23240 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23241 /// * *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.
23242 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23243 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23244 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23245 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23246 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileInsertCall<'a, C>
23247 where
23248 T: AsRef<str>,
23249 {
23250 self._additional_params
23251 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23252 self
23253 }
23254
23255 /// Identifies the authorization scope for the method you are building.
23256 ///
23257 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23258 /// [`Scope::Edit`].
23259 ///
23260 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23261 /// tokens for more than one scope.
23262 ///
23263 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23264 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23265 /// sufficient, a read-write scope will do as well.
23266 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileInsertCall<'a, C>
23267 where
23268 St: AsRef<str>,
23269 {
23270 self._scopes.insert(String::from(scope.as_ref()));
23271 self
23272 }
23273 /// Identifies the authorization scope(s) for the method you are building.
23274 ///
23275 /// See [`Self::add_scope()`] for details.
23276 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileInsertCall<'a, C>
23277 where
23278 I: IntoIterator<Item = St>,
23279 St: AsRef<str>,
23280 {
23281 self._scopes
23282 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23283 self
23284 }
23285
23286 /// Removes all scopes, and no default scope will be used either.
23287 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23288 /// for details).
23289 pub fn clear_scopes(mut self) -> ManagementProfileInsertCall<'a, C> {
23290 self._scopes.clear();
23291 self
23292 }
23293}
23294
23295/// Lists views (profiles) to which the user has access.
23296///
23297/// A builder for the *profiles.list* method supported by a *management* resource.
23298/// It is not used directly, but through a [`ManagementMethods`] instance.
23299///
23300/// # Example
23301///
23302/// Instantiate a resource method builder
23303///
23304/// ```test_harness,no_run
23305/// # extern crate hyper;
23306/// # extern crate hyper_rustls;
23307/// # extern crate google_analytics3 as analytics3;
23308/// # async fn dox() {
23309/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23310///
23311/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23312/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23313/// # secret,
23314/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23315/// # ).build().await.unwrap();
23316///
23317/// # let client = hyper_util::client::legacy::Client::builder(
23318/// # hyper_util::rt::TokioExecutor::new()
23319/// # )
23320/// # .build(
23321/// # hyper_rustls::HttpsConnectorBuilder::new()
23322/// # .with_native_roots()
23323/// # .unwrap()
23324/// # .https_or_http()
23325/// # .enable_http1()
23326/// # .build()
23327/// # );
23328/// # let mut hub = Analytics::new(client, auth);
23329/// // You can configure optional parameters by calling the respective setters at will, and
23330/// // execute the final call using `doit()`.
23331/// // Values shown here are possibly random and not representative !
23332/// let result = hub.management().profiles_list("accountId", "webPropertyId")
23333/// .start_index(-53)
23334/// .max_results(-83)
23335/// .doit().await;
23336/// # }
23337/// ```
23338pub struct ManagementProfileListCall<'a, C>
23339where
23340 C: 'a,
23341{
23342 hub: &'a Analytics<C>,
23343 _account_id: String,
23344 _web_property_id: String,
23345 _start_index: Option<i32>,
23346 _max_results: Option<i32>,
23347 _delegate: Option<&'a mut dyn common::Delegate>,
23348 _additional_params: HashMap<String, String>,
23349 _scopes: BTreeSet<String>,
23350}
23351
23352impl<'a, C> common::CallBuilder for ManagementProfileListCall<'a, C> {}
23353
23354impl<'a, C> ManagementProfileListCall<'a, C>
23355where
23356 C: common::Connector,
23357{
23358 /// Perform the operation you have build so far.
23359 pub async fn doit(mut self) -> common::Result<(common::Response, Profiles)> {
23360 use std::borrow::Cow;
23361 use std::io::{Read, Seek};
23362
23363 use common::{url::Params, ToParts};
23364 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23365
23366 let mut dd = common::DefaultDelegate;
23367 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23368 dlg.begin(common::MethodInfo {
23369 id: "analytics.management.profiles.list",
23370 http_method: hyper::Method::GET,
23371 });
23372
23373 for &field in [
23374 "alt",
23375 "accountId",
23376 "webPropertyId",
23377 "start-index",
23378 "max-results",
23379 ]
23380 .iter()
23381 {
23382 if self._additional_params.contains_key(field) {
23383 dlg.finished(false);
23384 return Err(common::Error::FieldClash(field));
23385 }
23386 }
23387
23388 let mut params = Params::with_capacity(6 + self._additional_params.len());
23389 params.push("accountId", self._account_id);
23390 params.push("webPropertyId", self._web_property_id);
23391 if let Some(value) = self._start_index.as_ref() {
23392 params.push("start-index", value.to_string());
23393 }
23394 if let Some(value) = self._max_results.as_ref() {
23395 params.push("max-results", value.to_string());
23396 }
23397
23398 params.extend(self._additional_params.iter());
23399
23400 params.push("alt", "json");
23401 let mut url = self.hub._base_url.clone()
23402 + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles";
23403 if self._scopes.is_empty() {
23404 self._scopes.insert(Scope::Readonly.as_ref().to_string());
23405 }
23406
23407 #[allow(clippy::single_element_loop)]
23408 for &(find_this, param_name) in [
23409 ("{accountId}", "accountId"),
23410 ("{webPropertyId}", "webPropertyId"),
23411 ]
23412 .iter()
23413 {
23414 url = params.uri_replacement(url, param_name, find_this, false);
23415 }
23416 {
23417 let to_remove = ["webPropertyId", "accountId"];
23418 params.remove_params(&to_remove);
23419 }
23420
23421 let url = params.parse_with_url(&url);
23422
23423 loop {
23424 let token = match self
23425 .hub
23426 .auth
23427 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23428 .await
23429 {
23430 Ok(token) => token,
23431 Err(e) => match dlg.token(e) {
23432 Ok(token) => token,
23433 Err(e) => {
23434 dlg.finished(false);
23435 return Err(common::Error::MissingToken(e));
23436 }
23437 },
23438 };
23439 let mut req_result = {
23440 let client = &self.hub.client;
23441 dlg.pre_request();
23442 let mut req_builder = hyper::Request::builder()
23443 .method(hyper::Method::GET)
23444 .uri(url.as_str())
23445 .header(USER_AGENT, self.hub._user_agent.clone());
23446
23447 if let Some(token) = token.as_ref() {
23448 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23449 }
23450
23451 let request = req_builder
23452 .header(CONTENT_LENGTH, 0_u64)
23453 .body(common::to_body::<String>(None));
23454
23455 client.request(request.unwrap()).await
23456 };
23457
23458 match req_result {
23459 Err(err) => {
23460 if let common::Retry::After(d) = dlg.http_error(&err) {
23461 sleep(d).await;
23462 continue;
23463 }
23464 dlg.finished(false);
23465 return Err(common::Error::HttpError(err));
23466 }
23467 Ok(res) => {
23468 let (mut parts, body) = res.into_parts();
23469 let mut body = common::Body::new(body);
23470 if !parts.status.is_success() {
23471 let bytes = common::to_bytes(body).await.unwrap_or_default();
23472 let error = serde_json::from_str(&common::to_string(&bytes));
23473 let response = common::to_response(parts, bytes.into());
23474
23475 if let common::Retry::After(d) =
23476 dlg.http_failure(&response, error.as_ref().ok())
23477 {
23478 sleep(d).await;
23479 continue;
23480 }
23481
23482 dlg.finished(false);
23483
23484 return Err(match error {
23485 Ok(value) => common::Error::BadRequest(value),
23486 _ => common::Error::Failure(response),
23487 });
23488 }
23489 let response = {
23490 let bytes = common::to_bytes(body).await.unwrap_or_default();
23491 let encoded = common::to_string(&bytes);
23492 match serde_json::from_str(&encoded) {
23493 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23494 Err(error) => {
23495 dlg.response_json_decode_error(&encoded, &error);
23496 return Err(common::Error::JsonDecodeError(
23497 encoded.to_string(),
23498 error,
23499 ));
23500 }
23501 }
23502 };
23503
23504 dlg.finished(true);
23505 return Ok(response);
23506 }
23507 }
23508 }
23509 }
23510
23511 /// 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.
23512 ///
23513 /// Sets the *account id* path property to the given value.
23514 ///
23515 /// Even though the property as already been set when instantiating this call,
23516 /// we provide this method for API completeness.
23517 pub fn account_id(mut self, new_value: &str) -> ManagementProfileListCall<'a, C> {
23518 self._account_id = new_value.to_string();
23519 self
23520 }
23521 /// 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.
23522 ///
23523 /// Sets the *web property id* path property to the given value.
23524 ///
23525 /// Even though the property as already been set when instantiating this call,
23526 /// we provide this method for API completeness.
23527 pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileListCall<'a, C> {
23528 self._web_property_id = new_value.to_string();
23529 self
23530 }
23531 /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
23532 ///
23533 /// Sets the *start-index* query property to the given value.
23534 pub fn start_index(mut self, new_value: i32) -> ManagementProfileListCall<'a, C> {
23535 self._start_index = Some(new_value);
23536 self
23537 }
23538 /// The maximum number of views (profiles) to include in this response.
23539 ///
23540 /// Sets the *max-results* query property to the given value.
23541 pub fn max_results(mut self, new_value: i32) -> ManagementProfileListCall<'a, C> {
23542 self._max_results = Some(new_value);
23543 self
23544 }
23545 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23546 /// while executing the actual API request.
23547 ///
23548 /// ````text
23549 /// It should be used to handle progress information, and to implement a certain level of resilience.
23550 /// ````
23551 ///
23552 /// Sets the *delegate* property to the given value.
23553 pub fn delegate(
23554 mut self,
23555 new_value: &'a mut dyn common::Delegate,
23556 ) -> ManagementProfileListCall<'a, C> {
23557 self._delegate = Some(new_value);
23558 self
23559 }
23560
23561 /// Set any additional parameter of the query string used in the request.
23562 /// It should be used to set parameters which are not yet available through their own
23563 /// setters.
23564 ///
23565 /// Please note that this method must not be used to set any of the known parameters
23566 /// which have their own setter method. If done anyway, the request will fail.
23567 ///
23568 /// # Additional Parameters
23569 ///
23570 /// * *alt* (query-string) - Data format for the response.
23571 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23572 /// * *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.
23573 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23574 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23575 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23576 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23577 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileListCall<'a, C>
23578 where
23579 T: AsRef<str>,
23580 {
23581 self._additional_params
23582 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23583 self
23584 }
23585
23586 /// Identifies the authorization scope for the method you are building.
23587 ///
23588 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23589 /// [`Scope::Readonly`].
23590 ///
23591 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23592 /// tokens for more than one scope.
23593 ///
23594 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23595 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23596 /// sufficient, a read-write scope will do as well.
23597 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileListCall<'a, C>
23598 where
23599 St: AsRef<str>,
23600 {
23601 self._scopes.insert(String::from(scope.as_ref()));
23602 self
23603 }
23604 /// Identifies the authorization scope(s) for the method you are building.
23605 ///
23606 /// See [`Self::add_scope()`] for details.
23607 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileListCall<'a, C>
23608 where
23609 I: IntoIterator<Item = St>,
23610 St: AsRef<str>,
23611 {
23612 self._scopes
23613 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23614 self
23615 }
23616
23617 /// Removes all scopes, and no default scope will be used either.
23618 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23619 /// for details).
23620 pub fn clear_scopes(mut self) -> ManagementProfileListCall<'a, C> {
23621 self._scopes.clear();
23622 self
23623 }
23624}
23625
23626/// Updates an existing view (profile). This method supports patch semantics.
23627///
23628/// A builder for the *profiles.patch* method supported by a *management* resource.
23629/// It is not used directly, but through a [`ManagementMethods`] instance.
23630///
23631/// # Example
23632///
23633/// Instantiate a resource method builder
23634///
23635/// ```test_harness,no_run
23636/// # extern crate hyper;
23637/// # extern crate hyper_rustls;
23638/// # extern crate google_analytics3 as analytics3;
23639/// use analytics3::api::Profile;
23640/// # async fn dox() {
23641/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23642///
23643/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23644/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23645/// # secret,
23646/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23647/// # ).build().await.unwrap();
23648///
23649/// # let client = hyper_util::client::legacy::Client::builder(
23650/// # hyper_util::rt::TokioExecutor::new()
23651/// # )
23652/// # .build(
23653/// # hyper_rustls::HttpsConnectorBuilder::new()
23654/// # .with_native_roots()
23655/// # .unwrap()
23656/// # .https_or_http()
23657/// # .enable_http1()
23658/// # .build()
23659/// # );
23660/// # let mut hub = Analytics::new(client, auth);
23661/// // As the method needs a request, you would usually fill it with the desired information
23662/// // into the respective structure. Some of the parts shown here might not be applicable !
23663/// // Values shown here are possibly random and not representative !
23664/// let mut req = Profile::default();
23665///
23666/// // You can configure optional parameters by calling the respective setters at will, and
23667/// // execute the final call using `doit()`.
23668/// // Values shown here are possibly random and not representative !
23669/// let result = hub.management().profiles_patch(req, "accountId", "webPropertyId", "profileId")
23670/// .doit().await;
23671/// # }
23672/// ```
23673pub struct ManagementProfilePatchCall<'a, C>
23674where
23675 C: 'a,
23676{
23677 hub: &'a Analytics<C>,
23678 _request: Profile,
23679 _account_id: String,
23680 _web_property_id: String,
23681 _profile_id: String,
23682 _delegate: Option<&'a mut dyn common::Delegate>,
23683 _additional_params: HashMap<String, String>,
23684 _scopes: BTreeSet<String>,
23685}
23686
23687impl<'a, C> common::CallBuilder for ManagementProfilePatchCall<'a, C> {}
23688
23689impl<'a, C> ManagementProfilePatchCall<'a, C>
23690where
23691 C: common::Connector,
23692{
23693 /// Perform the operation you have build so far.
23694 pub async fn doit(mut self) -> common::Result<(common::Response, Profile)> {
23695 use std::borrow::Cow;
23696 use std::io::{Read, Seek};
23697
23698 use common::{url::Params, ToParts};
23699 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23700
23701 let mut dd = common::DefaultDelegate;
23702 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23703 dlg.begin(common::MethodInfo {
23704 id: "analytics.management.profiles.patch",
23705 http_method: hyper::Method::PATCH,
23706 });
23707
23708 for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
23709 if self._additional_params.contains_key(field) {
23710 dlg.finished(false);
23711 return Err(common::Error::FieldClash(field));
23712 }
23713 }
23714
23715 let mut params = Params::with_capacity(6 + self._additional_params.len());
23716 params.push("accountId", self._account_id);
23717 params.push("webPropertyId", self._web_property_id);
23718 params.push("profileId", self._profile_id);
23719
23720 params.extend(self._additional_params.iter());
23721
23722 params.push("alt", "json");
23723 let mut url = self.hub._base_url.clone()
23724 + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}";
23725 if self._scopes.is_empty() {
23726 self._scopes.insert(Scope::Edit.as_ref().to_string());
23727 }
23728
23729 #[allow(clippy::single_element_loop)]
23730 for &(find_this, param_name) in [
23731 ("{accountId}", "accountId"),
23732 ("{webPropertyId}", "webPropertyId"),
23733 ("{profileId}", "profileId"),
23734 ]
23735 .iter()
23736 {
23737 url = params.uri_replacement(url, param_name, find_this, false);
23738 }
23739 {
23740 let to_remove = ["profileId", "webPropertyId", "accountId"];
23741 params.remove_params(&to_remove);
23742 }
23743
23744 let url = params.parse_with_url(&url);
23745
23746 let mut json_mime_type = mime::APPLICATION_JSON;
23747 let mut request_value_reader = {
23748 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23749 common::remove_json_null_values(&mut value);
23750 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23751 serde_json::to_writer(&mut dst, &value).unwrap();
23752 dst
23753 };
23754 let request_size = request_value_reader
23755 .seek(std::io::SeekFrom::End(0))
23756 .unwrap();
23757 request_value_reader
23758 .seek(std::io::SeekFrom::Start(0))
23759 .unwrap();
23760
23761 loop {
23762 let token = match self
23763 .hub
23764 .auth
23765 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23766 .await
23767 {
23768 Ok(token) => token,
23769 Err(e) => match dlg.token(e) {
23770 Ok(token) => token,
23771 Err(e) => {
23772 dlg.finished(false);
23773 return Err(common::Error::MissingToken(e));
23774 }
23775 },
23776 };
23777 request_value_reader
23778 .seek(std::io::SeekFrom::Start(0))
23779 .unwrap();
23780 let mut req_result = {
23781 let client = &self.hub.client;
23782 dlg.pre_request();
23783 let mut req_builder = hyper::Request::builder()
23784 .method(hyper::Method::PATCH)
23785 .uri(url.as_str())
23786 .header(USER_AGENT, self.hub._user_agent.clone());
23787
23788 if let Some(token) = token.as_ref() {
23789 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23790 }
23791
23792 let request = req_builder
23793 .header(CONTENT_TYPE, json_mime_type.to_string())
23794 .header(CONTENT_LENGTH, request_size as u64)
23795 .body(common::to_body(
23796 request_value_reader.get_ref().clone().into(),
23797 ));
23798
23799 client.request(request.unwrap()).await
23800 };
23801
23802 match req_result {
23803 Err(err) => {
23804 if let common::Retry::After(d) = dlg.http_error(&err) {
23805 sleep(d).await;
23806 continue;
23807 }
23808 dlg.finished(false);
23809 return Err(common::Error::HttpError(err));
23810 }
23811 Ok(res) => {
23812 let (mut parts, body) = res.into_parts();
23813 let mut body = common::Body::new(body);
23814 if !parts.status.is_success() {
23815 let bytes = common::to_bytes(body).await.unwrap_or_default();
23816 let error = serde_json::from_str(&common::to_string(&bytes));
23817 let response = common::to_response(parts, bytes.into());
23818
23819 if let common::Retry::After(d) =
23820 dlg.http_failure(&response, error.as_ref().ok())
23821 {
23822 sleep(d).await;
23823 continue;
23824 }
23825
23826 dlg.finished(false);
23827
23828 return Err(match error {
23829 Ok(value) => common::Error::BadRequest(value),
23830 _ => common::Error::Failure(response),
23831 });
23832 }
23833 let response = {
23834 let bytes = common::to_bytes(body).await.unwrap_or_default();
23835 let encoded = common::to_string(&bytes);
23836 match serde_json::from_str(&encoded) {
23837 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23838 Err(error) => {
23839 dlg.response_json_decode_error(&encoded, &error);
23840 return Err(common::Error::JsonDecodeError(
23841 encoded.to_string(),
23842 error,
23843 ));
23844 }
23845 }
23846 };
23847
23848 dlg.finished(true);
23849 return Ok(response);
23850 }
23851 }
23852 }
23853 }
23854
23855 ///
23856 /// Sets the *request* property to the given value.
23857 ///
23858 /// Even though the property as already been set when instantiating this call,
23859 /// we provide this method for API completeness.
23860 pub fn request(mut self, new_value: Profile) -> ManagementProfilePatchCall<'a, C> {
23861 self._request = new_value;
23862 self
23863 }
23864 /// Account ID to which the view (profile) belongs
23865 ///
23866 /// Sets the *account id* path property to the given value.
23867 ///
23868 /// Even though the property as already been set when instantiating this call,
23869 /// we provide this method for API completeness.
23870 pub fn account_id(mut self, new_value: &str) -> ManagementProfilePatchCall<'a, C> {
23871 self._account_id = new_value.to_string();
23872 self
23873 }
23874 /// Web property ID to which the view (profile) belongs
23875 ///
23876 /// Sets the *web property id* path property to the given value.
23877 ///
23878 /// Even though the property as already been set when instantiating this call,
23879 /// we provide this method for API completeness.
23880 pub fn web_property_id(mut self, new_value: &str) -> ManagementProfilePatchCall<'a, C> {
23881 self._web_property_id = new_value.to_string();
23882 self
23883 }
23884 /// ID of the view (profile) to be updated.
23885 ///
23886 /// Sets the *profile id* path property to the given value.
23887 ///
23888 /// Even though the property as already been set when instantiating this call,
23889 /// we provide this method for API completeness.
23890 pub fn profile_id(mut self, new_value: &str) -> ManagementProfilePatchCall<'a, C> {
23891 self._profile_id = new_value.to_string();
23892 self
23893 }
23894 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23895 /// while executing the actual API request.
23896 ///
23897 /// ````text
23898 /// It should be used to handle progress information, and to implement a certain level of resilience.
23899 /// ````
23900 ///
23901 /// Sets the *delegate* property to the given value.
23902 pub fn delegate(
23903 mut self,
23904 new_value: &'a mut dyn common::Delegate,
23905 ) -> ManagementProfilePatchCall<'a, C> {
23906 self._delegate = Some(new_value);
23907 self
23908 }
23909
23910 /// Set any additional parameter of the query string used in the request.
23911 /// It should be used to set parameters which are not yet available through their own
23912 /// setters.
23913 ///
23914 /// Please note that this method must not be used to set any of the known parameters
23915 /// which have their own setter method. If done anyway, the request will fail.
23916 ///
23917 /// # Additional Parameters
23918 ///
23919 /// * *alt* (query-string) - Data format for the response.
23920 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23921 /// * *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.
23922 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23923 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23924 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23925 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23926 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfilePatchCall<'a, C>
23927 where
23928 T: AsRef<str>,
23929 {
23930 self._additional_params
23931 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23932 self
23933 }
23934
23935 /// Identifies the authorization scope for the method you are building.
23936 ///
23937 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23938 /// [`Scope::Edit`].
23939 ///
23940 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23941 /// tokens for more than one scope.
23942 ///
23943 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23944 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23945 /// sufficient, a read-write scope will do as well.
23946 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfilePatchCall<'a, C>
23947 where
23948 St: AsRef<str>,
23949 {
23950 self._scopes.insert(String::from(scope.as_ref()));
23951 self
23952 }
23953 /// Identifies the authorization scope(s) for the method you are building.
23954 ///
23955 /// See [`Self::add_scope()`] for details.
23956 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfilePatchCall<'a, C>
23957 where
23958 I: IntoIterator<Item = St>,
23959 St: AsRef<str>,
23960 {
23961 self._scopes
23962 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23963 self
23964 }
23965
23966 /// Removes all scopes, and no default scope will be used either.
23967 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23968 /// for details).
23969 pub fn clear_scopes(mut self) -> ManagementProfilePatchCall<'a, C> {
23970 self._scopes.clear();
23971 self
23972 }
23973}
23974
23975/// Updates an existing view (profile).
23976///
23977/// A builder for the *profiles.update* method supported by a *management* resource.
23978/// It is not used directly, but through a [`ManagementMethods`] instance.
23979///
23980/// # Example
23981///
23982/// Instantiate a resource method builder
23983///
23984/// ```test_harness,no_run
23985/// # extern crate hyper;
23986/// # extern crate hyper_rustls;
23987/// # extern crate google_analytics3 as analytics3;
23988/// use analytics3::api::Profile;
23989/// # async fn dox() {
23990/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23991///
23992/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23993/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23994/// # secret,
23995/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23996/// # ).build().await.unwrap();
23997///
23998/// # let client = hyper_util::client::legacy::Client::builder(
23999/// # hyper_util::rt::TokioExecutor::new()
24000/// # )
24001/// # .build(
24002/// # hyper_rustls::HttpsConnectorBuilder::new()
24003/// # .with_native_roots()
24004/// # .unwrap()
24005/// # .https_or_http()
24006/// # .enable_http1()
24007/// # .build()
24008/// # );
24009/// # let mut hub = Analytics::new(client, auth);
24010/// // As the method needs a request, you would usually fill it with the desired information
24011/// // into the respective structure. Some of the parts shown here might not be applicable !
24012/// // Values shown here are possibly random and not representative !
24013/// let mut req = Profile::default();
24014///
24015/// // You can configure optional parameters by calling the respective setters at will, and
24016/// // execute the final call using `doit()`.
24017/// // Values shown here are possibly random and not representative !
24018/// let result = hub.management().profiles_update(req, "accountId", "webPropertyId", "profileId")
24019/// .doit().await;
24020/// # }
24021/// ```
24022pub struct ManagementProfileUpdateCall<'a, C>
24023where
24024 C: 'a,
24025{
24026 hub: &'a Analytics<C>,
24027 _request: Profile,
24028 _account_id: String,
24029 _web_property_id: String,
24030 _profile_id: String,
24031 _delegate: Option<&'a mut dyn common::Delegate>,
24032 _additional_params: HashMap<String, String>,
24033 _scopes: BTreeSet<String>,
24034}
24035
24036impl<'a, C> common::CallBuilder for ManagementProfileUpdateCall<'a, C> {}
24037
24038impl<'a, C> ManagementProfileUpdateCall<'a, C>
24039where
24040 C: common::Connector,
24041{
24042 /// Perform the operation you have build so far.
24043 pub async fn doit(mut self) -> common::Result<(common::Response, Profile)> {
24044 use std::borrow::Cow;
24045 use std::io::{Read, Seek};
24046
24047 use common::{url::Params, ToParts};
24048 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24049
24050 let mut dd = common::DefaultDelegate;
24051 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24052 dlg.begin(common::MethodInfo {
24053 id: "analytics.management.profiles.update",
24054 http_method: hyper::Method::PUT,
24055 });
24056
24057 for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
24058 if self._additional_params.contains_key(field) {
24059 dlg.finished(false);
24060 return Err(common::Error::FieldClash(field));
24061 }
24062 }
24063
24064 let mut params = Params::with_capacity(6 + self._additional_params.len());
24065 params.push("accountId", self._account_id);
24066 params.push("webPropertyId", self._web_property_id);
24067 params.push("profileId", self._profile_id);
24068
24069 params.extend(self._additional_params.iter());
24070
24071 params.push("alt", "json");
24072 let mut url = self.hub._base_url.clone()
24073 + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}";
24074 if self._scopes.is_empty() {
24075 self._scopes.insert(Scope::Edit.as_ref().to_string());
24076 }
24077
24078 #[allow(clippy::single_element_loop)]
24079 for &(find_this, param_name) in [
24080 ("{accountId}", "accountId"),
24081 ("{webPropertyId}", "webPropertyId"),
24082 ("{profileId}", "profileId"),
24083 ]
24084 .iter()
24085 {
24086 url = params.uri_replacement(url, param_name, find_this, false);
24087 }
24088 {
24089 let to_remove = ["profileId", "webPropertyId", "accountId"];
24090 params.remove_params(&to_remove);
24091 }
24092
24093 let url = params.parse_with_url(&url);
24094
24095 let mut json_mime_type = mime::APPLICATION_JSON;
24096 let mut request_value_reader = {
24097 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24098 common::remove_json_null_values(&mut value);
24099 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24100 serde_json::to_writer(&mut dst, &value).unwrap();
24101 dst
24102 };
24103 let request_size = request_value_reader
24104 .seek(std::io::SeekFrom::End(0))
24105 .unwrap();
24106 request_value_reader
24107 .seek(std::io::SeekFrom::Start(0))
24108 .unwrap();
24109
24110 loop {
24111 let token = match self
24112 .hub
24113 .auth
24114 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24115 .await
24116 {
24117 Ok(token) => token,
24118 Err(e) => match dlg.token(e) {
24119 Ok(token) => token,
24120 Err(e) => {
24121 dlg.finished(false);
24122 return Err(common::Error::MissingToken(e));
24123 }
24124 },
24125 };
24126 request_value_reader
24127 .seek(std::io::SeekFrom::Start(0))
24128 .unwrap();
24129 let mut req_result = {
24130 let client = &self.hub.client;
24131 dlg.pre_request();
24132 let mut req_builder = hyper::Request::builder()
24133 .method(hyper::Method::PUT)
24134 .uri(url.as_str())
24135 .header(USER_AGENT, self.hub._user_agent.clone());
24136
24137 if let Some(token) = token.as_ref() {
24138 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24139 }
24140
24141 let request = req_builder
24142 .header(CONTENT_TYPE, json_mime_type.to_string())
24143 .header(CONTENT_LENGTH, request_size as u64)
24144 .body(common::to_body(
24145 request_value_reader.get_ref().clone().into(),
24146 ));
24147
24148 client.request(request.unwrap()).await
24149 };
24150
24151 match req_result {
24152 Err(err) => {
24153 if let common::Retry::After(d) = dlg.http_error(&err) {
24154 sleep(d).await;
24155 continue;
24156 }
24157 dlg.finished(false);
24158 return Err(common::Error::HttpError(err));
24159 }
24160 Ok(res) => {
24161 let (mut parts, body) = res.into_parts();
24162 let mut body = common::Body::new(body);
24163 if !parts.status.is_success() {
24164 let bytes = common::to_bytes(body).await.unwrap_or_default();
24165 let error = serde_json::from_str(&common::to_string(&bytes));
24166 let response = common::to_response(parts, bytes.into());
24167
24168 if let common::Retry::After(d) =
24169 dlg.http_failure(&response, error.as_ref().ok())
24170 {
24171 sleep(d).await;
24172 continue;
24173 }
24174
24175 dlg.finished(false);
24176
24177 return Err(match error {
24178 Ok(value) => common::Error::BadRequest(value),
24179 _ => common::Error::Failure(response),
24180 });
24181 }
24182 let response = {
24183 let bytes = common::to_bytes(body).await.unwrap_or_default();
24184 let encoded = common::to_string(&bytes);
24185 match serde_json::from_str(&encoded) {
24186 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24187 Err(error) => {
24188 dlg.response_json_decode_error(&encoded, &error);
24189 return Err(common::Error::JsonDecodeError(
24190 encoded.to_string(),
24191 error,
24192 ));
24193 }
24194 }
24195 };
24196
24197 dlg.finished(true);
24198 return Ok(response);
24199 }
24200 }
24201 }
24202 }
24203
24204 ///
24205 /// Sets the *request* property to the given value.
24206 ///
24207 /// Even though the property as already been set when instantiating this call,
24208 /// we provide this method for API completeness.
24209 pub fn request(mut self, new_value: Profile) -> ManagementProfileUpdateCall<'a, C> {
24210 self._request = new_value;
24211 self
24212 }
24213 /// Account ID to which the view (profile) belongs
24214 ///
24215 /// Sets the *account id* path property to the given value.
24216 ///
24217 /// Even though the property as already been set when instantiating this call,
24218 /// we provide this method for API completeness.
24219 pub fn account_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C> {
24220 self._account_id = new_value.to_string();
24221 self
24222 }
24223 /// Web property ID to which the view (profile) belongs
24224 ///
24225 /// Sets the *web property id* path property to the given value.
24226 ///
24227 /// Even though the property as already been set when instantiating this call,
24228 /// we provide this method for API completeness.
24229 pub fn web_property_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C> {
24230 self._web_property_id = new_value.to_string();
24231 self
24232 }
24233 /// ID of the view (profile) to be updated.
24234 ///
24235 /// Sets the *profile id* path property to the given value.
24236 ///
24237 /// Even though the property as already been set when instantiating this call,
24238 /// we provide this method for API completeness.
24239 pub fn profile_id(mut self, new_value: &str) -> ManagementProfileUpdateCall<'a, C> {
24240 self._profile_id = new_value.to_string();
24241 self
24242 }
24243 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24244 /// while executing the actual API request.
24245 ///
24246 /// ````text
24247 /// It should be used to handle progress information, and to implement a certain level of resilience.
24248 /// ````
24249 ///
24250 /// Sets the *delegate* property to the given value.
24251 pub fn delegate(
24252 mut self,
24253 new_value: &'a mut dyn common::Delegate,
24254 ) -> ManagementProfileUpdateCall<'a, C> {
24255 self._delegate = Some(new_value);
24256 self
24257 }
24258
24259 /// Set any additional parameter of the query string used in the request.
24260 /// It should be used to set parameters which are not yet available through their own
24261 /// setters.
24262 ///
24263 /// Please note that this method must not be used to set any of the known parameters
24264 /// which have their own setter method. If done anyway, the request will fail.
24265 ///
24266 /// # Additional Parameters
24267 ///
24268 /// * *alt* (query-string) - Data format for the response.
24269 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24270 /// * *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.
24271 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24272 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24273 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24274 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24275 pub fn param<T>(mut self, name: T, value: T) -> ManagementProfileUpdateCall<'a, C>
24276 where
24277 T: AsRef<str>,
24278 {
24279 self._additional_params
24280 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24281 self
24282 }
24283
24284 /// Identifies the authorization scope for the method you are building.
24285 ///
24286 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24287 /// [`Scope::Edit`].
24288 ///
24289 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24290 /// tokens for more than one scope.
24291 ///
24292 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24293 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24294 /// sufficient, a read-write scope will do as well.
24295 pub fn add_scope<St>(mut self, scope: St) -> ManagementProfileUpdateCall<'a, C>
24296 where
24297 St: AsRef<str>,
24298 {
24299 self._scopes.insert(String::from(scope.as_ref()));
24300 self
24301 }
24302 /// Identifies the authorization scope(s) for the method you are building.
24303 ///
24304 /// See [`Self::add_scope()`] for details.
24305 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementProfileUpdateCall<'a, C>
24306 where
24307 I: IntoIterator<Item = St>,
24308 St: AsRef<str>,
24309 {
24310 self._scopes
24311 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24312 self
24313 }
24314
24315 /// Removes all scopes, and no default scope will be used either.
24316 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24317 /// for details).
24318 pub fn clear_scopes(mut self) -> ManagementProfileUpdateCall<'a, C> {
24319 self._scopes.clear();
24320 self
24321 }
24322}
24323
24324/// Delete a remarketing audience.
24325///
24326/// A builder for the *remarketingAudience.delete* method supported by a *management* resource.
24327/// It is not used directly, but through a [`ManagementMethods`] instance.
24328///
24329/// # Example
24330///
24331/// Instantiate a resource method builder
24332///
24333/// ```test_harness,no_run
24334/// # extern crate hyper;
24335/// # extern crate hyper_rustls;
24336/// # extern crate google_analytics3 as analytics3;
24337/// # async fn dox() {
24338/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24339///
24340/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24341/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24342/// # secret,
24343/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24344/// # ).build().await.unwrap();
24345///
24346/// # let client = hyper_util::client::legacy::Client::builder(
24347/// # hyper_util::rt::TokioExecutor::new()
24348/// # )
24349/// # .build(
24350/// # hyper_rustls::HttpsConnectorBuilder::new()
24351/// # .with_native_roots()
24352/// # .unwrap()
24353/// # .https_or_http()
24354/// # .enable_http1()
24355/// # .build()
24356/// # );
24357/// # let mut hub = Analytics::new(client, auth);
24358/// // You can configure optional parameters by calling the respective setters at will, and
24359/// // execute the final call using `doit()`.
24360/// // Values shown here are possibly random and not representative !
24361/// let result = hub.management().remarketing_audience_delete("accountId", "webPropertyId", "remarketingAudienceId")
24362/// .doit().await;
24363/// # }
24364/// ```
24365pub struct ManagementRemarketingAudienceDeleteCall<'a, C>
24366where
24367 C: 'a,
24368{
24369 hub: &'a Analytics<C>,
24370 _account_id: String,
24371 _web_property_id: String,
24372 _remarketing_audience_id: String,
24373 _delegate: Option<&'a mut dyn common::Delegate>,
24374 _additional_params: HashMap<String, String>,
24375 _scopes: BTreeSet<String>,
24376}
24377
24378impl<'a, C> common::CallBuilder for ManagementRemarketingAudienceDeleteCall<'a, C> {}
24379
24380impl<'a, C> ManagementRemarketingAudienceDeleteCall<'a, C>
24381where
24382 C: common::Connector,
24383{
24384 /// Perform the operation you have build so far.
24385 pub async fn doit(mut self) -> common::Result<common::Response> {
24386 use std::borrow::Cow;
24387 use std::io::{Read, Seek};
24388
24389 use common::{url::Params, ToParts};
24390 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24391
24392 let mut dd = common::DefaultDelegate;
24393 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24394 dlg.begin(common::MethodInfo {
24395 id: "analytics.management.remarketingAudience.delete",
24396 http_method: hyper::Method::DELETE,
24397 });
24398
24399 for &field in ["accountId", "webPropertyId", "remarketingAudienceId"].iter() {
24400 if self._additional_params.contains_key(field) {
24401 dlg.finished(false);
24402 return Err(common::Error::FieldClash(field));
24403 }
24404 }
24405
24406 let mut params = Params::with_capacity(4 + self._additional_params.len());
24407 params.push("accountId", self._account_id);
24408 params.push("webPropertyId", self._web_property_id);
24409 params.push("remarketingAudienceId", self._remarketing_audience_id);
24410
24411 params.extend(self._additional_params.iter());
24412
24413 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}";
24414 if self._scopes.is_empty() {
24415 self._scopes.insert(Scope::Edit.as_ref().to_string());
24416 }
24417
24418 #[allow(clippy::single_element_loop)]
24419 for &(find_this, param_name) in [
24420 ("{accountId}", "accountId"),
24421 ("{webPropertyId}", "webPropertyId"),
24422 ("{remarketingAudienceId}", "remarketingAudienceId"),
24423 ]
24424 .iter()
24425 {
24426 url = params.uri_replacement(url, param_name, find_this, false);
24427 }
24428 {
24429 let to_remove = ["remarketingAudienceId", "webPropertyId", "accountId"];
24430 params.remove_params(&to_remove);
24431 }
24432
24433 let url = params.parse_with_url(&url);
24434
24435 loop {
24436 let token = match self
24437 .hub
24438 .auth
24439 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24440 .await
24441 {
24442 Ok(token) => token,
24443 Err(e) => match dlg.token(e) {
24444 Ok(token) => token,
24445 Err(e) => {
24446 dlg.finished(false);
24447 return Err(common::Error::MissingToken(e));
24448 }
24449 },
24450 };
24451 let mut req_result = {
24452 let client = &self.hub.client;
24453 dlg.pre_request();
24454 let mut req_builder = hyper::Request::builder()
24455 .method(hyper::Method::DELETE)
24456 .uri(url.as_str())
24457 .header(USER_AGENT, self.hub._user_agent.clone());
24458
24459 if let Some(token) = token.as_ref() {
24460 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24461 }
24462
24463 let request = req_builder
24464 .header(CONTENT_LENGTH, 0_u64)
24465 .body(common::to_body::<String>(None));
24466
24467 client.request(request.unwrap()).await
24468 };
24469
24470 match req_result {
24471 Err(err) => {
24472 if let common::Retry::After(d) = dlg.http_error(&err) {
24473 sleep(d).await;
24474 continue;
24475 }
24476 dlg.finished(false);
24477 return Err(common::Error::HttpError(err));
24478 }
24479 Ok(res) => {
24480 let (mut parts, body) = res.into_parts();
24481 let mut body = common::Body::new(body);
24482 if !parts.status.is_success() {
24483 let bytes = common::to_bytes(body).await.unwrap_or_default();
24484 let error = serde_json::from_str(&common::to_string(&bytes));
24485 let response = common::to_response(parts, bytes.into());
24486
24487 if let common::Retry::After(d) =
24488 dlg.http_failure(&response, error.as_ref().ok())
24489 {
24490 sleep(d).await;
24491 continue;
24492 }
24493
24494 dlg.finished(false);
24495
24496 return Err(match error {
24497 Ok(value) => common::Error::BadRequest(value),
24498 _ => common::Error::Failure(response),
24499 });
24500 }
24501 let response = common::Response::from_parts(parts, body);
24502
24503 dlg.finished(true);
24504 return Ok(response);
24505 }
24506 }
24507 }
24508 }
24509
24510 /// Account ID to which the remarketing audience belongs.
24511 ///
24512 /// Sets the *account id* path property to the given value.
24513 ///
24514 /// Even though the property as already been set when instantiating this call,
24515 /// we provide this method for API completeness.
24516 pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
24517 self._account_id = new_value.to_string();
24518 self
24519 }
24520 /// Web property ID to which the remarketing audience belongs.
24521 ///
24522 /// Sets the *web property id* path property to the given value.
24523 ///
24524 /// Even though the property as already been set when instantiating this call,
24525 /// we provide this method for API completeness.
24526 pub fn web_property_id(
24527 mut self,
24528 new_value: &str,
24529 ) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
24530 self._web_property_id = new_value.to_string();
24531 self
24532 }
24533 /// The ID of the remarketing audience to delete.
24534 ///
24535 /// Sets the *remarketing audience 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 remarketing_audience_id(
24540 mut self,
24541 new_value: &str,
24542 ) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
24543 self._remarketing_audience_id = new_value.to_string();
24544 self
24545 }
24546 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24547 /// while executing the actual API request.
24548 ///
24549 /// ````text
24550 /// It should be used to handle progress information, and to implement a certain level of resilience.
24551 /// ````
24552 ///
24553 /// Sets the *delegate* property to the given value.
24554 pub fn delegate(
24555 mut self,
24556 new_value: &'a mut dyn common::Delegate,
24557 ) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
24558 self._delegate = Some(new_value);
24559 self
24560 }
24561
24562 /// Set any additional parameter of the query string used in the request.
24563 /// It should be used to set parameters which are not yet available through their own
24564 /// setters.
24565 ///
24566 /// Please note that this method must not be used to set any of the known parameters
24567 /// which have their own setter method. If done anyway, the request will fail.
24568 ///
24569 /// # Additional Parameters
24570 ///
24571 /// * *alt* (query-string) - Data format for the response.
24572 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24573 /// * *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.
24574 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24575 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24576 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24577 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24578 pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudienceDeleteCall<'a, C>
24579 where
24580 T: AsRef<str>,
24581 {
24582 self._additional_params
24583 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24584 self
24585 }
24586
24587 /// Identifies the authorization scope for the method you are building.
24588 ///
24589 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24590 /// [`Scope::Edit`].
24591 ///
24592 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24593 /// tokens for more than one scope.
24594 ///
24595 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24596 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24597 /// sufficient, a read-write scope will do as well.
24598 pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudienceDeleteCall<'a, C>
24599 where
24600 St: AsRef<str>,
24601 {
24602 self._scopes.insert(String::from(scope.as_ref()));
24603 self
24604 }
24605 /// Identifies the authorization scope(s) for the method you are building.
24606 ///
24607 /// See [`Self::add_scope()`] for details.
24608 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudienceDeleteCall<'a, C>
24609 where
24610 I: IntoIterator<Item = St>,
24611 St: AsRef<str>,
24612 {
24613 self._scopes
24614 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24615 self
24616 }
24617
24618 /// Removes all scopes, and no default scope will be used either.
24619 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24620 /// for details).
24621 pub fn clear_scopes(mut self) -> ManagementRemarketingAudienceDeleteCall<'a, C> {
24622 self._scopes.clear();
24623 self
24624 }
24625}
24626
24627/// Gets a remarketing audience to which the user has access.
24628///
24629/// A builder for the *remarketingAudience.get* method supported by a *management* resource.
24630/// It is not used directly, but through a [`ManagementMethods`] instance.
24631///
24632/// # Example
24633///
24634/// Instantiate a resource method builder
24635///
24636/// ```test_harness,no_run
24637/// # extern crate hyper;
24638/// # extern crate hyper_rustls;
24639/// # extern crate google_analytics3 as analytics3;
24640/// # async fn dox() {
24641/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24642///
24643/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24644/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24645/// # secret,
24646/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24647/// # ).build().await.unwrap();
24648///
24649/// # let client = hyper_util::client::legacy::Client::builder(
24650/// # hyper_util::rt::TokioExecutor::new()
24651/// # )
24652/// # .build(
24653/// # hyper_rustls::HttpsConnectorBuilder::new()
24654/// # .with_native_roots()
24655/// # .unwrap()
24656/// # .https_or_http()
24657/// # .enable_http1()
24658/// # .build()
24659/// # );
24660/// # let mut hub = Analytics::new(client, auth);
24661/// // You can configure optional parameters by calling the respective setters at will, and
24662/// // execute the final call using `doit()`.
24663/// // Values shown here are possibly random and not representative !
24664/// let result = hub.management().remarketing_audience_get("accountId", "webPropertyId", "remarketingAudienceId")
24665/// .doit().await;
24666/// # }
24667/// ```
24668pub struct ManagementRemarketingAudienceGetCall<'a, C>
24669where
24670 C: 'a,
24671{
24672 hub: &'a Analytics<C>,
24673 _account_id: String,
24674 _web_property_id: String,
24675 _remarketing_audience_id: String,
24676 _delegate: Option<&'a mut dyn common::Delegate>,
24677 _additional_params: HashMap<String, String>,
24678 _scopes: BTreeSet<String>,
24679}
24680
24681impl<'a, C> common::CallBuilder for ManagementRemarketingAudienceGetCall<'a, C> {}
24682
24683impl<'a, C> ManagementRemarketingAudienceGetCall<'a, C>
24684where
24685 C: common::Connector,
24686{
24687 /// Perform the operation you have build so far.
24688 pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingAudience)> {
24689 use std::borrow::Cow;
24690 use std::io::{Read, Seek};
24691
24692 use common::{url::Params, ToParts};
24693 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24694
24695 let mut dd = common::DefaultDelegate;
24696 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24697 dlg.begin(common::MethodInfo {
24698 id: "analytics.management.remarketingAudience.get",
24699 http_method: hyper::Method::GET,
24700 });
24701
24702 for &field in ["alt", "accountId", "webPropertyId", "remarketingAudienceId"].iter() {
24703 if self._additional_params.contains_key(field) {
24704 dlg.finished(false);
24705 return Err(common::Error::FieldClash(field));
24706 }
24707 }
24708
24709 let mut params = Params::with_capacity(5 + self._additional_params.len());
24710 params.push("accountId", self._account_id);
24711 params.push("webPropertyId", self._web_property_id);
24712 params.push("remarketingAudienceId", self._remarketing_audience_id);
24713
24714 params.extend(self._additional_params.iter());
24715
24716 params.push("alt", "json");
24717 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}";
24718 if self._scopes.is_empty() {
24719 self._scopes.insert(Scope::Readonly.as_ref().to_string());
24720 }
24721
24722 #[allow(clippy::single_element_loop)]
24723 for &(find_this, param_name) in [
24724 ("{accountId}", "accountId"),
24725 ("{webPropertyId}", "webPropertyId"),
24726 ("{remarketingAudienceId}", "remarketingAudienceId"),
24727 ]
24728 .iter()
24729 {
24730 url = params.uri_replacement(url, param_name, find_this, false);
24731 }
24732 {
24733 let to_remove = ["remarketingAudienceId", "webPropertyId", "accountId"];
24734 params.remove_params(&to_remove);
24735 }
24736
24737 let url = params.parse_with_url(&url);
24738
24739 loop {
24740 let token = match self
24741 .hub
24742 .auth
24743 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24744 .await
24745 {
24746 Ok(token) => token,
24747 Err(e) => match dlg.token(e) {
24748 Ok(token) => token,
24749 Err(e) => {
24750 dlg.finished(false);
24751 return Err(common::Error::MissingToken(e));
24752 }
24753 },
24754 };
24755 let mut req_result = {
24756 let client = &self.hub.client;
24757 dlg.pre_request();
24758 let mut req_builder = hyper::Request::builder()
24759 .method(hyper::Method::GET)
24760 .uri(url.as_str())
24761 .header(USER_AGENT, self.hub._user_agent.clone());
24762
24763 if let Some(token) = token.as_ref() {
24764 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24765 }
24766
24767 let request = req_builder
24768 .header(CONTENT_LENGTH, 0_u64)
24769 .body(common::to_body::<String>(None));
24770
24771 client.request(request.unwrap()).await
24772 };
24773
24774 match req_result {
24775 Err(err) => {
24776 if let common::Retry::After(d) = dlg.http_error(&err) {
24777 sleep(d).await;
24778 continue;
24779 }
24780 dlg.finished(false);
24781 return Err(common::Error::HttpError(err));
24782 }
24783 Ok(res) => {
24784 let (mut parts, body) = res.into_parts();
24785 let mut body = common::Body::new(body);
24786 if !parts.status.is_success() {
24787 let bytes = common::to_bytes(body).await.unwrap_or_default();
24788 let error = serde_json::from_str(&common::to_string(&bytes));
24789 let response = common::to_response(parts, bytes.into());
24790
24791 if let common::Retry::After(d) =
24792 dlg.http_failure(&response, error.as_ref().ok())
24793 {
24794 sleep(d).await;
24795 continue;
24796 }
24797
24798 dlg.finished(false);
24799
24800 return Err(match error {
24801 Ok(value) => common::Error::BadRequest(value),
24802 _ => common::Error::Failure(response),
24803 });
24804 }
24805 let response = {
24806 let bytes = common::to_bytes(body).await.unwrap_or_default();
24807 let encoded = common::to_string(&bytes);
24808 match serde_json::from_str(&encoded) {
24809 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24810 Err(error) => {
24811 dlg.response_json_decode_error(&encoded, &error);
24812 return Err(common::Error::JsonDecodeError(
24813 encoded.to_string(),
24814 error,
24815 ));
24816 }
24817 }
24818 };
24819
24820 dlg.finished(true);
24821 return Ok(response);
24822 }
24823 }
24824 }
24825 }
24826
24827 /// The account ID of the remarketing audience to retrieve.
24828 ///
24829 /// Sets the *account id* path property to the given value.
24830 ///
24831 /// Even though the property as already been set when instantiating this call,
24832 /// we provide this method for API completeness.
24833 pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceGetCall<'a, C> {
24834 self._account_id = new_value.to_string();
24835 self
24836 }
24837 /// The web property ID of the remarketing audience to retrieve.
24838 ///
24839 /// Sets the *web property id* path property to the given value.
24840 ///
24841 /// Even though the property as already been set when instantiating this call,
24842 /// we provide this method for API completeness.
24843 pub fn web_property_id(
24844 mut self,
24845 new_value: &str,
24846 ) -> ManagementRemarketingAudienceGetCall<'a, C> {
24847 self._web_property_id = new_value.to_string();
24848 self
24849 }
24850 /// The ID of the remarketing audience to retrieve.
24851 ///
24852 /// Sets the *remarketing audience id* path property to the given value.
24853 ///
24854 /// Even though the property as already been set when instantiating this call,
24855 /// we provide this method for API completeness.
24856 pub fn remarketing_audience_id(
24857 mut self,
24858 new_value: &str,
24859 ) -> ManagementRemarketingAudienceGetCall<'a, C> {
24860 self._remarketing_audience_id = new_value.to_string();
24861 self
24862 }
24863 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24864 /// while executing the actual API request.
24865 ///
24866 /// ````text
24867 /// It should be used to handle progress information, and to implement a certain level of resilience.
24868 /// ````
24869 ///
24870 /// Sets the *delegate* property to the given value.
24871 pub fn delegate(
24872 mut self,
24873 new_value: &'a mut dyn common::Delegate,
24874 ) -> ManagementRemarketingAudienceGetCall<'a, C> {
24875 self._delegate = Some(new_value);
24876 self
24877 }
24878
24879 /// Set any additional parameter of the query string used in the request.
24880 /// It should be used to set parameters which are not yet available through their own
24881 /// setters.
24882 ///
24883 /// Please note that this method must not be used to set any of the known parameters
24884 /// which have their own setter method. If done anyway, the request will fail.
24885 ///
24886 /// # Additional Parameters
24887 ///
24888 /// * *alt* (query-string) - Data format for the response.
24889 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24890 /// * *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.
24891 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24892 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24893 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24894 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24895 pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudienceGetCall<'a, C>
24896 where
24897 T: AsRef<str>,
24898 {
24899 self._additional_params
24900 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24901 self
24902 }
24903
24904 /// Identifies the authorization scope for the method you are building.
24905 ///
24906 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24907 /// [`Scope::Readonly`].
24908 ///
24909 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24910 /// tokens for more than one scope.
24911 ///
24912 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24913 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24914 /// sufficient, a read-write scope will do as well.
24915 pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudienceGetCall<'a, C>
24916 where
24917 St: AsRef<str>,
24918 {
24919 self._scopes.insert(String::from(scope.as_ref()));
24920 self
24921 }
24922 /// Identifies the authorization scope(s) for the method you are building.
24923 ///
24924 /// See [`Self::add_scope()`] for details.
24925 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudienceGetCall<'a, C>
24926 where
24927 I: IntoIterator<Item = St>,
24928 St: AsRef<str>,
24929 {
24930 self._scopes
24931 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24932 self
24933 }
24934
24935 /// Removes all scopes, and no default scope will be used either.
24936 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24937 /// for details).
24938 pub fn clear_scopes(mut self) -> ManagementRemarketingAudienceGetCall<'a, C> {
24939 self._scopes.clear();
24940 self
24941 }
24942}
24943
24944/// Creates a new remarketing audience.
24945///
24946/// A builder for the *remarketingAudience.insert* method supported by a *management* resource.
24947/// It is not used directly, but through a [`ManagementMethods`] instance.
24948///
24949/// # Example
24950///
24951/// Instantiate a resource method builder
24952///
24953/// ```test_harness,no_run
24954/// # extern crate hyper;
24955/// # extern crate hyper_rustls;
24956/// # extern crate google_analytics3 as analytics3;
24957/// use analytics3::api::RemarketingAudience;
24958/// # async fn dox() {
24959/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24960///
24961/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24962/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24963/// # secret,
24964/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24965/// # ).build().await.unwrap();
24966///
24967/// # let client = hyper_util::client::legacy::Client::builder(
24968/// # hyper_util::rt::TokioExecutor::new()
24969/// # )
24970/// # .build(
24971/// # hyper_rustls::HttpsConnectorBuilder::new()
24972/// # .with_native_roots()
24973/// # .unwrap()
24974/// # .https_or_http()
24975/// # .enable_http1()
24976/// # .build()
24977/// # );
24978/// # let mut hub = Analytics::new(client, auth);
24979/// // As the method needs a request, you would usually fill it with the desired information
24980/// // into the respective structure. Some of the parts shown here might not be applicable !
24981/// // Values shown here are possibly random and not representative !
24982/// let mut req = RemarketingAudience::default();
24983///
24984/// // You can configure optional parameters by calling the respective setters at will, and
24985/// // execute the final call using `doit()`.
24986/// // Values shown here are possibly random and not representative !
24987/// let result = hub.management().remarketing_audience_insert(req, "accountId", "webPropertyId")
24988/// .doit().await;
24989/// # }
24990/// ```
24991pub struct ManagementRemarketingAudienceInsertCall<'a, C>
24992where
24993 C: 'a,
24994{
24995 hub: &'a Analytics<C>,
24996 _request: RemarketingAudience,
24997 _account_id: String,
24998 _web_property_id: String,
24999 _delegate: Option<&'a mut dyn common::Delegate>,
25000 _additional_params: HashMap<String, String>,
25001 _scopes: BTreeSet<String>,
25002}
25003
25004impl<'a, C> common::CallBuilder for ManagementRemarketingAudienceInsertCall<'a, C> {}
25005
25006impl<'a, C> ManagementRemarketingAudienceInsertCall<'a, C>
25007where
25008 C: common::Connector,
25009{
25010 /// Perform the operation you have build so far.
25011 pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingAudience)> {
25012 use std::borrow::Cow;
25013 use std::io::{Read, Seek};
25014
25015 use common::{url::Params, ToParts};
25016 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25017
25018 let mut dd = common::DefaultDelegate;
25019 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25020 dlg.begin(common::MethodInfo {
25021 id: "analytics.management.remarketingAudience.insert",
25022 http_method: hyper::Method::POST,
25023 });
25024
25025 for &field in ["alt", "accountId", "webPropertyId"].iter() {
25026 if self._additional_params.contains_key(field) {
25027 dlg.finished(false);
25028 return Err(common::Error::FieldClash(field));
25029 }
25030 }
25031
25032 let mut params = Params::with_capacity(5 + self._additional_params.len());
25033 params.push("accountId", self._account_id);
25034 params.push("webPropertyId", self._web_property_id);
25035
25036 params.extend(self._additional_params.iter());
25037
25038 params.push("alt", "json");
25039 let mut url = self.hub._base_url.clone()
25040 + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences";
25041 if self._scopes.is_empty() {
25042 self._scopes.insert(Scope::Edit.as_ref().to_string());
25043 }
25044
25045 #[allow(clippy::single_element_loop)]
25046 for &(find_this, param_name) in [
25047 ("{accountId}", "accountId"),
25048 ("{webPropertyId}", "webPropertyId"),
25049 ]
25050 .iter()
25051 {
25052 url = params.uri_replacement(url, param_name, find_this, false);
25053 }
25054 {
25055 let to_remove = ["webPropertyId", "accountId"];
25056 params.remove_params(&to_remove);
25057 }
25058
25059 let url = params.parse_with_url(&url);
25060
25061 let mut json_mime_type = mime::APPLICATION_JSON;
25062 let mut request_value_reader = {
25063 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25064 common::remove_json_null_values(&mut value);
25065 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25066 serde_json::to_writer(&mut dst, &value).unwrap();
25067 dst
25068 };
25069 let request_size = request_value_reader
25070 .seek(std::io::SeekFrom::End(0))
25071 .unwrap();
25072 request_value_reader
25073 .seek(std::io::SeekFrom::Start(0))
25074 .unwrap();
25075
25076 loop {
25077 let token = match self
25078 .hub
25079 .auth
25080 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25081 .await
25082 {
25083 Ok(token) => token,
25084 Err(e) => match dlg.token(e) {
25085 Ok(token) => token,
25086 Err(e) => {
25087 dlg.finished(false);
25088 return Err(common::Error::MissingToken(e));
25089 }
25090 },
25091 };
25092 request_value_reader
25093 .seek(std::io::SeekFrom::Start(0))
25094 .unwrap();
25095 let mut req_result = {
25096 let client = &self.hub.client;
25097 dlg.pre_request();
25098 let mut req_builder = hyper::Request::builder()
25099 .method(hyper::Method::POST)
25100 .uri(url.as_str())
25101 .header(USER_AGENT, self.hub._user_agent.clone());
25102
25103 if let Some(token) = token.as_ref() {
25104 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25105 }
25106
25107 let request = req_builder
25108 .header(CONTENT_TYPE, json_mime_type.to_string())
25109 .header(CONTENT_LENGTH, request_size as u64)
25110 .body(common::to_body(
25111 request_value_reader.get_ref().clone().into(),
25112 ));
25113
25114 client.request(request.unwrap()).await
25115 };
25116
25117 match req_result {
25118 Err(err) => {
25119 if let common::Retry::After(d) = dlg.http_error(&err) {
25120 sleep(d).await;
25121 continue;
25122 }
25123 dlg.finished(false);
25124 return Err(common::Error::HttpError(err));
25125 }
25126 Ok(res) => {
25127 let (mut parts, body) = res.into_parts();
25128 let mut body = common::Body::new(body);
25129 if !parts.status.is_success() {
25130 let bytes = common::to_bytes(body).await.unwrap_or_default();
25131 let error = serde_json::from_str(&common::to_string(&bytes));
25132 let response = common::to_response(parts, bytes.into());
25133
25134 if let common::Retry::After(d) =
25135 dlg.http_failure(&response, error.as_ref().ok())
25136 {
25137 sleep(d).await;
25138 continue;
25139 }
25140
25141 dlg.finished(false);
25142
25143 return Err(match error {
25144 Ok(value) => common::Error::BadRequest(value),
25145 _ => common::Error::Failure(response),
25146 });
25147 }
25148 let response = {
25149 let bytes = common::to_bytes(body).await.unwrap_or_default();
25150 let encoded = common::to_string(&bytes);
25151 match serde_json::from_str(&encoded) {
25152 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25153 Err(error) => {
25154 dlg.response_json_decode_error(&encoded, &error);
25155 return Err(common::Error::JsonDecodeError(
25156 encoded.to_string(),
25157 error,
25158 ));
25159 }
25160 }
25161 };
25162
25163 dlg.finished(true);
25164 return Ok(response);
25165 }
25166 }
25167 }
25168 }
25169
25170 ///
25171 /// Sets the *request* property to the given value.
25172 ///
25173 /// Even though the property as already been set when instantiating this call,
25174 /// we provide this method for API completeness.
25175 pub fn request(
25176 mut self,
25177 new_value: RemarketingAudience,
25178 ) -> ManagementRemarketingAudienceInsertCall<'a, C> {
25179 self._request = new_value;
25180 self
25181 }
25182 /// The account ID for which to create the remarketing audience.
25183 ///
25184 /// Sets the *account id* path property to the given value.
25185 ///
25186 /// Even though the property as already been set when instantiating this call,
25187 /// we provide this method for API completeness.
25188 pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceInsertCall<'a, C> {
25189 self._account_id = new_value.to_string();
25190 self
25191 }
25192 /// Web property ID for which to create the remarketing audience.
25193 ///
25194 /// Sets the *web property id* path property to the given value.
25195 ///
25196 /// Even though the property as already been set when instantiating this call,
25197 /// we provide this method for API completeness.
25198 pub fn web_property_id(
25199 mut self,
25200 new_value: &str,
25201 ) -> ManagementRemarketingAudienceInsertCall<'a, C> {
25202 self._web_property_id = new_value.to_string();
25203 self
25204 }
25205 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25206 /// while executing the actual API request.
25207 ///
25208 /// ````text
25209 /// It should be used to handle progress information, and to implement a certain level of resilience.
25210 /// ````
25211 ///
25212 /// Sets the *delegate* property to the given value.
25213 pub fn delegate(
25214 mut self,
25215 new_value: &'a mut dyn common::Delegate,
25216 ) -> ManagementRemarketingAudienceInsertCall<'a, C> {
25217 self._delegate = Some(new_value);
25218 self
25219 }
25220
25221 /// Set any additional parameter of the query string used in the request.
25222 /// It should be used to set parameters which are not yet available through their own
25223 /// setters.
25224 ///
25225 /// Please note that this method must not be used to set any of the known parameters
25226 /// which have their own setter method. If done anyway, the request will fail.
25227 ///
25228 /// # Additional Parameters
25229 ///
25230 /// * *alt* (query-string) - Data format for the response.
25231 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25232 /// * *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.
25233 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25234 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25235 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25236 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25237 pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudienceInsertCall<'a, C>
25238 where
25239 T: AsRef<str>,
25240 {
25241 self._additional_params
25242 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25243 self
25244 }
25245
25246 /// Identifies the authorization scope for the method you are building.
25247 ///
25248 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25249 /// [`Scope::Edit`].
25250 ///
25251 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25252 /// tokens for more than one scope.
25253 ///
25254 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25255 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25256 /// sufficient, a read-write scope will do as well.
25257 pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudienceInsertCall<'a, C>
25258 where
25259 St: AsRef<str>,
25260 {
25261 self._scopes.insert(String::from(scope.as_ref()));
25262 self
25263 }
25264 /// Identifies the authorization scope(s) for the method you are building.
25265 ///
25266 /// See [`Self::add_scope()`] for details.
25267 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudienceInsertCall<'a, C>
25268 where
25269 I: IntoIterator<Item = St>,
25270 St: AsRef<str>,
25271 {
25272 self._scopes
25273 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25274 self
25275 }
25276
25277 /// Removes all scopes, and no default scope will be used either.
25278 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25279 /// for details).
25280 pub fn clear_scopes(mut self) -> ManagementRemarketingAudienceInsertCall<'a, C> {
25281 self._scopes.clear();
25282 self
25283 }
25284}
25285
25286/// Lists remarketing audiences to which the user has access.
25287///
25288/// A builder for the *remarketingAudience.list* method supported by a *management* resource.
25289/// It is not used directly, but through a [`ManagementMethods`] instance.
25290///
25291/// # Example
25292///
25293/// Instantiate a resource method builder
25294///
25295/// ```test_harness,no_run
25296/// # extern crate hyper;
25297/// # extern crate hyper_rustls;
25298/// # extern crate google_analytics3 as analytics3;
25299/// # async fn dox() {
25300/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25301///
25302/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25303/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25304/// # secret,
25305/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25306/// # ).build().await.unwrap();
25307///
25308/// # let client = hyper_util::client::legacy::Client::builder(
25309/// # hyper_util::rt::TokioExecutor::new()
25310/// # )
25311/// # .build(
25312/// # hyper_rustls::HttpsConnectorBuilder::new()
25313/// # .with_native_roots()
25314/// # .unwrap()
25315/// # .https_or_http()
25316/// # .enable_http1()
25317/// # .build()
25318/// # );
25319/// # let mut hub = Analytics::new(client, auth);
25320/// // You can configure optional parameters by calling the respective setters at will, and
25321/// // execute the final call using `doit()`.
25322/// // Values shown here are possibly random and not representative !
25323/// let result = hub.management().remarketing_audience_list("accountId", "webPropertyId")
25324/// .type_("eos")
25325/// .start_index(-52)
25326/// .max_results(-84)
25327/// .doit().await;
25328/// # }
25329/// ```
25330pub struct ManagementRemarketingAudienceListCall<'a, C>
25331where
25332 C: 'a,
25333{
25334 hub: &'a Analytics<C>,
25335 _account_id: String,
25336 _web_property_id: String,
25337 _type_: Option<String>,
25338 _start_index: Option<i32>,
25339 _max_results: Option<i32>,
25340 _delegate: Option<&'a mut dyn common::Delegate>,
25341 _additional_params: HashMap<String, String>,
25342 _scopes: BTreeSet<String>,
25343}
25344
25345impl<'a, C> common::CallBuilder for ManagementRemarketingAudienceListCall<'a, C> {}
25346
25347impl<'a, C> ManagementRemarketingAudienceListCall<'a, C>
25348where
25349 C: common::Connector,
25350{
25351 /// Perform the operation you have build so far.
25352 pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingAudiences)> {
25353 use std::borrow::Cow;
25354 use std::io::{Read, Seek};
25355
25356 use common::{url::Params, ToParts};
25357 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25358
25359 let mut dd = common::DefaultDelegate;
25360 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25361 dlg.begin(common::MethodInfo {
25362 id: "analytics.management.remarketingAudience.list",
25363 http_method: hyper::Method::GET,
25364 });
25365
25366 for &field in [
25367 "alt",
25368 "accountId",
25369 "webPropertyId",
25370 "type",
25371 "start-index",
25372 "max-results",
25373 ]
25374 .iter()
25375 {
25376 if self._additional_params.contains_key(field) {
25377 dlg.finished(false);
25378 return Err(common::Error::FieldClash(field));
25379 }
25380 }
25381
25382 let mut params = Params::with_capacity(7 + self._additional_params.len());
25383 params.push("accountId", self._account_id);
25384 params.push("webPropertyId", self._web_property_id);
25385 if let Some(value) = self._type_.as_ref() {
25386 params.push("type", value);
25387 }
25388 if let Some(value) = self._start_index.as_ref() {
25389 params.push("start-index", value.to_string());
25390 }
25391 if let Some(value) = self._max_results.as_ref() {
25392 params.push("max-results", value.to_string());
25393 }
25394
25395 params.extend(self._additional_params.iter());
25396
25397 params.push("alt", "json");
25398 let mut url = self.hub._base_url.clone()
25399 + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences";
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 ]
25409 .iter()
25410 {
25411 url = params.uri_replacement(url, param_name, find_this, false);
25412 }
25413 {
25414 let to_remove = ["webPropertyId", "accountId"];
25415 params.remove_params(&to_remove);
25416 }
25417
25418 let url = params.parse_with_url(&url);
25419
25420 loop {
25421 let token = match self
25422 .hub
25423 .auth
25424 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25425 .await
25426 {
25427 Ok(token) => token,
25428 Err(e) => match dlg.token(e) {
25429 Ok(token) => token,
25430 Err(e) => {
25431 dlg.finished(false);
25432 return Err(common::Error::MissingToken(e));
25433 }
25434 },
25435 };
25436 let mut req_result = {
25437 let client = &self.hub.client;
25438 dlg.pre_request();
25439 let mut req_builder = hyper::Request::builder()
25440 .method(hyper::Method::GET)
25441 .uri(url.as_str())
25442 .header(USER_AGENT, self.hub._user_agent.clone());
25443
25444 if let Some(token) = token.as_ref() {
25445 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25446 }
25447
25448 let request = req_builder
25449 .header(CONTENT_LENGTH, 0_u64)
25450 .body(common::to_body::<String>(None));
25451
25452 client.request(request.unwrap()).await
25453 };
25454
25455 match req_result {
25456 Err(err) => {
25457 if let common::Retry::After(d) = dlg.http_error(&err) {
25458 sleep(d).await;
25459 continue;
25460 }
25461 dlg.finished(false);
25462 return Err(common::Error::HttpError(err));
25463 }
25464 Ok(res) => {
25465 let (mut parts, body) = res.into_parts();
25466 let mut body = common::Body::new(body);
25467 if !parts.status.is_success() {
25468 let bytes = common::to_bytes(body).await.unwrap_or_default();
25469 let error = serde_json::from_str(&common::to_string(&bytes));
25470 let response = common::to_response(parts, bytes.into());
25471
25472 if let common::Retry::After(d) =
25473 dlg.http_failure(&response, error.as_ref().ok())
25474 {
25475 sleep(d).await;
25476 continue;
25477 }
25478
25479 dlg.finished(false);
25480
25481 return Err(match error {
25482 Ok(value) => common::Error::BadRequest(value),
25483 _ => common::Error::Failure(response),
25484 });
25485 }
25486 let response = {
25487 let bytes = common::to_bytes(body).await.unwrap_or_default();
25488 let encoded = common::to_string(&bytes);
25489 match serde_json::from_str(&encoded) {
25490 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25491 Err(error) => {
25492 dlg.response_json_decode_error(&encoded, &error);
25493 return Err(common::Error::JsonDecodeError(
25494 encoded.to_string(),
25495 error,
25496 ));
25497 }
25498 }
25499 };
25500
25501 dlg.finished(true);
25502 return Ok(response);
25503 }
25504 }
25505 }
25506 }
25507
25508 /// The account ID of the remarketing audiences to retrieve.
25509 ///
25510 /// Sets the *account id* path property to the given value.
25511 ///
25512 /// Even though the property as already been set when instantiating this call,
25513 /// we provide this method for API completeness.
25514 pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceListCall<'a, C> {
25515 self._account_id = new_value.to_string();
25516 self
25517 }
25518 /// The web property ID of the remarketing audiences to retrieve.
25519 ///
25520 /// Sets the *web property id* path property to the given value.
25521 ///
25522 /// Even though the property as already been set when instantiating this call,
25523 /// we provide this method for API completeness.
25524 pub fn web_property_id(
25525 mut self,
25526 new_value: &str,
25527 ) -> ManagementRemarketingAudienceListCall<'a, C> {
25528 self._web_property_id = new_value.to_string();
25529 self
25530 }
25531 ///
25532 /// Sets the *type* query property to the given value.
25533 pub fn type_(mut self, new_value: &str) -> ManagementRemarketingAudienceListCall<'a, C> {
25534 self._type_ = Some(new_value.to_string());
25535 self
25536 }
25537 /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
25538 ///
25539 /// Sets the *start-index* query property to the given value.
25540 pub fn start_index(mut self, new_value: i32) -> ManagementRemarketingAudienceListCall<'a, C> {
25541 self._start_index = Some(new_value);
25542 self
25543 }
25544 /// The maximum number of remarketing audiences to include in this response.
25545 ///
25546 /// Sets the *max-results* query property to the given value.
25547 pub fn max_results(mut self, new_value: i32) -> ManagementRemarketingAudienceListCall<'a, C> {
25548 self._max_results = Some(new_value);
25549 self
25550 }
25551 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25552 /// while executing the actual API request.
25553 ///
25554 /// ````text
25555 /// It should be used to handle progress information, and to implement a certain level of resilience.
25556 /// ````
25557 ///
25558 /// Sets the *delegate* property to the given value.
25559 pub fn delegate(
25560 mut self,
25561 new_value: &'a mut dyn common::Delegate,
25562 ) -> ManagementRemarketingAudienceListCall<'a, C> {
25563 self._delegate = Some(new_value);
25564 self
25565 }
25566
25567 /// Set any additional parameter of the query string used in the request.
25568 /// It should be used to set parameters which are not yet available through their own
25569 /// setters.
25570 ///
25571 /// Please note that this method must not be used to set any of the known parameters
25572 /// which have their own setter method. If done anyway, the request will fail.
25573 ///
25574 /// # Additional Parameters
25575 ///
25576 /// * *alt* (query-string) - Data format for the response.
25577 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25578 /// * *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.
25579 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25580 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25581 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25582 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25583 pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudienceListCall<'a, C>
25584 where
25585 T: AsRef<str>,
25586 {
25587 self._additional_params
25588 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25589 self
25590 }
25591
25592 /// Identifies the authorization scope for the method you are building.
25593 ///
25594 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25595 /// [`Scope::Readonly`].
25596 ///
25597 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25598 /// tokens for more than one scope.
25599 ///
25600 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25601 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25602 /// sufficient, a read-write scope will do as well.
25603 pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudienceListCall<'a, C>
25604 where
25605 St: AsRef<str>,
25606 {
25607 self._scopes.insert(String::from(scope.as_ref()));
25608 self
25609 }
25610 /// Identifies the authorization scope(s) for the method you are building.
25611 ///
25612 /// See [`Self::add_scope()`] for details.
25613 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudienceListCall<'a, C>
25614 where
25615 I: IntoIterator<Item = St>,
25616 St: AsRef<str>,
25617 {
25618 self._scopes
25619 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25620 self
25621 }
25622
25623 /// Removes all scopes, and no default scope will be used either.
25624 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25625 /// for details).
25626 pub fn clear_scopes(mut self) -> ManagementRemarketingAudienceListCall<'a, C> {
25627 self._scopes.clear();
25628 self
25629 }
25630}
25631
25632/// Updates an existing remarketing audience. This method supports patch semantics.
25633///
25634/// A builder for the *remarketingAudience.patch* method supported by a *management* resource.
25635/// It is not used directly, but through a [`ManagementMethods`] instance.
25636///
25637/// # Example
25638///
25639/// Instantiate a resource method builder
25640///
25641/// ```test_harness,no_run
25642/// # extern crate hyper;
25643/// # extern crate hyper_rustls;
25644/// # extern crate google_analytics3 as analytics3;
25645/// use analytics3::api::RemarketingAudience;
25646/// # async fn dox() {
25647/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25648///
25649/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25650/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25651/// # secret,
25652/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25653/// # ).build().await.unwrap();
25654///
25655/// # let client = hyper_util::client::legacy::Client::builder(
25656/// # hyper_util::rt::TokioExecutor::new()
25657/// # )
25658/// # .build(
25659/// # hyper_rustls::HttpsConnectorBuilder::new()
25660/// # .with_native_roots()
25661/// # .unwrap()
25662/// # .https_or_http()
25663/// # .enable_http1()
25664/// # .build()
25665/// # );
25666/// # let mut hub = Analytics::new(client, auth);
25667/// // As the method needs a request, you would usually fill it with the desired information
25668/// // into the respective structure. Some of the parts shown here might not be applicable !
25669/// // Values shown here are possibly random and not representative !
25670/// let mut req = RemarketingAudience::default();
25671///
25672/// // You can configure optional parameters by calling the respective setters at will, and
25673/// // execute the final call using `doit()`.
25674/// // Values shown here are possibly random and not representative !
25675/// let result = hub.management().remarketing_audience_patch(req, "accountId", "webPropertyId", "remarketingAudienceId")
25676/// .doit().await;
25677/// # }
25678/// ```
25679pub struct ManagementRemarketingAudiencePatchCall<'a, C>
25680where
25681 C: 'a,
25682{
25683 hub: &'a Analytics<C>,
25684 _request: RemarketingAudience,
25685 _account_id: String,
25686 _web_property_id: String,
25687 _remarketing_audience_id: String,
25688 _delegate: Option<&'a mut dyn common::Delegate>,
25689 _additional_params: HashMap<String, String>,
25690 _scopes: BTreeSet<String>,
25691}
25692
25693impl<'a, C> common::CallBuilder for ManagementRemarketingAudiencePatchCall<'a, C> {}
25694
25695impl<'a, C> ManagementRemarketingAudiencePatchCall<'a, C>
25696where
25697 C: common::Connector,
25698{
25699 /// Perform the operation you have build so far.
25700 pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingAudience)> {
25701 use std::borrow::Cow;
25702 use std::io::{Read, Seek};
25703
25704 use common::{url::Params, ToParts};
25705 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25706
25707 let mut dd = common::DefaultDelegate;
25708 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25709 dlg.begin(common::MethodInfo {
25710 id: "analytics.management.remarketingAudience.patch",
25711 http_method: hyper::Method::PATCH,
25712 });
25713
25714 for &field in ["alt", "accountId", "webPropertyId", "remarketingAudienceId"].iter() {
25715 if self._additional_params.contains_key(field) {
25716 dlg.finished(false);
25717 return Err(common::Error::FieldClash(field));
25718 }
25719 }
25720
25721 let mut params = Params::with_capacity(6 + self._additional_params.len());
25722 params.push("accountId", self._account_id);
25723 params.push("webPropertyId", self._web_property_id);
25724 params.push("remarketingAudienceId", self._remarketing_audience_id);
25725
25726 params.extend(self._additional_params.iter());
25727
25728 params.push("alt", "json");
25729 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}";
25730 if self._scopes.is_empty() {
25731 self._scopes.insert(Scope::Edit.as_ref().to_string());
25732 }
25733
25734 #[allow(clippy::single_element_loop)]
25735 for &(find_this, param_name) in [
25736 ("{accountId}", "accountId"),
25737 ("{webPropertyId}", "webPropertyId"),
25738 ("{remarketingAudienceId}", "remarketingAudienceId"),
25739 ]
25740 .iter()
25741 {
25742 url = params.uri_replacement(url, param_name, find_this, false);
25743 }
25744 {
25745 let to_remove = ["remarketingAudienceId", "webPropertyId", "accountId"];
25746 params.remove_params(&to_remove);
25747 }
25748
25749 let url = params.parse_with_url(&url);
25750
25751 let mut json_mime_type = mime::APPLICATION_JSON;
25752 let mut request_value_reader = {
25753 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25754 common::remove_json_null_values(&mut value);
25755 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25756 serde_json::to_writer(&mut dst, &value).unwrap();
25757 dst
25758 };
25759 let request_size = request_value_reader
25760 .seek(std::io::SeekFrom::End(0))
25761 .unwrap();
25762 request_value_reader
25763 .seek(std::io::SeekFrom::Start(0))
25764 .unwrap();
25765
25766 loop {
25767 let token = match self
25768 .hub
25769 .auth
25770 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25771 .await
25772 {
25773 Ok(token) => token,
25774 Err(e) => match dlg.token(e) {
25775 Ok(token) => token,
25776 Err(e) => {
25777 dlg.finished(false);
25778 return Err(common::Error::MissingToken(e));
25779 }
25780 },
25781 };
25782 request_value_reader
25783 .seek(std::io::SeekFrom::Start(0))
25784 .unwrap();
25785 let mut req_result = {
25786 let client = &self.hub.client;
25787 dlg.pre_request();
25788 let mut req_builder = hyper::Request::builder()
25789 .method(hyper::Method::PATCH)
25790 .uri(url.as_str())
25791 .header(USER_AGENT, self.hub._user_agent.clone());
25792
25793 if let Some(token) = token.as_ref() {
25794 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25795 }
25796
25797 let request = req_builder
25798 .header(CONTENT_TYPE, json_mime_type.to_string())
25799 .header(CONTENT_LENGTH, request_size as u64)
25800 .body(common::to_body(
25801 request_value_reader.get_ref().clone().into(),
25802 ));
25803
25804 client.request(request.unwrap()).await
25805 };
25806
25807 match req_result {
25808 Err(err) => {
25809 if let common::Retry::After(d) = dlg.http_error(&err) {
25810 sleep(d).await;
25811 continue;
25812 }
25813 dlg.finished(false);
25814 return Err(common::Error::HttpError(err));
25815 }
25816 Ok(res) => {
25817 let (mut parts, body) = res.into_parts();
25818 let mut body = common::Body::new(body);
25819 if !parts.status.is_success() {
25820 let bytes = common::to_bytes(body).await.unwrap_or_default();
25821 let error = serde_json::from_str(&common::to_string(&bytes));
25822 let response = common::to_response(parts, bytes.into());
25823
25824 if let common::Retry::After(d) =
25825 dlg.http_failure(&response, error.as_ref().ok())
25826 {
25827 sleep(d).await;
25828 continue;
25829 }
25830
25831 dlg.finished(false);
25832
25833 return Err(match error {
25834 Ok(value) => common::Error::BadRequest(value),
25835 _ => common::Error::Failure(response),
25836 });
25837 }
25838 let response = {
25839 let bytes = common::to_bytes(body).await.unwrap_or_default();
25840 let encoded = common::to_string(&bytes);
25841 match serde_json::from_str(&encoded) {
25842 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25843 Err(error) => {
25844 dlg.response_json_decode_error(&encoded, &error);
25845 return Err(common::Error::JsonDecodeError(
25846 encoded.to_string(),
25847 error,
25848 ));
25849 }
25850 }
25851 };
25852
25853 dlg.finished(true);
25854 return Ok(response);
25855 }
25856 }
25857 }
25858 }
25859
25860 ///
25861 /// Sets the *request* property to the given value.
25862 ///
25863 /// Even though the property as already been set when instantiating this call,
25864 /// we provide this method for API completeness.
25865 pub fn request(
25866 mut self,
25867 new_value: RemarketingAudience,
25868 ) -> ManagementRemarketingAudiencePatchCall<'a, C> {
25869 self._request = new_value;
25870 self
25871 }
25872 /// The account ID of the remarketing audience to update.
25873 ///
25874 /// Sets the *account id* path property to the given value.
25875 ///
25876 /// Even though the property as already been set when instantiating this call,
25877 /// we provide this method for API completeness.
25878 pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudiencePatchCall<'a, C> {
25879 self._account_id = new_value.to_string();
25880 self
25881 }
25882 /// The web property ID of the remarketing audience to update.
25883 ///
25884 /// Sets the *web property id* path property to the given value.
25885 ///
25886 /// Even though the property as already been set when instantiating this call,
25887 /// we provide this method for API completeness.
25888 pub fn web_property_id(
25889 mut self,
25890 new_value: &str,
25891 ) -> ManagementRemarketingAudiencePatchCall<'a, C> {
25892 self._web_property_id = new_value.to_string();
25893 self
25894 }
25895 /// The ID of the remarketing audience to update.
25896 ///
25897 /// Sets the *remarketing audience id* path property to the given value.
25898 ///
25899 /// Even though the property as already been set when instantiating this call,
25900 /// we provide this method for API completeness.
25901 pub fn remarketing_audience_id(
25902 mut self,
25903 new_value: &str,
25904 ) -> ManagementRemarketingAudiencePatchCall<'a, C> {
25905 self._remarketing_audience_id = new_value.to_string();
25906 self
25907 }
25908 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25909 /// while executing the actual API request.
25910 ///
25911 /// ````text
25912 /// It should be used to handle progress information, and to implement a certain level of resilience.
25913 /// ````
25914 ///
25915 /// Sets the *delegate* property to the given value.
25916 pub fn delegate(
25917 mut self,
25918 new_value: &'a mut dyn common::Delegate,
25919 ) -> ManagementRemarketingAudiencePatchCall<'a, C> {
25920 self._delegate = Some(new_value);
25921 self
25922 }
25923
25924 /// Set any additional parameter of the query string used in the request.
25925 /// It should be used to set parameters which are not yet available through their own
25926 /// setters.
25927 ///
25928 /// Please note that this method must not be used to set any of the known parameters
25929 /// which have their own setter method. If done anyway, the request will fail.
25930 ///
25931 /// # Additional Parameters
25932 ///
25933 /// * *alt* (query-string) - Data format for the response.
25934 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25935 /// * *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.
25936 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25937 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25938 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25939 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25940 pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudiencePatchCall<'a, C>
25941 where
25942 T: AsRef<str>,
25943 {
25944 self._additional_params
25945 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25946 self
25947 }
25948
25949 /// Identifies the authorization scope for the method you are building.
25950 ///
25951 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25952 /// [`Scope::Edit`].
25953 ///
25954 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25955 /// tokens for more than one scope.
25956 ///
25957 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25958 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25959 /// sufficient, a read-write scope will do as well.
25960 pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudiencePatchCall<'a, C>
25961 where
25962 St: AsRef<str>,
25963 {
25964 self._scopes.insert(String::from(scope.as_ref()));
25965 self
25966 }
25967 /// Identifies the authorization scope(s) for the method you are building.
25968 ///
25969 /// See [`Self::add_scope()`] for details.
25970 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudiencePatchCall<'a, C>
25971 where
25972 I: IntoIterator<Item = St>,
25973 St: AsRef<str>,
25974 {
25975 self._scopes
25976 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25977 self
25978 }
25979
25980 /// Removes all scopes, and no default scope will be used either.
25981 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25982 /// for details).
25983 pub fn clear_scopes(mut self) -> ManagementRemarketingAudiencePatchCall<'a, C> {
25984 self._scopes.clear();
25985 self
25986 }
25987}
25988
25989/// Updates an existing remarketing audience.
25990///
25991/// A builder for the *remarketingAudience.update* method supported by a *management* resource.
25992/// It is not used directly, but through a [`ManagementMethods`] instance.
25993///
25994/// # Example
25995///
25996/// Instantiate a resource method builder
25997///
25998/// ```test_harness,no_run
25999/// # extern crate hyper;
26000/// # extern crate hyper_rustls;
26001/// # extern crate google_analytics3 as analytics3;
26002/// use analytics3::api::RemarketingAudience;
26003/// # async fn dox() {
26004/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26005///
26006/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26007/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26008/// # secret,
26009/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
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_http1()
26021/// # .build()
26022/// # );
26023/// # let mut hub = Analytics::new(client, auth);
26024/// // As the method needs a request, you would usually fill it with the desired information
26025/// // into the respective structure. Some of the parts shown here might not be applicable !
26026/// // Values shown here are possibly random and not representative !
26027/// let mut req = RemarketingAudience::default();
26028///
26029/// // You can configure optional parameters by calling the respective setters at will, and
26030/// // execute the final call using `doit()`.
26031/// // Values shown here are possibly random and not representative !
26032/// let result = hub.management().remarketing_audience_update(req, "accountId", "webPropertyId", "remarketingAudienceId")
26033/// .doit().await;
26034/// # }
26035/// ```
26036pub struct ManagementRemarketingAudienceUpdateCall<'a, C>
26037where
26038 C: 'a,
26039{
26040 hub: &'a Analytics<C>,
26041 _request: RemarketingAudience,
26042 _account_id: String,
26043 _web_property_id: String,
26044 _remarketing_audience_id: String,
26045 _delegate: Option<&'a mut dyn common::Delegate>,
26046 _additional_params: HashMap<String, String>,
26047 _scopes: BTreeSet<String>,
26048}
26049
26050impl<'a, C> common::CallBuilder for ManagementRemarketingAudienceUpdateCall<'a, C> {}
26051
26052impl<'a, C> ManagementRemarketingAudienceUpdateCall<'a, C>
26053where
26054 C: common::Connector,
26055{
26056 /// Perform the operation you have build so far.
26057 pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingAudience)> {
26058 use std::borrow::Cow;
26059 use std::io::{Read, Seek};
26060
26061 use common::{url::Params, ToParts};
26062 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26063
26064 let mut dd = common::DefaultDelegate;
26065 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26066 dlg.begin(common::MethodInfo {
26067 id: "analytics.management.remarketingAudience.update",
26068 http_method: hyper::Method::PUT,
26069 });
26070
26071 for &field in ["alt", "accountId", "webPropertyId", "remarketingAudienceId"].iter() {
26072 if self._additional_params.contains_key(field) {
26073 dlg.finished(false);
26074 return Err(common::Error::FieldClash(field));
26075 }
26076 }
26077
26078 let mut params = Params::with_capacity(6 + self._additional_params.len());
26079 params.push("accountId", self._account_id);
26080 params.push("webPropertyId", self._web_property_id);
26081 params.push("remarketingAudienceId", self._remarketing_audience_id);
26082
26083 params.extend(self._additional_params.iter());
26084
26085 params.push("alt", "json");
26086 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/remarketingAudiences/{remarketingAudienceId}";
26087 if self._scopes.is_empty() {
26088 self._scopes.insert(Scope::Edit.as_ref().to_string());
26089 }
26090
26091 #[allow(clippy::single_element_loop)]
26092 for &(find_this, param_name) in [
26093 ("{accountId}", "accountId"),
26094 ("{webPropertyId}", "webPropertyId"),
26095 ("{remarketingAudienceId}", "remarketingAudienceId"),
26096 ]
26097 .iter()
26098 {
26099 url = params.uri_replacement(url, param_name, find_this, false);
26100 }
26101 {
26102 let to_remove = ["remarketingAudienceId", "webPropertyId", "accountId"];
26103 params.remove_params(&to_remove);
26104 }
26105
26106 let url = params.parse_with_url(&url);
26107
26108 let mut json_mime_type = mime::APPLICATION_JSON;
26109 let mut request_value_reader = {
26110 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26111 common::remove_json_null_values(&mut value);
26112 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26113 serde_json::to_writer(&mut dst, &value).unwrap();
26114 dst
26115 };
26116 let request_size = request_value_reader
26117 .seek(std::io::SeekFrom::End(0))
26118 .unwrap();
26119 request_value_reader
26120 .seek(std::io::SeekFrom::Start(0))
26121 .unwrap();
26122
26123 loop {
26124 let token = match self
26125 .hub
26126 .auth
26127 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26128 .await
26129 {
26130 Ok(token) => token,
26131 Err(e) => match dlg.token(e) {
26132 Ok(token) => token,
26133 Err(e) => {
26134 dlg.finished(false);
26135 return Err(common::Error::MissingToken(e));
26136 }
26137 },
26138 };
26139 request_value_reader
26140 .seek(std::io::SeekFrom::Start(0))
26141 .unwrap();
26142 let mut req_result = {
26143 let client = &self.hub.client;
26144 dlg.pre_request();
26145 let mut req_builder = hyper::Request::builder()
26146 .method(hyper::Method::PUT)
26147 .uri(url.as_str())
26148 .header(USER_AGENT, self.hub._user_agent.clone());
26149
26150 if let Some(token) = token.as_ref() {
26151 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26152 }
26153
26154 let request = req_builder
26155 .header(CONTENT_TYPE, json_mime_type.to_string())
26156 .header(CONTENT_LENGTH, request_size as u64)
26157 .body(common::to_body(
26158 request_value_reader.get_ref().clone().into(),
26159 ));
26160
26161 client.request(request.unwrap()).await
26162 };
26163
26164 match req_result {
26165 Err(err) => {
26166 if let common::Retry::After(d) = dlg.http_error(&err) {
26167 sleep(d).await;
26168 continue;
26169 }
26170 dlg.finished(false);
26171 return Err(common::Error::HttpError(err));
26172 }
26173 Ok(res) => {
26174 let (mut parts, body) = res.into_parts();
26175 let mut body = common::Body::new(body);
26176 if !parts.status.is_success() {
26177 let bytes = common::to_bytes(body).await.unwrap_or_default();
26178 let error = serde_json::from_str(&common::to_string(&bytes));
26179 let response = common::to_response(parts, bytes.into());
26180
26181 if let common::Retry::After(d) =
26182 dlg.http_failure(&response, error.as_ref().ok())
26183 {
26184 sleep(d).await;
26185 continue;
26186 }
26187
26188 dlg.finished(false);
26189
26190 return Err(match error {
26191 Ok(value) => common::Error::BadRequest(value),
26192 _ => common::Error::Failure(response),
26193 });
26194 }
26195 let response = {
26196 let bytes = common::to_bytes(body).await.unwrap_or_default();
26197 let encoded = common::to_string(&bytes);
26198 match serde_json::from_str(&encoded) {
26199 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26200 Err(error) => {
26201 dlg.response_json_decode_error(&encoded, &error);
26202 return Err(common::Error::JsonDecodeError(
26203 encoded.to_string(),
26204 error,
26205 ));
26206 }
26207 }
26208 };
26209
26210 dlg.finished(true);
26211 return Ok(response);
26212 }
26213 }
26214 }
26215 }
26216
26217 ///
26218 /// Sets the *request* property to the given value.
26219 ///
26220 /// Even though the property as already been set when instantiating this call,
26221 /// we provide this method for API completeness.
26222 pub fn request(
26223 mut self,
26224 new_value: RemarketingAudience,
26225 ) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
26226 self._request = new_value;
26227 self
26228 }
26229 /// The account ID of the remarketing audience to update.
26230 ///
26231 /// Sets the *account id* path property to the given value.
26232 ///
26233 /// Even though the property as already been set when instantiating this call,
26234 /// we provide this method for API completeness.
26235 pub fn account_id(mut self, new_value: &str) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
26236 self._account_id = new_value.to_string();
26237 self
26238 }
26239 /// The web property ID of the remarketing audience to update.
26240 ///
26241 /// Sets the *web property id* path property to the given value.
26242 ///
26243 /// Even though the property as already been set when instantiating this call,
26244 /// we provide this method for API completeness.
26245 pub fn web_property_id(
26246 mut self,
26247 new_value: &str,
26248 ) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
26249 self._web_property_id = new_value.to_string();
26250 self
26251 }
26252 /// The ID of the remarketing audience to update.
26253 ///
26254 /// Sets the *remarketing audience id* path property to the given value.
26255 ///
26256 /// Even though the property as already been set when instantiating this call,
26257 /// we provide this method for API completeness.
26258 pub fn remarketing_audience_id(
26259 mut self,
26260 new_value: &str,
26261 ) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
26262 self._remarketing_audience_id = new_value.to_string();
26263 self
26264 }
26265 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26266 /// while executing the actual API request.
26267 ///
26268 /// ````text
26269 /// It should be used to handle progress information, and to implement a certain level of resilience.
26270 /// ````
26271 ///
26272 /// Sets the *delegate* property to the given value.
26273 pub fn delegate(
26274 mut self,
26275 new_value: &'a mut dyn common::Delegate,
26276 ) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
26277 self._delegate = Some(new_value);
26278 self
26279 }
26280
26281 /// Set any additional parameter of the query string used in the request.
26282 /// It should be used to set parameters which are not yet available through their own
26283 /// setters.
26284 ///
26285 /// Please note that this method must not be used to set any of the known parameters
26286 /// which have their own setter method. If done anyway, the request will fail.
26287 ///
26288 /// # Additional Parameters
26289 ///
26290 /// * *alt* (query-string) - Data format for the response.
26291 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26292 /// * *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.
26293 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26294 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26295 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26296 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26297 pub fn param<T>(mut self, name: T, value: T) -> ManagementRemarketingAudienceUpdateCall<'a, C>
26298 where
26299 T: AsRef<str>,
26300 {
26301 self._additional_params
26302 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26303 self
26304 }
26305
26306 /// Identifies the authorization scope for the method you are building.
26307 ///
26308 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26309 /// [`Scope::Edit`].
26310 ///
26311 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26312 /// tokens for more than one scope.
26313 ///
26314 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26315 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26316 /// sufficient, a read-write scope will do as well.
26317 pub fn add_scope<St>(mut self, scope: St) -> ManagementRemarketingAudienceUpdateCall<'a, C>
26318 where
26319 St: AsRef<str>,
26320 {
26321 self._scopes.insert(String::from(scope.as_ref()));
26322 self
26323 }
26324 /// Identifies the authorization scope(s) for the method you are building.
26325 ///
26326 /// See [`Self::add_scope()`] for details.
26327 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementRemarketingAudienceUpdateCall<'a, C>
26328 where
26329 I: IntoIterator<Item = St>,
26330 St: AsRef<str>,
26331 {
26332 self._scopes
26333 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26334 self
26335 }
26336
26337 /// Removes all scopes, and no default scope will be used either.
26338 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26339 /// for details).
26340 pub fn clear_scopes(mut self) -> ManagementRemarketingAudienceUpdateCall<'a, C> {
26341 self._scopes.clear();
26342 self
26343 }
26344}
26345
26346/// Lists segments to which the user has access.
26347///
26348/// A builder for the *segments.list* method supported by a *management* resource.
26349/// It is not used directly, but through a [`ManagementMethods`] instance.
26350///
26351/// # Example
26352///
26353/// Instantiate a resource method builder
26354///
26355/// ```test_harness,no_run
26356/// # extern crate hyper;
26357/// # extern crate hyper_rustls;
26358/// # extern crate google_analytics3 as analytics3;
26359/// # async fn dox() {
26360/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26361///
26362/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26363/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26364/// # secret,
26365/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26366/// # ).build().await.unwrap();
26367///
26368/// # let client = hyper_util::client::legacy::Client::builder(
26369/// # hyper_util::rt::TokioExecutor::new()
26370/// # )
26371/// # .build(
26372/// # hyper_rustls::HttpsConnectorBuilder::new()
26373/// # .with_native_roots()
26374/// # .unwrap()
26375/// # .https_or_http()
26376/// # .enable_http1()
26377/// # .build()
26378/// # );
26379/// # let mut hub = Analytics::new(client, auth);
26380/// // You can configure optional parameters by calling the respective setters at will, and
26381/// // execute the final call using `doit()`.
26382/// // Values shown here are possibly random and not representative !
26383/// let result = hub.management().segments_list()
26384/// .start_index(-45)
26385/// .max_results(-87)
26386/// .doit().await;
26387/// # }
26388/// ```
26389pub struct ManagementSegmentListCall<'a, C>
26390where
26391 C: 'a,
26392{
26393 hub: &'a Analytics<C>,
26394 _start_index: Option<i32>,
26395 _max_results: Option<i32>,
26396 _delegate: Option<&'a mut dyn common::Delegate>,
26397 _additional_params: HashMap<String, String>,
26398 _scopes: BTreeSet<String>,
26399}
26400
26401impl<'a, C> common::CallBuilder for ManagementSegmentListCall<'a, C> {}
26402
26403impl<'a, C> ManagementSegmentListCall<'a, C>
26404where
26405 C: common::Connector,
26406{
26407 /// Perform the operation you have build so far.
26408 pub async fn doit(mut self) -> common::Result<(common::Response, Segments)> {
26409 use std::borrow::Cow;
26410 use std::io::{Read, Seek};
26411
26412 use common::{url::Params, ToParts};
26413 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26414
26415 let mut dd = common::DefaultDelegate;
26416 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26417 dlg.begin(common::MethodInfo {
26418 id: "analytics.management.segments.list",
26419 http_method: hyper::Method::GET,
26420 });
26421
26422 for &field in ["alt", "start-index", "max-results"].iter() {
26423 if self._additional_params.contains_key(field) {
26424 dlg.finished(false);
26425 return Err(common::Error::FieldClash(field));
26426 }
26427 }
26428
26429 let mut params = Params::with_capacity(4 + self._additional_params.len());
26430 if let Some(value) = self._start_index.as_ref() {
26431 params.push("start-index", value.to_string());
26432 }
26433 if let Some(value) = self._max_results.as_ref() {
26434 params.push("max-results", value.to_string());
26435 }
26436
26437 params.extend(self._additional_params.iter());
26438
26439 params.push("alt", "json");
26440 let mut url = self.hub._base_url.clone() + "management/segments";
26441 if self._scopes.is_empty() {
26442 self._scopes.insert(Scope::Readonly.as_ref().to_string());
26443 }
26444
26445 let url = params.parse_with_url(&url);
26446
26447 loop {
26448 let token = match self
26449 .hub
26450 .auth
26451 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26452 .await
26453 {
26454 Ok(token) => token,
26455 Err(e) => match dlg.token(e) {
26456 Ok(token) => token,
26457 Err(e) => {
26458 dlg.finished(false);
26459 return Err(common::Error::MissingToken(e));
26460 }
26461 },
26462 };
26463 let mut req_result = {
26464 let client = &self.hub.client;
26465 dlg.pre_request();
26466 let mut req_builder = hyper::Request::builder()
26467 .method(hyper::Method::GET)
26468 .uri(url.as_str())
26469 .header(USER_AGENT, self.hub._user_agent.clone());
26470
26471 if let Some(token) = token.as_ref() {
26472 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26473 }
26474
26475 let request = req_builder
26476 .header(CONTENT_LENGTH, 0_u64)
26477 .body(common::to_body::<String>(None));
26478
26479 client.request(request.unwrap()).await
26480 };
26481
26482 match req_result {
26483 Err(err) => {
26484 if let common::Retry::After(d) = dlg.http_error(&err) {
26485 sleep(d).await;
26486 continue;
26487 }
26488 dlg.finished(false);
26489 return Err(common::Error::HttpError(err));
26490 }
26491 Ok(res) => {
26492 let (mut parts, body) = res.into_parts();
26493 let mut body = common::Body::new(body);
26494 if !parts.status.is_success() {
26495 let bytes = common::to_bytes(body).await.unwrap_or_default();
26496 let error = serde_json::from_str(&common::to_string(&bytes));
26497 let response = common::to_response(parts, bytes.into());
26498
26499 if let common::Retry::After(d) =
26500 dlg.http_failure(&response, error.as_ref().ok())
26501 {
26502 sleep(d).await;
26503 continue;
26504 }
26505
26506 dlg.finished(false);
26507
26508 return Err(match error {
26509 Ok(value) => common::Error::BadRequest(value),
26510 _ => common::Error::Failure(response),
26511 });
26512 }
26513 let response = {
26514 let bytes = common::to_bytes(body).await.unwrap_or_default();
26515 let encoded = common::to_string(&bytes);
26516 match serde_json::from_str(&encoded) {
26517 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26518 Err(error) => {
26519 dlg.response_json_decode_error(&encoded, &error);
26520 return Err(common::Error::JsonDecodeError(
26521 encoded.to_string(),
26522 error,
26523 ));
26524 }
26525 }
26526 };
26527
26528 dlg.finished(true);
26529 return Ok(response);
26530 }
26531 }
26532 }
26533 }
26534
26535 /// An index of the first segment to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
26536 ///
26537 /// Sets the *start-index* query property to the given value.
26538 pub fn start_index(mut self, new_value: i32) -> ManagementSegmentListCall<'a, C> {
26539 self._start_index = Some(new_value);
26540 self
26541 }
26542 /// The maximum number of segments to include in this response.
26543 ///
26544 /// Sets the *max-results* query property to the given value.
26545 pub fn max_results(mut self, new_value: i32) -> ManagementSegmentListCall<'a, C> {
26546 self._max_results = Some(new_value);
26547 self
26548 }
26549 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26550 /// while executing the actual API request.
26551 ///
26552 /// ````text
26553 /// It should be used to handle progress information, and to implement a certain level of resilience.
26554 /// ````
26555 ///
26556 /// Sets the *delegate* property to the given value.
26557 pub fn delegate(
26558 mut self,
26559 new_value: &'a mut dyn common::Delegate,
26560 ) -> ManagementSegmentListCall<'a, C> {
26561 self._delegate = Some(new_value);
26562 self
26563 }
26564
26565 /// Set any additional parameter of the query string used in the request.
26566 /// It should be used to set parameters which are not yet available through their own
26567 /// setters.
26568 ///
26569 /// Please note that this method must not be used to set any of the known parameters
26570 /// which have their own setter method. If done anyway, the request will fail.
26571 ///
26572 /// # Additional Parameters
26573 ///
26574 /// * *alt* (query-string) - Data format for the response.
26575 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26576 /// * *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.
26577 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26578 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26579 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26580 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26581 pub fn param<T>(mut self, name: T, value: T) -> ManagementSegmentListCall<'a, C>
26582 where
26583 T: AsRef<str>,
26584 {
26585 self._additional_params
26586 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26587 self
26588 }
26589
26590 /// Identifies the authorization scope for the method you are building.
26591 ///
26592 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26593 /// [`Scope::Readonly`].
26594 ///
26595 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26596 /// tokens for more than one scope.
26597 ///
26598 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26599 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26600 /// sufficient, a read-write scope will do as well.
26601 pub fn add_scope<St>(mut self, scope: St) -> ManagementSegmentListCall<'a, C>
26602 where
26603 St: AsRef<str>,
26604 {
26605 self._scopes.insert(String::from(scope.as_ref()));
26606 self
26607 }
26608 /// Identifies the authorization scope(s) for the method you are building.
26609 ///
26610 /// See [`Self::add_scope()`] for details.
26611 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementSegmentListCall<'a, C>
26612 where
26613 I: IntoIterator<Item = St>,
26614 St: AsRef<str>,
26615 {
26616 self._scopes
26617 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26618 self
26619 }
26620
26621 /// Removes all scopes, and no default scope will be used either.
26622 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26623 /// for details).
26624 pub fn clear_scopes(mut self) -> ManagementSegmentListCall<'a, C> {
26625 self._scopes.clear();
26626 self
26627 }
26628}
26629
26630/// Deletes an unsampled report.
26631///
26632/// A builder for the *unsampledReports.delete* method supported by a *management* resource.
26633/// It is not used directly, but through a [`ManagementMethods`] instance.
26634///
26635/// # Example
26636///
26637/// Instantiate a resource method builder
26638///
26639/// ```test_harness,no_run
26640/// # extern crate hyper;
26641/// # extern crate hyper_rustls;
26642/// # extern crate google_analytics3 as analytics3;
26643/// # async fn dox() {
26644/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26645///
26646/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26647/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26648/// # secret,
26649/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26650/// # ).build().await.unwrap();
26651///
26652/// # let client = hyper_util::client::legacy::Client::builder(
26653/// # hyper_util::rt::TokioExecutor::new()
26654/// # )
26655/// # .build(
26656/// # hyper_rustls::HttpsConnectorBuilder::new()
26657/// # .with_native_roots()
26658/// # .unwrap()
26659/// # .https_or_http()
26660/// # .enable_http1()
26661/// # .build()
26662/// # );
26663/// # let mut hub = Analytics::new(client, auth);
26664/// // You can configure optional parameters by calling the respective setters at will, and
26665/// // execute the final call using `doit()`.
26666/// // Values shown here are possibly random and not representative !
26667/// let result = hub.management().unsampled_reports_delete("accountId", "webPropertyId", "profileId", "unsampledReportId")
26668/// .doit().await;
26669/// # }
26670/// ```
26671pub struct ManagementUnsampledReportDeleteCall<'a, C>
26672where
26673 C: 'a,
26674{
26675 hub: &'a Analytics<C>,
26676 _account_id: String,
26677 _web_property_id: String,
26678 _profile_id: String,
26679 _unsampled_report_id: String,
26680 _delegate: Option<&'a mut dyn common::Delegate>,
26681 _additional_params: HashMap<String, String>,
26682 _scopes: BTreeSet<String>,
26683}
26684
26685impl<'a, C> common::CallBuilder for ManagementUnsampledReportDeleteCall<'a, C> {}
26686
26687impl<'a, C> ManagementUnsampledReportDeleteCall<'a, C>
26688where
26689 C: common::Connector,
26690{
26691 /// Perform the operation you have build so far.
26692 pub async fn doit(mut self) -> common::Result<common::Response> {
26693 use std::borrow::Cow;
26694 use std::io::{Read, Seek};
26695
26696 use common::{url::Params, ToParts};
26697 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26698
26699 let mut dd = common::DefaultDelegate;
26700 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26701 dlg.begin(common::MethodInfo {
26702 id: "analytics.management.unsampledReports.delete",
26703 http_method: hyper::Method::DELETE,
26704 });
26705
26706 for &field in [
26707 "accountId",
26708 "webPropertyId",
26709 "profileId",
26710 "unsampledReportId",
26711 ]
26712 .iter()
26713 {
26714 if self._additional_params.contains_key(field) {
26715 dlg.finished(false);
26716 return Err(common::Error::FieldClash(field));
26717 }
26718 }
26719
26720 let mut params = Params::with_capacity(5 + self._additional_params.len());
26721 params.push("accountId", self._account_id);
26722 params.push("webPropertyId", self._web_property_id);
26723 params.push("profileId", self._profile_id);
26724 params.push("unsampledReportId", self._unsampled_report_id);
26725
26726 params.extend(self._additional_params.iter());
26727
26728 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports/{unsampledReportId}";
26729 if self._scopes.is_empty() {
26730 self._scopes.insert(Scope::Edit.as_ref().to_string());
26731 }
26732
26733 #[allow(clippy::single_element_loop)]
26734 for &(find_this, param_name) in [
26735 ("{accountId}", "accountId"),
26736 ("{webPropertyId}", "webPropertyId"),
26737 ("{profileId}", "profileId"),
26738 ("{unsampledReportId}", "unsampledReportId"),
26739 ]
26740 .iter()
26741 {
26742 url = params.uri_replacement(url, param_name, find_this, false);
26743 }
26744 {
26745 let to_remove = [
26746 "unsampledReportId",
26747 "profileId",
26748 "webPropertyId",
26749 "accountId",
26750 ];
26751 params.remove_params(&to_remove);
26752 }
26753
26754 let url = params.parse_with_url(&url);
26755
26756 loop {
26757 let token = match self
26758 .hub
26759 .auth
26760 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26761 .await
26762 {
26763 Ok(token) => token,
26764 Err(e) => match dlg.token(e) {
26765 Ok(token) => token,
26766 Err(e) => {
26767 dlg.finished(false);
26768 return Err(common::Error::MissingToken(e));
26769 }
26770 },
26771 };
26772 let mut req_result = {
26773 let client = &self.hub.client;
26774 dlg.pre_request();
26775 let mut req_builder = hyper::Request::builder()
26776 .method(hyper::Method::DELETE)
26777 .uri(url.as_str())
26778 .header(USER_AGENT, self.hub._user_agent.clone());
26779
26780 if let Some(token) = token.as_ref() {
26781 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26782 }
26783
26784 let request = req_builder
26785 .header(CONTENT_LENGTH, 0_u64)
26786 .body(common::to_body::<String>(None));
26787
26788 client.request(request.unwrap()).await
26789 };
26790
26791 match req_result {
26792 Err(err) => {
26793 if let common::Retry::After(d) = dlg.http_error(&err) {
26794 sleep(d).await;
26795 continue;
26796 }
26797 dlg.finished(false);
26798 return Err(common::Error::HttpError(err));
26799 }
26800 Ok(res) => {
26801 let (mut parts, body) = res.into_parts();
26802 let mut body = common::Body::new(body);
26803 if !parts.status.is_success() {
26804 let bytes = common::to_bytes(body).await.unwrap_or_default();
26805 let error = serde_json::from_str(&common::to_string(&bytes));
26806 let response = common::to_response(parts, bytes.into());
26807
26808 if let common::Retry::After(d) =
26809 dlg.http_failure(&response, error.as_ref().ok())
26810 {
26811 sleep(d).await;
26812 continue;
26813 }
26814
26815 dlg.finished(false);
26816
26817 return Err(match error {
26818 Ok(value) => common::Error::BadRequest(value),
26819 _ => common::Error::Failure(response),
26820 });
26821 }
26822 let response = common::Response::from_parts(parts, body);
26823
26824 dlg.finished(true);
26825 return Ok(response);
26826 }
26827 }
26828 }
26829 }
26830
26831 /// Account ID to delete the unsampled report for.
26832 ///
26833 /// Sets the *account id* path property to the given value.
26834 ///
26835 /// Even though the property as already been set when instantiating this call,
26836 /// we provide this method for API completeness.
26837 pub fn account_id(mut self, new_value: &str) -> ManagementUnsampledReportDeleteCall<'a, C> {
26838 self._account_id = new_value.to_string();
26839 self
26840 }
26841 /// Web property ID to delete the unsampled reports for.
26842 ///
26843 /// Sets the *web property id* path property to the given value.
26844 ///
26845 /// Even though the property as already been set when instantiating this call,
26846 /// we provide this method for API completeness.
26847 pub fn web_property_id(
26848 mut self,
26849 new_value: &str,
26850 ) -> ManagementUnsampledReportDeleteCall<'a, C> {
26851 self._web_property_id = new_value.to_string();
26852 self
26853 }
26854 /// View (Profile) ID to delete the unsampled report for.
26855 ///
26856 /// Sets the *profile id* path property to the given value.
26857 ///
26858 /// Even though the property as already been set when instantiating this call,
26859 /// we provide this method for API completeness.
26860 pub fn profile_id(mut self, new_value: &str) -> ManagementUnsampledReportDeleteCall<'a, C> {
26861 self._profile_id = new_value.to_string();
26862 self
26863 }
26864 /// ID of the unsampled report to be deleted.
26865 ///
26866 /// Sets the *unsampled report id* path property to the given value.
26867 ///
26868 /// Even though the property as already been set when instantiating this call,
26869 /// we provide this method for API completeness.
26870 pub fn unsampled_report_id(
26871 mut self,
26872 new_value: &str,
26873 ) -> ManagementUnsampledReportDeleteCall<'a, C> {
26874 self._unsampled_report_id = new_value.to_string();
26875 self
26876 }
26877 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26878 /// while executing the actual API request.
26879 ///
26880 /// ````text
26881 /// It should be used to handle progress information, and to implement a certain level of resilience.
26882 /// ````
26883 ///
26884 /// Sets the *delegate* property to the given value.
26885 pub fn delegate(
26886 mut self,
26887 new_value: &'a mut dyn common::Delegate,
26888 ) -> ManagementUnsampledReportDeleteCall<'a, C> {
26889 self._delegate = Some(new_value);
26890 self
26891 }
26892
26893 /// Set any additional parameter of the query string used in the request.
26894 /// It should be used to set parameters which are not yet available through their own
26895 /// setters.
26896 ///
26897 /// Please note that this method must not be used to set any of the known parameters
26898 /// which have their own setter method. If done anyway, the request will fail.
26899 ///
26900 /// # Additional Parameters
26901 ///
26902 /// * *alt* (query-string) - Data format for the response.
26903 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26904 /// * *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.
26905 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26906 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26907 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26908 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26909 pub fn param<T>(mut self, name: T, value: T) -> ManagementUnsampledReportDeleteCall<'a, C>
26910 where
26911 T: AsRef<str>,
26912 {
26913 self._additional_params
26914 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26915 self
26916 }
26917
26918 /// Identifies the authorization scope for the method you are building.
26919 ///
26920 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26921 /// [`Scope::Edit`].
26922 ///
26923 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26924 /// tokens for more than one scope.
26925 ///
26926 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26927 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26928 /// sufficient, a read-write scope will do as well.
26929 pub fn add_scope<St>(mut self, scope: St) -> ManagementUnsampledReportDeleteCall<'a, C>
26930 where
26931 St: AsRef<str>,
26932 {
26933 self._scopes.insert(String::from(scope.as_ref()));
26934 self
26935 }
26936 /// Identifies the authorization scope(s) for the method you are building.
26937 ///
26938 /// See [`Self::add_scope()`] for details.
26939 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUnsampledReportDeleteCall<'a, C>
26940 where
26941 I: IntoIterator<Item = St>,
26942 St: AsRef<str>,
26943 {
26944 self._scopes
26945 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26946 self
26947 }
26948
26949 /// Removes all scopes, and no default scope will be used either.
26950 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26951 /// for details).
26952 pub fn clear_scopes(mut self) -> ManagementUnsampledReportDeleteCall<'a, C> {
26953 self._scopes.clear();
26954 self
26955 }
26956}
26957
26958/// Returns a single unsampled report.
26959///
26960/// A builder for the *unsampledReports.get* method supported by a *management* resource.
26961/// It is not used directly, but through a [`ManagementMethods`] instance.
26962///
26963/// # Example
26964///
26965/// Instantiate a resource method builder
26966///
26967/// ```test_harness,no_run
26968/// # extern crate hyper;
26969/// # extern crate hyper_rustls;
26970/// # extern crate google_analytics3 as analytics3;
26971/// # async fn dox() {
26972/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26973///
26974/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26975/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26976/// # secret,
26977/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26978/// # ).build().await.unwrap();
26979///
26980/// # let client = hyper_util::client::legacy::Client::builder(
26981/// # hyper_util::rt::TokioExecutor::new()
26982/// # )
26983/// # .build(
26984/// # hyper_rustls::HttpsConnectorBuilder::new()
26985/// # .with_native_roots()
26986/// # .unwrap()
26987/// # .https_or_http()
26988/// # .enable_http1()
26989/// # .build()
26990/// # );
26991/// # let mut hub = Analytics::new(client, auth);
26992/// // You can configure optional parameters by calling the respective setters at will, and
26993/// // execute the final call using `doit()`.
26994/// // Values shown here are possibly random and not representative !
26995/// let result = hub.management().unsampled_reports_get("accountId", "webPropertyId", "profileId", "unsampledReportId")
26996/// .doit().await;
26997/// # }
26998/// ```
26999pub struct ManagementUnsampledReportGetCall<'a, C>
27000where
27001 C: 'a,
27002{
27003 hub: &'a Analytics<C>,
27004 _account_id: String,
27005 _web_property_id: String,
27006 _profile_id: String,
27007 _unsampled_report_id: String,
27008 _delegate: Option<&'a mut dyn common::Delegate>,
27009 _additional_params: HashMap<String, String>,
27010 _scopes: BTreeSet<String>,
27011}
27012
27013impl<'a, C> common::CallBuilder for ManagementUnsampledReportGetCall<'a, C> {}
27014
27015impl<'a, C> ManagementUnsampledReportGetCall<'a, C>
27016where
27017 C: common::Connector,
27018{
27019 /// Perform the operation you have build so far.
27020 pub async fn doit(mut self) -> common::Result<(common::Response, UnsampledReport)> {
27021 use std::borrow::Cow;
27022 use std::io::{Read, Seek};
27023
27024 use common::{url::Params, ToParts};
27025 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27026
27027 let mut dd = common::DefaultDelegate;
27028 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27029 dlg.begin(common::MethodInfo {
27030 id: "analytics.management.unsampledReports.get",
27031 http_method: hyper::Method::GET,
27032 });
27033
27034 for &field in [
27035 "alt",
27036 "accountId",
27037 "webPropertyId",
27038 "profileId",
27039 "unsampledReportId",
27040 ]
27041 .iter()
27042 {
27043 if self._additional_params.contains_key(field) {
27044 dlg.finished(false);
27045 return Err(common::Error::FieldClash(field));
27046 }
27047 }
27048
27049 let mut params = Params::with_capacity(6 + self._additional_params.len());
27050 params.push("accountId", self._account_id);
27051 params.push("webPropertyId", self._web_property_id);
27052 params.push("profileId", self._profile_id);
27053 params.push("unsampledReportId", self._unsampled_report_id);
27054
27055 params.extend(self._additional_params.iter());
27056
27057 params.push("alt", "json");
27058 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports/{unsampledReportId}";
27059 if self._scopes.is_empty() {
27060 self._scopes.insert(Scope::Readonly.as_ref().to_string());
27061 }
27062
27063 #[allow(clippy::single_element_loop)]
27064 for &(find_this, param_name) in [
27065 ("{accountId}", "accountId"),
27066 ("{webPropertyId}", "webPropertyId"),
27067 ("{profileId}", "profileId"),
27068 ("{unsampledReportId}", "unsampledReportId"),
27069 ]
27070 .iter()
27071 {
27072 url = params.uri_replacement(url, param_name, find_this, false);
27073 }
27074 {
27075 let to_remove = [
27076 "unsampledReportId",
27077 "profileId",
27078 "webPropertyId",
27079 "accountId",
27080 ];
27081 params.remove_params(&to_remove);
27082 }
27083
27084 let url = params.parse_with_url(&url);
27085
27086 loop {
27087 let token = match self
27088 .hub
27089 .auth
27090 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27091 .await
27092 {
27093 Ok(token) => token,
27094 Err(e) => match dlg.token(e) {
27095 Ok(token) => token,
27096 Err(e) => {
27097 dlg.finished(false);
27098 return Err(common::Error::MissingToken(e));
27099 }
27100 },
27101 };
27102 let mut req_result = {
27103 let client = &self.hub.client;
27104 dlg.pre_request();
27105 let mut req_builder = hyper::Request::builder()
27106 .method(hyper::Method::GET)
27107 .uri(url.as_str())
27108 .header(USER_AGENT, self.hub._user_agent.clone());
27109
27110 if let Some(token) = token.as_ref() {
27111 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27112 }
27113
27114 let request = req_builder
27115 .header(CONTENT_LENGTH, 0_u64)
27116 .body(common::to_body::<String>(None));
27117
27118 client.request(request.unwrap()).await
27119 };
27120
27121 match req_result {
27122 Err(err) => {
27123 if let common::Retry::After(d) = dlg.http_error(&err) {
27124 sleep(d).await;
27125 continue;
27126 }
27127 dlg.finished(false);
27128 return Err(common::Error::HttpError(err));
27129 }
27130 Ok(res) => {
27131 let (mut parts, body) = res.into_parts();
27132 let mut body = common::Body::new(body);
27133 if !parts.status.is_success() {
27134 let bytes = common::to_bytes(body).await.unwrap_or_default();
27135 let error = serde_json::from_str(&common::to_string(&bytes));
27136 let response = common::to_response(parts, bytes.into());
27137
27138 if let common::Retry::After(d) =
27139 dlg.http_failure(&response, error.as_ref().ok())
27140 {
27141 sleep(d).await;
27142 continue;
27143 }
27144
27145 dlg.finished(false);
27146
27147 return Err(match error {
27148 Ok(value) => common::Error::BadRequest(value),
27149 _ => common::Error::Failure(response),
27150 });
27151 }
27152 let response = {
27153 let bytes = common::to_bytes(body).await.unwrap_or_default();
27154 let encoded = common::to_string(&bytes);
27155 match serde_json::from_str(&encoded) {
27156 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27157 Err(error) => {
27158 dlg.response_json_decode_error(&encoded, &error);
27159 return Err(common::Error::JsonDecodeError(
27160 encoded.to_string(),
27161 error,
27162 ));
27163 }
27164 }
27165 };
27166
27167 dlg.finished(true);
27168 return Ok(response);
27169 }
27170 }
27171 }
27172 }
27173
27174 /// Account ID to retrieve unsampled report for.
27175 ///
27176 /// Sets the *account id* path property to the given value.
27177 ///
27178 /// Even though the property as already been set when instantiating this call,
27179 /// we provide this method for API completeness.
27180 pub fn account_id(mut self, new_value: &str) -> ManagementUnsampledReportGetCall<'a, C> {
27181 self._account_id = new_value.to_string();
27182 self
27183 }
27184 /// Web property ID to retrieve unsampled reports for.
27185 ///
27186 /// Sets the *web property id* path property to the given value.
27187 ///
27188 /// Even though the property as already been set when instantiating this call,
27189 /// we provide this method for API completeness.
27190 pub fn web_property_id(mut self, new_value: &str) -> ManagementUnsampledReportGetCall<'a, C> {
27191 self._web_property_id = new_value.to_string();
27192 self
27193 }
27194 /// View (Profile) ID to retrieve unsampled report for.
27195 ///
27196 /// Sets the *profile id* path property to the given value.
27197 ///
27198 /// Even though the property as already been set when instantiating this call,
27199 /// we provide this method for API completeness.
27200 pub fn profile_id(mut self, new_value: &str) -> ManagementUnsampledReportGetCall<'a, C> {
27201 self._profile_id = new_value.to_string();
27202 self
27203 }
27204 /// ID of the unsampled report to retrieve.
27205 ///
27206 /// Sets the *unsampled report id* path property to the given value.
27207 ///
27208 /// Even though the property as already been set when instantiating this call,
27209 /// we provide this method for API completeness.
27210 pub fn unsampled_report_id(
27211 mut self,
27212 new_value: &str,
27213 ) -> ManagementUnsampledReportGetCall<'a, C> {
27214 self._unsampled_report_id = new_value.to_string();
27215 self
27216 }
27217 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27218 /// while executing the actual API request.
27219 ///
27220 /// ````text
27221 /// It should be used to handle progress information, and to implement a certain level of resilience.
27222 /// ````
27223 ///
27224 /// Sets the *delegate* property to the given value.
27225 pub fn delegate(
27226 mut self,
27227 new_value: &'a mut dyn common::Delegate,
27228 ) -> ManagementUnsampledReportGetCall<'a, C> {
27229 self._delegate = Some(new_value);
27230 self
27231 }
27232
27233 /// Set any additional parameter of the query string used in the request.
27234 /// It should be used to set parameters which are not yet available through their own
27235 /// setters.
27236 ///
27237 /// Please note that this method must not be used to set any of the known parameters
27238 /// which have their own setter method. If done anyway, the request will fail.
27239 ///
27240 /// # Additional Parameters
27241 ///
27242 /// * *alt* (query-string) - Data format for the response.
27243 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27244 /// * *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.
27245 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27246 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27247 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27248 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27249 pub fn param<T>(mut self, name: T, value: T) -> ManagementUnsampledReportGetCall<'a, C>
27250 where
27251 T: AsRef<str>,
27252 {
27253 self._additional_params
27254 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27255 self
27256 }
27257
27258 /// Identifies the authorization scope for the method you are building.
27259 ///
27260 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27261 /// [`Scope::Readonly`].
27262 ///
27263 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27264 /// tokens for more than one scope.
27265 ///
27266 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27267 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27268 /// sufficient, a read-write scope will do as well.
27269 pub fn add_scope<St>(mut self, scope: St) -> ManagementUnsampledReportGetCall<'a, C>
27270 where
27271 St: AsRef<str>,
27272 {
27273 self._scopes.insert(String::from(scope.as_ref()));
27274 self
27275 }
27276 /// Identifies the authorization scope(s) for the method you are building.
27277 ///
27278 /// See [`Self::add_scope()`] for details.
27279 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUnsampledReportGetCall<'a, C>
27280 where
27281 I: IntoIterator<Item = St>,
27282 St: AsRef<str>,
27283 {
27284 self._scopes
27285 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27286 self
27287 }
27288
27289 /// Removes all scopes, and no default scope will be used either.
27290 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27291 /// for details).
27292 pub fn clear_scopes(mut self) -> ManagementUnsampledReportGetCall<'a, C> {
27293 self._scopes.clear();
27294 self
27295 }
27296}
27297
27298/// Create a new unsampled report.
27299///
27300/// A builder for the *unsampledReports.insert* method supported by a *management* resource.
27301/// It is not used directly, but through a [`ManagementMethods`] instance.
27302///
27303/// # Example
27304///
27305/// Instantiate a resource method builder
27306///
27307/// ```test_harness,no_run
27308/// # extern crate hyper;
27309/// # extern crate hyper_rustls;
27310/// # extern crate google_analytics3 as analytics3;
27311/// use analytics3::api::UnsampledReport;
27312/// # async fn dox() {
27313/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27314///
27315/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27316/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27317/// # secret,
27318/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27319/// # ).build().await.unwrap();
27320///
27321/// # let client = hyper_util::client::legacy::Client::builder(
27322/// # hyper_util::rt::TokioExecutor::new()
27323/// # )
27324/// # .build(
27325/// # hyper_rustls::HttpsConnectorBuilder::new()
27326/// # .with_native_roots()
27327/// # .unwrap()
27328/// # .https_or_http()
27329/// # .enable_http1()
27330/// # .build()
27331/// # );
27332/// # let mut hub = Analytics::new(client, auth);
27333/// // As the method needs a request, you would usually fill it with the desired information
27334/// // into the respective structure. Some of the parts shown here might not be applicable !
27335/// // Values shown here are possibly random and not representative !
27336/// let mut req = UnsampledReport::default();
27337///
27338/// // You can configure optional parameters by calling the respective setters at will, and
27339/// // execute the final call using `doit()`.
27340/// // Values shown here are possibly random and not representative !
27341/// let result = hub.management().unsampled_reports_insert(req, "accountId", "webPropertyId", "profileId")
27342/// .doit().await;
27343/// # }
27344/// ```
27345pub struct ManagementUnsampledReportInsertCall<'a, C>
27346where
27347 C: 'a,
27348{
27349 hub: &'a Analytics<C>,
27350 _request: UnsampledReport,
27351 _account_id: String,
27352 _web_property_id: String,
27353 _profile_id: String,
27354 _delegate: Option<&'a mut dyn common::Delegate>,
27355 _additional_params: HashMap<String, String>,
27356 _scopes: BTreeSet<String>,
27357}
27358
27359impl<'a, C> common::CallBuilder for ManagementUnsampledReportInsertCall<'a, C> {}
27360
27361impl<'a, C> ManagementUnsampledReportInsertCall<'a, C>
27362where
27363 C: common::Connector,
27364{
27365 /// Perform the operation you have build so far.
27366 pub async fn doit(mut self) -> common::Result<(common::Response, UnsampledReport)> {
27367 use std::borrow::Cow;
27368 use std::io::{Read, Seek};
27369
27370 use common::{url::Params, ToParts};
27371 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27372
27373 let mut dd = common::DefaultDelegate;
27374 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27375 dlg.begin(common::MethodInfo {
27376 id: "analytics.management.unsampledReports.insert",
27377 http_method: hyper::Method::POST,
27378 });
27379
27380 for &field in ["alt", "accountId", "webPropertyId", "profileId"].iter() {
27381 if self._additional_params.contains_key(field) {
27382 dlg.finished(false);
27383 return Err(common::Error::FieldClash(field));
27384 }
27385 }
27386
27387 let mut params = Params::with_capacity(6 + self._additional_params.len());
27388 params.push("accountId", self._account_id);
27389 params.push("webPropertyId", self._web_property_id);
27390 params.push("profileId", self._profile_id);
27391
27392 params.extend(self._additional_params.iter());
27393
27394 params.push("alt", "json");
27395 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports";
27396 if self._scopes.is_empty() {
27397 self._scopes.insert(Scope::Full.as_ref().to_string());
27398 }
27399
27400 #[allow(clippy::single_element_loop)]
27401 for &(find_this, param_name) in [
27402 ("{accountId}", "accountId"),
27403 ("{webPropertyId}", "webPropertyId"),
27404 ("{profileId}", "profileId"),
27405 ]
27406 .iter()
27407 {
27408 url = params.uri_replacement(url, param_name, find_this, false);
27409 }
27410 {
27411 let to_remove = ["profileId", "webPropertyId", "accountId"];
27412 params.remove_params(&to_remove);
27413 }
27414
27415 let url = params.parse_with_url(&url);
27416
27417 let mut json_mime_type = mime::APPLICATION_JSON;
27418 let mut request_value_reader = {
27419 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27420 common::remove_json_null_values(&mut value);
27421 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27422 serde_json::to_writer(&mut dst, &value).unwrap();
27423 dst
27424 };
27425 let request_size = request_value_reader
27426 .seek(std::io::SeekFrom::End(0))
27427 .unwrap();
27428 request_value_reader
27429 .seek(std::io::SeekFrom::Start(0))
27430 .unwrap();
27431
27432 loop {
27433 let token = match self
27434 .hub
27435 .auth
27436 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27437 .await
27438 {
27439 Ok(token) => token,
27440 Err(e) => match dlg.token(e) {
27441 Ok(token) => token,
27442 Err(e) => {
27443 dlg.finished(false);
27444 return Err(common::Error::MissingToken(e));
27445 }
27446 },
27447 };
27448 request_value_reader
27449 .seek(std::io::SeekFrom::Start(0))
27450 .unwrap();
27451 let mut req_result = {
27452 let client = &self.hub.client;
27453 dlg.pre_request();
27454 let mut req_builder = hyper::Request::builder()
27455 .method(hyper::Method::POST)
27456 .uri(url.as_str())
27457 .header(USER_AGENT, self.hub._user_agent.clone());
27458
27459 if let Some(token) = token.as_ref() {
27460 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27461 }
27462
27463 let request = req_builder
27464 .header(CONTENT_TYPE, json_mime_type.to_string())
27465 .header(CONTENT_LENGTH, request_size as u64)
27466 .body(common::to_body(
27467 request_value_reader.get_ref().clone().into(),
27468 ));
27469
27470 client.request(request.unwrap()).await
27471 };
27472
27473 match req_result {
27474 Err(err) => {
27475 if let common::Retry::After(d) = dlg.http_error(&err) {
27476 sleep(d).await;
27477 continue;
27478 }
27479 dlg.finished(false);
27480 return Err(common::Error::HttpError(err));
27481 }
27482 Ok(res) => {
27483 let (mut parts, body) = res.into_parts();
27484 let mut body = common::Body::new(body);
27485 if !parts.status.is_success() {
27486 let bytes = common::to_bytes(body).await.unwrap_or_default();
27487 let error = serde_json::from_str(&common::to_string(&bytes));
27488 let response = common::to_response(parts, bytes.into());
27489
27490 if let common::Retry::After(d) =
27491 dlg.http_failure(&response, error.as_ref().ok())
27492 {
27493 sleep(d).await;
27494 continue;
27495 }
27496
27497 dlg.finished(false);
27498
27499 return Err(match error {
27500 Ok(value) => common::Error::BadRequest(value),
27501 _ => common::Error::Failure(response),
27502 });
27503 }
27504 let response = {
27505 let bytes = common::to_bytes(body).await.unwrap_or_default();
27506 let encoded = common::to_string(&bytes);
27507 match serde_json::from_str(&encoded) {
27508 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27509 Err(error) => {
27510 dlg.response_json_decode_error(&encoded, &error);
27511 return Err(common::Error::JsonDecodeError(
27512 encoded.to_string(),
27513 error,
27514 ));
27515 }
27516 }
27517 };
27518
27519 dlg.finished(true);
27520 return Ok(response);
27521 }
27522 }
27523 }
27524 }
27525
27526 ///
27527 /// Sets the *request* property to the given value.
27528 ///
27529 /// Even though the property as already been set when instantiating this call,
27530 /// we provide this method for API completeness.
27531 pub fn request(
27532 mut self,
27533 new_value: UnsampledReport,
27534 ) -> ManagementUnsampledReportInsertCall<'a, C> {
27535 self._request = new_value;
27536 self
27537 }
27538 /// Account ID to create the unsampled report for.
27539 ///
27540 /// Sets the *account id* path property to the given value.
27541 ///
27542 /// Even though the property as already been set when instantiating this call,
27543 /// we provide this method for API completeness.
27544 pub fn account_id(mut self, new_value: &str) -> ManagementUnsampledReportInsertCall<'a, C> {
27545 self._account_id = new_value.to_string();
27546 self
27547 }
27548 /// Web property ID to create the unsampled report for.
27549 ///
27550 /// Sets the *web property id* path property to the given value.
27551 ///
27552 /// Even though the property as already been set when instantiating this call,
27553 /// we provide this method for API completeness.
27554 pub fn web_property_id(
27555 mut self,
27556 new_value: &str,
27557 ) -> ManagementUnsampledReportInsertCall<'a, C> {
27558 self._web_property_id = new_value.to_string();
27559 self
27560 }
27561 /// View (Profile) ID to create the unsampled report for.
27562 ///
27563 /// Sets the *profile id* path property to the given value.
27564 ///
27565 /// Even though the property as already been set when instantiating this call,
27566 /// we provide this method for API completeness.
27567 pub fn profile_id(mut self, new_value: &str) -> ManagementUnsampledReportInsertCall<'a, C> {
27568 self._profile_id = new_value.to_string();
27569 self
27570 }
27571 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27572 /// while executing the actual API request.
27573 ///
27574 /// ````text
27575 /// It should be used to handle progress information, and to implement a certain level of resilience.
27576 /// ````
27577 ///
27578 /// Sets the *delegate* property to the given value.
27579 pub fn delegate(
27580 mut self,
27581 new_value: &'a mut dyn common::Delegate,
27582 ) -> ManagementUnsampledReportInsertCall<'a, C> {
27583 self._delegate = Some(new_value);
27584 self
27585 }
27586
27587 /// Set any additional parameter of the query string used in the request.
27588 /// It should be used to set parameters which are not yet available through their own
27589 /// setters.
27590 ///
27591 /// Please note that this method must not be used to set any of the known parameters
27592 /// which have their own setter method. If done anyway, the request will fail.
27593 ///
27594 /// # Additional Parameters
27595 ///
27596 /// * *alt* (query-string) - Data format for the response.
27597 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27598 /// * *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.
27599 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27600 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27601 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27602 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27603 pub fn param<T>(mut self, name: T, value: T) -> ManagementUnsampledReportInsertCall<'a, C>
27604 where
27605 T: AsRef<str>,
27606 {
27607 self._additional_params
27608 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27609 self
27610 }
27611
27612 /// Identifies the authorization scope for the method you are building.
27613 ///
27614 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27615 /// [`Scope::Full`].
27616 ///
27617 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27618 /// tokens for more than one scope.
27619 ///
27620 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27621 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27622 /// sufficient, a read-write scope will do as well.
27623 pub fn add_scope<St>(mut self, scope: St) -> ManagementUnsampledReportInsertCall<'a, C>
27624 where
27625 St: AsRef<str>,
27626 {
27627 self._scopes.insert(String::from(scope.as_ref()));
27628 self
27629 }
27630 /// Identifies the authorization scope(s) for the method you are building.
27631 ///
27632 /// See [`Self::add_scope()`] for details.
27633 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUnsampledReportInsertCall<'a, C>
27634 where
27635 I: IntoIterator<Item = St>,
27636 St: AsRef<str>,
27637 {
27638 self._scopes
27639 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27640 self
27641 }
27642
27643 /// Removes all scopes, and no default scope will be used either.
27644 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27645 /// for details).
27646 pub fn clear_scopes(mut self) -> ManagementUnsampledReportInsertCall<'a, C> {
27647 self._scopes.clear();
27648 self
27649 }
27650}
27651
27652/// Lists unsampled reports to which the user has access.
27653///
27654/// A builder for the *unsampledReports.list* method supported by a *management* resource.
27655/// It is not used directly, but through a [`ManagementMethods`] instance.
27656///
27657/// # Example
27658///
27659/// Instantiate a resource method builder
27660///
27661/// ```test_harness,no_run
27662/// # extern crate hyper;
27663/// # extern crate hyper_rustls;
27664/// # extern crate google_analytics3 as analytics3;
27665/// # async fn dox() {
27666/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27667///
27668/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27669/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27670/// # secret,
27671/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27672/// # ).build().await.unwrap();
27673///
27674/// # let client = hyper_util::client::legacy::Client::builder(
27675/// # hyper_util::rt::TokioExecutor::new()
27676/// # )
27677/// # .build(
27678/// # hyper_rustls::HttpsConnectorBuilder::new()
27679/// # .with_native_roots()
27680/// # .unwrap()
27681/// # .https_or_http()
27682/// # .enable_http1()
27683/// # .build()
27684/// # );
27685/// # let mut hub = Analytics::new(client, auth);
27686/// // You can configure optional parameters by calling the respective setters at will, and
27687/// // execute the final call using `doit()`.
27688/// // Values shown here are possibly random and not representative !
27689/// let result = hub.management().unsampled_reports_list("accountId", "webPropertyId", "profileId")
27690/// .start_index(-15)
27691/// .max_results(-82)
27692/// .doit().await;
27693/// # }
27694/// ```
27695pub struct ManagementUnsampledReportListCall<'a, C>
27696where
27697 C: 'a,
27698{
27699 hub: &'a Analytics<C>,
27700 _account_id: String,
27701 _web_property_id: String,
27702 _profile_id: String,
27703 _start_index: Option<i32>,
27704 _max_results: Option<i32>,
27705 _delegate: Option<&'a mut dyn common::Delegate>,
27706 _additional_params: HashMap<String, String>,
27707 _scopes: BTreeSet<String>,
27708}
27709
27710impl<'a, C> common::CallBuilder for ManagementUnsampledReportListCall<'a, C> {}
27711
27712impl<'a, C> ManagementUnsampledReportListCall<'a, C>
27713where
27714 C: common::Connector,
27715{
27716 /// Perform the operation you have build so far.
27717 pub async fn doit(mut self) -> common::Result<(common::Response, UnsampledReports)> {
27718 use std::borrow::Cow;
27719 use std::io::{Read, Seek};
27720
27721 use common::{url::Params, ToParts};
27722 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27723
27724 let mut dd = common::DefaultDelegate;
27725 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27726 dlg.begin(common::MethodInfo {
27727 id: "analytics.management.unsampledReports.list",
27728 http_method: hyper::Method::GET,
27729 });
27730
27731 for &field in [
27732 "alt",
27733 "accountId",
27734 "webPropertyId",
27735 "profileId",
27736 "start-index",
27737 "max-results",
27738 ]
27739 .iter()
27740 {
27741 if self._additional_params.contains_key(field) {
27742 dlg.finished(false);
27743 return Err(common::Error::FieldClash(field));
27744 }
27745 }
27746
27747 let mut params = Params::with_capacity(7 + self._additional_params.len());
27748 params.push("accountId", self._account_id);
27749 params.push("webPropertyId", self._web_property_id);
27750 params.push("profileId", self._profile_id);
27751 if let Some(value) = self._start_index.as_ref() {
27752 params.push("start-index", value.to_string());
27753 }
27754 if let Some(value) = self._max_results.as_ref() {
27755 params.push("max-results", value.to_string());
27756 }
27757
27758 params.extend(self._additional_params.iter());
27759
27760 params.push("alt", "json");
27761 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports";
27762 if self._scopes.is_empty() {
27763 self._scopes.insert(Scope::Readonly.as_ref().to_string());
27764 }
27765
27766 #[allow(clippy::single_element_loop)]
27767 for &(find_this, param_name) in [
27768 ("{accountId}", "accountId"),
27769 ("{webPropertyId}", "webPropertyId"),
27770 ("{profileId}", "profileId"),
27771 ]
27772 .iter()
27773 {
27774 url = params.uri_replacement(url, param_name, find_this, false);
27775 }
27776 {
27777 let to_remove = ["profileId", "webPropertyId", "accountId"];
27778 params.remove_params(&to_remove);
27779 }
27780
27781 let url = params.parse_with_url(&url);
27782
27783 loop {
27784 let token = match self
27785 .hub
27786 .auth
27787 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27788 .await
27789 {
27790 Ok(token) => token,
27791 Err(e) => match dlg.token(e) {
27792 Ok(token) => token,
27793 Err(e) => {
27794 dlg.finished(false);
27795 return Err(common::Error::MissingToken(e));
27796 }
27797 },
27798 };
27799 let mut req_result = {
27800 let client = &self.hub.client;
27801 dlg.pre_request();
27802 let mut req_builder = hyper::Request::builder()
27803 .method(hyper::Method::GET)
27804 .uri(url.as_str())
27805 .header(USER_AGENT, self.hub._user_agent.clone());
27806
27807 if let Some(token) = token.as_ref() {
27808 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27809 }
27810
27811 let request = req_builder
27812 .header(CONTENT_LENGTH, 0_u64)
27813 .body(common::to_body::<String>(None));
27814
27815 client.request(request.unwrap()).await
27816 };
27817
27818 match req_result {
27819 Err(err) => {
27820 if let common::Retry::After(d) = dlg.http_error(&err) {
27821 sleep(d).await;
27822 continue;
27823 }
27824 dlg.finished(false);
27825 return Err(common::Error::HttpError(err));
27826 }
27827 Ok(res) => {
27828 let (mut parts, body) = res.into_parts();
27829 let mut body = common::Body::new(body);
27830 if !parts.status.is_success() {
27831 let bytes = common::to_bytes(body).await.unwrap_or_default();
27832 let error = serde_json::from_str(&common::to_string(&bytes));
27833 let response = common::to_response(parts, bytes.into());
27834
27835 if let common::Retry::After(d) =
27836 dlg.http_failure(&response, error.as_ref().ok())
27837 {
27838 sleep(d).await;
27839 continue;
27840 }
27841
27842 dlg.finished(false);
27843
27844 return Err(match error {
27845 Ok(value) => common::Error::BadRequest(value),
27846 _ => common::Error::Failure(response),
27847 });
27848 }
27849 let response = {
27850 let bytes = common::to_bytes(body).await.unwrap_or_default();
27851 let encoded = common::to_string(&bytes);
27852 match serde_json::from_str(&encoded) {
27853 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27854 Err(error) => {
27855 dlg.response_json_decode_error(&encoded, &error);
27856 return Err(common::Error::JsonDecodeError(
27857 encoded.to_string(),
27858 error,
27859 ));
27860 }
27861 }
27862 };
27863
27864 dlg.finished(true);
27865 return Ok(response);
27866 }
27867 }
27868 }
27869 }
27870
27871 /// Account ID to retrieve unsampled reports for. Must be a specific account ID, ~all is not supported.
27872 ///
27873 /// Sets the *account id* path property to the given value.
27874 ///
27875 /// Even though the property as already been set when instantiating this call,
27876 /// we provide this method for API completeness.
27877 pub fn account_id(mut self, new_value: &str) -> ManagementUnsampledReportListCall<'a, C> {
27878 self._account_id = new_value.to_string();
27879 self
27880 }
27881 /// Web property ID to retrieve unsampled reports for. Must be a specific web property ID, ~all is not supported.
27882 ///
27883 /// Sets the *web property id* path property to the given value.
27884 ///
27885 /// Even though the property as already been set when instantiating this call,
27886 /// we provide this method for API completeness.
27887 pub fn web_property_id(mut self, new_value: &str) -> ManagementUnsampledReportListCall<'a, C> {
27888 self._web_property_id = new_value.to_string();
27889 self
27890 }
27891 /// View (Profile) ID to retrieve unsampled reports for. Must be a specific view (profile) ID, ~all is not supported.
27892 ///
27893 /// Sets the *profile id* path property to the given value.
27894 ///
27895 /// Even though the property as already been set when instantiating this call,
27896 /// we provide this method for API completeness.
27897 pub fn profile_id(mut self, new_value: &str) -> ManagementUnsampledReportListCall<'a, C> {
27898 self._profile_id = new_value.to_string();
27899 self
27900 }
27901 /// An index of the first unsampled report to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
27902 ///
27903 /// Sets the *start-index* query property to the given value.
27904 pub fn start_index(mut self, new_value: i32) -> ManagementUnsampledReportListCall<'a, C> {
27905 self._start_index = Some(new_value);
27906 self
27907 }
27908 /// The maximum number of unsampled reports to include in this response.
27909 ///
27910 /// Sets the *max-results* query property to the given value.
27911 pub fn max_results(mut self, new_value: i32) -> ManagementUnsampledReportListCall<'a, C> {
27912 self._max_results = Some(new_value);
27913 self
27914 }
27915 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27916 /// while executing the actual API request.
27917 ///
27918 /// ````text
27919 /// It should be used to handle progress information, and to implement a certain level of resilience.
27920 /// ````
27921 ///
27922 /// Sets the *delegate* property to the given value.
27923 pub fn delegate(
27924 mut self,
27925 new_value: &'a mut dyn common::Delegate,
27926 ) -> ManagementUnsampledReportListCall<'a, C> {
27927 self._delegate = Some(new_value);
27928 self
27929 }
27930
27931 /// Set any additional parameter of the query string used in the request.
27932 /// It should be used to set parameters which are not yet available through their own
27933 /// setters.
27934 ///
27935 /// Please note that this method must not be used to set any of the known parameters
27936 /// which have their own setter method. If done anyway, the request will fail.
27937 ///
27938 /// # Additional Parameters
27939 ///
27940 /// * *alt* (query-string) - Data format for the response.
27941 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27942 /// * *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.
27943 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27944 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27945 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27946 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27947 pub fn param<T>(mut self, name: T, value: T) -> ManagementUnsampledReportListCall<'a, C>
27948 where
27949 T: AsRef<str>,
27950 {
27951 self._additional_params
27952 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27953 self
27954 }
27955
27956 /// Identifies the authorization scope for the method you are building.
27957 ///
27958 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27959 /// [`Scope::Readonly`].
27960 ///
27961 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27962 /// tokens for more than one scope.
27963 ///
27964 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27965 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27966 /// sufficient, a read-write scope will do as well.
27967 pub fn add_scope<St>(mut self, scope: St) -> ManagementUnsampledReportListCall<'a, C>
27968 where
27969 St: AsRef<str>,
27970 {
27971 self._scopes.insert(String::from(scope.as_ref()));
27972 self
27973 }
27974 /// Identifies the authorization scope(s) for the method you are building.
27975 ///
27976 /// See [`Self::add_scope()`] for details.
27977 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUnsampledReportListCall<'a, C>
27978 where
27979 I: IntoIterator<Item = St>,
27980 St: AsRef<str>,
27981 {
27982 self._scopes
27983 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27984 self
27985 }
27986
27987 /// Removes all scopes, and no default scope will be used either.
27988 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27989 /// for details).
27990 pub fn clear_scopes(mut self) -> ManagementUnsampledReportListCall<'a, C> {
27991 self._scopes.clear();
27992 self
27993 }
27994}
27995
27996/// Delete data associated with a previous upload.
27997///
27998/// A builder for the *uploads.deleteUploadData* method supported by a *management* resource.
27999/// It is not used directly, but through a [`ManagementMethods`] instance.
28000///
28001/// # Example
28002///
28003/// Instantiate a resource method builder
28004///
28005/// ```test_harness,no_run
28006/// # extern crate hyper;
28007/// # extern crate hyper_rustls;
28008/// # extern crate google_analytics3 as analytics3;
28009/// use analytics3::api::AnalyticsDataimportDeleteUploadDataRequest;
28010/// # async fn dox() {
28011/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28012///
28013/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28014/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28015/// # secret,
28016/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28017/// # ).build().await.unwrap();
28018///
28019/// # let client = hyper_util::client::legacy::Client::builder(
28020/// # hyper_util::rt::TokioExecutor::new()
28021/// # )
28022/// # .build(
28023/// # hyper_rustls::HttpsConnectorBuilder::new()
28024/// # .with_native_roots()
28025/// # .unwrap()
28026/// # .https_or_http()
28027/// # .enable_http1()
28028/// # .build()
28029/// # );
28030/// # let mut hub = Analytics::new(client, auth);
28031/// // As the method needs a request, you would usually fill it with the desired information
28032/// // into the respective structure. Some of the parts shown here might not be applicable !
28033/// // Values shown here are possibly random and not representative !
28034/// let mut req = AnalyticsDataimportDeleteUploadDataRequest::default();
28035///
28036/// // You can configure optional parameters by calling the respective setters at will, and
28037/// // execute the final call using `doit()`.
28038/// // Values shown here are possibly random and not representative !
28039/// let result = hub.management().uploads_delete_upload_data(req, "accountId", "webPropertyId", "customDataSourceId")
28040/// .doit().await;
28041/// # }
28042/// ```
28043pub struct ManagementUploadDeleteUploadDataCall<'a, C>
28044where
28045 C: 'a,
28046{
28047 hub: &'a Analytics<C>,
28048 _request: AnalyticsDataimportDeleteUploadDataRequest,
28049 _account_id: String,
28050 _web_property_id: String,
28051 _custom_data_source_id: String,
28052 _delegate: Option<&'a mut dyn common::Delegate>,
28053 _additional_params: HashMap<String, String>,
28054 _scopes: BTreeSet<String>,
28055}
28056
28057impl<'a, C> common::CallBuilder for ManagementUploadDeleteUploadDataCall<'a, C> {}
28058
28059impl<'a, C> ManagementUploadDeleteUploadDataCall<'a, C>
28060where
28061 C: common::Connector,
28062{
28063 /// Perform the operation you have build so far.
28064 pub async fn doit(mut self) -> common::Result<common::Response> {
28065 use std::borrow::Cow;
28066 use std::io::{Read, Seek};
28067
28068 use common::{url::Params, ToParts};
28069 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28070
28071 let mut dd = common::DefaultDelegate;
28072 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28073 dlg.begin(common::MethodInfo {
28074 id: "analytics.management.uploads.deleteUploadData",
28075 http_method: hyper::Method::POST,
28076 });
28077
28078 for &field in ["accountId", "webPropertyId", "customDataSourceId"].iter() {
28079 if self._additional_params.contains_key(field) {
28080 dlg.finished(false);
28081 return Err(common::Error::FieldClash(field));
28082 }
28083 }
28084
28085 let mut params = Params::with_capacity(5 + self._additional_params.len());
28086 params.push("accountId", self._account_id);
28087 params.push("webPropertyId", self._web_property_id);
28088 params.push("customDataSourceId", self._custom_data_source_id);
28089
28090 params.extend(self._additional_params.iter());
28091
28092 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/deleteUploadData";
28093 if self._scopes.is_empty() {
28094 self._scopes.insert(Scope::Full.as_ref().to_string());
28095 }
28096
28097 #[allow(clippy::single_element_loop)]
28098 for &(find_this, param_name) in [
28099 ("{accountId}", "accountId"),
28100 ("{webPropertyId}", "webPropertyId"),
28101 ("{customDataSourceId}", "customDataSourceId"),
28102 ]
28103 .iter()
28104 {
28105 url = params.uri_replacement(url, param_name, find_this, false);
28106 }
28107 {
28108 let to_remove = ["customDataSourceId", "webPropertyId", "accountId"];
28109 params.remove_params(&to_remove);
28110 }
28111
28112 let url = params.parse_with_url(&url);
28113
28114 let mut json_mime_type = mime::APPLICATION_JSON;
28115 let mut request_value_reader = {
28116 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28117 common::remove_json_null_values(&mut value);
28118 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28119 serde_json::to_writer(&mut dst, &value).unwrap();
28120 dst
28121 };
28122 let request_size = request_value_reader
28123 .seek(std::io::SeekFrom::End(0))
28124 .unwrap();
28125 request_value_reader
28126 .seek(std::io::SeekFrom::Start(0))
28127 .unwrap();
28128
28129 loop {
28130 let token = match self
28131 .hub
28132 .auth
28133 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28134 .await
28135 {
28136 Ok(token) => token,
28137 Err(e) => match dlg.token(e) {
28138 Ok(token) => token,
28139 Err(e) => {
28140 dlg.finished(false);
28141 return Err(common::Error::MissingToken(e));
28142 }
28143 },
28144 };
28145 request_value_reader
28146 .seek(std::io::SeekFrom::Start(0))
28147 .unwrap();
28148 let mut req_result = {
28149 let client = &self.hub.client;
28150 dlg.pre_request();
28151 let mut req_builder = hyper::Request::builder()
28152 .method(hyper::Method::POST)
28153 .uri(url.as_str())
28154 .header(USER_AGENT, self.hub._user_agent.clone());
28155
28156 if let Some(token) = token.as_ref() {
28157 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28158 }
28159
28160 let request = req_builder
28161 .header(CONTENT_TYPE, json_mime_type.to_string())
28162 .header(CONTENT_LENGTH, request_size as u64)
28163 .body(common::to_body(
28164 request_value_reader.get_ref().clone().into(),
28165 ));
28166
28167 client.request(request.unwrap()).await
28168 };
28169
28170 match req_result {
28171 Err(err) => {
28172 if let common::Retry::After(d) = dlg.http_error(&err) {
28173 sleep(d).await;
28174 continue;
28175 }
28176 dlg.finished(false);
28177 return Err(common::Error::HttpError(err));
28178 }
28179 Ok(res) => {
28180 let (mut parts, body) = res.into_parts();
28181 let mut body = common::Body::new(body);
28182 if !parts.status.is_success() {
28183 let bytes = common::to_bytes(body).await.unwrap_or_default();
28184 let error = serde_json::from_str(&common::to_string(&bytes));
28185 let response = common::to_response(parts, bytes.into());
28186
28187 if let common::Retry::After(d) =
28188 dlg.http_failure(&response, error.as_ref().ok())
28189 {
28190 sleep(d).await;
28191 continue;
28192 }
28193
28194 dlg.finished(false);
28195
28196 return Err(match error {
28197 Ok(value) => common::Error::BadRequest(value),
28198 _ => common::Error::Failure(response),
28199 });
28200 }
28201 let response = common::Response::from_parts(parts, body);
28202
28203 dlg.finished(true);
28204 return Ok(response);
28205 }
28206 }
28207 }
28208 }
28209
28210 ///
28211 /// Sets the *request* property to the given value.
28212 ///
28213 /// Even though the property as already been set when instantiating this call,
28214 /// we provide this method for API completeness.
28215 pub fn request(
28216 mut self,
28217 new_value: AnalyticsDataimportDeleteUploadDataRequest,
28218 ) -> ManagementUploadDeleteUploadDataCall<'a, C> {
28219 self._request = new_value;
28220 self
28221 }
28222 /// Account Id for the uploads to be deleted.
28223 ///
28224 /// Sets the *account id* path property to the given value.
28225 ///
28226 /// Even though the property as already been set when instantiating this call,
28227 /// we provide this method for API completeness.
28228 pub fn account_id(mut self, new_value: &str) -> ManagementUploadDeleteUploadDataCall<'a, C> {
28229 self._account_id = new_value.to_string();
28230 self
28231 }
28232 /// Web property Id for the uploads to be deleted.
28233 ///
28234 /// Sets the *web property id* path property to the given value.
28235 ///
28236 /// Even though the property as already been set when instantiating this call,
28237 /// we provide this method for API completeness.
28238 pub fn web_property_id(
28239 mut self,
28240 new_value: &str,
28241 ) -> ManagementUploadDeleteUploadDataCall<'a, C> {
28242 self._web_property_id = new_value.to_string();
28243 self
28244 }
28245 /// Custom data source Id for the uploads to be deleted.
28246 ///
28247 /// Sets the *custom data source id* path property to the given value.
28248 ///
28249 /// Even though the property as already been set when instantiating this call,
28250 /// we provide this method for API completeness.
28251 pub fn custom_data_source_id(
28252 mut self,
28253 new_value: &str,
28254 ) -> ManagementUploadDeleteUploadDataCall<'a, C> {
28255 self._custom_data_source_id = new_value.to_string();
28256 self
28257 }
28258 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28259 /// while executing the actual API request.
28260 ///
28261 /// ````text
28262 /// It should be used to handle progress information, and to implement a certain level of resilience.
28263 /// ````
28264 ///
28265 /// Sets the *delegate* property to the given value.
28266 pub fn delegate(
28267 mut self,
28268 new_value: &'a mut dyn common::Delegate,
28269 ) -> ManagementUploadDeleteUploadDataCall<'a, C> {
28270 self._delegate = Some(new_value);
28271 self
28272 }
28273
28274 /// Set any additional parameter of the query string used in the request.
28275 /// It should be used to set parameters which are not yet available through their own
28276 /// setters.
28277 ///
28278 /// Please note that this method must not be used to set any of the known parameters
28279 /// which have their own setter method. If done anyway, the request will fail.
28280 ///
28281 /// # Additional Parameters
28282 ///
28283 /// * *alt* (query-string) - Data format for the response.
28284 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28285 /// * *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.
28286 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28287 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28288 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28289 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28290 pub fn param<T>(mut self, name: T, value: T) -> ManagementUploadDeleteUploadDataCall<'a, C>
28291 where
28292 T: AsRef<str>,
28293 {
28294 self._additional_params
28295 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28296 self
28297 }
28298
28299 /// Identifies the authorization scope for the method you are building.
28300 ///
28301 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28302 /// [`Scope::Full`].
28303 ///
28304 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28305 /// tokens for more than one scope.
28306 ///
28307 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28308 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28309 /// sufficient, a read-write scope will do as well.
28310 pub fn add_scope<St>(mut self, scope: St) -> ManagementUploadDeleteUploadDataCall<'a, C>
28311 where
28312 St: AsRef<str>,
28313 {
28314 self._scopes.insert(String::from(scope.as_ref()));
28315 self
28316 }
28317 /// Identifies the authorization scope(s) for the method you are building.
28318 ///
28319 /// See [`Self::add_scope()`] for details.
28320 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUploadDeleteUploadDataCall<'a, C>
28321 where
28322 I: IntoIterator<Item = St>,
28323 St: AsRef<str>,
28324 {
28325 self._scopes
28326 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28327 self
28328 }
28329
28330 /// Removes all scopes, and no default scope will be used either.
28331 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28332 /// for details).
28333 pub fn clear_scopes(mut self) -> ManagementUploadDeleteUploadDataCall<'a, C> {
28334 self._scopes.clear();
28335 self
28336 }
28337}
28338
28339/// List uploads to which the user has access.
28340///
28341/// A builder for the *uploads.get* method supported by a *management* resource.
28342/// It is not used directly, but through a [`ManagementMethods`] instance.
28343///
28344/// # Example
28345///
28346/// Instantiate a resource method builder
28347///
28348/// ```test_harness,no_run
28349/// # extern crate hyper;
28350/// # extern crate hyper_rustls;
28351/// # extern crate google_analytics3 as analytics3;
28352/// # async fn dox() {
28353/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28354///
28355/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28356/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28357/// # secret,
28358/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28359/// # ).build().await.unwrap();
28360///
28361/// # let client = hyper_util::client::legacy::Client::builder(
28362/// # hyper_util::rt::TokioExecutor::new()
28363/// # )
28364/// # .build(
28365/// # hyper_rustls::HttpsConnectorBuilder::new()
28366/// # .with_native_roots()
28367/// # .unwrap()
28368/// # .https_or_http()
28369/// # .enable_http1()
28370/// # .build()
28371/// # );
28372/// # let mut hub = Analytics::new(client, auth);
28373/// // You can configure optional parameters by calling the respective setters at will, and
28374/// // execute the final call using `doit()`.
28375/// // Values shown here are possibly random and not representative !
28376/// let result = hub.management().uploads_get("accountId", "webPropertyId", "customDataSourceId", "uploadId")
28377/// .doit().await;
28378/// # }
28379/// ```
28380pub struct ManagementUploadGetCall<'a, C>
28381where
28382 C: 'a,
28383{
28384 hub: &'a Analytics<C>,
28385 _account_id: String,
28386 _web_property_id: String,
28387 _custom_data_source_id: String,
28388 _upload_id: String,
28389 _delegate: Option<&'a mut dyn common::Delegate>,
28390 _additional_params: HashMap<String, String>,
28391 _scopes: BTreeSet<String>,
28392}
28393
28394impl<'a, C> common::CallBuilder for ManagementUploadGetCall<'a, C> {}
28395
28396impl<'a, C> ManagementUploadGetCall<'a, C>
28397where
28398 C: common::Connector,
28399{
28400 /// Perform the operation you have build so far.
28401 pub async fn doit(mut self) -> common::Result<(common::Response, Upload)> {
28402 use std::borrow::Cow;
28403 use std::io::{Read, Seek};
28404
28405 use common::{url::Params, ToParts};
28406 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28407
28408 let mut dd = common::DefaultDelegate;
28409 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28410 dlg.begin(common::MethodInfo {
28411 id: "analytics.management.uploads.get",
28412 http_method: hyper::Method::GET,
28413 });
28414
28415 for &field in [
28416 "alt",
28417 "accountId",
28418 "webPropertyId",
28419 "customDataSourceId",
28420 "uploadId",
28421 ]
28422 .iter()
28423 {
28424 if self._additional_params.contains_key(field) {
28425 dlg.finished(false);
28426 return Err(common::Error::FieldClash(field));
28427 }
28428 }
28429
28430 let mut params = Params::with_capacity(6 + self._additional_params.len());
28431 params.push("accountId", self._account_id);
28432 params.push("webPropertyId", self._web_property_id);
28433 params.push("customDataSourceId", self._custom_data_source_id);
28434 params.push("uploadId", self._upload_id);
28435
28436 params.extend(self._additional_params.iter());
28437
28438 params.push("alt", "json");
28439 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads/{uploadId}";
28440 if self._scopes.is_empty() {
28441 self._scopes.insert(Scope::Readonly.as_ref().to_string());
28442 }
28443
28444 #[allow(clippy::single_element_loop)]
28445 for &(find_this, param_name) in [
28446 ("{accountId}", "accountId"),
28447 ("{webPropertyId}", "webPropertyId"),
28448 ("{customDataSourceId}", "customDataSourceId"),
28449 ("{uploadId}", "uploadId"),
28450 ]
28451 .iter()
28452 {
28453 url = params.uri_replacement(url, param_name, find_this, false);
28454 }
28455 {
28456 let to_remove = [
28457 "uploadId",
28458 "customDataSourceId",
28459 "webPropertyId",
28460 "accountId",
28461 ];
28462 params.remove_params(&to_remove);
28463 }
28464
28465 let url = params.parse_with_url(&url);
28466
28467 loop {
28468 let token = match self
28469 .hub
28470 .auth
28471 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28472 .await
28473 {
28474 Ok(token) => token,
28475 Err(e) => match dlg.token(e) {
28476 Ok(token) => token,
28477 Err(e) => {
28478 dlg.finished(false);
28479 return Err(common::Error::MissingToken(e));
28480 }
28481 },
28482 };
28483 let mut req_result = {
28484 let client = &self.hub.client;
28485 dlg.pre_request();
28486 let mut req_builder = hyper::Request::builder()
28487 .method(hyper::Method::GET)
28488 .uri(url.as_str())
28489 .header(USER_AGENT, self.hub._user_agent.clone());
28490
28491 if let Some(token) = token.as_ref() {
28492 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28493 }
28494
28495 let request = req_builder
28496 .header(CONTENT_LENGTH, 0_u64)
28497 .body(common::to_body::<String>(None));
28498
28499 client.request(request.unwrap()).await
28500 };
28501
28502 match req_result {
28503 Err(err) => {
28504 if let common::Retry::After(d) = dlg.http_error(&err) {
28505 sleep(d).await;
28506 continue;
28507 }
28508 dlg.finished(false);
28509 return Err(common::Error::HttpError(err));
28510 }
28511 Ok(res) => {
28512 let (mut parts, body) = res.into_parts();
28513 let mut body = common::Body::new(body);
28514 if !parts.status.is_success() {
28515 let bytes = common::to_bytes(body).await.unwrap_or_default();
28516 let error = serde_json::from_str(&common::to_string(&bytes));
28517 let response = common::to_response(parts, bytes.into());
28518
28519 if let common::Retry::After(d) =
28520 dlg.http_failure(&response, error.as_ref().ok())
28521 {
28522 sleep(d).await;
28523 continue;
28524 }
28525
28526 dlg.finished(false);
28527
28528 return Err(match error {
28529 Ok(value) => common::Error::BadRequest(value),
28530 _ => common::Error::Failure(response),
28531 });
28532 }
28533 let response = {
28534 let bytes = common::to_bytes(body).await.unwrap_or_default();
28535 let encoded = common::to_string(&bytes);
28536 match serde_json::from_str(&encoded) {
28537 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28538 Err(error) => {
28539 dlg.response_json_decode_error(&encoded, &error);
28540 return Err(common::Error::JsonDecodeError(
28541 encoded.to_string(),
28542 error,
28543 ));
28544 }
28545 }
28546 };
28547
28548 dlg.finished(true);
28549 return Ok(response);
28550 }
28551 }
28552 }
28553 }
28554
28555 /// Account Id for the upload to retrieve.
28556 ///
28557 /// Sets the *account id* path property to the given value.
28558 ///
28559 /// Even though the property as already been set when instantiating this call,
28560 /// we provide this method for API completeness.
28561 pub fn account_id(mut self, new_value: &str) -> ManagementUploadGetCall<'a, C> {
28562 self._account_id = new_value.to_string();
28563 self
28564 }
28565 /// Web property Id for the upload to retrieve.
28566 ///
28567 /// Sets the *web property id* path property to the given value.
28568 ///
28569 /// Even though the property as already been set when instantiating this call,
28570 /// we provide this method for API completeness.
28571 pub fn web_property_id(mut self, new_value: &str) -> ManagementUploadGetCall<'a, C> {
28572 self._web_property_id = new_value.to_string();
28573 self
28574 }
28575 /// Custom data source Id for upload to retrieve.
28576 ///
28577 /// Sets the *custom data source id* path property to the given value.
28578 ///
28579 /// Even though the property as already been set when instantiating this call,
28580 /// we provide this method for API completeness.
28581 pub fn custom_data_source_id(mut self, new_value: &str) -> ManagementUploadGetCall<'a, C> {
28582 self._custom_data_source_id = new_value.to_string();
28583 self
28584 }
28585 /// Upload Id to retrieve.
28586 ///
28587 /// Sets the *upload id* path property to the given value.
28588 ///
28589 /// Even though the property as already been set when instantiating this call,
28590 /// we provide this method for API completeness.
28591 pub fn upload_id(mut self, new_value: &str) -> ManagementUploadGetCall<'a, C> {
28592 self._upload_id = new_value.to_string();
28593 self
28594 }
28595 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28596 /// while executing the actual API request.
28597 ///
28598 /// ````text
28599 /// It should be used to handle progress information, and to implement a certain level of resilience.
28600 /// ````
28601 ///
28602 /// Sets the *delegate* property to the given value.
28603 pub fn delegate(
28604 mut self,
28605 new_value: &'a mut dyn common::Delegate,
28606 ) -> ManagementUploadGetCall<'a, C> {
28607 self._delegate = Some(new_value);
28608 self
28609 }
28610
28611 /// Set any additional parameter of the query string used in the request.
28612 /// It should be used to set parameters which are not yet available through their own
28613 /// setters.
28614 ///
28615 /// Please note that this method must not be used to set any of the known parameters
28616 /// which have their own setter method. If done anyway, the request will fail.
28617 ///
28618 /// # Additional Parameters
28619 ///
28620 /// * *alt* (query-string) - Data format for the response.
28621 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28622 /// * *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.
28623 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28624 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28625 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28626 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28627 pub fn param<T>(mut self, name: T, value: T) -> ManagementUploadGetCall<'a, C>
28628 where
28629 T: AsRef<str>,
28630 {
28631 self._additional_params
28632 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28633 self
28634 }
28635
28636 /// Identifies the authorization scope for the method you are building.
28637 ///
28638 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28639 /// [`Scope::Readonly`].
28640 ///
28641 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28642 /// tokens for more than one scope.
28643 ///
28644 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28645 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28646 /// sufficient, a read-write scope will do as well.
28647 pub fn add_scope<St>(mut self, scope: St) -> ManagementUploadGetCall<'a, C>
28648 where
28649 St: AsRef<str>,
28650 {
28651 self._scopes.insert(String::from(scope.as_ref()));
28652 self
28653 }
28654 /// Identifies the authorization scope(s) for the method you are building.
28655 ///
28656 /// See [`Self::add_scope()`] for details.
28657 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUploadGetCall<'a, C>
28658 where
28659 I: IntoIterator<Item = St>,
28660 St: AsRef<str>,
28661 {
28662 self._scopes
28663 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28664 self
28665 }
28666
28667 /// Removes all scopes, and no default scope will be used either.
28668 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28669 /// for details).
28670 pub fn clear_scopes(mut self) -> ManagementUploadGetCall<'a, C> {
28671 self._scopes.clear();
28672 self
28673 }
28674}
28675
28676/// List uploads to which the user has access.
28677///
28678/// A builder for the *uploads.list* method supported by a *management* resource.
28679/// It is not used directly, but through a [`ManagementMethods`] instance.
28680///
28681/// # Example
28682///
28683/// Instantiate a resource method builder
28684///
28685/// ```test_harness,no_run
28686/// # extern crate hyper;
28687/// # extern crate hyper_rustls;
28688/// # extern crate google_analytics3 as analytics3;
28689/// # async fn dox() {
28690/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28691///
28692/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28693/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28694/// # secret,
28695/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28696/// # ).build().await.unwrap();
28697///
28698/// # let client = hyper_util::client::legacy::Client::builder(
28699/// # hyper_util::rt::TokioExecutor::new()
28700/// # )
28701/// # .build(
28702/// # hyper_rustls::HttpsConnectorBuilder::new()
28703/// # .with_native_roots()
28704/// # .unwrap()
28705/// # .https_or_http()
28706/// # .enable_http1()
28707/// # .build()
28708/// # );
28709/// # let mut hub = Analytics::new(client, auth);
28710/// // You can configure optional parameters by calling the respective setters at will, and
28711/// // execute the final call using `doit()`.
28712/// // Values shown here are possibly random and not representative !
28713/// let result = hub.management().uploads_list("accountId", "webPropertyId", "customDataSourceId")
28714/// .start_index(-99)
28715/// .max_results(-82)
28716/// .doit().await;
28717/// # }
28718/// ```
28719pub struct ManagementUploadListCall<'a, C>
28720where
28721 C: 'a,
28722{
28723 hub: &'a Analytics<C>,
28724 _account_id: String,
28725 _web_property_id: String,
28726 _custom_data_source_id: String,
28727 _start_index: Option<i32>,
28728 _max_results: Option<i32>,
28729 _delegate: Option<&'a mut dyn common::Delegate>,
28730 _additional_params: HashMap<String, String>,
28731 _scopes: BTreeSet<String>,
28732}
28733
28734impl<'a, C> common::CallBuilder for ManagementUploadListCall<'a, C> {}
28735
28736impl<'a, C> ManagementUploadListCall<'a, C>
28737where
28738 C: common::Connector,
28739{
28740 /// Perform the operation you have build so far.
28741 pub async fn doit(mut self) -> common::Result<(common::Response, Uploads)> {
28742 use std::borrow::Cow;
28743 use std::io::{Read, Seek};
28744
28745 use common::{url::Params, ToParts};
28746 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28747
28748 let mut dd = common::DefaultDelegate;
28749 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28750 dlg.begin(common::MethodInfo {
28751 id: "analytics.management.uploads.list",
28752 http_method: hyper::Method::GET,
28753 });
28754
28755 for &field in [
28756 "alt",
28757 "accountId",
28758 "webPropertyId",
28759 "customDataSourceId",
28760 "start-index",
28761 "max-results",
28762 ]
28763 .iter()
28764 {
28765 if self._additional_params.contains_key(field) {
28766 dlg.finished(false);
28767 return Err(common::Error::FieldClash(field));
28768 }
28769 }
28770
28771 let mut params = Params::with_capacity(7 + self._additional_params.len());
28772 params.push("accountId", self._account_id);
28773 params.push("webPropertyId", self._web_property_id);
28774 params.push("customDataSourceId", self._custom_data_source_id);
28775 if let Some(value) = self._start_index.as_ref() {
28776 params.push("start-index", value.to_string());
28777 }
28778 if let Some(value) = self._max_results.as_ref() {
28779 params.push("max-results", value.to_string());
28780 }
28781
28782 params.extend(self._additional_params.iter());
28783
28784 params.push("alt", "json");
28785 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads";
28786 if self._scopes.is_empty() {
28787 self._scopes.insert(Scope::Readonly.as_ref().to_string());
28788 }
28789
28790 #[allow(clippy::single_element_loop)]
28791 for &(find_this, param_name) in [
28792 ("{accountId}", "accountId"),
28793 ("{webPropertyId}", "webPropertyId"),
28794 ("{customDataSourceId}", "customDataSourceId"),
28795 ]
28796 .iter()
28797 {
28798 url = params.uri_replacement(url, param_name, find_this, false);
28799 }
28800 {
28801 let to_remove = ["customDataSourceId", "webPropertyId", "accountId"];
28802 params.remove_params(&to_remove);
28803 }
28804
28805 let url = params.parse_with_url(&url);
28806
28807 loop {
28808 let token = match self
28809 .hub
28810 .auth
28811 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28812 .await
28813 {
28814 Ok(token) => token,
28815 Err(e) => match dlg.token(e) {
28816 Ok(token) => token,
28817 Err(e) => {
28818 dlg.finished(false);
28819 return Err(common::Error::MissingToken(e));
28820 }
28821 },
28822 };
28823 let mut req_result = {
28824 let client = &self.hub.client;
28825 dlg.pre_request();
28826 let mut req_builder = hyper::Request::builder()
28827 .method(hyper::Method::GET)
28828 .uri(url.as_str())
28829 .header(USER_AGENT, self.hub._user_agent.clone());
28830
28831 if let Some(token) = token.as_ref() {
28832 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28833 }
28834
28835 let request = req_builder
28836 .header(CONTENT_LENGTH, 0_u64)
28837 .body(common::to_body::<String>(None));
28838
28839 client.request(request.unwrap()).await
28840 };
28841
28842 match req_result {
28843 Err(err) => {
28844 if let common::Retry::After(d) = dlg.http_error(&err) {
28845 sleep(d).await;
28846 continue;
28847 }
28848 dlg.finished(false);
28849 return Err(common::Error::HttpError(err));
28850 }
28851 Ok(res) => {
28852 let (mut parts, body) = res.into_parts();
28853 let mut body = common::Body::new(body);
28854 if !parts.status.is_success() {
28855 let bytes = common::to_bytes(body).await.unwrap_or_default();
28856 let error = serde_json::from_str(&common::to_string(&bytes));
28857 let response = common::to_response(parts, bytes.into());
28858
28859 if let common::Retry::After(d) =
28860 dlg.http_failure(&response, error.as_ref().ok())
28861 {
28862 sleep(d).await;
28863 continue;
28864 }
28865
28866 dlg.finished(false);
28867
28868 return Err(match error {
28869 Ok(value) => common::Error::BadRequest(value),
28870 _ => common::Error::Failure(response),
28871 });
28872 }
28873 let response = {
28874 let bytes = common::to_bytes(body).await.unwrap_or_default();
28875 let encoded = common::to_string(&bytes);
28876 match serde_json::from_str(&encoded) {
28877 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28878 Err(error) => {
28879 dlg.response_json_decode_error(&encoded, &error);
28880 return Err(common::Error::JsonDecodeError(
28881 encoded.to_string(),
28882 error,
28883 ));
28884 }
28885 }
28886 };
28887
28888 dlg.finished(true);
28889 return Ok(response);
28890 }
28891 }
28892 }
28893 }
28894
28895 /// Account Id for the uploads to retrieve.
28896 ///
28897 /// Sets the *account id* path property to the given value.
28898 ///
28899 /// Even though the property as already been set when instantiating this call,
28900 /// we provide this method for API completeness.
28901 pub fn account_id(mut self, new_value: &str) -> ManagementUploadListCall<'a, C> {
28902 self._account_id = new_value.to_string();
28903 self
28904 }
28905 /// Web property Id for the uploads to retrieve.
28906 ///
28907 /// Sets the *web property id* path property to the given value.
28908 ///
28909 /// Even though the property as already been set when instantiating this call,
28910 /// we provide this method for API completeness.
28911 pub fn web_property_id(mut self, new_value: &str) -> ManagementUploadListCall<'a, C> {
28912 self._web_property_id = new_value.to_string();
28913 self
28914 }
28915 /// Custom data source Id for uploads to retrieve.
28916 ///
28917 /// Sets the *custom data source id* path property to the given value.
28918 ///
28919 /// Even though the property as already been set when instantiating this call,
28920 /// we provide this method for API completeness.
28921 pub fn custom_data_source_id(mut self, new_value: &str) -> ManagementUploadListCall<'a, C> {
28922 self._custom_data_source_id = new_value.to_string();
28923 self
28924 }
28925 /// A 1-based index of the first upload to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
28926 ///
28927 /// Sets the *start-index* query property to the given value.
28928 pub fn start_index(mut self, new_value: i32) -> ManagementUploadListCall<'a, C> {
28929 self._start_index = Some(new_value);
28930 self
28931 }
28932 /// The maximum number of uploads to include in this response.
28933 ///
28934 /// Sets the *max-results* query property to the given value.
28935 pub fn max_results(mut self, new_value: i32) -> ManagementUploadListCall<'a, C> {
28936 self._max_results = Some(new_value);
28937 self
28938 }
28939 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28940 /// while executing the actual API request.
28941 ///
28942 /// ````text
28943 /// It should be used to handle progress information, and to implement a certain level of resilience.
28944 /// ````
28945 ///
28946 /// Sets the *delegate* property to the given value.
28947 pub fn delegate(
28948 mut self,
28949 new_value: &'a mut dyn common::Delegate,
28950 ) -> ManagementUploadListCall<'a, C> {
28951 self._delegate = Some(new_value);
28952 self
28953 }
28954
28955 /// Set any additional parameter of the query string used in the request.
28956 /// It should be used to set parameters which are not yet available through their own
28957 /// setters.
28958 ///
28959 /// Please note that this method must not be used to set any of the known parameters
28960 /// which have their own setter method. If done anyway, the request will fail.
28961 ///
28962 /// # Additional Parameters
28963 ///
28964 /// * *alt* (query-string) - Data format for the response.
28965 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28966 /// * *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.
28967 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28968 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28969 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28970 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28971 pub fn param<T>(mut self, name: T, value: T) -> ManagementUploadListCall<'a, C>
28972 where
28973 T: AsRef<str>,
28974 {
28975 self._additional_params
28976 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28977 self
28978 }
28979
28980 /// Identifies the authorization scope for the method you are building.
28981 ///
28982 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28983 /// [`Scope::Readonly`].
28984 ///
28985 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28986 /// tokens for more than one scope.
28987 ///
28988 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28989 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28990 /// sufficient, a read-write scope will do as well.
28991 pub fn add_scope<St>(mut self, scope: St) -> ManagementUploadListCall<'a, C>
28992 where
28993 St: AsRef<str>,
28994 {
28995 self._scopes.insert(String::from(scope.as_ref()));
28996 self
28997 }
28998 /// Identifies the authorization scope(s) for the method you are building.
28999 ///
29000 /// See [`Self::add_scope()`] for details.
29001 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUploadListCall<'a, C>
29002 where
29003 I: IntoIterator<Item = St>,
29004 St: AsRef<str>,
29005 {
29006 self._scopes
29007 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29008 self
29009 }
29010
29011 /// Removes all scopes, and no default scope will be used either.
29012 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29013 /// for details).
29014 pub fn clear_scopes(mut self) -> ManagementUploadListCall<'a, C> {
29015 self._scopes.clear();
29016 self
29017 }
29018}
29019
29020/// Upload data for a custom data source.
29021///
29022/// A builder for the *uploads.uploadData* method supported by a *management* resource.
29023/// It is not used directly, but through a [`ManagementMethods`] instance.
29024///
29025/// # Example
29026///
29027/// Instantiate a resource method builder
29028///
29029/// ```test_harness,no_run
29030/// # extern crate hyper;
29031/// # extern crate hyper_rustls;
29032/// # extern crate google_analytics3 as analytics3;
29033/// use std::fs;
29034/// # async fn dox() {
29035/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29036///
29037/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29038/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29039/// # secret,
29040/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29041/// # ).build().await.unwrap();
29042///
29043/// # let client = hyper_util::client::legacy::Client::builder(
29044/// # hyper_util::rt::TokioExecutor::new()
29045/// # )
29046/// # .build(
29047/// # hyper_rustls::HttpsConnectorBuilder::new()
29048/// # .with_native_roots()
29049/// # .unwrap()
29050/// # .https_or_http()
29051/// # .enable_http1()
29052/// # .build()
29053/// # );
29054/// # let mut hub = Analytics::new(client, auth);
29055/// // You can configure optional parameters by calling the respective setters at will, and
29056/// // execute the final call using `upload(...)`.
29057/// // Values shown here are possibly random and not representative !
29058/// let result = hub.management().uploads_upload_data("accountId", "webPropertyId", "customDataSourceId")
29059/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
29060/// # }
29061/// ```
29062pub struct ManagementUploadUploadDataCall<'a, C>
29063where
29064 C: 'a,
29065{
29066 hub: &'a Analytics<C>,
29067 _account_id: String,
29068 _web_property_id: String,
29069 _custom_data_source_id: String,
29070 _delegate: Option<&'a mut dyn common::Delegate>,
29071 _additional_params: HashMap<String, String>,
29072 _scopes: BTreeSet<String>,
29073}
29074
29075impl<'a, C> common::CallBuilder for ManagementUploadUploadDataCall<'a, C> {}
29076
29077impl<'a, C> ManagementUploadUploadDataCall<'a, C>
29078where
29079 C: common::Connector,
29080{
29081 /// Perform the operation you have build so far.
29082 async fn doit<RS>(
29083 mut self,
29084 mut reader: RS,
29085 reader_mime_type: mime::Mime,
29086 protocol: common::UploadProtocol,
29087 ) -> common::Result<(common::Response, Upload)>
29088 where
29089 RS: common::ReadSeek,
29090 {
29091 use std::borrow::Cow;
29092 use std::io::{Read, Seek};
29093
29094 use common::{url::Params, ToParts};
29095 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29096
29097 let mut dd = common::DefaultDelegate;
29098 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29099 dlg.begin(common::MethodInfo {
29100 id: "analytics.management.uploads.uploadData",
29101 http_method: hyper::Method::POST,
29102 });
29103
29104 for &field in ["alt", "accountId", "webPropertyId", "customDataSourceId"].iter() {
29105 if self._additional_params.contains_key(field) {
29106 dlg.finished(false);
29107 return Err(common::Error::FieldClash(field));
29108 }
29109 }
29110
29111 let mut params = Params::with_capacity(5 + self._additional_params.len());
29112 params.push("accountId", self._account_id);
29113 params.push("webPropertyId", self._web_property_id);
29114 params.push("customDataSourceId", self._custom_data_source_id);
29115
29116 params.extend(self._additional_params.iter());
29117
29118 params.push("alt", "json");
29119 let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
29120 (self.hub._root_url.clone() + "resumable/upload/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads", "resumable")
29121 } else if protocol == common::UploadProtocol::Simple {
29122 (self.hub._root_url.clone() + "upload/analytics/v3/management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads", "multipart")
29123 } else {
29124 unreachable!()
29125 };
29126 params.push("uploadType", upload_type);
29127 if self._scopes.is_empty() {
29128 self._scopes.insert(Scope::Full.as_ref().to_string());
29129 }
29130
29131 #[allow(clippy::single_element_loop)]
29132 for &(find_this, param_name) in [
29133 ("{accountId}", "accountId"),
29134 ("{webPropertyId}", "webPropertyId"),
29135 ("{customDataSourceId}", "customDataSourceId"),
29136 ]
29137 .iter()
29138 {
29139 url = params.uri_replacement(url, param_name, find_this, false);
29140 }
29141 {
29142 let to_remove = ["customDataSourceId", "webPropertyId", "accountId"];
29143 params.remove_params(&to_remove);
29144 }
29145
29146 let url = params.parse_with_url(&url);
29147
29148 let mut upload_url_from_server;
29149
29150 loop {
29151 let token = match self
29152 .hub
29153 .auth
29154 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29155 .await
29156 {
29157 Ok(token) => token,
29158 Err(e) => match dlg.token(e) {
29159 Ok(token) => token,
29160 Err(e) => {
29161 dlg.finished(false);
29162 return Err(common::Error::MissingToken(e));
29163 }
29164 },
29165 };
29166 let mut req_result = {
29167 let client = &self.hub.client;
29168 dlg.pre_request();
29169 let mut req_builder = hyper::Request::builder()
29170 .method(hyper::Method::POST)
29171 .uri(url.as_str())
29172 .header(USER_AGENT, self.hub._user_agent.clone());
29173
29174 if let Some(token) = token.as_ref() {
29175 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29176 }
29177
29178 upload_url_from_server = true;
29179 if protocol == common::UploadProtocol::Resumable {
29180 req_builder = req_builder
29181 .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
29182 }
29183
29184 let request = if protocol == common::UploadProtocol::Simple {
29185 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
29186 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
29187 if size > 1073741824 {
29188 return Err(common::Error::UploadSizeLimitExceeded(size, 1073741824));
29189 }
29190 let mut bytes = Vec::with_capacity(size as usize);
29191 reader.read_to_end(&mut bytes)?;
29192 req_builder
29193 .header(CONTENT_TYPE, reader_mime_type.to_string())
29194 .header(CONTENT_LENGTH, size)
29195 .body(common::to_body(bytes.into()))
29196 } else {
29197 req_builder.body(common::to_body::<String>(None))
29198 };
29199
29200 client.request(request.unwrap()).await
29201 };
29202
29203 match req_result {
29204 Err(err) => {
29205 if let common::Retry::After(d) = dlg.http_error(&err) {
29206 sleep(d).await;
29207 continue;
29208 }
29209 dlg.finished(false);
29210 return Err(common::Error::HttpError(err));
29211 }
29212 Ok(res) => {
29213 let (mut parts, body) = res.into_parts();
29214 let mut body = common::Body::new(body);
29215 if !parts.status.is_success() {
29216 let bytes = common::to_bytes(body).await.unwrap_or_default();
29217 let error = serde_json::from_str(&common::to_string(&bytes));
29218 let response = common::to_response(parts, bytes.into());
29219
29220 if let common::Retry::After(d) =
29221 dlg.http_failure(&response, error.as_ref().ok())
29222 {
29223 sleep(d).await;
29224 continue;
29225 }
29226
29227 dlg.finished(false);
29228
29229 return Err(match error {
29230 Ok(value) => common::Error::BadRequest(value),
29231 _ => common::Error::Failure(response),
29232 });
29233 }
29234 if protocol == common::UploadProtocol::Resumable {
29235 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
29236 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
29237 if size > 1073741824 {
29238 return Err(common::Error::UploadSizeLimitExceeded(size, 1073741824));
29239 }
29240 let upload_result = {
29241 let url_str = &parts
29242 .headers
29243 .get("Location")
29244 .expect("LOCATION header is part of protocol")
29245 .to_str()
29246 .unwrap();
29247 if upload_url_from_server {
29248 dlg.store_upload_url(Some(url_str));
29249 }
29250
29251 common::ResumableUploadHelper {
29252 client: &self.hub.client,
29253 delegate: dlg,
29254 start_at: if upload_url_from_server {
29255 Some(0)
29256 } else {
29257 None
29258 },
29259 auth: &self.hub.auth,
29260 user_agent: &self.hub._user_agent,
29261 // TODO: Check this assumption
29262 auth_header: format!(
29263 "Bearer {}",
29264 token
29265 .ok_or_else(|| common::Error::MissingToken(
29266 "resumable upload requires token".into()
29267 ))?
29268 .as_str()
29269 ),
29270 url: url_str,
29271 reader: &mut reader,
29272 media_type: reader_mime_type.clone(),
29273 content_length: size,
29274 }
29275 .upload()
29276 .await
29277 };
29278 match upload_result {
29279 None => {
29280 dlg.finished(false);
29281 return Err(common::Error::Cancelled);
29282 }
29283 Some(Err(err)) => {
29284 dlg.finished(false);
29285 return Err(common::Error::HttpError(err));
29286 }
29287 Some(Ok(response)) => {
29288 (parts, body) = response.into_parts();
29289 if !parts.status.is_success() {
29290 dlg.store_upload_url(None);
29291 dlg.finished(false);
29292 return Err(common::Error::Failure(
29293 common::Response::from_parts(parts, body),
29294 ));
29295 }
29296 }
29297 }
29298 }
29299 let response = {
29300 let bytes = common::to_bytes(body).await.unwrap_or_default();
29301 let encoded = common::to_string(&bytes);
29302 match serde_json::from_str(&encoded) {
29303 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29304 Err(error) => {
29305 dlg.response_json_decode_error(&encoded, &error);
29306 return Err(common::Error::JsonDecodeError(
29307 encoded.to_string(),
29308 error,
29309 ));
29310 }
29311 }
29312 };
29313
29314 dlg.finished(true);
29315 return Ok(response);
29316 }
29317 }
29318 }
29319 }
29320
29321 /// Upload media in a resumable fashion.
29322 /// Even if the upload fails or is interrupted, it can be resumed for a
29323 /// certain amount of time as the server maintains state temporarily.
29324 ///
29325 /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
29326 /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
29327 /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
29328 /// `cancel_chunk_upload(...)`.
29329 ///
29330 /// * *multipart*: yes
29331 /// * *max size*: 1GB
29332 /// * *valid mime types*: 'application/octet-stream'
29333 pub async fn upload_resumable<RS>(
29334 self,
29335 resumeable_stream: RS,
29336 mime_type: mime::Mime,
29337 ) -> common::Result<(common::Response, Upload)>
29338 where
29339 RS: common::ReadSeek,
29340 {
29341 self.doit(
29342 resumeable_stream,
29343 mime_type,
29344 common::UploadProtocol::Resumable,
29345 )
29346 .await
29347 }
29348 /// Upload media all at once.
29349 /// If the upload fails for whichever reason, all progress is lost.
29350 ///
29351 /// * *multipart*: yes
29352 /// * *max size*: 1GB
29353 /// * *valid mime types*: 'application/octet-stream'
29354 pub async fn upload<RS>(
29355 self,
29356 stream: RS,
29357 mime_type: mime::Mime,
29358 ) -> common::Result<(common::Response, Upload)>
29359 where
29360 RS: common::ReadSeek,
29361 {
29362 self.doit(stream, mime_type, common::UploadProtocol::Simple)
29363 .await
29364 }
29365
29366 /// Account Id associated with the upload.
29367 ///
29368 /// Sets the *account id* path property to the given value.
29369 ///
29370 /// Even though the property as already been set when instantiating this call,
29371 /// we provide this method for API completeness.
29372 pub fn account_id(mut self, new_value: &str) -> ManagementUploadUploadDataCall<'a, C> {
29373 self._account_id = new_value.to_string();
29374 self
29375 }
29376 /// Web property UA-string associated with the upload.
29377 ///
29378 /// Sets the *web property id* path property to the given value.
29379 ///
29380 /// Even though the property as already been set when instantiating this call,
29381 /// we provide this method for API completeness.
29382 pub fn web_property_id(mut self, new_value: &str) -> ManagementUploadUploadDataCall<'a, C> {
29383 self._web_property_id = new_value.to_string();
29384 self
29385 }
29386 /// Custom data source Id to which the data being uploaded belongs.
29387 ///
29388 /// Sets the *custom data source id* path property to the given value.
29389 ///
29390 /// Even though the property as already been set when instantiating this call,
29391 /// we provide this method for API completeness.
29392 pub fn custom_data_source_id(
29393 mut self,
29394 new_value: &str,
29395 ) -> ManagementUploadUploadDataCall<'a, C> {
29396 self._custom_data_source_id = new_value.to_string();
29397 self
29398 }
29399 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29400 /// while executing the actual API request.
29401 ///
29402 /// ````text
29403 /// It should be used to handle progress information, and to implement a certain level of resilience.
29404 /// ````
29405 ///
29406 /// Sets the *delegate* property to the given value.
29407 pub fn delegate(
29408 mut self,
29409 new_value: &'a mut dyn common::Delegate,
29410 ) -> ManagementUploadUploadDataCall<'a, C> {
29411 self._delegate = Some(new_value);
29412 self
29413 }
29414
29415 /// Set any additional parameter of the query string used in the request.
29416 /// It should be used to set parameters which are not yet available through their own
29417 /// setters.
29418 ///
29419 /// Please note that this method must not be used to set any of the known parameters
29420 /// which have their own setter method. If done anyway, the request will fail.
29421 ///
29422 /// # Additional Parameters
29423 ///
29424 /// * *alt* (query-string) - Data format for the response.
29425 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29426 /// * *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.
29427 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29428 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29429 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29430 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29431 pub fn param<T>(mut self, name: T, value: T) -> ManagementUploadUploadDataCall<'a, C>
29432 where
29433 T: AsRef<str>,
29434 {
29435 self._additional_params
29436 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29437 self
29438 }
29439
29440 /// Identifies the authorization scope for the method you are building.
29441 ///
29442 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29443 /// [`Scope::Full`].
29444 ///
29445 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29446 /// tokens for more than one scope.
29447 ///
29448 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29449 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29450 /// sufficient, a read-write scope will do as well.
29451 pub fn add_scope<St>(mut self, scope: St) -> ManagementUploadUploadDataCall<'a, C>
29452 where
29453 St: AsRef<str>,
29454 {
29455 self._scopes.insert(String::from(scope.as_ref()));
29456 self
29457 }
29458 /// Identifies the authorization scope(s) for the method you are building.
29459 ///
29460 /// See [`Self::add_scope()`] for details.
29461 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementUploadUploadDataCall<'a, C>
29462 where
29463 I: IntoIterator<Item = St>,
29464 St: AsRef<str>,
29465 {
29466 self._scopes
29467 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29468 self
29469 }
29470
29471 /// Removes all scopes, and no default scope will be used either.
29472 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29473 /// for details).
29474 pub fn clear_scopes(mut self) -> ManagementUploadUploadDataCall<'a, C> {
29475 self._scopes.clear();
29476 self
29477 }
29478}
29479
29480/// Deletes a web property-Google Ads link.
29481///
29482/// A builder for the *webPropertyAdWordsLinks.delete* method supported by a *management* resource.
29483/// It is not used directly, but through a [`ManagementMethods`] instance.
29484///
29485/// # Example
29486///
29487/// Instantiate a resource method builder
29488///
29489/// ```test_harness,no_run
29490/// # extern crate hyper;
29491/// # extern crate hyper_rustls;
29492/// # extern crate google_analytics3 as analytics3;
29493/// # async fn dox() {
29494/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29495///
29496/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29497/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29498/// # secret,
29499/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29500/// # ).build().await.unwrap();
29501///
29502/// # let client = hyper_util::client::legacy::Client::builder(
29503/// # hyper_util::rt::TokioExecutor::new()
29504/// # )
29505/// # .build(
29506/// # hyper_rustls::HttpsConnectorBuilder::new()
29507/// # .with_native_roots()
29508/// # .unwrap()
29509/// # .https_or_http()
29510/// # .enable_http1()
29511/// # .build()
29512/// # );
29513/// # let mut hub = Analytics::new(client, auth);
29514/// // You can configure optional parameters by calling the respective setters at will, and
29515/// // execute the final call using `doit()`.
29516/// // Values shown here are possibly random and not representative !
29517/// let result = hub.management().web_property_ad_words_links_delete("accountId", "webPropertyId", "webPropertyAdWordsLinkId")
29518/// .doit().await;
29519/// # }
29520/// ```
29521pub struct ManagementWebPropertyAdWordsLinkDeleteCall<'a, C>
29522where
29523 C: 'a,
29524{
29525 hub: &'a Analytics<C>,
29526 _account_id: String,
29527 _web_property_id: String,
29528 _web_property_ad_words_link_id: String,
29529 _delegate: Option<&'a mut dyn common::Delegate>,
29530 _additional_params: HashMap<String, String>,
29531 _scopes: BTreeSet<String>,
29532}
29533
29534impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {}
29535
29536impl<'a, C> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C>
29537where
29538 C: common::Connector,
29539{
29540 /// Perform the operation you have build so far.
29541 pub async fn doit(mut self) -> common::Result<common::Response> {
29542 use std::borrow::Cow;
29543 use std::io::{Read, Seek};
29544
29545 use common::{url::Params, ToParts};
29546 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29547
29548 let mut dd = common::DefaultDelegate;
29549 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29550 dlg.begin(common::MethodInfo {
29551 id: "analytics.management.webPropertyAdWordsLinks.delete",
29552 http_method: hyper::Method::DELETE,
29553 });
29554
29555 for &field in ["accountId", "webPropertyId", "webPropertyAdWordsLinkId"].iter() {
29556 if self._additional_params.contains_key(field) {
29557 dlg.finished(false);
29558 return Err(common::Error::FieldClash(field));
29559 }
29560 }
29561
29562 let mut params = Params::with_capacity(4 + self._additional_params.len());
29563 params.push("accountId", self._account_id);
29564 params.push("webPropertyId", self._web_property_id);
29565 params.push(
29566 "webPropertyAdWordsLinkId",
29567 self._web_property_ad_words_link_id,
29568 );
29569
29570 params.extend(self._additional_params.iter());
29571
29572 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}";
29573 if self._scopes.is_empty() {
29574 self._scopes.insert(Scope::Edit.as_ref().to_string());
29575 }
29576
29577 #[allow(clippy::single_element_loop)]
29578 for &(find_this, param_name) in [
29579 ("{accountId}", "accountId"),
29580 ("{webPropertyId}", "webPropertyId"),
29581 ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId"),
29582 ]
29583 .iter()
29584 {
29585 url = params.uri_replacement(url, param_name, find_this, false);
29586 }
29587 {
29588 let to_remove = ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"];
29589 params.remove_params(&to_remove);
29590 }
29591
29592 let url = params.parse_with_url(&url);
29593
29594 loop {
29595 let token = match self
29596 .hub
29597 .auth
29598 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29599 .await
29600 {
29601 Ok(token) => token,
29602 Err(e) => match dlg.token(e) {
29603 Ok(token) => token,
29604 Err(e) => {
29605 dlg.finished(false);
29606 return Err(common::Error::MissingToken(e));
29607 }
29608 },
29609 };
29610 let mut req_result = {
29611 let client = &self.hub.client;
29612 dlg.pre_request();
29613 let mut req_builder = hyper::Request::builder()
29614 .method(hyper::Method::DELETE)
29615 .uri(url.as_str())
29616 .header(USER_AGENT, self.hub._user_agent.clone());
29617
29618 if let Some(token) = token.as_ref() {
29619 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29620 }
29621
29622 let request = req_builder
29623 .header(CONTENT_LENGTH, 0_u64)
29624 .body(common::to_body::<String>(None));
29625
29626 client.request(request.unwrap()).await
29627 };
29628
29629 match req_result {
29630 Err(err) => {
29631 if let common::Retry::After(d) = dlg.http_error(&err) {
29632 sleep(d).await;
29633 continue;
29634 }
29635 dlg.finished(false);
29636 return Err(common::Error::HttpError(err));
29637 }
29638 Ok(res) => {
29639 let (mut parts, body) = res.into_parts();
29640 let mut body = common::Body::new(body);
29641 if !parts.status.is_success() {
29642 let bytes = common::to_bytes(body).await.unwrap_or_default();
29643 let error = serde_json::from_str(&common::to_string(&bytes));
29644 let response = common::to_response(parts, bytes.into());
29645
29646 if let common::Retry::After(d) =
29647 dlg.http_failure(&response, error.as_ref().ok())
29648 {
29649 sleep(d).await;
29650 continue;
29651 }
29652
29653 dlg.finished(false);
29654
29655 return Err(match error {
29656 Ok(value) => common::Error::BadRequest(value),
29657 _ => common::Error::Failure(response),
29658 });
29659 }
29660 let response = common::Response::from_parts(parts, body);
29661
29662 dlg.finished(true);
29663 return Ok(response);
29664 }
29665 }
29666 }
29667 }
29668
29669 /// ID of the account which the given web property belongs to.
29670 ///
29671 /// Sets the *account id* path property to the given value.
29672 ///
29673 /// Even though the property as already been set when instantiating this call,
29674 /// we provide this method for API completeness.
29675 pub fn account_id(
29676 mut self,
29677 new_value: &str,
29678 ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
29679 self._account_id = new_value.to_string();
29680 self
29681 }
29682 /// Web property ID to delete the Google Ads link for.
29683 ///
29684 /// Sets the *web property id* path property to the given value.
29685 ///
29686 /// Even though the property as already been set when instantiating this call,
29687 /// we provide this method for API completeness.
29688 pub fn web_property_id(
29689 mut self,
29690 new_value: &str,
29691 ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
29692 self._web_property_id = new_value.to_string();
29693 self
29694 }
29695 /// Web property Google Ads link ID.
29696 ///
29697 /// Sets the *web property ad words link id* path property to the given value.
29698 ///
29699 /// Even though the property as already been set when instantiating this call,
29700 /// we provide this method for API completeness.
29701 pub fn web_property_ad_words_link_id(
29702 mut self,
29703 new_value: &str,
29704 ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
29705 self._web_property_ad_words_link_id = new_value.to_string();
29706 self
29707 }
29708 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29709 /// while executing the actual API request.
29710 ///
29711 /// ````text
29712 /// It should be used to handle progress information, and to implement a certain level of resilience.
29713 /// ````
29714 ///
29715 /// Sets the *delegate* property to the given value.
29716 pub fn delegate(
29717 mut self,
29718 new_value: &'a mut dyn common::Delegate,
29719 ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
29720 self._delegate = Some(new_value);
29721 self
29722 }
29723
29724 /// Set any additional parameter of the query string used in the request.
29725 /// It should be used to set parameters which are not yet available through their own
29726 /// setters.
29727 ///
29728 /// Please note that this method must not be used to set any of the known parameters
29729 /// which have their own setter method. If done anyway, the request will fail.
29730 ///
29731 /// # Additional Parameters
29732 ///
29733 /// * *alt* (query-string) - Data format for the response.
29734 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29735 /// * *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.
29736 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29737 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29738 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29739 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29740 pub fn param<T>(
29741 mut self,
29742 name: T,
29743 value: T,
29744 ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C>
29745 where
29746 T: AsRef<str>,
29747 {
29748 self._additional_params
29749 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29750 self
29751 }
29752
29753 /// Identifies the authorization scope for the method you are building.
29754 ///
29755 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29756 /// [`Scope::Edit`].
29757 ///
29758 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29759 /// tokens for more than one scope.
29760 ///
29761 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29762 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29763 /// sufficient, a read-write scope will do as well.
29764 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C>
29765 where
29766 St: AsRef<str>,
29767 {
29768 self._scopes.insert(String::from(scope.as_ref()));
29769 self
29770 }
29771 /// Identifies the authorization scope(s) for the method you are building.
29772 ///
29773 /// See [`Self::add_scope()`] for details.
29774 pub fn add_scopes<I, St>(
29775 mut self,
29776 scopes: I,
29777 ) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C>
29778 where
29779 I: IntoIterator<Item = St>,
29780 St: AsRef<str>,
29781 {
29782 self._scopes
29783 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29784 self
29785 }
29786
29787 /// Removes all scopes, and no default scope will be used either.
29788 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29789 /// for details).
29790 pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C> {
29791 self._scopes.clear();
29792 self
29793 }
29794}
29795
29796/// Returns a web property-Google Ads link to which the user has access.
29797///
29798/// A builder for the *webPropertyAdWordsLinks.get* method supported by a *management* resource.
29799/// It is not used directly, but through a [`ManagementMethods`] instance.
29800///
29801/// # Example
29802///
29803/// Instantiate a resource method builder
29804///
29805/// ```test_harness,no_run
29806/// # extern crate hyper;
29807/// # extern crate hyper_rustls;
29808/// # extern crate google_analytics3 as analytics3;
29809/// # async fn dox() {
29810/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29811///
29812/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29813/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29814/// # secret,
29815/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29816/// # ).build().await.unwrap();
29817///
29818/// # let client = hyper_util::client::legacy::Client::builder(
29819/// # hyper_util::rt::TokioExecutor::new()
29820/// # )
29821/// # .build(
29822/// # hyper_rustls::HttpsConnectorBuilder::new()
29823/// # .with_native_roots()
29824/// # .unwrap()
29825/// # .https_or_http()
29826/// # .enable_http1()
29827/// # .build()
29828/// # );
29829/// # let mut hub = Analytics::new(client, auth);
29830/// // You can configure optional parameters by calling the respective setters at will, and
29831/// // execute the final call using `doit()`.
29832/// // Values shown here are possibly random and not representative !
29833/// let result = hub.management().web_property_ad_words_links_get("accountId", "webPropertyId", "webPropertyAdWordsLinkId")
29834/// .doit().await;
29835/// # }
29836/// ```
29837pub struct ManagementWebPropertyAdWordsLinkGetCall<'a, C>
29838where
29839 C: 'a,
29840{
29841 hub: &'a Analytics<C>,
29842 _account_id: String,
29843 _web_property_id: String,
29844 _web_property_ad_words_link_id: String,
29845 _delegate: Option<&'a mut dyn common::Delegate>,
29846 _additional_params: HashMap<String, String>,
29847 _scopes: BTreeSet<String>,
29848}
29849
29850impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkGetCall<'a, C> {}
29851
29852impl<'a, C> ManagementWebPropertyAdWordsLinkGetCall<'a, C>
29853where
29854 C: common::Connector,
29855{
29856 /// Perform the operation you have build so far.
29857 pub async fn doit(mut self) -> common::Result<(common::Response, EntityAdWordsLink)> {
29858 use std::borrow::Cow;
29859 use std::io::{Read, Seek};
29860
29861 use common::{url::Params, ToParts};
29862 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29863
29864 let mut dd = common::DefaultDelegate;
29865 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29866 dlg.begin(common::MethodInfo {
29867 id: "analytics.management.webPropertyAdWordsLinks.get",
29868 http_method: hyper::Method::GET,
29869 });
29870
29871 for &field in [
29872 "alt",
29873 "accountId",
29874 "webPropertyId",
29875 "webPropertyAdWordsLinkId",
29876 ]
29877 .iter()
29878 {
29879 if self._additional_params.contains_key(field) {
29880 dlg.finished(false);
29881 return Err(common::Error::FieldClash(field));
29882 }
29883 }
29884
29885 let mut params = Params::with_capacity(5 + self._additional_params.len());
29886 params.push("accountId", self._account_id);
29887 params.push("webPropertyId", self._web_property_id);
29888 params.push(
29889 "webPropertyAdWordsLinkId",
29890 self._web_property_ad_words_link_id,
29891 );
29892
29893 params.extend(self._additional_params.iter());
29894
29895 params.push("alt", "json");
29896 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}";
29897 if self._scopes.is_empty() {
29898 self._scopes.insert(Scope::Readonly.as_ref().to_string());
29899 }
29900
29901 #[allow(clippy::single_element_loop)]
29902 for &(find_this, param_name) in [
29903 ("{accountId}", "accountId"),
29904 ("{webPropertyId}", "webPropertyId"),
29905 ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId"),
29906 ]
29907 .iter()
29908 {
29909 url = params.uri_replacement(url, param_name, find_this, false);
29910 }
29911 {
29912 let to_remove = ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"];
29913 params.remove_params(&to_remove);
29914 }
29915
29916 let url = params.parse_with_url(&url);
29917
29918 loop {
29919 let token = match self
29920 .hub
29921 .auth
29922 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29923 .await
29924 {
29925 Ok(token) => token,
29926 Err(e) => match dlg.token(e) {
29927 Ok(token) => token,
29928 Err(e) => {
29929 dlg.finished(false);
29930 return Err(common::Error::MissingToken(e));
29931 }
29932 },
29933 };
29934 let mut req_result = {
29935 let client = &self.hub.client;
29936 dlg.pre_request();
29937 let mut req_builder = hyper::Request::builder()
29938 .method(hyper::Method::GET)
29939 .uri(url.as_str())
29940 .header(USER_AGENT, self.hub._user_agent.clone());
29941
29942 if let Some(token) = token.as_ref() {
29943 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29944 }
29945
29946 let request = req_builder
29947 .header(CONTENT_LENGTH, 0_u64)
29948 .body(common::to_body::<String>(None));
29949
29950 client.request(request.unwrap()).await
29951 };
29952
29953 match req_result {
29954 Err(err) => {
29955 if let common::Retry::After(d) = dlg.http_error(&err) {
29956 sleep(d).await;
29957 continue;
29958 }
29959 dlg.finished(false);
29960 return Err(common::Error::HttpError(err));
29961 }
29962 Ok(res) => {
29963 let (mut parts, body) = res.into_parts();
29964 let mut body = common::Body::new(body);
29965 if !parts.status.is_success() {
29966 let bytes = common::to_bytes(body).await.unwrap_or_default();
29967 let error = serde_json::from_str(&common::to_string(&bytes));
29968 let response = common::to_response(parts, bytes.into());
29969
29970 if let common::Retry::After(d) =
29971 dlg.http_failure(&response, error.as_ref().ok())
29972 {
29973 sleep(d).await;
29974 continue;
29975 }
29976
29977 dlg.finished(false);
29978
29979 return Err(match error {
29980 Ok(value) => common::Error::BadRequest(value),
29981 _ => common::Error::Failure(response),
29982 });
29983 }
29984 let response = {
29985 let bytes = common::to_bytes(body).await.unwrap_or_default();
29986 let encoded = common::to_string(&bytes);
29987 match serde_json::from_str(&encoded) {
29988 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29989 Err(error) => {
29990 dlg.response_json_decode_error(&encoded, &error);
29991 return Err(common::Error::JsonDecodeError(
29992 encoded.to_string(),
29993 error,
29994 ));
29995 }
29996 }
29997 };
29998
29999 dlg.finished(true);
30000 return Ok(response);
30001 }
30002 }
30003 }
30004 }
30005
30006 /// ID of the account which the given web property belongs to.
30007 ///
30008 /// Sets the *account id* path property to the given value.
30009 ///
30010 /// Even though the property as already been set when instantiating this call,
30011 /// we provide this method for API completeness.
30012 pub fn account_id(mut self, new_value: &str) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
30013 self._account_id = new_value.to_string();
30014 self
30015 }
30016 /// Web property ID to retrieve the Google Ads link for.
30017 ///
30018 /// Sets the *web property id* path property to the given value.
30019 ///
30020 /// Even though the property as already been set when instantiating this call,
30021 /// we provide this method for API completeness.
30022 pub fn web_property_id(
30023 mut self,
30024 new_value: &str,
30025 ) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
30026 self._web_property_id = new_value.to_string();
30027 self
30028 }
30029 /// Web property-Google Ads link ID.
30030 ///
30031 /// Sets the *web property ad words link id* path property to the given value.
30032 ///
30033 /// Even though the property as already been set when instantiating this call,
30034 /// we provide this method for API completeness.
30035 pub fn web_property_ad_words_link_id(
30036 mut self,
30037 new_value: &str,
30038 ) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
30039 self._web_property_ad_words_link_id = new_value.to_string();
30040 self
30041 }
30042 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30043 /// while executing the actual API request.
30044 ///
30045 /// ````text
30046 /// It should be used to handle progress information, and to implement a certain level of resilience.
30047 /// ````
30048 ///
30049 /// Sets the *delegate* property to the given value.
30050 pub fn delegate(
30051 mut self,
30052 new_value: &'a mut dyn common::Delegate,
30053 ) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
30054 self._delegate = Some(new_value);
30055 self
30056 }
30057
30058 /// Set any additional parameter of the query string used in the request.
30059 /// It should be used to set parameters which are not yet available through their own
30060 /// setters.
30061 ///
30062 /// Please note that this method must not be used to set any of the known parameters
30063 /// which have their own setter method. If done anyway, the request will fail.
30064 ///
30065 /// # Additional Parameters
30066 ///
30067 /// * *alt* (query-string) - Data format for the response.
30068 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30069 /// * *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.
30070 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30071 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30072 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30073 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30074 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C>
30075 where
30076 T: AsRef<str>,
30077 {
30078 self._additional_params
30079 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30080 self
30081 }
30082
30083 /// Identifies the authorization scope for the method you are building.
30084 ///
30085 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30086 /// [`Scope::Readonly`].
30087 ///
30088 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30089 /// tokens for more than one scope.
30090 ///
30091 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30092 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30093 /// sufficient, a read-write scope will do as well.
30094 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C>
30095 where
30096 St: AsRef<str>,
30097 {
30098 self._scopes.insert(String::from(scope.as_ref()));
30099 self
30100 }
30101 /// Identifies the authorization scope(s) for the method you are building.
30102 ///
30103 /// See [`Self::add_scope()`] for details.
30104 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C>
30105 where
30106 I: IntoIterator<Item = St>,
30107 St: AsRef<str>,
30108 {
30109 self._scopes
30110 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30111 self
30112 }
30113
30114 /// Removes all scopes, and no default scope will be used either.
30115 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30116 /// for details).
30117 pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkGetCall<'a, C> {
30118 self._scopes.clear();
30119 self
30120 }
30121}
30122
30123/// Creates a webProperty-Google Ads link.
30124///
30125/// A builder for the *webPropertyAdWordsLinks.insert* method supported by a *management* resource.
30126/// It is not used directly, but through a [`ManagementMethods`] instance.
30127///
30128/// # Example
30129///
30130/// Instantiate a resource method builder
30131///
30132/// ```test_harness,no_run
30133/// # extern crate hyper;
30134/// # extern crate hyper_rustls;
30135/// # extern crate google_analytics3 as analytics3;
30136/// use analytics3::api::EntityAdWordsLink;
30137/// # async fn dox() {
30138/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30139///
30140/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30141/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30142/// # secret,
30143/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30144/// # ).build().await.unwrap();
30145///
30146/// # let client = hyper_util::client::legacy::Client::builder(
30147/// # hyper_util::rt::TokioExecutor::new()
30148/// # )
30149/// # .build(
30150/// # hyper_rustls::HttpsConnectorBuilder::new()
30151/// # .with_native_roots()
30152/// # .unwrap()
30153/// # .https_or_http()
30154/// # .enable_http1()
30155/// # .build()
30156/// # );
30157/// # let mut hub = Analytics::new(client, auth);
30158/// // As the method needs a request, you would usually fill it with the desired information
30159/// // into the respective structure. Some of the parts shown here might not be applicable !
30160/// // Values shown here are possibly random and not representative !
30161/// let mut req = EntityAdWordsLink::default();
30162///
30163/// // You can configure optional parameters by calling the respective setters at will, and
30164/// // execute the final call using `doit()`.
30165/// // Values shown here are possibly random and not representative !
30166/// let result = hub.management().web_property_ad_words_links_insert(req, "accountId", "webPropertyId")
30167/// .doit().await;
30168/// # }
30169/// ```
30170pub struct ManagementWebPropertyAdWordsLinkInsertCall<'a, C>
30171where
30172 C: 'a,
30173{
30174 hub: &'a Analytics<C>,
30175 _request: EntityAdWordsLink,
30176 _account_id: String,
30177 _web_property_id: String,
30178 _delegate: Option<&'a mut dyn common::Delegate>,
30179 _additional_params: HashMap<String, String>,
30180 _scopes: BTreeSet<String>,
30181}
30182
30183impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {}
30184
30185impl<'a, C> ManagementWebPropertyAdWordsLinkInsertCall<'a, C>
30186where
30187 C: common::Connector,
30188{
30189 /// Perform the operation you have build so far.
30190 pub async fn doit(mut self) -> common::Result<(common::Response, EntityAdWordsLink)> {
30191 use std::borrow::Cow;
30192 use std::io::{Read, Seek};
30193
30194 use common::{url::Params, ToParts};
30195 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30196
30197 let mut dd = common::DefaultDelegate;
30198 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30199 dlg.begin(common::MethodInfo {
30200 id: "analytics.management.webPropertyAdWordsLinks.insert",
30201 http_method: hyper::Method::POST,
30202 });
30203
30204 for &field in ["alt", "accountId", "webPropertyId"].iter() {
30205 if self._additional_params.contains_key(field) {
30206 dlg.finished(false);
30207 return Err(common::Error::FieldClash(field));
30208 }
30209 }
30210
30211 let mut params = Params::with_capacity(5 + self._additional_params.len());
30212 params.push("accountId", self._account_id);
30213 params.push("webPropertyId", self._web_property_id);
30214
30215 params.extend(self._additional_params.iter());
30216
30217 params.push("alt", "json");
30218 let mut url = self.hub._base_url.clone()
30219 + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks";
30220 if self._scopes.is_empty() {
30221 self._scopes.insert(Scope::Edit.as_ref().to_string());
30222 }
30223
30224 #[allow(clippy::single_element_loop)]
30225 for &(find_this, param_name) in [
30226 ("{accountId}", "accountId"),
30227 ("{webPropertyId}", "webPropertyId"),
30228 ]
30229 .iter()
30230 {
30231 url = params.uri_replacement(url, param_name, find_this, false);
30232 }
30233 {
30234 let to_remove = ["webPropertyId", "accountId"];
30235 params.remove_params(&to_remove);
30236 }
30237
30238 let url = params.parse_with_url(&url);
30239
30240 let mut json_mime_type = mime::APPLICATION_JSON;
30241 let mut request_value_reader = {
30242 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30243 common::remove_json_null_values(&mut value);
30244 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30245 serde_json::to_writer(&mut dst, &value).unwrap();
30246 dst
30247 };
30248 let request_size = request_value_reader
30249 .seek(std::io::SeekFrom::End(0))
30250 .unwrap();
30251 request_value_reader
30252 .seek(std::io::SeekFrom::Start(0))
30253 .unwrap();
30254
30255 loop {
30256 let token = match self
30257 .hub
30258 .auth
30259 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30260 .await
30261 {
30262 Ok(token) => token,
30263 Err(e) => match dlg.token(e) {
30264 Ok(token) => token,
30265 Err(e) => {
30266 dlg.finished(false);
30267 return Err(common::Error::MissingToken(e));
30268 }
30269 },
30270 };
30271 request_value_reader
30272 .seek(std::io::SeekFrom::Start(0))
30273 .unwrap();
30274 let mut req_result = {
30275 let client = &self.hub.client;
30276 dlg.pre_request();
30277 let mut req_builder = hyper::Request::builder()
30278 .method(hyper::Method::POST)
30279 .uri(url.as_str())
30280 .header(USER_AGENT, self.hub._user_agent.clone());
30281
30282 if let Some(token) = token.as_ref() {
30283 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30284 }
30285
30286 let request = req_builder
30287 .header(CONTENT_TYPE, json_mime_type.to_string())
30288 .header(CONTENT_LENGTH, request_size as u64)
30289 .body(common::to_body(
30290 request_value_reader.get_ref().clone().into(),
30291 ));
30292
30293 client.request(request.unwrap()).await
30294 };
30295
30296 match req_result {
30297 Err(err) => {
30298 if let common::Retry::After(d) = dlg.http_error(&err) {
30299 sleep(d).await;
30300 continue;
30301 }
30302 dlg.finished(false);
30303 return Err(common::Error::HttpError(err));
30304 }
30305 Ok(res) => {
30306 let (mut parts, body) = res.into_parts();
30307 let mut body = common::Body::new(body);
30308 if !parts.status.is_success() {
30309 let bytes = common::to_bytes(body).await.unwrap_or_default();
30310 let error = serde_json::from_str(&common::to_string(&bytes));
30311 let response = common::to_response(parts, bytes.into());
30312
30313 if let common::Retry::After(d) =
30314 dlg.http_failure(&response, error.as_ref().ok())
30315 {
30316 sleep(d).await;
30317 continue;
30318 }
30319
30320 dlg.finished(false);
30321
30322 return Err(match error {
30323 Ok(value) => common::Error::BadRequest(value),
30324 _ => common::Error::Failure(response),
30325 });
30326 }
30327 let response = {
30328 let bytes = common::to_bytes(body).await.unwrap_or_default();
30329 let encoded = common::to_string(&bytes);
30330 match serde_json::from_str(&encoded) {
30331 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30332 Err(error) => {
30333 dlg.response_json_decode_error(&encoded, &error);
30334 return Err(common::Error::JsonDecodeError(
30335 encoded.to_string(),
30336 error,
30337 ));
30338 }
30339 }
30340 };
30341
30342 dlg.finished(true);
30343 return Ok(response);
30344 }
30345 }
30346 }
30347 }
30348
30349 ///
30350 /// Sets the *request* property to the given value.
30351 ///
30352 /// Even though the property as already been set when instantiating this call,
30353 /// we provide this method for API completeness.
30354 pub fn request(
30355 mut self,
30356 new_value: EntityAdWordsLink,
30357 ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
30358 self._request = new_value;
30359 self
30360 }
30361 /// ID of the Google Analytics account to create the link for.
30362 ///
30363 /// Sets the *account id* path property to the given value.
30364 ///
30365 /// Even though the property as already been set when instantiating this call,
30366 /// we provide this method for API completeness.
30367 pub fn account_id(
30368 mut self,
30369 new_value: &str,
30370 ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
30371 self._account_id = new_value.to_string();
30372 self
30373 }
30374 /// Web property ID to create the link for.
30375 ///
30376 /// Sets the *web property id* path property to the given value.
30377 ///
30378 /// Even though the property as already been set when instantiating this call,
30379 /// we provide this method for API completeness.
30380 pub fn web_property_id(
30381 mut self,
30382 new_value: &str,
30383 ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
30384 self._web_property_id = new_value.to_string();
30385 self
30386 }
30387 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30388 /// while executing the actual API request.
30389 ///
30390 /// ````text
30391 /// It should be used to handle progress information, and to implement a certain level of resilience.
30392 /// ````
30393 ///
30394 /// Sets the *delegate* property to the given value.
30395 pub fn delegate(
30396 mut self,
30397 new_value: &'a mut dyn common::Delegate,
30398 ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
30399 self._delegate = Some(new_value);
30400 self
30401 }
30402
30403 /// Set any additional parameter of the query string used in the request.
30404 /// It should be used to set parameters which are not yet available through their own
30405 /// setters.
30406 ///
30407 /// Please note that this method must not be used to set any of the known parameters
30408 /// which have their own setter method. If done anyway, the request will fail.
30409 ///
30410 /// # Additional Parameters
30411 ///
30412 /// * *alt* (query-string) - Data format for the response.
30413 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30414 /// * *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.
30415 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30416 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30417 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30418 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30419 pub fn param<T>(
30420 mut self,
30421 name: T,
30422 value: T,
30423 ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C>
30424 where
30425 T: AsRef<str>,
30426 {
30427 self._additional_params
30428 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30429 self
30430 }
30431
30432 /// Identifies the authorization scope for the method you are building.
30433 ///
30434 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30435 /// [`Scope::Edit`].
30436 ///
30437 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30438 /// tokens for more than one scope.
30439 ///
30440 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30441 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30442 /// sufficient, a read-write scope will do as well.
30443 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C>
30444 where
30445 St: AsRef<str>,
30446 {
30447 self._scopes.insert(String::from(scope.as_ref()));
30448 self
30449 }
30450 /// Identifies the authorization scope(s) for the method you are building.
30451 ///
30452 /// See [`Self::add_scope()`] for details.
30453 pub fn add_scopes<I, St>(
30454 mut self,
30455 scopes: I,
30456 ) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C>
30457 where
30458 I: IntoIterator<Item = St>,
30459 St: AsRef<str>,
30460 {
30461 self._scopes
30462 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30463 self
30464 }
30465
30466 /// Removes all scopes, and no default scope will be used either.
30467 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30468 /// for details).
30469 pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkInsertCall<'a, C> {
30470 self._scopes.clear();
30471 self
30472 }
30473}
30474
30475/// Lists webProperty-Google Ads links for a given web property.
30476///
30477/// A builder for the *webPropertyAdWordsLinks.list* method supported by a *management* resource.
30478/// It is not used directly, but through a [`ManagementMethods`] instance.
30479///
30480/// # Example
30481///
30482/// Instantiate a resource method builder
30483///
30484/// ```test_harness,no_run
30485/// # extern crate hyper;
30486/// # extern crate hyper_rustls;
30487/// # extern crate google_analytics3 as analytics3;
30488/// # async fn dox() {
30489/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30490///
30491/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30492/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30493/// # secret,
30494/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30495/// # ).build().await.unwrap();
30496///
30497/// # let client = hyper_util::client::legacy::Client::builder(
30498/// # hyper_util::rt::TokioExecutor::new()
30499/// # )
30500/// # .build(
30501/// # hyper_rustls::HttpsConnectorBuilder::new()
30502/// # .with_native_roots()
30503/// # .unwrap()
30504/// # .https_or_http()
30505/// # .enable_http1()
30506/// # .build()
30507/// # );
30508/// # let mut hub = Analytics::new(client, auth);
30509/// // You can configure optional parameters by calling the respective setters at will, and
30510/// // execute the final call using `doit()`.
30511/// // Values shown here are possibly random and not representative !
30512/// let result = hub.management().web_property_ad_words_links_list("accountId", "webPropertyId")
30513/// .start_index(-81)
30514/// .max_results(-71)
30515/// .doit().await;
30516/// # }
30517/// ```
30518pub struct ManagementWebPropertyAdWordsLinkListCall<'a, C>
30519where
30520 C: 'a,
30521{
30522 hub: &'a Analytics<C>,
30523 _account_id: String,
30524 _web_property_id: String,
30525 _start_index: Option<i32>,
30526 _max_results: Option<i32>,
30527 _delegate: Option<&'a mut dyn common::Delegate>,
30528 _additional_params: HashMap<String, String>,
30529 _scopes: BTreeSet<String>,
30530}
30531
30532impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkListCall<'a, C> {}
30533
30534impl<'a, C> ManagementWebPropertyAdWordsLinkListCall<'a, C>
30535where
30536 C: common::Connector,
30537{
30538 /// Perform the operation you have build so far.
30539 pub async fn doit(mut self) -> common::Result<(common::Response, EntityAdWordsLinks)> {
30540 use std::borrow::Cow;
30541 use std::io::{Read, Seek};
30542
30543 use common::{url::Params, ToParts};
30544 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30545
30546 let mut dd = common::DefaultDelegate;
30547 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30548 dlg.begin(common::MethodInfo {
30549 id: "analytics.management.webPropertyAdWordsLinks.list",
30550 http_method: hyper::Method::GET,
30551 });
30552
30553 for &field in [
30554 "alt",
30555 "accountId",
30556 "webPropertyId",
30557 "start-index",
30558 "max-results",
30559 ]
30560 .iter()
30561 {
30562 if self._additional_params.contains_key(field) {
30563 dlg.finished(false);
30564 return Err(common::Error::FieldClash(field));
30565 }
30566 }
30567
30568 let mut params = Params::with_capacity(6 + self._additional_params.len());
30569 params.push("accountId", self._account_id);
30570 params.push("webPropertyId", self._web_property_id);
30571 if let Some(value) = self._start_index.as_ref() {
30572 params.push("start-index", value.to_string());
30573 }
30574 if let Some(value) = self._max_results.as_ref() {
30575 params.push("max-results", value.to_string());
30576 }
30577
30578 params.extend(self._additional_params.iter());
30579
30580 params.push("alt", "json");
30581 let mut url = self.hub._base_url.clone()
30582 + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks";
30583 if self._scopes.is_empty() {
30584 self._scopes.insert(Scope::Readonly.as_ref().to_string());
30585 }
30586
30587 #[allow(clippy::single_element_loop)]
30588 for &(find_this, param_name) in [
30589 ("{accountId}", "accountId"),
30590 ("{webPropertyId}", "webPropertyId"),
30591 ]
30592 .iter()
30593 {
30594 url = params.uri_replacement(url, param_name, find_this, false);
30595 }
30596 {
30597 let to_remove = ["webPropertyId", "accountId"];
30598 params.remove_params(&to_remove);
30599 }
30600
30601 let url = params.parse_with_url(&url);
30602
30603 loop {
30604 let token = match self
30605 .hub
30606 .auth
30607 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30608 .await
30609 {
30610 Ok(token) => token,
30611 Err(e) => match dlg.token(e) {
30612 Ok(token) => token,
30613 Err(e) => {
30614 dlg.finished(false);
30615 return Err(common::Error::MissingToken(e));
30616 }
30617 },
30618 };
30619 let mut req_result = {
30620 let client = &self.hub.client;
30621 dlg.pre_request();
30622 let mut req_builder = hyper::Request::builder()
30623 .method(hyper::Method::GET)
30624 .uri(url.as_str())
30625 .header(USER_AGENT, self.hub._user_agent.clone());
30626
30627 if let Some(token) = token.as_ref() {
30628 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30629 }
30630
30631 let request = req_builder
30632 .header(CONTENT_LENGTH, 0_u64)
30633 .body(common::to_body::<String>(None));
30634
30635 client.request(request.unwrap()).await
30636 };
30637
30638 match req_result {
30639 Err(err) => {
30640 if let common::Retry::After(d) = dlg.http_error(&err) {
30641 sleep(d).await;
30642 continue;
30643 }
30644 dlg.finished(false);
30645 return Err(common::Error::HttpError(err));
30646 }
30647 Ok(res) => {
30648 let (mut parts, body) = res.into_parts();
30649 let mut body = common::Body::new(body);
30650 if !parts.status.is_success() {
30651 let bytes = common::to_bytes(body).await.unwrap_or_default();
30652 let error = serde_json::from_str(&common::to_string(&bytes));
30653 let response = common::to_response(parts, bytes.into());
30654
30655 if let common::Retry::After(d) =
30656 dlg.http_failure(&response, error.as_ref().ok())
30657 {
30658 sleep(d).await;
30659 continue;
30660 }
30661
30662 dlg.finished(false);
30663
30664 return Err(match error {
30665 Ok(value) => common::Error::BadRequest(value),
30666 _ => common::Error::Failure(response),
30667 });
30668 }
30669 let response = {
30670 let bytes = common::to_bytes(body).await.unwrap_or_default();
30671 let encoded = common::to_string(&bytes);
30672 match serde_json::from_str(&encoded) {
30673 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30674 Err(error) => {
30675 dlg.response_json_decode_error(&encoded, &error);
30676 return Err(common::Error::JsonDecodeError(
30677 encoded.to_string(),
30678 error,
30679 ));
30680 }
30681 }
30682 };
30683
30684 dlg.finished(true);
30685 return Ok(response);
30686 }
30687 }
30688 }
30689 }
30690
30691 /// ID of the account which the given web property belongs to.
30692 ///
30693 /// Sets the *account id* path property to the given value.
30694 ///
30695 /// Even though the property as already been set when instantiating this call,
30696 /// we provide this method for API completeness.
30697 pub fn account_id(
30698 mut self,
30699 new_value: &str,
30700 ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
30701 self._account_id = new_value.to_string();
30702 self
30703 }
30704 /// Web property ID to retrieve the Google Ads links for.
30705 ///
30706 /// Sets the *web property id* path property to the given value.
30707 ///
30708 /// Even though the property as already been set when instantiating this call,
30709 /// we provide this method for API completeness.
30710 pub fn web_property_id(
30711 mut self,
30712 new_value: &str,
30713 ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
30714 self._web_property_id = new_value.to_string();
30715 self
30716 }
30717 /// An index of the first webProperty-Google Ads link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
30718 ///
30719 /// Sets the *start-index* query property to the given value.
30720 pub fn start_index(
30721 mut self,
30722 new_value: i32,
30723 ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
30724 self._start_index = Some(new_value);
30725 self
30726 }
30727 /// The maximum number of webProperty-Google Ads links to include in this response.
30728 ///
30729 /// Sets the *max-results* query property to the given value.
30730 pub fn max_results(
30731 mut self,
30732 new_value: i32,
30733 ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
30734 self._max_results = Some(new_value);
30735 self
30736 }
30737 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30738 /// while executing the actual API request.
30739 ///
30740 /// ````text
30741 /// It should be used to handle progress information, and to implement a certain level of resilience.
30742 /// ````
30743 ///
30744 /// Sets the *delegate* property to the given value.
30745 pub fn delegate(
30746 mut self,
30747 new_value: &'a mut dyn common::Delegate,
30748 ) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
30749 self._delegate = Some(new_value);
30750 self
30751 }
30752
30753 /// Set any additional parameter of the query string used in the request.
30754 /// It should be used to set parameters which are not yet available through their own
30755 /// setters.
30756 ///
30757 /// Please note that this method must not be used to set any of the known parameters
30758 /// which have their own setter method. If done anyway, the request will fail.
30759 ///
30760 /// # Additional Parameters
30761 ///
30762 /// * *alt* (query-string) - Data format for the response.
30763 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30764 /// * *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.
30765 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30766 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30767 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30768 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30769 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebPropertyAdWordsLinkListCall<'a, C>
30770 where
30771 T: AsRef<str>,
30772 {
30773 self._additional_params
30774 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30775 self
30776 }
30777
30778 /// Identifies the authorization scope for the method you are building.
30779 ///
30780 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30781 /// [`Scope::Readonly`].
30782 ///
30783 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30784 /// tokens for more than one scope.
30785 ///
30786 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30787 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30788 /// sufficient, a read-write scope will do as well.
30789 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkListCall<'a, C>
30790 where
30791 St: AsRef<str>,
30792 {
30793 self._scopes.insert(String::from(scope.as_ref()));
30794 self
30795 }
30796 /// Identifies the authorization scope(s) for the method you are building.
30797 ///
30798 /// See [`Self::add_scope()`] for details.
30799 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebPropertyAdWordsLinkListCall<'a, C>
30800 where
30801 I: IntoIterator<Item = St>,
30802 St: AsRef<str>,
30803 {
30804 self._scopes
30805 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30806 self
30807 }
30808
30809 /// Removes all scopes, and no default scope will be used either.
30810 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30811 /// for details).
30812 pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkListCall<'a, C> {
30813 self._scopes.clear();
30814 self
30815 }
30816}
30817
30818/// Updates an existing webProperty-Google Ads link. This method supports patch semantics.
30819///
30820/// A builder for the *webPropertyAdWordsLinks.patch* method supported by a *management* resource.
30821/// It is not used directly, but through a [`ManagementMethods`] instance.
30822///
30823/// # Example
30824///
30825/// Instantiate a resource method builder
30826///
30827/// ```test_harness,no_run
30828/// # extern crate hyper;
30829/// # extern crate hyper_rustls;
30830/// # extern crate google_analytics3 as analytics3;
30831/// use analytics3::api::EntityAdWordsLink;
30832/// # async fn dox() {
30833/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30834///
30835/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30836/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30837/// # secret,
30838/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30839/// # ).build().await.unwrap();
30840///
30841/// # let client = hyper_util::client::legacy::Client::builder(
30842/// # hyper_util::rt::TokioExecutor::new()
30843/// # )
30844/// # .build(
30845/// # hyper_rustls::HttpsConnectorBuilder::new()
30846/// # .with_native_roots()
30847/// # .unwrap()
30848/// # .https_or_http()
30849/// # .enable_http1()
30850/// # .build()
30851/// # );
30852/// # let mut hub = Analytics::new(client, auth);
30853/// // As the method needs a request, you would usually fill it with the desired information
30854/// // into the respective structure. Some of the parts shown here might not be applicable !
30855/// // Values shown here are possibly random and not representative !
30856/// let mut req = EntityAdWordsLink::default();
30857///
30858/// // You can configure optional parameters by calling the respective setters at will, and
30859/// // execute the final call using `doit()`.
30860/// // Values shown here are possibly random and not representative !
30861/// let result = hub.management().web_property_ad_words_links_patch(req, "accountId", "webPropertyId", "webPropertyAdWordsLinkId")
30862/// .doit().await;
30863/// # }
30864/// ```
30865pub struct ManagementWebPropertyAdWordsLinkPatchCall<'a, C>
30866where
30867 C: 'a,
30868{
30869 hub: &'a Analytics<C>,
30870 _request: EntityAdWordsLink,
30871 _account_id: String,
30872 _web_property_id: String,
30873 _web_property_ad_words_link_id: String,
30874 _delegate: Option<&'a mut dyn common::Delegate>,
30875 _additional_params: HashMap<String, String>,
30876 _scopes: BTreeSet<String>,
30877}
30878
30879impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {}
30880
30881impl<'a, C> ManagementWebPropertyAdWordsLinkPatchCall<'a, C>
30882where
30883 C: common::Connector,
30884{
30885 /// Perform the operation you have build so far.
30886 pub async fn doit(mut self) -> common::Result<(common::Response, EntityAdWordsLink)> {
30887 use std::borrow::Cow;
30888 use std::io::{Read, Seek};
30889
30890 use common::{url::Params, ToParts};
30891 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30892
30893 let mut dd = common::DefaultDelegate;
30894 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30895 dlg.begin(common::MethodInfo {
30896 id: "analytics.management.webPropertyAdWordsLinks.patch",
30897 http_method: hyper::Method::PATCH,
30898 });
30899
30900 for &field in [
30901 "alt",
30902 "accountId",
30903 "webPropertyId",
30904 "webPropertyAdWordsLinkId",
30905 ]
30906 .iter()
30907 {
30908 if self._additional_params.contains_key(field) {
30909 dlg.finished(false);
30910 return Err(common::Error::FieldClash(field));
30911 }
30912 }
30913
30914 let mut params = Params::with_capacity(6 + self._additional_params.len());
30915 params.push("accountId", self._account_id);
30916 params.push("webPropertyId", self._web_property_id);
30917 params.push(
30918 "webPropertyAdWordsLinkId",
30919 self._web_property_ad_words_link_id,
30920 );
30921
30922 params.extend(self._additional_params.iter());
30923
30924 params.push("alt", "json");
30925 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}";
30926 if self._scopes.is_empty() {
30927 self._scopes.insert(Scope::Edit.as_ref().to_string());
30928 }
30929
30930 #[allow(clippy::single_element_loop)]
30931 for &(find_this, param_name) in [
30932 ("{accountId}", "accountId"),
30933 ("{webPropertyId}", "webPropertyId"),
30934 ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId"),
30935 ]
30936 .iter()
30937 {
30938 url = params.uri_replacement(url, param_name, find_this, false);
30939 }
30940 {
30941 let to_remove = ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"];
30942 params.remove_params(&to_remove);
30943 }
30944
30945 let url = params.parse_with_url(&url);
30946
30947 let mut json_mime_type = mime::APPLICATION_JSON;
30948 let mut request_value_reader = {
30949 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30950 common::remove_json_null_values(&mut value);
30951 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30952 serde_json::to_writer(&mut dst, &value).unwrap();
30953 dst
30954 };
30955 let request_size = request_value_reader
30956 .seek(std::io::SeekFrom::End(0))
30957 .unwrap();
30958 request_value_reader
30959 .seek(std::io::SeekFrom::Start(0))
30960 .unwrap();
30961
30962 loop {
30963 let token = match self
30964 .hub
30965 .auth
30966 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30967 .await
30968 {
30969 Ok(token) => token,
30970 Err(e) => match dlg.token(e) {
30971 Ok(token) => token,
30972 Err(e) => {
30973 dlg.finished(false);
30974 return Err(common::Error::MissingToken(e));
30975 }
30976 },
30977 };
30978 request_value_reader
30979 .seek(std::io::SeekFrom::Start(0))
30980 .unwrap();
30981 let mut req_result = {
30982 let client = &self.hub.client;
30983 dlg.pre_request();
30984 let mut req_builder = hyper::Request::builder()
30985 .method(hyper::Method::PATCH)
30986 .uri(url.as_str())
30987 .header(USER_AGENT, self.hub._user_agent.clone());
30988
30989 if let Some(token) = token.as_ref() {
30990 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30991 }
30992
30993 let request = req_builder
30994 .header(CONTENT_TYPE, json_mime_type.to_string())
30995 .header(CONTENT_LENGTH, request_size as u64)
30996 .body(common::to_body(
30997 request_value_reader.get_ref().clone().into(),
30998 ));
30999
31000 client.request(request.unwrap()).await
31001 };
31002
31003 match req_result {
31004 Err(err) => {
31005 if let common::Retry::After(d) = dlg.http_error(&err) {
31006 sleep(d).await;
31007 continue;
31008 }
31009 dlg.finished(false);
31010 return Err(common::Error::HttpError(err));
31011 }
31012 Ok(res) => {
31013 let (mut parts, body) = res.into_parts();
31014 let mut body = common::Body::new(body);
31015 if !parts.status.is_success() {
31016 let bytes = common::to_bytes(body).await.unwrap_or_default();
31017 let error = serde_json::from_str(&common::to_string(&bytes));
31018 let response = common::to_response(parts, bytes.into());
31019
31020 if let common::Retry::After(d) =
31021 dlg.http_failure(&response, error.as_ref().ok())
31022 {
31023 sleep(d).await;
31024 continue;
31025 }
31026
31027 dlg.finished(false);
31028
31029 return Err(match error {
31030 Ok(value) => common::Error::BadRequest(value),
31031 _ => common::Error::Failure(response),
31032 });
31033 }
31034 let response = {
31035 let bytes = common::to_bytes(body).await.unwrap_or_default();
31036 let encoded = common::to_string(&bytes);
31037 match serde_json::from_str(&encoded) {
31038 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31039 Err(error) => {
31040 dlg.response_json_decode_error(&encoded, &error);
31041 return Err(common::Error::JsonDecodeError(
31042 encoded.to_string(),
31043 error,
31044 ));
31045 }
31046 }
31047 };
31048
31049 dlg.finished(true);
31050 return Ok(response);
31051 }
31052 }
31053 }
31054 }
31055
31056 ///
31057 /// Sets the *request* property to the given value.
31058 ///
31059 /// Even though the property as already been set when instantiating this call,
31060 /// we provide this method for API completeness.
31061 pub fn request(
31062 mut self,
31063 new_value: EntityAdWordsLink,
31064 ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31065 self._request = new_value;
31066 self
31067 }
31068 /// ID of the account which the given web property belongs to.
31069 ///
31070 /// Sets the *account id* path property to the given value.
31071 ///
31072 /// Even though the property as already been set when instantiating this call,
31073 /// we provide this method for API completeness.
31074 pub fn account_id(
31075 mut self,
31076 new_value: &str,
31077 ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31078 self._account_id = new_value.to_string();
31079 self
31080 }
31081 /// Web property ID to retrieve the Google Ads link for.
31082 ///
31083 /// Sets the *web property id* path property to the given value.
31084 ///
31085 /// Even though the property as already been set when instantiating this call,
31086 /// we provide this method for API completeness.
31087 pub fn web_property_id(
31088 mut self,
31089 new_value: &str,
31090 ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31091 self._web_property_id = new_value.to_string();
31092 self
31093 }
31094 /// Web property-Google Ads link ID.
31095 ///
31096 /// Sets the *web property ad words link id* path property to the given value.
31097 ///
31098 /// Even though the property as already been set when instantiating this call,
31099 /// we provide this method for API completeness.
31100 pub fn web_property_ad_words_link_id(
31101 mut self,
31102 new_value: &str,
31103 ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31104 self._web_property_ad_words_link_id = new_value.to_string();
31105 self
31106 }
31107 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31108 /// while executing the actual API request.
31109 ///
31110 /// ````text
31111 /// It should be used to handle progress information, and to implement a certain level of resilience.
31112 /// ````
31113 ///
31114 /// Sets the *delegate* property to the given value.
31115 pub fn delegate(
31116 mut self,
31117 new_value: &'a mut dyn common::Delegate,
31118 ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31119 self._delegate = Some(new_value);
31120 self
31121 }
31122
31123 /// Set any additional parameter of the query string used in the request.
31124 /// It should be used to set parameters which are not yet available through their own
31125 /// setters.
31126 ///
31127 /// Please note that this method must not be used to set any of the known parameters
31128 /// which have their own setter method. If done anyway, the request will fail.
31129 ///
31130 /// # Additional Parameters
31131 ///
31132 /// * *alt* (query-string) - Data format for the response.
31133 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31134 /// * *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.
31135 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31136 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31137 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31138 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31139 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C>
31140 where
31141 T: AsRef<str>,
31142 {
31143 self._additional_params
31144 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31145 self
31146 }
31147
31148 /// Identifies the authorization scope for the method you are building.
31149 ///
31150 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31151 /// [`Scope::Edit`].
31152 ///
31153 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31154 /// tokens for more than one scope.
31155 ///
31156 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31157 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31158 /// sufficient, a read-write scope will do as well.
31159 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C>
31160 where
31161 St: AsRef<str>,
31162 {
31163 self._scopes.insert(String::from(scope.as_ref()));
31164 self
31165 }
31166 /// Identifies the authorization scope(s) for the method you are building.
31167 ///
31168 /// See [`Self::add_scope()`] for details.
31169 pub fn add_scopes<I, St>(
31170 mut self,
31171 scopes: I,
31172 ) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C>
31173 where
31174 I: IntoIterator<Item = St>,
31175 St: AsRef<str>,
31176 {
31177 self._scopes
31178 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31179 self
31180 }
31181
31182 /// Removes all scopes, and no default scope will be used either.
31183 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31184 /// for details).
31185 pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkPatchCall<'a, C> {
31186 self._scopes.clear();
31187 self
31188 }
31189}
31190
31191/// Updates an existing webProperty-Google Ads link.
31192///
31193/// A builder for the *webPropertyAdWordsLinks.update* method supported by a *management* resource.
31194/// It is not used directly, but through a [`ManagementMethods`] instance.
31195///
31196/// # Example
31197///
31198/// Instantiate a resource method builder
31199///
31200/// ```test_harness,no_run
31201/// # extern crate hyper;
31202/// # extern crate hyper_rustls;
31203/// # extern crate google_analytics3 as analytics3;
31204/// use analytics3::api::EntityAdWordsLink;
31205/// # async fn dox() {
31206/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31207///
31208/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31209/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31210/// # secret,
31211/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31212/// # ).build().await.unwrap();
31213///
31214/// # let client = hyper_util::client::legacy::Client::builder(
31215/// # hyper_util::rt::TokioExecutor::new()
31216/// # )
31217/// # .build(
31218/// # hyper_rustls::HttpsConnectorBuilder::new()
31219/// # .with_native_roots()
31220/// # .unwrap()
31221/// # .https_or_http()
31222/// # .enable_http1()
31223/// # .build()
31224/// # );
31225/// # let mut hub = Analytics::new(client, auth);
31226/// // As the method needs a request, you would usually fill it with the desired information
31227/// // into the respective structure. Some of the parts shown here might not be applicable !
31228/// // Values shown here are possibly random and not representative !
31229/// let mut req = EntityAdWordsLink::default();
31230///
31231/// // You can configure optional parameters by calling the respective setters at will, and
31232/// // execute the final call using `doit()`.
31233/// // Values shown here are possibly random and not representative !
31234/// let result = hub.management().web_property_ad_words_links_update(req, "accountId", "webPropertyId", "webPropertyAdWordsLinkId")
31235/// .doit().await;
31236/// # }
31237/// ```
31238pub struct ManagementWebPropertyAdWordsLinkUpdateCall<'a, C>
31239where
31240 C: 'a,
31241{
31242 hub: &'a Analytics<C>,
31243 _request: EntityAdWordsLink,
31244 _account_id: String,
31245 _web_property_id: String,
31246 _web_property_ad_words_link_id: String,
31247 _delegate: Option<&'a mut dyn common::Delegate>,
31248 _additional_params: HashMap<String, String>,
31249 _scopes: BTreeSet<String>,
31250}
31251
31252impl<'a, C> common::CallBuilder for ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {}
31253
31254impl<'a, C> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C>
31255where
31256 C: common::Connector,
31257{
31258 /// Perform the operation you have build so far.
31259 pub async fn doit(mut self) -> common::Result<(common::Response, EntityAdWordsLink)> {
31260 use std::borrow::Cow;
31261 use std::io::{Read, Seek};
31262
31263 use common::{url::Params, ToParts};
31264 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31265
31266 let mut dd = common::DefaultDelegate;
31267 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31268 dlg.begin(common::MethodInfo {
31269 id: "analytics.management.webPropertyAdWordsLinks.update",
31270 http_method: hyper::Method::PUT,
31271 });
31272
31273 for &field in [
31274 "alt",
31275 "accountId",
31276 "webPropertyId",
31277 "webPropertyAdWordsLinkId",
31278 ]
31279 .iter()
31280 {
31281 if self._additional_params.contains_key(field) {
31282 dlg.finished(false);
31283 return Err(common::Error::FieldClash(field));
31284 }
31285 }
31286
31287 let mut params = Params::with_capacity(6 + self._additional_params.len());
31288 params.push("accountId", self._account_id);
31289 params.push("webPropertyId", self._web_property_id);
31290 params.push(
31291 "webPropertyAdWordsLinkId",
31292 self._web_property_ad_words_link_id,
31293 );
31294
31295 params.extend(self._additional_params.iter());
31296
31297 params.push("alt", "json");
31298 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}";
31299 if self._scopes.is_empty() {
31300 self._scopes.insert(Scope::Edit.as_ref().to_string());
31301 }
31302
31303 #[allow(clippy::single_element_loop)]
31304 for &(find_this, param_name) in [
31305 ("{accountId}", "accountId"),
31306 ("{webPropertyId}", "webPropertyId"),
31307 ("{webPropertyAdWordsLinkId}", "webPropertyAdWordsLinkId"),
31308 ]
31309 .iter()
31310 {
31311 url = params.uri_replacement(url, param_name, find_this, false);
31312 }
31313 {
31314 let to_remove = ["webPropertyAdWordsLinkId", "webPropertyId", "accountId"];
31315 params.remove_params(&to_remove);
31316 }
31317
31318 let url = params.parse_with_url(&url);
31319
31320 let mut json_mime_type = mime::APPLICATION_JSON;
31321 let mut request_value_reader = {
31322 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31323 common::remove_json_null_values(&mut value);
31324 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31325 serde_json::to_writer(&mut dst, &value).unwrap();
31326 dst
31327 };
31328 let request_size = request_value_reader
31329 .seek(std::io::SeekFrom::End(0))
31330 .unwrap();
31331 request_value_reader
31332 .seek(std::io::SeekFrom::Start(0))
31333 .unwrap();
31334
31335 loop {
31336 let token = match self
31337 .hub
31338 .auth
31339 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31340 .await
31341 {
31342 Ok(token) => token,
31343 Err(e) => match dlg.token(e) {
31344 Ok(token) => token,
31345 Err(e) => {
31346 dlg.finished(false);
31347 return Err(common::Error::MissingToken(e));
31348 }
31349 },
31350 };
31351 request_value_reader
31352 .seek(std::io::SeekFrom::Start(0))
31353 .unwrap();
31354 let mut req_result = {
31355 let client = &self.hub.client;
31356 dlg.pre_request();
31357 let mut req_builder = hyper::Request::builder()
31358 .method(hyper::Method::PUT)
31359 .uri(url.as_str())
31360 .header(USER_AGENT, self.hub._user_agent.clone());
31361
31362 if let Some(token) = token.as_ref() {
31363 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31364 }
31365
31366 let request = req_builder
31367 .header(CONTENT_TYPE, json_mime_type.to_string())
31368 .header(CONTENT_LENGTH, request_size as u64)
31369 .body(common::to_body(
31370 request_value_reader.get_ref().clone().into(),
31371 ));
31372
31373 client.request(request.unwrap()).await
31374 };
31375
31376 match req_result {
31377 Err(err) => {
31378 if let common::Retry::After(d) = dlg.http_error(&err) {
31379 sleep(d).await;
31380 continue;
31381 }
31382 dlg.finished(false);
31383 return Err(common::Error::HttpError(err));
31384 }
31385 Ok(res) => {
31386 let (mut parts, body) = res.into_parts();
31387 let mut body = common::Body::new(body);
31388 if !parts.status.is_success() {
31389 let bytes = common::to_bytes(body).await.unwrap_or_default();
31390 let error = serde_json::from_str(&common::to_string(&bytes));
31391 let response = common::to_response(parts, bytes.into());
31392
31393 if let common::Retry::After(d) =
31394 dlg.http_failure(&response, error.as_ref().ok())
31395 {
31396 sleep(d).await;
31397 continue;
31398 }
31399
31400 dlg.finished(false);
31401
31402 return Err(match error {
31403 Ok(value) => common::Error::BadRequest(value),
31404 _ => common::Error::Failure(response),
31405 });
31406 }
31407 let response = {
31408 let bytes = common::to_bytes(body).await.unwrap_or_default();
31409 let encoded = common::to_string(&bytes);
31410 match serde_json::from_str(&encoded) {
31411 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31412 Err(error) => {
31413 dlg.response_json_decode_error(&encoded, &error);
31414 return Err(common::Error::JsonDecodeError(
31415 encoded.to_string(),
31416 error,
31417 ));
31418 }
31419 }
31420 };
31421
31422 dlg.finished(true);
31423 return Ok(response);
31424 }
31425 }
31426 }
31427 }
31428
31429 ///
31430 /// Sets the *request* property to the given value.
31431 ///
31432 /// Even though the property as already been set when instantiating this call,
31433 /// we provide this method for API completeness.
31434 pub fn request(
31435 mut self,
31436 new_value: EntityAdWordsLink,
31437 ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
31438 self._request = new_value;
31439 self
31440 }
31441 /// ID of the account which the given web property belongs to.
31442 ///
31443 /// Sets the *account id* path property to the given value.
31444 ///
31445 /// Even though the property as already been set when instantiating this call,
31446 /// we provide this method for API completeness.
31447 pub fn account_id(
31448 mut self,
31449 new_value: &str,
31450 ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
31451 self._account_id = new_value.to_string();
31452 self
31453 }
31454 /// Web property ID to retrieve the Google Ads link for.
31455 ///
31456 /// Sets the *web property id* path property to the given value.
31457 ///
31458 /// Even though the property as already been set when instantiating this call,
31459 /// we provide this method for API completeness.
31460 pub fn web_property_id(
31461 mut self,
31462 new_value: &str,
31463 ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
31464 self._web_property_id = new_value.to_string();
31465 self
31466 }
31467 /// Web property-Google Ads link ID.
31468 ///
31469 /// Sets the *web property ad words link id* path property to the given value.
31470 ///
31471 /// Even though the property as already been set when instantiating this call,
31472 /// we provide this method for API completeness.
31473 pub fn web_property_ad_words_link_id(
31474 mut self,
31475 new_value: &str,
31476 ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
31477 self._web_property_ad_words_link_id = new_value.to_string();
31478 self
31479 }
31480 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31481 /// while executing the actual API request.
31482 ///
31483 /// ````text
31484 /// It should be used to handle progress information, and to implement a certain level of resilience.
31485 /// ````
31486 ///
31487 /// Sets the *delegate* property to the given value.
31488 pub fn delegate(
31489 mut self,
31490 new_value: &'a mut dyn common::Delegate,
31491 ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
31492 self._delegate = Some(new_value);
31493 self
31494 }
31495
31496 /// Set any additional parameter of the query string used in the request.
31497 /// It should be used to set parameters which are not yet available through their own
31498 /// setters.
31499 ///
31500 /// Please note that this method must not be used to set any of the known parameters
31501 /// which have their own setter method. If done anyway, the request will fail.
31502 ///
31503 /// # Additional Parameters
31504 ///
31505 /// * *alt* (query-string) - Data format for the response.
31506 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31507 /// * *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.
31508 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31509 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31510 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31511 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31512 pub fn param<T>(
31513 mut self,
31514 name: T,
31515 value: T,
31516 ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C>
31517 where
31518 T: AsRef<str>,
31519 {
31520 self._additional_params
31521 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31522 self
31523 }
31524
31525 /// Identifies the authorization scope for the method you are building.
31526 ///
31527 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31528 /// [`Scope::Edit`].
31529 ///
31530 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31531 /// tokens for more than one scope.
31532 ///
31533 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31534 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31535 /// sufficient, a read-write scope will do as well.
31536 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C>
31537 where
31538 St: AsRef<str>,
31539 {
31540 self._scopes.insert(String::from(scope.as_ref()));
31541 self
31542 }
31543 /// Identifies the authorization scope(s) for the method you are building.
31544 ///
31545 /// See [`Self::add_scope()`] for details.
31546 pub fn add_scopes<I, St>(
31547 mut self,
31548 scopes: I,
31549 ) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C>
31550 where
31551 I: IntoIterator<Item = St>,
31552 St: AsRef<str>,
31553 {
31554 self._scopes
31555 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31556 self
31557 }
31558
31559 /// Removes all scopes, and no default scope will be used either.
31560 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31561 /// for details).
31562 pub fn clear_scopes(mut self) -> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C> {
31563 self._scopes.clear();
31564 self
31565 }
31566}
31567
31568/// Gets a web property to which the user has access.
31569///
31570/// A builder for the *webproperties.get* method supported by a *management* resource.
31571/// It is not used directly, but through a [`ManagementMethods`] instance.
31572///
31573/// # Example
31574///
31575/// Instantiate a resource method builder
31576///
31577/// ```test_harness,no_run
31578/// # extern crate hyper;
31579/// # extern crate hyper_rustls;
31580/// # extern crate google_analytics3 as analytics3;
31581/// # async fn dox() {
31582/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31583///
31584/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31585/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31586/// # secret,
31587/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31588/// # ).build().await.unwrap();
31589///
31590/// # let client = hyper_util::client::legacy::Client::builder(
31591/// # hyper_util::rt::TokioExecutor::new()
31592/// # )
31593/// # .build(
31594/// # hyper_rustls::HttpsConnectorBuilder::new()
31595/// # .with_native_roots()
31596/// # .unwrap()
31597/// # .https_or_http()
31598/// # .enable_http1()
31599/// # .build()
31600/// # );
31601/// # let mut hub = Analytics::new(client, auth);
31602/// // You can configure optional parameters by calling the respective setters at will, and
31603/// // execute the final call using `doit()`.
31604/// // Values shown here are possibly random and not representative !
31605/// let result = hub.management().webproperties_get("accountId", "webPropertyId")
31606/// .doit().await;
31607/// # }
31608/// ```
31609pub struct ManagementWebpropertyGetCall<'a, C>
31610where
31611 C: 'a,
31612{
31613 hub: &'a Analytics<C>,
31614 _account_id: String,
31615 _web_property_id: String,
31616 _delegate: Option<&'a mut dyn common::Delegate>,
31617 _additional_params: HashMap<String, String>,
31618 _scopes: BTreeSet<String>,
31619}
31620
31621impl<'a, C> common::CallBuilder for ManagementWebpropertyGetCall<'a, C> {}
31622
31623impl<'a, C> ManagementWebpropertyGetCall<'a, C>
31624where
31625 C: common::Connector,
31626{
31627 /// Perform the operation you have build so far.
31628 pub async fn doit(mut self) -> common::Result<(common::Response, Webproperty)> {
31629 use std::borrow::Cow;
31630 use std::io::{Read, Seek};
31631
31632 use common::{url::Params, ToParts};
31633 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31634
31635 let mut dd = common::DefaultDelegate;
31636 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31637 dlg.begin(common::MethodInfo {
31638 id: "analytics.management.webproperties.get",
31639 http_method: hyper::Method::GET,
31640 });
31641
31642 for &field in ["alt", "accountId", "webPropertyId"].iter() {
31643 if self._additional_params.contains_key(field) {
31644 dlg.finished(false);
31645 return Err(common::Error::FieldClash(field));
31646 }
31647 }
31648
31649 let mut params = Params::with_capacity(4 + self._additional_params.len());
31650 params.push("accountId", self._account_id);
31651 params.push("webPropertyId", self._web_property_id);
31652
31653 params.extend(self._additional_params.iter());
31654
31655 params.push("alt", "json");
31656 let mut url = self.hub._base_url.clone()
31657 + "management/accounts/{accountId}/webproperties/{webPropertyId}";
31658 if self._scopes.is_empty() {
31659 self._scopes.insert(Scope::Readonly.as_ref().to_string());
31660 }
31661
31662 #[allow(clippy::single_element_loop)]
31663 for &(find_this, param_name) in [
31664 ("{accountId}", "accountId"),
31665 ("{webPropertyId}", "webPropertyId"),
31666 ]
31667 .iter()
31668 {
31669 url = params.uri_replacement(url, param_name, find_this, false);
31670 }
31671 {
31672 let to_remove = ["webPropertyId", "accountId"];
31673 params.remove_params(&to_remove);
31674 }
31675
31676 let url = params.parse_with_url(&url);
31677
31678 loop {
31679 let token = match self
31680 .hub
31681 .auth
31682 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31683 .await
31684 {
31685 Ok(token) => token,
31686 Err(e) => match dlg.token(e) {
31687 Ok(token) => token,
31688 Err(e) => {
31689 dlg.finished(false);
31690 return Err(common::Error::MissingToken(e));
31691 }
31692 },
31693 };
31694 let mut req_result = {
31695 let client = &self.hub.client;
31696 dlg.pre_request();
31697 let mut req_builder = hyper::Request::builder()
31698 .method(hyper::Method::GET)
31699 .uri(url.as_str())
31700 .header(USER_AGENT, self.hub._user_agent.clone());
31701
31702 if let Some(token) = token.as_ref() {
31703 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31704 }
31705
31706 let request = req_builder
31707 .header(CONTENT_LENGTH, 0_u64)
31708 .body(common::to_body::<String>(None));
31709
31710 client.request(request.unwrap()).await
31711 };
31712
31713 match req_result {
31714 Err(err) => {
31715 if let common::Retry::After(d) = dlg.http_error(&err) {
31716 sleep(d).await;
31717 continue;
31718 }
31719 dlg.finished(false);
31720 return Err(common::Error::HttpError(err));
31721 }
31722 Ok(res) => {
31723 let (mut parts, body) = res.into_parts();
31724 let mut body = common::Body::new(body);
31725 if !parts.status.is_success() {
31726 let bytes = common::to_bytes(body).await.unwrap_or_default();
31727 let error = serde_json::from_str(&common::to_string(&bytes));
31728 let response = common::to_response(parts, bytes.into());
31729
31730 if let common::Retry::After(d) =
31731 dlg.http_failure(&response, error.as_ref().ok())
31732 {
31733 sleep(d).await;
31734 continue;
31735 }
31736
31737 dlg.finished(false);
31738
31739 return Err(match error {
31740 Ok(value) => common::Error::BadRequest(value),
31741 _ => common::Error::Failure(response),
31742 });
31743 }
31744 let response = {
31745 let bytes = common::to_bytes(body).await.unwrap_or_default();
31746 let encoded = common::to_string(&bytes);
31747 match serde_json::from_str(&encoded) {
31748 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31749 Err(error) => {
31750 dlg.response_json_decode_error(&encoded, &error);
31751 return Err(common::Error::JsonDecodeError(
31752 encoded.to_string(),
31753 error,
31754 ));
31755 }
31756 }
31757 };
31758
31759 dlg.finished(true);
31760 return Ok(response);
31761 }
31762 }
31763 }
31764 }
31765
31766 /// Account ID to retrieve the web property for.
31767 ///
31768 /// Sets the *account id* path property to the given value.
31769 ///
31770 /// Even though the property as already been set when instantiating this call,
31771 /// we provide this method for API completeness.
31772 pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyGetCall<'a, C> {
31773 self._account_id = new_value.to_string();
31774 self
31775 }
31776 /// ID to retrieve the web property for.
31777 ///
31778 /// Sets the *web property id* path property to the given value.
31779 ///
31780 /// Even though the property as already been set when instantiating this call,
31781 /// we provide this method for API completeness.
31782 pub fn web_property_id(mut self, new_value: &str) -> ManagementWebpropertyGetCall<'a, C> {
31783 self._web_property_id = new_value.to_string();
31784 self
31785 }
31786 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31787 /// while executing the actual API request.
31788 ///
31789 /// ````text
31790 /// It should be used to handle progress information, and to implement a certain level of resilience.
31791 /// ````
31792 ///
31793 /// Sets the *delegate* property to the given value.
31794 pub fn delegate(
31795 mut self,
31796 new_value: &'a mut dyn common::Delegate,
31797 ) -> ManagementWebpropertyGetCall<'a, C> {
31798 self._delegate = Some(new_value);
31799 self
31800 }
31801
31802 /// Set any additional parameter of the query string used in the request.
31803 /// It should be used to set parameters which are not yet available through their own
31804 /// setters.
31805 ///
31806 /// Please note that this method must not be used to set any of the known parameters
31807 /// which have their own setter method. If done anyway, the request will fail.
31808 ///
31809 /// # Additional Parameters
31810 ///
31811 /// * *alt* (query-string) - Data format for the response.
31812 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31813 /// * *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.
31814 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31815 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31816 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31817 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31818 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyGetCall<'a, C>
31819 where
31820 T: AsRef<str>,
31821 {
31822 self._additional_params
31823 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31824 self
31825 }
31826
31827 /// Identifies the authorization scope for the method you are building.
31828 ///
31829 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31830 /// [`Scope::Readonly`].
31831 ///
31832 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31833 /// tokens for more than one scope.
31834 ///
31835 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31836 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31837 /// sufficient, a read-write scope will do as well.
31838 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyGetCall<'a, C>
31839 where
31840 St: AsRef<str>,
31841 {
31842 self._scopes.insert(String::from(scope.as_ref()));
31843 self
31844 }
31845 /// Identifies the authorization scope(s) for the method you are building.
31846 ///
31847 /// See [`Self::add_scope()`] for details.
31848 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyGetCall<'a, C>
31849 where
31850 I: IntoIterator<Item = St>,
31851 St: AsRef<str>,
31852 {
31853 self._scopes
31854 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31855 self
31856 }
31857
31858 /// Removes all scopes, and no default scope will be used either.
31859 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31860 /// for details).
31861 pub fn clear_scopes(mut self) -> ManagementWebpropertyGetCall<'a, C> {
31862 self._scopes.clear();
31863 self
31864 }
31865}
31866
31867/// 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.
31868///
31869/// A builder for the *webproperties.insert* method supported by a *management* resource.
31870/// It is not used directly, but through a [`ManagementMethods`] instance.
31871///
31872/// # Example
31873///
31874/// Instantiate a resource method builder
31875///
31876/// ```test_harness,no_run
31877/// # extern crate hyper;
31878/// # extern crate hyper_rustls;
31879/// # extern crate google_analytics3 as analytics3;
31880/// use analytics3::api::Webproperty;
31881/// # async fn dox() {
31882/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31883///
31884/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31885/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31886/// # secret,
31887/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31888/// # ).build().await.unwrap();
31889///
31890/// # let client = hyper_util::client::legacy::Client::builder(
31891/// # hyper_util::rt::TokioExecutor::new()
31892/// # )
31893/// # .build(
31894/// # hyper_rustls::HttpsConnectorBuilder::new()
31895/// # .with_native_roots()
31896/// # .unwrap()
31897/// # .https_or_http()
31898/// # .enable_http1()
31899/// # .build()
31900/// # );
31901/// # let mut hub = Analytics::new(client, auth);
31902/// // As the method needs a request, you would usually fill it with the desired information
31903/// // into the respective structure. Some of the parts shown here might not be applicable !
31904/// // Values shown here are possibly random and not representative !
31905/// let mut req = Webproperty::default();
31906///
31907/// // You can configure optional parameters by calling the respective setters at will, and
31908/// // execute the final call using `doit()`.
31909/// // Values shown here are possibly random and not representative !
31910/// let result = hub.management().webproperties_insert(req, "accountId")
31911/// .doit().await;
31912/// # }
31913/// ```
31914pub struct ManagementWebpropertyInsertCall<'a, C>
31915where
31916 C: 'a,
31917{
31918 hub: &'a Analytics<C>,
31919 _request: Webproperty,
31920 _account_id: String,
31921 _delegate: Option<&'a mut dyn common::Delegate>,
31922 _additional_params: HashMap<String, String>,
31923 _scopes: BTreeSet<String>,
31924}
31925
31926impl<'a, C> common::CallBuilder for ManagementWebpropertyInsertCall<'a, C> {}
31927
31928impl<'a, C> ManagementWebpropertyInsertCall<'a, C>
31929where
31930 C: common::Connector,
31931{
31932 /// Perform the operation you have build so far.
31933 pub async fn doit(mut self) -> common::Result<(common::Response, Webproperty)> {
31934 use std::borrow::Cow;
31935 use std::io::{Read, Seek};
31936
31937 use common::{url::Params, ToParts};
31938 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31939
31940 let mut dd = common::DefaultDelegate;
31941 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31942 dlg.begin(common::MethodInfo {
31943 id: "analytics.management.webproperties.insert",
31944 http_method: hyper::Method::POST,
31945 });
31946
31947 for &field in ["alt", "accountId"].iter() {
31948 if self._additional_params.contains_key(field) {
31949 dlg.finished(false);
31950 return Err(common::Error::FieldClash(field));
31951 }
31952 }
31953
31954 let mut params = Params::with_capacity(4 + self._additional_params.len());
31955 params.push("accountId", self._account_id);
31956
31957 params.extend(self._additional_params.iter());
31958
31959 params.push("alt", "json");
31960 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties";
31961 if self._scopes.is_empty() {
31962 self._scopes.insert(Scope::Edit.as_ref().to_string());
31963 }
31964
31965 #[allow(clippy::single_element_loop)]
31966 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
31967 url = params.uri_replacement(url, param_name, find_this, false);
31968 }
31969 {
31970 let to_remove = ["accountId"];
31971 params.remove_params(&to_remove);
31972 }
31973
31974 let url = params.parse_with_url(&url);
31975
31976 let mut json_mime_type = mime::APPLICATION_JSON;
31977 let mut request_value_reader = {
31978 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31979 common::remove_json_null_values(&mut value);
31980 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31981 serde_json::to_writer(&mut dst, &value).unwrap();
31982 dst
31983 };
31984 let request_size = request_value_reader
31985 .seek(std::io::SeekFrom::End(0))
31986 .unwrap();
31987 request_value_reader
31988 .seek(std::io::SeekFrom::Start(0))
31989 .unwrap();
31990
31991 loop {
31992 let token = match self
31993 .hub
31994 .auth
31995 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31996 .await
31997 {
31998 Ok(token) => token,
31999 Err(e) => match dlg.token(e) {
32000 Ok(token) => token,
32001 Err(e) => {
32002 dlg.finished(false);
32003 return Err(common::Error::MissingToken(e));
32004 }
32005 },
32006 };
32007 request_value_reader
32008 .seek(std::io::SeekFrom::Start(0))
32009 .unwrap();
32010 let mut req_result = {
32011 let client = &self.hub.client;
32012 dlg.pre_request();
32013 let mut req_builder = hyper::Request::builder()
32014 .method(hyper::Method::POST)
32015 .uri(url.as_str())
32016 .header(USER_AGENT, self.hub._user_agent.clone());
32017
32018 if let Some(token) = token.as_ref() {
32019 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32020 }
32021
32022 let request = req_builder
32023 .header(CONTENT_TYPE, json_mime_type.to_string())
32024 .header(CONTENT_LENGTH, request_size as u64)
32025 .body(common::to_body(
32026 request_value_reader.get_ref().clone().into(),
32027 ));
32028
32029 client.request(request.unwrap()).await
32030 };
32031
32032 match req_result {
32033 Err(err) => {
32034 if let common::Retry::After(d) = dlg.http_error(&err) {
32035 sleep(d).await;
32036 continue;
32037 }
32038 dlg.finished(false);
32039 return Err(common::Error::HttpError(err));
32040 }
32041 Ok(res) => {
32042 let (mut parts, body) = res.into_parts();
32043 let mut body = common::Body::new(body);
32044 if !parts.status.is_success() {
32045 let bytes = common::to_bytes(body).await.unwrap_or_default();
32046 let error = serde_json::from_str(&common::to_string(&bytes));
32047 let response = common::to_response(parts, bytes.into());
32048
32049 if let common::Retry::After(d) =
32050 dlg.http_failure(&response, error.as_ref().ok())
32051 {
32052 sleep(d).await;
32053 continue;
32054 }
32055
32056 dlg.finished(false);
32057
32058 return Err(match error {
32059 Ok(value) => common::Error::BadRequest(value),
32060 _ => common::Error::Failure(response),
32061 });
32062 }
32063 let response = {
32064 let bytes = common::to_bytes(body).await.unwrap_or_default();
32065 let encoded = common::to_string(&bytes);
32066 match serde_json::from_str(&encoded) {
32067 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32068 Err(error) => {
32069 dlg.response_json_decode_error(&encoded, &error);
32070 return Err(common::Error::JsonDecodeError(
32071 encoded.to_string(),
32072 error,
32073 ));
32074 }
32075 }
32076 };
32077
32078 dlg.finished(true);
32079 return Ok(response);
32080 }
32081 }
32082 }
32083 }
32084
32085 ///
32086 /// Sets the *request* property to the given value.
32087 ///
32088 /// Even though the property as already been set when instantiating this call,
32089 /// we provide this method for API completeness.
32090 pub fn request(mut self, new_value: Webproperty) -> ManagementWebpropertyInsertCall<'a, C> {
32091 self._request = new_value;
32092 self
32093 }
32094 /// Account ID to create the web property for.
32095 ///
32096 /// Sets the *account id* path property to the given value.
32097 ///
32098 /// Even though the property as already been set when instantiating this call,
32099 /// we provide this method for API completeness.
32100 pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyInsertCall<'a, C> {
32101 self._account_id = new_value.to_string();
32102 self
32103 }
32104 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32105 /// while executing the actual API request.
32106 ///
32107 /// ````text
32108 /// It should be used to handle progress information, and to implement a certain level of resilience.
32109 /// ````
32110 ///
32111 /// Sets the *delegate* property to the given value.
32112 pub fn delegate(
32113 mut self,
32114 new_value: &'a mut dyn common::Delegate,
32115 ) -> ManagementWebpropertyInsertCall<'a, C> {
32116 self._delegate = Some(new_value);
32117 self
32118 }
32119
32120 /// Set any additional parameter of the query string used in the request.
32121 /// It should be used to set parameters which are not yet available through their own
32122 /// setters.
32123 ///
32124 /// Please note that this method must not be used to set any of the known parameters
32125 /// which have their own setter method. If done anyway, the request will fail.
32126 ///
32127 /// # Additional Parameters
32128 ///
32129 /// * *alt* (query-string) - Data format for the response.
32130 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32131 /// * *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.
32132 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32133 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32134 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32135 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32136 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyInsertCall<'a, C>
32137 where
32138 T: AsRef<str>,
32139 {
32140 self._additional_params
32141 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32142 self
32143 }
32144
32145 /// Identifies the authorization scope for the method you are building.
32146 ///
32147 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32148 /// [`Scope::Edit`].
32149 ///
32150 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32151 /// tokens for more than one scope.
32152 ///
32153 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32154 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32155 /// sufficient, a read-write scope will do as well.
32156 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyInsertCall<'a, C>
32157 where
32158 St: AsRef<str>,
32159 {
32160 self._scopes.insert(String::from(scope.as_ref()));
32161 self
32162 }
32163 /// Identifies the authorization scope(s) for the method you are building.
32164 ///
32165 /// See [`Self::add_scope()`] for details.
32166 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyInsertCall<'a, C>
32167 where
32168 I: IntoIterator<Item = St>,
32169 St: AsRef<str>,
32170 {
32171 self._scopes
32172 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32173 self
32174 }
32175
32176 /// Removes all scopes, and no default scope will be used either.
32177 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32178 /// for details).
32179 pub fn clear_scopes(mut self) -> ManagementWebpropertyInsertCall<'a, C> {
32180 self._scopes.clear();
32181 self
32182 }
32183}
32184
32185/// Lists web properties to which the user has access.
32186///
32187/// A builder for the *webproperties.list* method supported by a *management* resource.
32188/// It is not used directly, but through a [`ManagementMethods`] instance.
32189///
32190/// # Example
32191///
32192/// Instantiate a resource method builder
32193///
32194/// ```test_harness,no_run
32195/// # extern crate hyper;
32196/// # extern crate hyper_rustls;
32197/// # extern crate google_analytics3 as analytics3;
32198/// # async fn dox() {
32199/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32200///
32201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32202/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32203/// # secret,
32204/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32205/// # ).build().await.unwrap();
32206///
32207/// # let client = hyper_util::client::legacy::Client::builder(
32208/// # hyper_util::rt::TokioExecutor::new()
32209/// # )
32210/// # .build(
32211/// # hyper_rustls::HttpsConnectorBuilder::new()
32212/// # .with_native_roots()
32213/// # .unwrap()
32214/// # .https_or_http()
32215/// # .enable_http1()
32216/// # .build()
32217/// # );
32218/// # let mut hub = Analytics::new(client, auth);
32219/// // You can configure optional parameters by calling the respective setters at will, and
32220/// // execute the final call using `doit()`.
32221/// // Values shown here are possibly random and not representative !
32222/// let result = hub.management().webproperties_list("accountId")
32223/// .start_index(-15)
32224/// .max_results(-62)
32225/// .doit().await;
32226/// # }
32227/// ```
32228pub struct ManagementWebpropertyListCall<'a, C>
32229where
32230 C: 'a,
32231{
32232 hub: &'a Analytics<C>,
32233 _account_id: String,
32234 _start_index: Option<i32>,
32235 _max_results: Option<i32>,
32236 _delegate: Option<&'a mut dyn common::Delegate>,
32237 _additional_params: HashMap<String, String>,
32238 _scopes: BTreeSet<String>,
32239}
32240
32241impl<'a, C> common::CallBuilder for ManagementWebpropertyListCall<'a, C> {}
32242
32243impl<'a, C> ManagementWebpropertyListCall<'a, C>
32244where
32245 C: common::Connector,
32246{
32247 /// Perform the operation you have build so far.
32248 pub async fn doit(mut self) -> common::Result<(common::Response, Webproperties)> {
32249 use std::borrow::Cow;
32250 use std::io::{Read, Seek};
32251
32252 use common::{url::Params, ToParts};
32253 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32254
32255 let mut dd = common::DefaultDelegate;
32256 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32257 dlg.begin(common::MethodInfo {
32258 id: "analytics.management.webproperties.list",
32259 http_method: hyper::Method::GET,
32260 });
32261
32262 for &field in ["alt", "accountId", "start-index", "max-results"].iter() {
32263 if self._additional_params.contains_key(field) {
32264 dlg.finished(false);
32265 return Err(common::Error::FieldClash(field));
32266 }
32267 }
32268
32269 let mut params = Params::with_capacity(5 + self._additional_params.len());
32270 params.push("accountId", self._account_id);
32271 if let Some(value) = self._start_index.as_ref() {
32272 params.push("start-index", value.to_string());
32273 }
32274 if let Some(value) = self._max_results.as_ref() {
32275 params.push("max-results", value.to_string());
32276 }
32277
32278 params.extend(self._additional_params.iter());
32279
32280 params.push("alt", "json");
32281 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties";
32282 if self._scopes.is_empty() {
32283 self._scopes.insert(Scope::Readonly.as_ref().to_string());
32284 }
32285
32286 #[allow(clippy::single_element_loop)]
32287 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
32288 url = params.uri_replacement(url, param_name, find_this, false);
32289 }
32290 {
32291 let to_remove = ["accountId"];
32292 params.remove_params(&to_remove);
32293 }
32294
32295 let url = params.parse_with_url(&url);
32296
32297 loop {
32298 let token = match self
32299 .hub
32300 .auth
32301 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32302 .await
32303 {
32304 Ok(token) => token,
32305 Err(e) => match dlg.token(e) {
32306 Ok(token) => token,
32307 Err(e) => {
32308 dlg.finished(false);
32309 return Err(common::Error::MissingToken(e));
32310 }
32311 },
32312 };
32313 let mut req_result = {
32314 let client = &self.hub.client;
32315 dlg.pre_request();
32316 let mut req_builder = hyper::Request::builder()
32317 .method(hyper::Method::GET)
32318 .uri(url.as_str())
32319 .header(USER_AGENT, self.hub._user_agent.clone());
32320
32321 if let Some(token) = token.as_ref() {
32322 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32323 }
32324
32325 let request = req_builder
32326 .header(CONTENT_LENGTH, 0_u64)
32327 .body(common::to_body::<String>(None));
32328
32329 client.request(request.unwrap()).await
32330 };
32331
32332 match req_result {
32333 Err(err) => {
32334 if let common::Retry::After(d) = dlg.http_error(&err) {
32335 sleep(d).await;
32336 continue;
32337 }
32338 dlg.finished(false);
32339 return Err(common::Error::HttpError(err));
32340 }
32341 Ok(res) => {
32342 let (mut parts, body) = res.into_parts();
32343 let mut body = common::Body::new(body);
32344 if !parts.status.is_success() {
32345 let bytes = common::to_bytes(body).await.unwrap_or_default();
32346 let error = serde_json::from_str(&common::to_string(&bytes));
32347 let response = common::to_response(parts, bytes.into());
32348
32349 if let common::Retry::After(d) =
32350 dlg.http_failure(&response, error.as_ref().ok())
32351 {
32352 sleep(d).await;
32353 continue;
32354 }
32355
32356 dlg.finished(false);
32357
32358 return Err(match error {
32359 Ok(value) => common::Error::BadRequest(value),
32360 _ => common::Error::Failure(response),
32361 });
32362 }
32363 let response = {
32364 let bytes = common::to_bytes(body).await.unwrap_or_default();
32365 let encoded = common::to_string(&bytes);
32366 match serde_json::from_str(&encoded) {
32367 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32368 Err(error) => {
32369 dlg.response_json_decode_error(&encoded, &error);
32370 return Err(common::Error::JsonDecodeError(
32371 encoded.to_string(),
32372 error,
32373 ));
32374 }
32375 }
32376 };
32377
32378 dlg.finished(true);
32379 return Ok(response);
32380 }
32381 }
32382 }
32383 }
32384
32385 /// 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.
32386 ///
32387 /// Sets the *account id* path property to the given value.
32388 ///
32389 /// Even though the property as already been set when instantiating this call,
32390 /// we provide this method for API completeness.
32391 pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyListCall<'a, C> {
32392 self._account_id = new_value.to_string();
32393 self
32394 }
32395 /// An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
32396 ///
32397 /// Sets the *start-index* query property to the given value.
32398 pub fn start_index(mut self, new_value: i32) -> ManagementWebpropertyListCall<'a, C> {
32399 self._start_index = Some(new_value);
32400 self
32401 }
32402 /// The maximum number of web properties to include in this response.
32403 ///
32404 /// Sets the *max-results* query property to the given value.
32405 pub fn max_results(mut self, new_value: i32) -> ManagementWebpropertyListCall<'a, C> {
32406 self._max_results = Some(new_value);
32407 self
32408 }
32409 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32410 /// while executing the actual API request.
32411 ///
32412 /// ````text
32413 /// It should be used to handle progress information, and to implement a certain level of resilience.
32414 /// ````
32415 ///
32416 /// Sets the *delegate* property to the given value.
32417 pub fn delegate(
32418 mut self,
32419 new_value: &'a mut dyn common::Delegate,
32420 ) -> ManagementWebpropertyListCall<'a, C> {
32421 self._delegate = Some(new_value);
32422 self
32423 }
32424
32425 /// Set any additional parameter of the query string used in the request.
32426 /// It should be used to set parameters which are not yet available through their own
32427 /// setters.
32428 ///
32429 /// Please note that this method must not be used to set any of the known parameters
32430 /// which have their own setter method. If done anyway, the request will fail.
32431 ///
32432 /// # Additional Parameters
32433 ///
32434 /// * *alt* (query-string) - Data format for the response.
32435 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32436 /// * *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.
32437 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32438 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32439 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32440 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32441 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyListCall<'a, C>
32442 where
32443 T: AsRef<str>,
32444 {
32445 self._additional_params
32446 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32447 self
32448 }
32449
32450 /// Identifies the authorization scope for the method you are building.
32451 ///
32452 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32453 /// [`Scope::Readonly`].
32454 ///
32455 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32456 /// tokens for more than one scope.
32457 ///
32458 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32459 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32460 /// sufficient, a read-write scope will do as well.
32461 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyListCall<'a, C>
32462 where
32463 St: AsRef<str>,
32464 {
32465 self._scopes.insert(String::from(scope.as_ref()));
32466 self
32467 }
32468 /// Identifies the authorization scope(s) for the method you are building.
32469 ///
32470 /// See [`Self::add_scope()`] for details.
32471 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyListCall<'a, C>
32472 where
32473 I: IntoIterator<Item = St>,
32474 St: AsRef<str>,
32475 {
32476 self._scopes
32477 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32478 self
32479 }
32480
32481 /// Removes all scopes, and no default scope will be used either.
32482 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32483 /// for details).
32484 pub fn clear_scopes(mut self) -> ManagementWebpropertyListCall<'a, C> {
32485 self._scopes.clear();
32486 self
32487 }
32488}
32489
32490/// Updates an existing web property. This method supports patch semantics.
32491///
32492/// A builder for the *webproperties.patch* method supported by a *management* resource.
32493/// It is not used directly, but through a [`ManagementMethods`] instance.
32494///
32495/// # Example
32496///
32497/// Instantiate a resource method builder
32498///
32499/// ```test_harness,no_run
32500/// # extern crate hyper;
32501/// # extern crate hyper_rustls;
32502/// # extern crate google_analytics3 as analytics3;
32503/// use analytics3::api::Webproperty;
32504/// # async fn dox() {
32505/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32506///
32507/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32508/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32509/// # secret,
32510/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32511/// # ).build().await.unwrap();
32512///
32513/// # let client = hyper_util::client::legacy::Client::builder(
32514/// # hyper_util::rt::TokioExecutor::new()
32515/// # )
32516/// # .build(
32517/// # hyper_rustls::HttpsConnectorBuilder::new()
32518/// # .with_native_roots()
32519/// # .unwrap()
32520/// # .https_or_http()
32521/// # .enable_http1()
32522/// # .build()
32523/// # );
32524/// # let mut hub = Analytics::new(client, auth);
32525/// // As the method needs a request, you would usually fill it with the desired information
32526/// // into the respective structure. Some of the parts shown here might not be applicable !
32527/// // Values shown here are possibly random and not representative !
32528/// let mut req = Webproperty::default();
32529///
32530/// // You can configure optional parameters by calling the respective setters at will, and
32531/// // execute the final call using `doit()`.
32532/// // Values shown here are possibly random and not representative !
32533/// let result = hub.management().webproperties_patch(req, "accountId", "webPropertyId")
32534/// .doit().await;
32535/// # }
32536/// ```
32537pub struct ManagementWebpropertyPatchCall<'a, C>
32538where
32539 C: 'a,
32540{
32541 hub: &'a Analytics<C>,
32542 _request: Webproperty,
32543 _account_id: String,
32544 _web_property_id: String,
32545 _delegate: Option<&'a mut dyn common::Delegate>,
32546 _additional_params: HashMap<String, String>,
32547 _scopes: BTreeSet<String>,
32548}
32549
32550impl<'a, C> common::CallBuilder for ManagementWebpropertyPatchCall<'a, C> {}
32551
32552impl<'a, C> ManagementWebpropertyPatchCall<'a, C>
32553where
32554 C: common::Connector,
32555{
32556 /// Perform the operation you have build so far.
32557 pub async fn doit(mut self) -> common::Result<(common::Response, Webproperty)> {
32558 use std::borrow::Cow;
32559 use std::io::{Read, Seek};
32560
32561 use common::{url::Params, ToParts};
32562 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32563
32564 let mut dd = common::DefaultDelegate;
32565 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32566 dlg.begin(common::MethodInfo {
32567 id: "analytics.management.webproperties.patch",
32568 http_method: hyper::Method::PATCH,
32569 });
32570
32571 for &field in ["alt", "accountId", "webPropertyId"].iter() {
32572 if self._additional_params.contains_key(field) {
32573 dlg.finished(false);
32574 return Err(common::Error::FieldClash(field));
32575 }
32576 }
32577
32578 let mut params = Params::with_capacity(5 + self._additional_params.len());
32579 params.push("accountId", self._account_id);
32580 params.push("webPropertyId", self._web_property_id);
32581
32582 params.extend(self._additional_params.iter());
32583
32584 params.push("alt", "json");
32585 let mut url = self.hub._base_url.clone()
32586 + "management/accounts/{accountId}/webproperties/{webPropertyId}";
32587 if self._scopes.is_empty() {
32588 self._scopes.insert(Scope::Edit.as_ref().to_string());
32589 }
32590
32591 #[allow(clippy::single_element_loop)]
32592 for &(find_this, param_name) in [
32593 ("{accountId}", "accountId"),
32594 ("{webPropertyId}", "webPropertyId"),
32595 ]
32596 .iter()
32597 {
32598 url = params.uri_replacement(url, param_name, find_this, false);
32599 }
32600 {
32601 let to_remove = ["webPropertyId", "accountId"];
32602 params.remove_params(&to_remove);
32603 }
32604
32605 let url = params.parse_with_url(&url);
32606
32607 let mut json_mime_type = mime::APPLICATION_JSON;
32608 let mut request_value_reader = {
32609 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32610 common::remove_json_null_values(&mut value);
32611 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32612 serde_json::to_writer(&mut dst, &value).unwrap();
32613 dst
32614 };
32615 let request_size = request_value_reader
32616 .seek(std::io::SeekFrom::End(0))
32617 .unwrap();
32618 request_value_reader
32619 .seek(std::io::SeekFrom::Start(0))
32620 .unwrap();
32621
32622 loop {
32623 let token = match self
32624 .hub
32625 .auth
32626 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32627 .await
32628 {
32629 Ok(token) => token,
32630 Err(e) => match dlg.token(e) {
32631 Ok(token) => token,
32632 Err(e) => {
32633 dlg.finished(false);
32634 return Err(common::Error::MissingToken(e));
32635 }
32636 },
32637 };
32638 request_value_reader
32639 .seek(std::io::SeekFrom::Start(0))
32640 .unwrap();
32641 let mut req_result = {
32642 let client = &self.hub.client;
32643 dlg.pre_request();
32644 let mut req_builder = hyper::Request::builder()
32645 .method(hyper::Method::PATCH)
32646 .uri(url.as_str())
32647 .header(USER_AGENT, self.hub._user_agent.clone());
32648
32649 if let Some(token) = token.as_ref() {
32650 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32651 }
32652
32653 let request = req_builder
32654 .header(CONTENT_TYPE, json_mime_type.to_string())
32655 .header(CONTENT_LENGTH, request_size as u64)
32656 .body(common::to_body(
32657 request_value_reader.get_ref().clone().into(),
32658 ));
32659
32660 client.request(request.unwrap()).await
32661 };
32662
32663 match req_result {
32664 Err(err) => {
32665 if let common::Retry::After(d) = dlg.http_error(&err) {
32666 sleep(d).await;
32667 continue;
32668 }
32669 dlg.finished(false);
32670 return Err(common::Error::HttpError(err));
32671 }
32672 Ok(res) => {
32673 let (mut parts, body) = res.into_parts();
32674 let mut body = common::Body::new(body);
32675 if !parts.status.is_success() {
32676 let bytes = common::to_bytes(body).await.unwrap_or_default();
32677 let error = serde_json::from_str(&common::to_string(&bytes));
32678 let response = common::to_response(parts, bytes.into());
32679
32680 if let common::Retry::After(d) =
32681 dlg.http_failure(&response, error.as_ref().ok())
32682 {
32683 sleep(d).await;
32684 continue;
32685 }
32686
32687 dlg.finished(false);
32688
32689 return Err(match error {
32690 Ok(value) => common::Error::BadRequest(value),
32691 _ => common::Error::Failure(response),
32692 });
32693 }
32694 let response = {
32695 let bytes = common::to_bytes(body).await.unwrap_or_default();
32696 let encoded = common::to_string(&bytes);
32697 match serde_json::from_str(&encoded) {
32698 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32699 Err(error) => {
32700 dlg.response_json_decode_error(&encoded, &error);
32701 return Err(common::Error::JsonDecodeError(
32702 encoded.to_string(),
32703 error,
32704 ));
32705 }
32706 }
32707 };
32708
32709 dlg.finished(true);
32710 return Ok(response);
32711 }
32712 }
32713 }
32714 }
32715
32716 ///
32717 /// Sets the *request* property to the given value.
32718 ///
32719 /// Even though the property as already been set when instantiating this call,
32720 /// we provide this method for API completeness.
32721 pub fn request(mut self, new_value: Webproperty) -> ManagementWebpropertyPatchCall<'a, C> {
32722 self._request = new_value;
32723 self
32724 }
32725 /// Account ID to which the web property belongs
32726 ///
32727 /// Sets the *account id* path property to the given value.
32728 ///
32729 /// Even though the property as already been set when instantiating this call,
32730 /// we provide this method for API completeness.
32731 pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyPatchCall<'a, C> {
32732 self._account_id = new_value.to_string();
32733 self
32734 }
32735 /// Web property ID
32736 ///
32737 /// Sets the *web property id* path property to the given value.
32738 ///
32739 /// Even though the property as already been set when instantiating this call,
32740 /// we provide this method for API completeness.
32741 pub fn web_property_id(mut self, new_value: &str) -> ManagementWebpropertyPatchCall<'a, C> {
32742 self._web_property_id = new_value.to_string();
32743 self
32744 }
32745 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32746 /// while executing the actual API request.
32747 ///
32748 /// ````text
32749 /// It should be used to handle progress information, and to implement a certain level of resilience.
32750 /// ````
32751 ///
32752 /// Sets the *delegate* property to the given value.
32753 pub fn delegate(
32754 mut self,
32755 new_value: &'a mut dyn common::Delegate,
32756 ) -> ManagementWebpropertyPatchCall<'a, C> {
32757 self._delegate = Some(new_value);
32758 self
32759 }
32760
32761 /// Set any additional parameter of the query string used in the request.
32762 /// It should be used to set parameters which are not yet available through their own
32763 /// setters.
32764 ///
32765 /// Please note that this method must not be used to set any of the known parameters
32766 /// which have their own setter method. If done anyway, the request will fail.
32767 ///
32768 /// # Additional Parameters
32769 ///
32770 /// * *alt* (query-string) - Data format for the response.
32771 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32772 /// * *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.
32773 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32774 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32775 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32776 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32777 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyPatchCall<'a, C>
32778 where
32779 T: AsRef<str>,
32780 {
32781 self._additional_params
32782 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32783 self
32784 }
32785
32786 /// Identifies the authorization scope for the method you are building.
32787 ///
32788 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32789 /// [`Scope::Edit`].
32790 ///
32791 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32792 /// tokens for more than one scope.
32793 ///
32794 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32795 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32796 /// sufficient, a read-write scope will do as well.
32797 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyPatchCall<'a, C>
32798 where
32799 St: AsRef<str>,
32800 {
32801 self._scopes.insert(String::from(scope.as_ref()));
32802 self
32803 }
32804 /// Identifies the authorization scope(s) for the method you are building.
32805 ///
32806 /// See [`Self::add_scope()`] for details.
32807 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyPatchCall<'a, C>
32808 where
32809 I: IntoIterator<Item = St>,
32810 St: AsRef<str>,
32811 {
32812 self._scopes
32813 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32814 self
32815 }
32816
32817 /// Removes all scopes, and no default scope will be used either.
32818 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32819 /// for details).
32820 pub fn clear_scopes(mut self) -> ManagementWebpropertyPatchCall<'a, C> {
32821 self._scopes.clear();
32822 self
32823 }
32824}
32825
32826/// Updates an existing web property.
32827///
32828/// A builder for the *webproperties.update* method supported by a *management* resource.
32829/// It is not used directly, but through a [`ManagementMethods`] instance.
32830///
32831/// # Example
32832///
32833/// Instantiate a resource method builder
32834///
32835/// ```test_harness,no_run
32836/// # extern crate hyper;
32837/// # extern crate hyper_rustls;
32838/// # extern crate google_analytics3 as analytics3;
32839/// use analytics3::api::Webproperty;
32840/// # async fn dox() {
32841/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32842///
32843/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32844/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32845/// # secret,
32846/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32847/// # ).build().await.unwrap();
32848///
32849/// # let client = hyper_util::client::legacy::Client::builder(
32850/// # hyper_util::rt::TokioExecutor::new()
32851/// # )
32852/// # .build(
32853/// # hyper_rustls::HttpsConnectorBuilder::new()
32854/// # .with_native_roots()
32855/// # .unwrap()
32856/// # .https_or_http()
32857/// # .enable_http1()
32858/// # .build()
32859/// # );
32860/// # let mut hub = Analytics::new(client, auth);
32861/// // As the method needs a request, you would usually fill it with the desired information
32862/// // into the respective structure. Some of the parts shown here might not be applicable !
32863/// // Values shown here are possibly random and not representative !
32864/// let mut req = Webproperty::default();
32865///
32866/// // You can configure optional parameters by calling the respective setters at will, and
32867/// // execute the final call using `doit()`.
32868/// // Values shown here are possibly random and not representative !
32869/// let result = hub.management().webproperties_update(req, "accountId", "webPropertyId")
32870/// .doit().await;
32871/// # }
32872/// ```
32873pub struct ManagementWebpropertyUpdateCall<'a, C>
32874where
32875 C: 'a,
32876{
32877 hub: &'a Analytics<C>,
32878 _request: Webproperty,
32879 _account_id: String,
32880 _web_property_id: String,
32881 _delegate: Option<&'a mut dyn common::Delegate>,
32882 _additional_params: HashMap<String, String>,
32883 _scopes: BTreeSet<String>,
32884}
32885
32886impl<'a, C> common::CallBuilder for ManagementWebpropertyUpdateCall<'a, C> {}
32887
32888impl<'a, C> ManagementWebpropertyUpdateCall<'a, C>
32889where
32890 C: common::Connector,
32891{
32892 /// Perform the operation you have build so far.
32893 pub async fn doit(mut self) -> common::Result<(common::Response, Webproperty)> {
32894 use std::borrow::Cow;
32895 use std::io::{Read, Seek};
32896
32897 use common::{url::Params, ToParts};
32898 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32899
32900 let mut dd = common::DefaultDelegate;
32901 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32902 dlg.begin(common::MethodInfo {
32903 id: "analytics.management.webproperties.update",
32904 http_method: hyper::Method::PUT,
32905 });
32906
32907 for &field in ["alt", "accountId", "webPropertyId"].iter() {
32908 if self._additional_params.contains_key(field) {
32909 dlg.finished(false);
32910 return Err(common::Error::FieldClash(field));
32911 }
32912 }
32913
32914 let mut params = Params::with_capacity(5 + self._additional_params.len());
32915 params.push("accountId", self._account_id);
32916 params.push("webPropertyId", self._web_property_id);
32917
32918 params.extend(self._additional_params.iter());
32919
32920 params.push("alt", "json");
32921 let mut url = self.hub._base_url.clone()
32922 + "management/accounts/{accountId}/webproperties/{webPropertyId}";
32923 if self._scopes.is_empty() {
32924 self._scopes.insert(Scope::Edit.as_ref().to_string());
32925 }
32926
32927 #[allow(clippy::single_element_loop)]
32928 for &(find_this, param_name) in [
32929 ("{accountId}", "accountId"),
32930 ("{webPropertyId}", "webPropertyId"),
32931 ]
32932 .iter()
32933 {
32934 url = params.uri_replacement(url, param_name, find_this, false);
32935 }
32936 {
32937 let to_remove = ["webPropertyId", "accountId"];
32938 params.remove_params(&to_remove);
32939 }
32940
32941 let url = params.parse_with_url(&url);
32942
32943 let mut json_mime_type = mime::APPLICATION_JSON;
32944 let mut request_value_reader = {
32945 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32946 common::remove_json_null_values(&mut value);
32947 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32948 serde_json::to_writer(&mut dst, &value).unwrap();
32949 dst
32950 };
32951 let request_size = request_value_reader
32952 .seek(std::io::SeekFrom::End(0))
32953 .unwrap();
32954 request_value_reader
32955 .seek(std::io::SeekFrom::Start(0))
32956 .unwrap();
32957
32958 loop {
32959 let token = match self
32960 .hub
32961 .auth
32962 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32963 .await
32964 {
32965 Ok(token) => token,
32966 Err(e) => match dlg.token(e) {
32967 Ok(token) => token,
32968 Err(e) => {
32969 dlg.finished(false);
32970 return Err(common::Error::MissingToken(e));
32971 }
32972 },
32973 };
32974 request_value_reader
32975 .seek(std::io::SeekFrom::Start(0))
32976 .unwrap();
32977 let mut req_result = {
32978 let client = &self.hub.client;
32979 dlg.pre_request();
32980 let mut req_builder = hyper::Request::builder()
32981 .method(hyper::Method::PUT)
32982 .uri(url.as_str())
32983 .header(USER_AGENT, self.hub._user_agent.clone());
32984
32985 if let Some(token) = token.as_ref() {
32986 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32987 }
32988
32989 let request = req_builder
32990 .header(CONTENT_TYPE, json_mime_type.to_string())
32991 .header(CONTENT_LENGTH, request_size as u64)
32992 .body(common::to_body(
32993 request_value_reader.get_ref().clone().into(),
32994 ));
32995
32996 client.request(request.unwrap()).await
32997 };
32998
32999 match req_result {
33000 Err(err) => {
33001 if let common::Retry::After(d) = dlg.http_error(&err) {
33002 sleep(d).await;
33003 continue;
33004 }
33005 dlg.finished(false);
33006 return Err(common::Error::HttpError(err));
33007 }
33008 Ok(res) => {
33009 let (mut parts, body) = res.into_parts();
33010 let mut body = common::Body::new(body);
33011 if !parts.status.is_success() {
33012 let bytes = common::to_bytes(body).await.unwrap_or_default();
33013 let error = serde_json::from_str(&common::to_string(&bytes));
33014 let response = common::to_response(parts, bytes.into());
33015
33016 if let common::Retry::After(d) =
33017 dlg.http_failure(&response, error.as_ref().ok())
33018 {
33019 sleep(d).await;
33020 continue;
33021 }
33022
33023 dlg.finished(false);
33024
33025 return Err(match error {
33026 Ok(value) => common::Error::BadRequest(value),
33027 _ => common::Error::Failure(response),
33028 });
33029 }
33030 let response = {
33031 let bytes = common::to_bytes(body).await.unwrap_or_default();
33032 let encoded = common::to_string(&bytes);
33033 match serde_json::from_str(&encoded) {
33034 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33035 Err(error) => {
33036 dlg.response_json_decode_error(&encoded, &error);
33037 return Err(common::Error::JsonDecodeError(
33038 encoded.to_string(),
33039 error,
33040 ));
33041 }
33042 }
33043 };
33044
33045 dlg.finished(true);
33046 return Ok(response);
33047 }
33048 }
33049 }
33050 }
33051
33052 ///
33053 /// Sets the *request* property to the given value.
33054 ///
33055 /// Even though the property as already been set when instantiating this call,
33056 /// we provide this method for API completeness.
33057 pub fn request(mut self, new_value: Webproperty) -> ManagementWebpropertyUpdateCall<'a, C> {
33058 self._request = new_value;
33059 self
33060 }
33061 /// Account ID to which the web property belongs
33062 ///
33063 /// Sets the *account id* path property to the given value.
33064 ///
33065 /// Even though the property as already been set when instantiating this call,
33066 /// we provide this method for API completeness.
33067 pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyUpdateCall<'a, C> {
33068 self._account_id = new_value.to_string();
33069 self
33070 }
33071 /// Web property ID
33072 ///
33073 /// Sets the *web property id* path property to the given value.
33074 ///
33075 /// Even though the property as already been set when instantiating this call,
33076 /// we provide this method for API completeness.
33077 pub fn web_property_id(mut self, new_value: &str) -> ManagementWebpropertyUpdateCall<'a, C> {
33078 self._web_property_id = new_value.to_string();
33079 self
33080 }
33081 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33082 /// while executing the actual API request.
33083 ///
33084 /// ````text
33085 /// It should be used to handle progress information, and to implement a certain level of resilience.
33086 /// ````
33087 ///
33088 /// Sets the *delegate* property to the given value.
33089 pub fn delegate(
33090 mut self,
33091 new_value: &'a mut dyn common::Delegate,
33092 ) -> ManagementWebpropertyUpdateCall<'a, C> {
33093 self._delegate = Some(new_value);
33094 self
33095 }
33096
33097 /// Set any additional parameter of the query string used in the request.
33098 /// It should be used to set parameters which are not yet available through their own
33099 /// setters.
33100 ///
33101 /// Please note that this method must not be used to set any of the known parameters
33102 /// which have their own setter method. If done anyway, the request will fail.
33103 ///
33104 /// # Additional Parameters
33105 ///
33106 /// * *alt* (query-string) - Data format for the response.
33107 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33108 /// * *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.
33109 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33110 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33111 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33112 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33113 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyUpdateCall<'a, C>
33114 where
33115 T: AsRef<str>,
33116 {
33117 self._additional_params
33118 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33119 self
33120 }
33121
33122 /// Identifies the authorization scope for the method you are building.
33123 ///
33124 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33125 /// [`Scope::Edit`].
33126 ///
33127 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33128 /// tokens for more than one scope.
33129 ///
33130 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33131 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33132 /// sufficient, a read-write scope will do as well.
33133 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyUpdateCall<'a, C>
33134 where
33135 St: AsRef<str>,
33136 {
33137 self._scopes.insert(String::from(scope.as_ref()));
33138 self
33139 }
33140 /// Identifies the authorization scope(s) for the method you are building.
33141 ///
33142 /// See [`Self::add_scope()`] for details.
33143 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyUpdateCall<'a, C>
33144 where
33145 I: IntoIterator<Item = St>,
33146 St: AsRef<str>,
33147 {
33148 self._scopes
33149 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33150 self
33151 }
33152
33153 /// Removes all scopes, and no default scope will be used either.
33154 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33155 /// for details).
33156 pub fn clear_scopes(mut self) -> ManagementWebpropertyUpdateCall<'a, C> {
33157 self._scopes.clear();
33158 self
33159 }
33160}
33161
33162/// Removes a user from the given web property.
33163///
33164/// A builder for the *webpropertyUserLinks.delete* method supported by a *management* resource.
33165/// It is not used directly, but through a [`ManagementMethods`] instance.
33166///
33167/// # Example
33168///
33169/// Instantiate a resource method builder
33170///
33171/// ```test_harness,no_run
33172/// # extern crate hyper;
33173/// # extern crate hyper_rustls;
33174/// # extern crate google_analytics3 as analytics3;
33175/// # async fn dox() {
33176/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33177///
33178/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33179/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
33180/// # secret,
33181/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33182/// # ).build().await.unwrap();
33183///
33184/// # let client = hyper_util::client::legacy::Client::builder(
33185/// # hyper_util::rt::TokioExecutor::new()
33186/// # )
33187/// # .build(
33188/// # hyper_rustls::HttpsConnectorBuilder::new()
33189/// # .with_native_roots()
33190/// # .unwrap()
33191/// # .https_or_http()
33192/// # .enable_http1()
33193/// # .build()
33194/// # );
33195/// # let mut hub = Analytics::new(client, auth);
33196/// // You can configure optional parameters by calling the respective setters at will, and
33197/// // execute the final call using `doit()`.
33198/// // Values shown here are possibly random and not representative !
33199/// let result = hub.management().webproperty_user_links_delete("accountId", "webPropertyId", "linkId")
33200/// .doit().await;
33201/// # }
33202/// ```
33203pub struct ManagementWebpropertyUserLinkDeleteCall<'a, C>
33204where
33205 C: 'a,
33206{
33207 hub: &'a Analytics<C>,
33208 _account_id: String,
33209 _web_property_id: String,
33210 _link_id: String,
33211 _delegate: Option<&'a mut dyn common::Delegate>,
33212 _additional_params: HashMap<String, String>,
33213 _scopes: BTreeSet<String>,
33214}
33215
33216impl<'a, C> common::CallBuilder for ManagementWebpropertyUserLinkDeleteCall<'a, C> {}
33217
33218impl<'a, C> ManagementWebpropertyUserLinkDeleteCall<'a, C>
33219where
33220 C: common::Connector,
33221{
33222 /// Perform the operation you have build so far.
33223 pub async fn doit(mut self) -> common::Result<common::Response> {
33224 use std::borrow::Cow;
33225 use std::io::{Read, Seek};
33226
33227 use common::{url::Params, ToParts};
33228 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33229
33230 let mut dd = common::DefaultDelegate;
33231 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33232 dlg.begin(common::MethodInfo {
33233 id: "analytics.management.webpropertyUserLinks.delete",
33234 http_method: hyper::Method::DELETE,
33235 });
33236
33237 for &field in ["accountId", "webPropertyId", "linkId"].iter() {
33238 if self._additional_params.contains_key(field) {
33239 dlg.finished(false);
33240 return Err(common::Error::FieldClash(field));
33241 }
33242 }
33243
33244 let mut params = Params::with_capacity(4 + self._additional_params.len());
33245 params.push("accountId", self._account_id);
33246 params.push("webPropertyId", self._web_property_id);
33247 params.push("linkId", self._link_id);
33248
33249 params.extend(self._additional_params.iter());
33250
33251 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks/{linkId}";
33252 if self._scopes.is_empty() {
33253 self._scopes.insert(Scope::ManageUser.as_ref().to_string());
33254 }
33255
33256 #[allow(clippy::single_element_loop)]
33257 for &(find_this, param_name) in [
33258 ("{accountId}", "accountId"),
33259 ("{webPropertyId}", "webPropertyId"),
33260 ("{linkId}", "linkId"),
33261 ]
33262 .iter()
33263 {
33264 url = params.uri_replacement(url, param_name, find_this, false);
33265 }
33266 {
33267 let to_remove = ["linkId", "webPropertyId", "accountId"];
33268 params.remove_params(&to_remove);
33269 }
33270
33271 let url = params.parse_with_url(&url);
33272
33273 loop {
33274 let token = match self
33275 .hub
33276 .auth
33277 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33278 .await
33279 {
33280 Ok(token) => token,
33281 Err(e) => match dlg.token(e) {
33282 Ok(token) => token,
33283 Err(e) => {
33284 dlg.finished(false);
33285 return Err(common::Error::MissingToken(e));
33286 }
33287 },
33288 };
33289 let mut req_result = {
33290 let client = &self.hub.client;
33291 dlg.pre_request();
33292 let mut req_builder = hyper::Request::builder()
33293 .method(hyper::Method::DELETE)
33294 .uri(url.as_str())
33295 .header(USER_AGENT, self.hub._user_agent.clone());
33296
33297 if let Some(token) = token.as_ref() {
33298 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33299 }
33300
33301 let request = req_builder
33302 .header(CONTENT_LENGTH, 0_u64)
33303 .body(common::to_body::<String>(None));
33304
33305 client.request(request.unwrap()).await
33306 };
33307
33308 match req_result {
33309 Err(err) => {
33310 if let common::Retry::After(d) = dlg.http_error(&err) {
33311 sleep(d).await;
33312 continue;
33313 }
33314 dlg.finished(false);
33315 return Err(common::Error::HttpError(err));
33316 }
33317 Ok(res) => {
33318 let (mut parts, body) = res.into_parts();
33319 let mut body = common::Body::new(body);
33320 if !parts.status.is_success() {
33321 let bytes = common::to_bytes(body).await.unwrap_or_default();
33322 let error = serde_json::from_str(&common::to_string(&bytes));
33323 let response = common::to_response(parts, bytes.into());
33324
33325 if let common::Retry::After(d) =
33326 dlg.http_failure(&response, error.as_ref().ok())
33327 {
33328 sleep(d).await;
33329 continue;
33330 }
33331
33332 dlg.finished(false);
33333
33334 return Err(match error {
33335 Ok(value) => common::Error::BadRequest(value),
33336 _ => common::Error::Failure(response),
33337 });
33338 }
33339 let response = common::Response::from_parts(parts, body);
33340
33341 dlg.finished(true);
33342 return Ok(response);
33343 }
33344 }
33345 }
33346 }
33347
33348 /// Account ID to delete the user link for.
33349 ///
33350 /// Sets the *account id* path property to the given value.
33351 ///
33352 /// Even though the property as already been set when instantiating this call,
33353 /// we provide this method for API completeness.
33354 pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
33355 self._account_id = new_value.to_string();
33356 self
33357 }
33358 /// Web Property ID to delete the user link for.
33359 ///
33360 /// Sets the *web property id* path property to the given value.
33361 ///
33362 /// Even though the property as already been set when instantiating this call,
33363 /// we provide this method for API completeness.
33364 pub fn web_property_id(
33365 mut self,
33366 new_value: &str,
33367 ) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
33368 self._web_property_id = new_value.to_string();
33369 self
33370 }
33371 /// Link ID to delete the user link for.
33372 ///
33373 /// Sets the *link id* path property to the given value.
33374 ///
33375 /// Even though the property as already been set when instantiating this call,
33376 /// we provide this method for API completeness.
33377 pub fn link_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
33378 self._link_id = new_value.to_string();
33379 self
33380 }
33381 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33382 /// while executing the actual API request.
33383 ///
33384 /// ````text
33385 /// It should be used to handle progress information, and to implement a certain level of resilience.
33386 /// ````
33387 ///
33388 /// Sets the *delegate* property to the given value.
33389 pub fn delegate(
33390 mut self,
33391 new_value: &'a mut dyn common::Delegate,
33392 ) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
33393 self._delegate = Some(new_value);
33394 self
33395 }
33396
33397 /// Set any additional parameter of the query string used in the request.
33398 /// It should be used to set parameters which are not yet available through their own
33399 /// setters.
33400 ///
33401 /// Please note that this method must not be used to set any of the known parameters
33402 /// which have their own setter method. If done anyway, the request will fail.
33403 ///
33404 /// # Additional Parameters
33405 ///
33406 /// * *alt* (query-string) - Data format for the response.
33407 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33408 /// * *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.
33409 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33410 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33411 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33412 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33413 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyUserLinkDeleteCall<'a, C>
33414 where
33415 T: AsRef<str>,
33416 {
33417 self._additional_params
33418 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33419 self
33420 }
33421
33422 /// Identifies the authorization scope for the method you are building.
33423 ///
33424 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33425 /// [`Scope::ManageUser`].
33426 ///
33427 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33428 /// tokens for more than one scope.
33429 ///
33430 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33431 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33432 /// sufficient, a read-write scope will do as well.
33433 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyUserLinkDeleteCall<'a, C>
33434 where
33435 St: AsRef<str>,
33436 {
33437 self._scopes.insert(String::from(scope.as_ref()));
33438 self
33439 }
33440 /// Identifies the authorization scope(s) for the method you are building.
33441 ///
33442 /// See [`Self::add_scope()`] for details.
33443 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyUserLinkDeleteCall<'a, C>
33444 where
33445 I: IntoIterator<Item = St>,
33446 St: AsRef<str>,
33447 {
33448 self._scopes
33449 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33450 self
33451 }
33452
33453 /// Removes all scopes, and no default scope will be used either.
33454 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33455 /// for details).
33456 pub fn clear_scopes(mut self) -> ManagementWebpropertyUserLinkDeleteCall<'a, C> {
33457 self._scopes.clear();
33458 self
33459 }
33460}
33461
33462/// Adds a new user to the given web property.
33463///
33464/// A builder for the *webpropertyUserLinks.insert* method supported by a *management* resource.
33465/// It is not used directly, but through a [`ManagementMethods`] instance.
33466///
33467/// # Example
33468///
33469/// Instantiate a resource method builder
33470///
33471/// ```test_harness,no_run
33472/// # extern crate hyper;
33473/// # extern crate hyper_rustls;
33474/// # extern crate google_analytics3 as analytics3;
33475/// use analytics3::api::EntityUserLink;
33476/// # async fn dox() {
33477/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33478///
33479/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33480/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
33481/// # secret,
33482/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33483/// # ).build().await.unwrap();
33484///
33485/// # let client = hyper_util::client::legacy::Client::builder(
33486/// # hyper_util::rt::TokioExecutor::new()
33487/// # )
33488/// # .build(
33489/// # hyper_rustls::HttpsConnectorBuilder::new()
33490/// # .with_native_roots()
33491/// # .unwrap()
33492/// # .https_or_http()
33493/// # .enable_http1()
33494/// # .build()
33495/// # );
33496/// # let mut hub = Analytics::new(client, auth);
33497/// // As the method needs a request, you would usually fill it with the desired information
33498/// // into the respective structure. Some of the parts shown here might not be applicable !
33499/// // Values shown here are possibly random and not representative !
33500/// let mut req = EntityUserLink::default();
33501///
33502/// // You can configure optional parameters by calling the respective setters at will, and
33503/// // execute the final call using `doit()`.
33504/// // Values shown here are possibly random and not representative !
33505/// let result = hub.management().webproperty_user_links_insert(req, "accountId", "webPropertyId")
33506/// .doit().await;
33507/// # }
33508/// ```
33509pub struct ManagementWebpropertyUserLinkInsertCall<'a, C>
33510where
33511 C: 'a,
33512{
33513 hub: &'a Analytics<C>,
33514 _request: EntityUserLink,
33515 _account_id: String,
33516 _web_property_id: String,
33517 _delegate: Option<&'a mut dyn common::Delegate>,
33518 _additional_params: HashMap<String, String>,
33519 _scopes: BTreeSet<String>,
33520}
33521
33522impl<'a, C> common::CallBuilder for ManagementWebpropertyUserLinkInsertCall<'a, C> {}
33523
33524impl<'a, C> ManagementWebpropertyUserLinkInsertCall<'a, C>
33525where
33526 C: common::Connector,
33527{
33528 /// Perform the operation you have build so far.
33529 pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
33530 use std::borrow::Cow;
33531 use std::io::{Read, Seek};
33532
33533 use common::{url::Params, ToParts};
33534 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33535
33536 let mut dd = common::DefaultDelegate;
33537 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33538 dlg.begin(common::MethodInfo {
33539 id: "analytics.management.webpropertyUserLinks.insert",
33540 http_method: hyper::Method::POST,
33541 });
33542
33543 for &field in ["alt", "accountId", "webPropertyId"].iter() {
33544 if self._additional_params.contains_key(field) {
33545 dlg.finished(false);
33546 return Err(common::Error::FieldClash(field));
33547 }
33548 }
33549
33550 let mut params = Params::with_capacity(5 + self._additional_params.len());
33551 params.push("accountId", self._account_id);
33552 params.push("webPropertyId", self._web_property_id);
33553
33554 params.extend(self._additional_params.iter());
33555
33556 params.push("alt", "json");
33557 let mut url = self.hub._base_url.clone()
33558 + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks";
33559 if self._scopes.is_empty() {
33560 self._scopes.insert(Scope::ManageUser.as_ref().to_string());
33561 }
33562
33563 #[allow(clippy::single_element_loop)]
33564 for &(find_this, param_name) in [
33565 ("{accountId}", "accountId"),
33566 ("{webPropertyId}", "webPropertyId"),
33567 ]
33568 .iter()
33569 {
33570 url = params.uri_replacement(url, param_name, find_this, false);
33571 }
33572 {
33573 let to_remove = ["webPropertyId", "accountId"];
33574 params.remove_params(&to_remove);
33575 }
33576
33577 let url = params.parse_with_url(&url);
33578
33579 let mut json_mime_type = mime::APPLICATION_JSON;
33580 let mut request_value_reader = {
33581 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33582 common::remove_json_null_values(&mut value);
33583 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33584 serde_json::to_writer(&mut dst, &value).unwrap();
33585 dst
33586 };
33587 let request_size = request_value_reader
33588 .seek(std::io::SeekFrom::End(0))
33589 .unwrap();
33590 request_value_reader
33591 .seek(std::io::SeekFrom::Start(0))
33592 .unwrap();
33593
33594 loop {
33595 let token = match self
33596 .hub
33597 .auth
33598 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33599 .await
33600 {
33601 Ok(token) => token,
33602 Err(e) => match dlg.token(e) {
33603 Ok(token) => token,
33604 Err(e) => {
33605 dlg.finished(false);
33606 return Err(common::Error::MissingToken(e));
33607 }
33608 },
33609 };
33610 request_value_reader
33611 .seek(std::io::SeekFrom::Start(0))
33612 .unwrap();
33613 let mut req_result = {
33614 let client = &self.hub.client;
33615 dlg.pre_request();
33616 let mut req_builder = hyper::Request::builder()
33617 .method(hyper::Method::POST)
33618 .uri(url.as_str())
33619 .header(USER_AGENT, self.hub._user_agent.clone());
33620
33621 if let Some(token) = token.as_ref() {
33622 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33623 }
33624
33625 let request = req_builder
33626 .header(CONTENT_TYPE, json_mime_type.to_string())
33627 .header(CONTENT_LENGTH, request_size as u64)
33628 .body(common::to_body(
33629 request_value_reader.get_ref().clone().into(),
33630 ));
33631
33632 client.request(request.unwrap()).await
33633 };
33634
33635 match req_result {
33636 Err(err) => {
33637 if let common::Retry::After(d) = dlg.http_error(&err) {
33638 sleep(d).await;
33639 continue;
33640 }
33641 dlg.finished(false);
33642 return Err(common::Error::HttpError(err));
33643 }
33644 Ok(res) => {
33645 let (mut parts, body) = res.into_parts();
33646 let mut body = common::Body::new(body);
33647 if !parts.status.is_success() {
33648 let bytes = common::to_bytes(body).await.unwrap_or_default();
33649 let error = serde_json::from_str(&common::to_string(&bytes));
33650 let response = common::to_response(parts, bytes.into());
33651
33652 if let common::Retry::After(d) =
33653 dlg.http_failure(&response, error.as_ref().ok())
33654 {
33655 sleep(d).await;
33656 continue;
33657 }
33658
33659 dlg.finished(false);
33660
33661 return Err(match error {
33662 Ok(value) => common::Error::BadRequest(value),
33663 _ => common::Error::Failure(response),
33664 });
33665 }
33666 let response = {
33667 let bytes = common::to_bytes(body).await.unwrap_or_default();
33668 let encoded = common::to_string(&bytes);
33669 match serde_json::from_str(&encoded) {
33670 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33671 Err(error) => {
33672 dlg.response_json_decode_error(&encoded, &error);
33673 return Err(common::Error::JsonDecodeError(
33674 encoded.to_string(),
33675 error,
33676 ));
33677 }
33678 }
33679 };
33680
33681 dlg.finished(true);
33682 return Ok(response);
33683 }
33684 }
33685 }
33686 }
33687
33688 ///
33689 /// Sets the *request* property to the given value.
33690 ///
33691 /// Even though the property as already been set when instantiating this call,
33692 /// we provide this method for API completeness.
33693 pub fn request(
33694 mut self,
33695 new_value: EntityUserLink,
33696 ) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
33697 self._request = new_value;
33698 self
33699 }
33700 /// Account ID to create the user link for.
33701 ///
33702 /// Sets the *account id* path property to the given value.
33703 ///
33704 /// Even though the property as already been set when instantiating this call,
33705 /// we provide this method for API completeness.
33706 pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
33707 self._account_id = new_value.to_string();
33708 self
33709 }
33710 /// Web Property ID to create the user link for.
33711 ///
33712 /// Sets the *web property id* path property to the given value.
33713 ///
33714 /// Even though the property as already been set when instantiating this call,
33715 /// we provide this method for API completeness.
33716 pub fn web_property_id(
33717 mut self,
33718 new_value: &str,
33719 ) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
33720 self._web_property_id = new_value.to_string();
33721 self
33722 }
33723 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33724 /// while executing the actual API request.
33725 ///
33726 /// ````text
33727 /// It should be used to handle progress information, and to implement a certain level of resilience.
33728 /// ````
33729 ///
33730 /// Sets the *delegate* property to the given value.
33731 pub fn delegate(
33732 mut self,
33733 new_value: &'a mut dyn common::Delegate,
33734 ) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
33735 self._delegate = Some(new_value);
33736 self
33737 }
33738
33739 /// Set any additional parameter of the query string used in the request.
33740 /// It should be used to set parameters which are not yet available through their own
33741 /// setters.
33742 ///
33743 /// Please note that this method must not be used to set any of the known parameters
33744 /// which have their own setter method. If done anyway, the request will fail.
33745 ///
33746 /// # Additional Parameters
33747 ///
33748 /// * *alt* (query-string) - Data format for the response.
33749 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33750 /// * *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.
33751 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33752 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33753 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33754 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33755 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyUserLinkInsertCall<'a, C>
33756 where
33757 T: AsRef<str>,
33758 {
33759 self._additional_params
33760 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33761 self
33762 }
33763
33764 /// Identifies the authorization scope for the method you are building.
33765 ///
33766 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33767 /// [`Scope::ManageUser`].
33768 ///
33769 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33770 /// tokens for more than one scope.
33771 ///
33772 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33773 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33774 /// sufficient, a read-write scope will do as well.
33775 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyUserLinkInsertCall<'a, C>
33776 where
33777 St: AsRef<str>,
33778 {
33779 self._scopes.insert(String::from(scope.as_ref()));
33780 self
33781 }
33782 /// Identifies the authorization scope(s) for the method you are building.
33783 ///
33784 /// See [`Self::add_scope()`] for details.
33785 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyUserLinkInsertCall<'a, C>
33786 where
33787 I: IntoIterator<Item = St>,
33788 St: AsRef<str>,
33789 {
33790 self._scopes
33791 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33792 self
33793 }
33794
33795 /// Removes all scopes, and no default scope will be used either.
33796 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33797 /// for details).
33798 pub fn clear_scopes(mut self) -> ManagementWebpropertyUserLinkInsertCall<'a, C> {
33799 self._scopes.clear();
33800 self
33801 }
33802}
33803
33804/// Lists webProperty-user links for a given web property.
33805///
33806/// A builder for the *webpropertyUserLinks.list* method supported by a *management* resource.
33807/// It is not used directly, but through a [`ManagementMethods`] instance.
33808///
33809/// # Example
33810///
33811/// Instantiate a resource method builder
33812///
33813/// ```test_harness,no_run
33814/// # extern crate hyper;
33815/// # extern crate hyper_rustls;
33816/// # extern crate google_analytics3 as analytics3;
33817/// # async fn dox() {
33818/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33819///
33820/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33821/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
33822/// # secret,
33823/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33824/// # ).build().await.unwrap();
33825///
33826/// # let client = hyper_util::client::legacy::Client::builder(
33827/// # hyper_util::rt::TokioExecutor::new()
33828/// # )
33829/// # .build(
33830/// # hyper_rustls::HttpsConnectorBuilder::new()
33831/// # .with_native_roots()
33832/// # .unwrap()
33833/// # .https_or_http()
33834/// # .enable_http1()
33835/// # .build()
33836/// # );
33837/// # let mut hub = Analytics::new(client, auth);
33838/// // You can configure optional parameters by calling the respective setters at will, and
33839/// // execute the final call using `doit()`.
33840/// // Values shown here are possibly random and not representative !
33841/// let result = hub.management().webproperty_user_links_list("accountId", "webPropertyId")
33842/// .start_index(-100)
33843/// .max_results(-63)
33844/// .doit().await;
33845/// # }
33846/// ```
33847pub struct ManagementWebpropertyUserLinkListCall<'a, C>
33848where
33849 C: 'a,
33850{
33851 hub: &'a Analytics<C>,
33852 _account_id: String,
33853 _web_property_id: String,
33854 _start_index: Option<i32>,
33855 _max_results: Option<i32>,
33856 _delegate: Option<&'a mut dyn common::Delegate>,
33857 _additional_params: HashMap<String, String>,
33858 _scopes: BTreeSet<String>,
33859}
33860
33861impl<'a, C> common::CallBuilder for ManagementWebpropertyUserLinkListCall<'a, C> {}
33862
33863impl<'a, C> ManagementWebpropertyUserLinkListCall<'a, C>
33864where
33865 C: common::Connector,
33866{
33867 /// Perform the operation you have build so far.
33868 pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLinks)> {
33869 use std::borrow::Cow;
33870 use std::io::{Read, Seek};
33871
33872 use common::{url::Params, ToParts};
33873 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33874
33875 let mut dd = common::DefaultDelegate;
33876 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33877 dlg.begin(common::MethodInfo {
33878 id: "analytics.management.webpropertyUserLinks.list",
33879 http_method: hyper::Method::GET,
33880 });
33881
33882 for &field in [
33883 "alt",
33884 "accountId",
33885 "webPropertyId",
33886 "start-index",
33887 "max-results",
33888 ]
33889 .iter()
33890 {
33891 if self._additional_params.contains_key(field) {
33892 dlg.finished(false);
33893 return Err(common::Error::FieldClash(field));
33894 }
33895 }
33896
33897 let mut params = Params::with_capacity(6 + self._additional_params.len());
33898 params.push("accountId", self._account_id);
33899 params.push("webPropertyId", self._web_property_id);
33900 if let Some(value) = self._start_index.as_ref() {
33901 params.push("start-index", value.to_string());
33902 }
33903 if let Some(value) = self._max_results.as_ref() {
33904 params.push("max-results", value.to_string());
33905 }
33906
33907 params.extend(self._additional_params.iter());
33908
33909 params.push("alt", "json");
33910 let mut url = self.hub._base_url.clone()
33911 + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks";
33912 if self._scopes.is_empty() {
33913 self._scopes
33914 .insert(Scope::ManageUserReadonly.as_ref().to_string());
33915 }
33916
33917 #[allow(clippy::single_element_loop)]
33918 for &(find_this, param_name) in [
33919 ("{accountId}", "accountId"),
33920 ("{webPropertyId}", "webPropertyId"),
33921 ]
33922 .iter()
33923 {
33924 url = params.uri_replacement(url, param_name, find_this, false);
33925 }
33926 {
33927 let to_remove = ["webPropertyId", "accountId"];
33928 params.remove_params(&to_remove);
33929 }
33930
33931 let url = params.parse_with_url(&url);
33932
33933 loop {
33934 let token = match self
33935 .hub
33936 .auth
33937 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33938 .await
33939 {
33940 Ok(token) => token,
33941 Err(e) => match dlg.token(e) {
33942 Ok(token) => token,
33943 Err(e) => {
33944 dlg.finished(false);
33945 return Err(common::Error::MissingToken(e));
33946 }
33947 },
33948 };
33949 let mut req_result = {
33950 let client = &self.hub.client;
33951 dlg.pre_request();
33952 let mut req_builder = hyper::Request::builder()
33953 .method(hyper::Method::GET)
33954 .uri(url.as_str())
33955 .header(USER_AGENT, self.hub._user_agent.clone());
33956
33957 if let Some(token) = token.as_ref() {
33958 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33959 }
33960
33961 let request = req_builder
33962 .header(CONTENT_LENGTH, 0_u64)
33963 .body(common::to_body::<String>(None));
33964
33965 client.request(request.unwrap()).await
33966 };
33967
33968 match req_result {
33969 Err(err) => {
33970 if let common::Retry::After(d) = dlg.http_error(&err) {
33971 sleep(d).await;
33972 continue;
33973 }
33974 dlg.finished(false);
33975 return Err(common::Error::HttpError(err));
33976 }
33977 Ok(res) => {
33978 let (mut parts, body) = res.into_parts();
33979 let mut body = common::Body::new(body);
33980 if !parts.status.is_success() {
33981 let bytes = common::to_bytes(body).await.unwrap_or_default();
33982 let error = serde_json::from_str(&common::to_string(&bytes));
33983 let response = common::to_response(parts, bytes.into());
33984
33985 if let common::Retry::After(d) =
33986 dlg.http_failure(&response, error.as_ref().ok())
33987 {
33988 sleep(d).await;
33989 continue;
33990 }
33991
33992 dlg.finished(false);
33993
33994 return Err(match error {
33995 Ok(value) => common::Error::BadRequest(value),
33996 _ => common::Error::Failure(response),
33997 });
33998 }
33999 let response = {
34000 let bytes = common::to_bytes(body).await.unwrap_or_default();
34001 let encoded = common::to_string(&bytes);
34002 match serde_json::from_str(&encoded) {
34003 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34004 Err(error) => {
34005 dlg.response_json_decode_error(&encoded, &error);
34006 return Err(common::Error::JsonDecodeError(
34007 encoded.to_string(),
34008 error,
34009 ));
34010 }
34011 }
34012 };
34013
34014 dlg.finished(true);
34015 return Ok(response);
34016 }
34017 }
34018 }
34019 }
34020
34021 /// Account ID which the given web property belongs to.
34022 ///
34023 /// Sets the *account id* path property to the given value.
34024 ///
34025 /// Even though the property as already been set when instantiating this call,
34026 /// we provide this method for API completeness.
34027 pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkListCall<'a, C> {
34028 self._account_id = new_value.to_string();
34029 self
34030 }
34031 /// 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.
34032 ///
34033 /// Sets the *web property id* path property to the given value.
34034 ///
34035 /// Even though the property as already been set when instantiating this call,
34036 /// we provide this method for API completeness.
34037 pub fn web_property_id(
34038 mut self,
34039 new_value: &str,
34040 ) -> ManagementWebpropertyUserLinkListCall<'a, C> {
34041 self._web_property_id = new_value.to_string();
34042 self
34043 }
34044 /// An index of the first webProperty-user link to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.
34045 ///
34046 /// Sets the *start-index* query property to the given value.
34047 pub fn start_index(mut self, new_value: i32) -> ManagementWebpropertyUserLinkListCall<'a, C> {
34048 self._start_index = Some(new_value);
34049 self
34050 }
34051 /// The maximum number of webProperty-user Links to include in this response.
34052 ///
34053 /// Sets the *max-results* query property to the given value.
34054 pub fn max_results(mut self, new_value: i32) -> ManagementWebpropertyUserLinkListCall<'a, C> {
34055 self._max_results = Some(new_value);
34056 self
34057 }
34058 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34059 /// while executing the actual API request.
34060 ///
34061 /// ````text
34062 /// It should be used to handle progress information, and to implement a certain level of resilience.
34063 /// ````
34064 ///
34065 /// Sets the *delegate* property to the given value.
34066 pub fn delegate(
34067 mut self,
34068 new_value: &'a mut dyn common::Delegate,
34069 ) -> ManagementWebpropertyUserLinkListCall<'a, C> {
34070 self._delegate = Some(new_value);
34071 self
34072 }
34073
34074 /// Set any additional parameter of the query string used in the request.
34075 /// It should be used to set parameters which are not yet available through their own
34076 /// setters.
34077 ///
34078 /// Please note that this method must not be used to set any of the known parameters
34079 /// which have their own setter method. If done anyway, the request will fail.
34080 ///
34081 /// # Additional Parameters
34082 ///
34083 /// * *alt* (query-string) - Data format for the response.
34084 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34085 /// * *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.
34086 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34087 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34088 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34089 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34090 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyUserLinkListCall<'a, C>
34091 where
34092 T: AsRef<str>,
34093 {
34094 self._additional_params
34095 .insert(name.as_ref().to_string(), value.as_ref().to_string());
34096 self
34097 }
34098
34099 /// Identifies the authorization scope for the method you are building.
34100 ///
34101 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34102 /// [`Scope::ManageUserReadonly`].
34103 ///
34104 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34105 /// tokens for more than one scope.
34106 ///
34107 /// Usually there is more than one suitable scope to authorize an operation, some of which may
34108 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34109 /// sufficient, a read-write scope will do as well.
34110 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyUserLinkListCall<'a, C>
34111 where
34112 St: AsRef<str>,
34113 {
34114 self._scopes.insert(String::from(scope.as_ref()));
34115 self
34116 }
34117 /// Identifies the authorization scope(s) for the method you are building.
34118 ///
34119 /// See [`Self::add_scope()`] for details.
34120 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyUserLinkListCall<'a, C>
34121 where
34122 I: IntoIterator<Item = St>,
34123 St: AsRef<str>,
34124 {
34125 self._scopes
34126 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34127 self
34128 }
34129
34130 /// Removes all scopes, and no default scope will be used either.
34131 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34132 /// for details).
34133 pub fn clear_scopes(mut self) -> ManagementWebpropertyUserLinkListCall<'a, C> {
34134 self._scopes.clear();
34135 self
34136 }
34137}
34138
34139/// Updates permissions for an existing user on the given web property.
34140///
34141/// A builder for the *webpropertyUserLinks.update* method supported by a *management* resource.
34142/// It is not used directly, but through a [`ManagementMethods`] instance.
34143///
34144/// # Example
34145///
34146/// Instantiate a resource method builder
34147///
34148/// ```test_harness,no_run
34149/// # extern crate hyper;
34150/// # extern crate hyper_rustls;
34151/// # extern crate google_analytics3 as analytics3;
34152/// use analytics3::api::EntityUserLink;
34153/// # async fn dox() {
34154/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34155///
34156/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34157/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
34158/// # secret,
34159/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34160/// # ).build().await.unwrap();
34161///
34162/// # let client = hyper_util::client::legacy::Client::builder(
34163/// # hyper_util::rt::TokioExecutor::new()
34164/// # )
34165/// # .build(
34166/// # hyper_rustls::HttpsConnectorBuilder::new()
34167/// # .with_native_roots()
34168/// # .unwrap()
34169/// # .https_or_http()
34170/// # .enable_http1()
34171/// # .build()
34172/// # );
34173/// # let mut hub = Analytics::new(client, auth);
34174/// // As the method needs a request, you would usually fill it with the desired information
34175/// // into the respective structure. Some of the parts shown here might not be applicable !
34176/// // Values shown here are possibly random and not representative !
34177/// let mut req = EntityUserLink::default();
34178///
34179/// // You can configure optional parameters by calling the respective setters at will, and
34180/// // execute the final call using `doit()`.
34181/// // Values shown here are possibly random and not representative !
34182/// let result = hub.management().webproperty_user_links_update(req, "accountId", "webPropertyId", "linkId")
34183/// .doit().await;
34184/// # }
34185/// ```
34186pub struct ManagementWebpropertyUserLinkUpdateCall<'a, C>
34187where
34188 C: 'a,
34189{
34190 hub: &'a Analytics<C>,
34191 _request: EntityUserLink,
34192 _account_id: String,
34193 _web_property_id: String,
34194 _link_id: String,
34195 _delegate: Option<&'a mut dyn common::Delegate>,
34196 _additional_params: HashMap<String, String>,
34197 _scopes: BTreeSet<String>,
34198}
34199
34200impl<'a, C> common::CallBuilder for ManagementWebpropertyUserLinkUpdateCall<'a, C> {}
34201
34202impl<'a, C> ManagementWebpropertyUserLinkUpdateCall<'a, C>
34203where
34204 C: common::Connector,
34205{
34206 /// Perform the operation you have build so far.
34207 pub async fn doit(mut self) -> common::Result<(common::Response, EntityUserLink)> {
34208 use std::borrow::Cow;
34209 use std::io::{Read, Seek};
34210
34211 use common::{url::Params, ToParts};
34212 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34213
34214 let mut dd = common::DefaultDelegate;
34215 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34216 dlg.begin(common::MethodInfo {
34217 id: "analytics.management.webpropertyUserLinks.update",
34218 http_method: hyper::Method::PUT,
34219 });
34220
34221 for &field in ["alt", "accountId", "webPropertyId", "linkId"].iter() {
34222 if self._additional_params.contains_key(field) {
34223 dlg.finished(false);
34224 return Err(common::Error::FieldClash(field));
34225 }
34226 }
34227
34228 let mut params = Params::with_capacity(6 + self._additional_params.len());
34229 params.push("accountId", self._account_id);
34230 params.push("webPropertyId", self._web_property_id);
34231 params.push("linkId", self._link_id);
34232
34233 params.extend(self._additional_params.iter());
34234
34235 params.push("alt", "json");
34236 let mut url = self.hub._base_url.clone() + "management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks/{linkId}";
34237 if self._scopes.is_empty() {
34238 self._scopes.insert(Scope::ManageUser.as_ref().to_string());
34239 }
34240
34241 #[allow(clippy::single_element_loop)]
34242 for &(find_this, param_name) in [
34243 ("{accountId}", "accountId"),
34244 ("{webPropertyId}", "webPropertyId"),
34245 ("{linkId}", "linkId"),
34246 ]
34247 .iter()
34248 {
34249 url = params.uri_replacement(url, param_name, find_this, false);
34250 }
34251 {
34252 let to_remove = ["linkId", "webPropertyId", "accountId"];
34253 params.remove_params(&to_remove);
34254 }
34255
34256 let url = params.parse_with_url(&url);
34257
34258 let mut json_mime_type = mime::APPLICATION_JSON;
34259 let mut request_value_reader = {
34260 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
34261 common::remove_json_null_values(&mut value);
34262 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
34263 serde_json::to_writer(&mut dst, &value).unwrap();
34264 dst
34265 };
34266 let request_size = request_value_reader
34267 .seek(std::io::SeekFrom::End(0))
34268 .unwrap();
34269 request_value_reader
34270 .seek(std::io::SeekFrom::Start(0))
34271 .unwrap();
34272
34273 loop {
34274 let token = match self
34275 .hub
34276 .auth
34277 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34278 .await
34279 {
34280 Ok(token) => token,
34281 Err(e) => match dlg.token(e) {
34282 Ok(token) => token,
34283 Err(e) => {
34284 dlg.finished(false);
34285 return Err(common::Error::MissingToken(e));
34286 }
34287 },
34288 };
34289 request_value_reader
34290 .seek(std::io::SeekFrom::Start(0))
34291 .unwrap();
34292 let mut req_result = {
34293 let client = &self.hub.client;
34294 dlg.pre_request();
34295 let mut req_builder = hyper::Request::builder()
34296 .method(hyper::Method::PUT)
34297 .uri(url.as_str())
34298 .header(USER_AGENT, self.hub._user_agent.clone());
34299
34300 if let Some(token) = token.as_ref() {
34301 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34302 }
34303
34304 let request = req_builder
34305 .header(CONTENT_TYPE, json_mime_type.to_string())
34306 .header(CONTENT_LENGTH, request_size as u64)
34307 .body(common::to_body(
34308 request_value_reader.get_ref().clone().into(),
34309 ));
34310
34311 client.request(request.unwrap()).await
34312 };
34313
34314 match req_result {
34315 Err(err) => {
34316 if let common::Retry::After(d) = dlg.http_error(&err) {
34317 sleep(d).await;
34318 continue;
34319 }
34320 dlg.finished(false);
34321 return Err(common::Error::HttpError(err));
34322 }
34323 Ok(res) => {
34324 let (mut parts, body) = res.into_parts();
34325 let mut body = common::Body::new(body);
34326 if !parts.status.is_success() {
34327 let bytes = common::to_bytes(body).await.unwrap_or_default();
34328 let error = serde_json::from_str(&common::to_string(&bytes));
34329 let response = common::to_response(parts, bytes.into());
34330
34331 if let common::Retry::After(d) =
34332 dlg.http_failure(&response, error.as_ref().ok())
34333 {
34334 sleep(d).await;
34335 continue;
34336 }
34337
34338 dlg.finished(false);
34339
34340 return Err(match error {
34341 Ok(value) => common::Error::BadRequest(value),
34342 _ => common::Error::Failure(response),
34343 });
34344 }
34345 let response = {
34346 let bytes = common::to_bytes(body).await.unwrap_or_default();
34347 let encoded = common::to_string(&bytes);
34348 match serde_json::from_str(&encoded) {
34349 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34350 Err(error) => {
34351 dlg.response_json_decode_error(&encoded, &error);
34352 return Err(common::Error::JsonDecodeError(
34353 encoded.to_string(),
34354 error,
34355 ));
34356 }
34357 }
34358 };
34359
34360 dlg.finished(true);
34361 return Ok(response);
34362 }
34363 }
34364 }
34365 }
34366
34367 ///
34368 /// Sets the *request* property to the given value.
34369 ///
34370 /// Even though the property as already been set when instantiating this call,
34371 /// we provide this method for API completeness.
34372 pub fn request(
34373 mut self,
34374 new_value: EntityUserLink,
34375 ) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
34376 self._request = new_value;
34377 self
34378 }
34379 /// Account ID to update the account-user link for.
34380 ///
34381 /// Sets the *account id* path property to the given value.
34382 ///
34383 /// Even though the property as already been set when instantiating this call,
34384 /// we provide this method for API completeness.
34385 pub fn account_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
34386 self._account_id = new_value.to_string();
34387 self
34388 }
34389 /// Web property ID to update the account-user link for.
34390 ///
34391 /// Sets the *web property id* path property to the given value.
34392 ///
34393 /// Even though the property as already been set when instantiating this call,
34394 /// we provide this method for API completeness.
34395 pub fn web_property_id(
34396 mut self,
34397 new_value: &str,
34398 ) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
34399 self._web_property_id = new_value.to_string();
34400 self
34401 }
34402 /// Link ID to update the account-user link for.
34403 ///
34404 /// Sets the *link id* path property to the given value.
34405 ///
34406 /// Even though the property as already been set when instantiating this call,
34407 /// we provide this method for API completeness.
34408 pub fn link_id(mut self, new_value: &str) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
34409 self._link_id = new_value.to_string();
34410 self
34411 }
34412 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34413 /// while executing the actual API request.
34414 ///
34415 /// ````text
34416 /// It should be used to handle progress information, and to implement a certain level of resilience.
34417 /// ````
34418 ///
34419 /// Sets the *delegate* property to the given value.
34420 pub fn delegate(
34421 mut self,
34422 new_value: &'a mut dyn common::Delegate,
34423 ) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
34424 self._delegate = Some(new_value);
34425 self
34426 }
34427
34428 /// Set any additional parameter of the query string used in the request.
34429 /// It should be used to set parameters which are not yet available through their own
34430 /// setters.
34431 ///
34432 /// Please note that this method must not be used to set any of the known parameters
34433 /// which have their own setter method. If done anyway, the request will fail.
34434 ///
34435 /// # Additional Parameters
34436 ///
34437 /// * *alt* (query-string) - Data format for the response.
34438 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34439 /// * *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.
34440 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34441 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34442 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34443 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34444 pub fn param<T>(mut self, name: T, value: T) -> ManagementWebpropertyUserLinkUpdateCall<'a, C>
34445 where
34446 T: AsRef<str>,
34447 {
34448 self._additional_params
34449 .insert(name.as_ref().to_string(), value.as_ref().to_string());
34450 self
34451 }
34452
34453 /// Identifies the authorization scope for the method you are building.
34454 ///
34455 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34456 /// [`Scope::ManageUser`].
34457 ///
34458 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34459 /// tokens for more than one scope.
34460 ///
34461 /// Usually there is more than one suitable scope to authorize an operation, some of which may
34462 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34463 /// sufficient, a read-write scope will do as well.
34464 pub fn add_scope<St>(mut self, scope: St) -> ManagementWebpropertyUserLinkUpdateCall<'a, C>
34465 where
34466 St: AsRef<str>,
34467 {
34468 self._scopes.insert(String::from(scope.as_ref()));
34469 self
34470 }
34471 /// Identifies the authorization scope(s) for the method you are building.
34472 ///
34473 /// See [`Self::add_scope()`] for details.
34474 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagementWebpropertyUserLinkUpdateCall<'a, C>
34475 where
34476 I: IntoIterator<Item = St>,
34477 St: AsRef<str>,
34478 {
34479 self._scopes
34480 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34481 self
34482 }
34483
34484 /// Removes all scopes, and no default scope will be used either.
34485 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34486 /// for details).
34487 pub fn clear_scopes(mut self) -> ManagementWebpropertyUserLinkUpdateCall<'a, C> {
34488 self._scopes.clear();
34489 self
34490 }
34491}
34492
34493/// Lists all columns for a report type
34494///
34495/// A builder for the *columns.list* method supported by a *metadata* resource.
34496/// It is not used directly, but through a [`MetadataMethods`] instance.
34497///
34498/// # Example
34499///
34500/// Instantiate a resource method builder
34501///
34502/// ```test_harness,no_run
34503/// # extern crate hyper;
34504/// # extern crate hyper_rustls;
34505/// # extern crate google_analytics3 as analytics3;
34506/// # async fn dox() {
34507/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34508///
34509/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34510/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
34511/// # secret,
34512/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34513/// # ).build().await.unwrap();
34514///
34515/// # let client = hyper_util::client::legacy::Client::builder(
34516/// # hyper_util::rt::TokioExecutor::new()
34517/// # )
34518/// # .build(
34519/// # hyper_rustls::HttpsConnectorBuilder::new()
34520/// # .with_native_roots()
34521/// # .unwrap()
34522/// # .https_or_http()
34523/// # .enable_http1()
34524/// # .build()
34525/// # );
34526/// # let mut hub = Analytics::new(client, auth);
34527/// // You can configure optional parameters by calling the respective setters at will, and
34528/// // execute the final call using `doit()`.
34529/// // Values shown here are possibly random and not representative !
34530/// let result = hub.metadata().columns_list("reportType")
34531/// .doit().await;
34532/// # }
34533/// ```
34534pub struct MetadataColumnListCall<'a, C>
34535where
34536 C: 'a,
34537{
34538 hub: &'a Analytics<C>,
34539 _report_type: String,
34540 _delegate: Option<&'a mut dyn common::Delegate>,
34541 _additional_params: HashMap<String, String>,
34542 _scopes: BTreeSet<String>,
34543}
34544
34545impl<'a, C> common::CallBuilder for MetadataColumnListCall<'a, C> {}
34546
34547impl<'a, C> MetadataColumnListCall<'a, C>
34548where
34549 C: common::Connector,
34550{
34551 /// Perform the operation you have build so far.
34552 pub async fn doit(mut self) -> common::Result<(common::Response, Columns)> {
34553 use std::borrow::Cow;
34554 use std::io::{Read, Seek};
34555
34556 use common::{url::Params, ToParts};
34557 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34558
34559 let mut dd = common::DefaultDelegate;
34560 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34561 dlg.begin(common::MethodInfo {
34562 id: "analytics.metadata.columns.list",
34563 http_method: hyper::Method::GET,
34564 });
34565
34566 for &field in ["alt", "reportType"].iter() {
34567 if self._additional_params.contains_key(field) {
34568 dlg.finished(false);
34569 return Err(common::Error::FieldClash(field));
34570 }
34571 }
34572
34573 let mut params = Params::with_capacity(3 + self._additional_params.len());
34574 params.push("reportType", self._report_type);
34575
34576 params.extend(self._additional_params.iter());
34577
34578 params.push("alt", "json");
34579 let mut url = self.hub._base_url.clone() + "metadata/{reportType}/columns";
34580 if self._scopes.is_empty() {
34581 self._scopes.insert(Scope::Readonly.as_ref().to_string());
34582 }
34583
34584 #[allow(clippy::single_element_loop)]
34585 for &(find_this, param_name) in [("{reportType}", "reportType")].iter() {
34586 url = params.uri_replacement(url, param_name, find_this, false);
34587 }
34588 {
34589 let to_remove = ["reportType"];
34590 params.remove_params(&to_remove);
34591 }
34592
34593 let url = params.parse_with_url(&url);
34594
34595 loop {
34596 let token = match self
34597 .hub
34598 .auth
34599 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34600 .await
34601 {
34602 Ok(token) => token,
34603 Err(e) => match dlg.token(e) {
34604 Ok(token) => token,
34605 Err(e) => {
34606 dlg.finished(false);
34607 return Err(common::Error::MissingToken(e));
34608 }
34609 },
34610 };
34611 let mut req_result = {
34612 let client = &self.hub.client;
34613 dlg.pre_request();
34614 let mut req_builder = hyper::Request::builder()
34615 .method(hyper::Method::GET)
34616 .uri(url.as_str())
34617 .header(USER_AGENT, self.hub._user_agent.clone());
34618
34619 if let Some(token) = token.as_ref() {
34620 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34621 }
34622
34623 let request = req_builder
34624 .header(CONTENT_LENGTH, 0_u64)
34625 .body(common::to_body::<String>(None));
34626
34627 client.request(request.unwrap()).await
34628 };
34629
34630 match req_result {
34631 Err(err) => {
34632 if let common::Retry::After(d) = dlg.http_error(&err) {
34633 sleep(d).await;
34634 continue;
34635 }
34636 dlg.finished(false);
34637 return Err(common::Error::HttpError(err));
34638 }
34639 Ok(res) => {
34640 let (mut parts, body) = res.into_parts();
34641 let mut body = common::Body::new(body);
34642 if !parts.status.is_success() {
34643 let bytes = common::to_bytes(body).await.unwrap_or_default();
34644 let error = serde_json::from_str(&common::to_string(&bytes));
34645 let response = common::to_response(parts, bytes.into());
34646
34647 if let common::Retry::After(d) =
34648 dlg.http_failure(&response, error.as_ref().ok())
34649 {
34650 sleep(d).await;
34651 continue;
34652 }
34653
34654 dlg.finished(false);
34655
34656 return Err(match error {
34657 Ok(value) => common::Error::BadRequest(value),
34658 _ => common::Error::Failure(response),
34659 });
34660 }
34661 let response = {
34662 let bytes = common::to_bytes(body).await.unwrap_or_default();
34663 let encoded = common::to_string(&bytes);
34664 match serde_json::from_str(&encoded) {
34665 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34666 Err(error) => {
34667 dlg.response_json_decode_error(&encoded, &error);
34668 return Err(common::Error::JsonDecodeError(
34669 encoded.to_string(),
34670 error,
34671 ));
34672 }
34673 }
34674 };
34675
34676 dlg.finished(true);
34677 return Ok(response);
34678 }
34679 }
34680 }
34681 }
34682
34683 /// Report type. Allowed Values: 'ga'. Where 'ga' corresponds to the Core Reporting API
34684 ///
34685 /// Sets the *report type* path property to the given value.
34686 ///
34687 /// Even though the property as already been set when instantiating this call,
34688 /// we provide this method for API completeness.
34689 pub fn report_type(mut self, new_value: &str) -> MetadataColumnListCall<'a, C> {
34690 self._report_type = new_value.to_string();
34691 self
34692 }
34693 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34694 /// while executing the actual API request.
34695 ///
34696 /// ````text
34697 /// It should be used to handle progress information, and to implement a certain level of resilience.
34698 /// ````
34699 ///
34700 /// Sets the *delegate* property to the given value.
34701 pub fn delegate(
34702 mut self,
34703 new_value: &'a mut dyn common::Delegate,
34704 ) -> MetadataColumnListCall<'a, C> {
34705 self._delegate = Some(new_value);
34706 self
34707 }
34708
34709 /// Set any additional parameter of the query string used in the request.
34710 /// It should be used to set parameters which are not yet available through their own
34711 /// setters.
34712 ///
34713 /// Please note that this method must not be used to set any of the known parameters
34714 /// which have their own setter method. If done anyway, the request will fail.
34715 ///
34716 /// # Additional Parameters
34717 ///
34718 /// * *alt* (query-string) - Data format for the response.
34719 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34720 /// * *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.
34721 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34722 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34723 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34724 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34725 pub fn param<T>(mut self, name: T, value: T) -> MetadataColumnListCall<'a, C>
34726 where
34727 T: AsRef<str>,
34728 {
34729 self._additional_params
34730 .insert(name.as_ref().to_string(), value.as_ref().to_string());
34731 self
34732 }
34733
34734 /// Identifies the authorization scope for the method you are building.
34735 ///
34736 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34737 /// [`Scope::Readonly`].
34738 ///
34739 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34740 /// tokens for more than one scope.
34741 ///
34742 /// Usually there is more than one suitable scope to authorize an operation, some of which may
34743 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34744 /// sufficient, a read-write scope will do as well.
34745 pub fn add_scope<St>(mut self, scope: St) -> MetadataColumnListCall<'a, C>
34746 where
34747 St: AsRef<str>,
34748 {
34749 self._scopes.insert(String::from(scope.as_ref()));
34750 self
34751 }
34752 /// Identifies the authorization scope(s) for the method you are building.
34753 ///
34754 /// See [`Self::add_scope()`] for details.
34755 pub fn add_scopes<I, St>(mut self, scopes: I) -> MetadataColumnListCall<'a, C>
34756 where
34757 I: IntoIterator<Item = St>,
34758 St: AsRef<str>,
34759 {
34760 self._scopes
34761 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34762 self
34763 }
34764
34765 /// Removes all scopes, and no default scope will be used either.
34766 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34767 /// for details).
34768 pub fn clear_scopes(mut self) -> MetadataColumnListCall<'a, C> {
34769 self._scopes.clear();
34770 self
34771 }
34772}
34773
34774/// Creates an account ticket.
34775///
34776/// A builder for the *createAccountTicket* method supported by a *provisioning* resource.
34777/// It is not used directly, but through a [`ProvisioningMethods`] instance.
34778///
34779/// # Example
34780///
34781/// Instantiate a resource method builder
34782///
34783/// ```test_harness,no_run
34784/// # extern crate hyper;
34785/// # extern crate hyper_rustls;
34786/// # extern crate google_analytics3 as analytics3;
34787/// use analytics3::api::AccountTicket;
34788/// # async fn dox() {
34789/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34790///
34791/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34792/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
34793/// # secret,
34794/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34795/// # ).build().await.unwrap();
34796///
34797/// # let client = hyper_util::client::legacy::Client::builder(
34798/// # hyper_util::rt::TokioExecutor::new()
34799/// # )
34800/// # .build(
34801/// # hyper_rustls::HttpsConnectorBuilder::new()
34802/// # .with_native_roots()
34803/// # .unwrap()
34804/// # .https_or_http()
34805/// # .enable_http1()
34806/// # .build()
34807/// # );
34808/// # let mut hub = Analytics::new(client, auth);
34809/// // As the method needs a request, you would usually fill it with the desired information
34810/// // into the respective structure. Some of the parts shown here might not be applicable !
34811/// // Values shown here are possibly random and not representative !
34812/// let mut req = AccountTicket::default();
34813///
34814/// // You can configure optional parameters by calling the respective setters at will, and
34815/// // execute the final call using `doit()`.
34816/// // Values shown here are possibly random and not representative !
34817/// let result = hub.provisioning().create_account_ticket(req)
34818/// .doit().await;
34819/// # }
34820/// ```
34821pub struct ProvisioningCreateAccountTicketCall<'a, C>
34822where
34823 C: 'a,
34824{
34825 hub: &'a Analytics<C>,
34826 _request: AccountTicket,
34827 _delegate: Option<&'a mut dyn common::Delegate>,
34828 _additional_params: HashMap<String, String>,
34829 _scopes: BTreeSet<String>,
34830}
34831
34832impl<'a, C> common::CallBuilder for ProvisioningCreateAccountTicketCall<'a, C> {}
34833
34834impl<'a, C> ProvisioningCreateAccountTicketCall<'a, C>
34835where
34836 C: common::Connector,
34837{
34838 /// Perform the operation you have build so far.
34839 pub async fn doit(mut self) -> common::Result<(common::Response, AccountTicket)> {
34840 use std::borrow::Cow;
34841 use std::io::{Read, Seek};
34842
34843 use common::{url::Params, ToParts};
34844 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34845
34846 let mut dd = common::DefaultDelegate;
34847 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34848 dlg.begin(common::MethodInfo {
34849 id: "analytics.provisioning.createAccountTicket",
34850 http_method: hyper::Method::POST,
34851 });
34852
34853 for &field in ["alt"].iter() {
34854 if self._additional_params.contains_key(field) {
34855 dlg.finished(false);
34856 return Err(common::Error::FieldClash(field));
34857 }
34858 }
34859
34860 let mut params = Params::with_capacity(3 + self._additional_params.len());
34861
34862 params.extend(self._additional_params.iter());
34863
34864 params.push("alt", "json");
34865 let mut url = self.hub._base_url.clone() + "provisioning/createAccountTicket";
34866 if self._scopes.is_empty() {
34867 self._scopes.insert(Scope::Provision.as_ref().to_string());
34868 }
34869
34870 let url = params.parse_with_url(&url);
34871
34872 let mut json_mime_type = mime::APPLICATION_JSON;
34873 let mut request_value_reader = {
34874 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
34875 common::remove_json_null_values(&mut value);
34876 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
34877 serde_json::to_writer(&mut dst, &value).unwrap();
34878 dst
34879 };
34880 let request_size = request_value_reader
34881 .seek(std::io::SeekFrom::End(0))
34882 .unwrap();
34883 request_value_reader
34884 .seek(std::io::SeekFrom::Start(0))
34885 .unwrap();
34886
34887 loop {
34888 let token = match self
34889 .hub
34890 .auth
34891 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34892 .await
34893 {
34894 Ok(token) => token,
34895 Err(e) => match dlg.token(e) {
34896 Ok(token) => token,
34897 Err(e) => {
34898 dlg.finished(false);
34899 return Err(common::Error::MissingToken(e));
34900 }
34901 },
34902 };
34903 request_value_reader
34904 .seek(std::io::SeekFrom::Start(0))
34905 .unwrap();
34906 let mut req_result = {
34907 let client = &self.hub.client;
34908 dlg.pre_request();
34909 let mut req_builder = hyper::Request::builder()
34910 .method(hyper::Method::POST)
34911 .uri(url.as_str())
34912 .header(USER_AGENT, self.hub._user_agent.clone());
34913
34914 if let Some(token) = token.as_ref() {
34915 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34916 }
34917
34918 let request = req_builder
34919 .header(CONTENT_TYPE, json_mime_type.to_string())
34920 .header(CONTENT_LENGTH, request_size as u64)
34921 .body(common::to_body(
34922 request_value_reader.get_ref().clone().into(),
34923 ));
34924
34925 client.request(request.unwrap()).await
34926 };
34927
34928 match req_result {
34929 Err(err) => {
34930 if let common::Retry::After(d) = dlg.http_error(&err) {
34931 sleep(d).await;
34932 continue;
34933 }
34934 dlg.finished(false);
34935 return Err(common::Error::HttpError(err));
34936 }
34937 Ok(res) => {
34938 let (mut parts, body) = res.into_parts();
34939 let mut body = common::Body::new(body);
34940 if !parts.status.is_success() {
34941 let bytes = common::to_bytes(body).await.unwrap_or_default();
34942 let error = serde_json::from_str(&common::to_string(&bytes));
34943 let response = common::to_response(parts, bytes.into());
34944
34945 if let common::Retry::After(d) =
34946 dlg.http_failure(&response, error.as_ref().ok())
34947 {
34948 sleep(d).await;
34949 continue;
34950 }
34951
34952 dlg.finished(false);
34953
34954 return Err(match error {
34955 Ok(value) => common::Error::BadRequest(value),
34956 _ => common::Error::Failure(response),
34957 });
34958 }
34959 let response = {
34960 let bytes = common::to_bytes(body).await.unwrap_or_default();
34961 let encoded = common::to_string(&bytes);
34962 match serde_json::from_str(&encoded) {
34963 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34964 Err(error) => {
34965 dlg.response_json_decode_error(&encoded, &error);
34966 return Err(common::Error::JsonDecodeError(
34967 encoded.to_string(),
34968 error,
34969 ));
34970 }
34971 }
34972 };
34973
34974 dlg.finished(true);
34975 return Ok(response);
34976 }
34977 }
34978 }
34979 }
34980
34981 ///
34982 /// Sets the *request* property to the given value.
34983 ///
34984 /// Even though the property as already been set when instantiating this call,
34985 /// we provide this method for API completeness.
34986 pub fn request(
34987 mut self,
34988 new_value: AccountTicket,
34989 ) -> ProvisioningCreateAccountTicketCall<'a, C> {
34990 self._request = new_value;
34991 self
34992 }
34993 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34994 /// while executing the actual API request.
34995 ///
34996 /// ````text
34997 /// It should be used to handle progress information, and to implement a certain level of resilience.
34998 /// ````
34999 ///
35000 /// Sets the *delegate* property to the given value.
35001 pub fn delegate(
35002 mut self,
35003 new_value: &'a mut dyn common::Delegate,
35004 ) -> ProvisioningCreateAccountTicketCall<'a, C> {
35005 self._delegate = Some(new_value);
35006 self
35007 }
35008
35009 /// Set any additional parameter of the query string used in the request.
35010 /// It should be used to set parameters which are not yet available through their own
35011 /// setters.
35012 ///
35013 /// Please note that this method must not be used to set any of the known parameters
35014 /// which have their own setter method. If done anyway, the request will fail.
35015 ///
35016 /// # Additional Parameters
35017 ///
35018 /// * *alt* (query-string) - Data format for the response.
35019 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35020 /// * *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.
35021 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35022 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35023 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
35024 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
35025 pub fn param<T>(mut self, name: T, value: T) -> ProvisioningCreateAccountTicketCall<'a, C>
35026 where
35027 T: AsRef<str>,
35028 {
35029 self._additional_params
35030 .insert(name.as_ref().to_string(), value.as_ref().to_string());
35031 self
35032 }
35033
35034 /// Identifies the authorization scope for the method you are building.
35035 ///
35036 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35037 /// [`Scope::Provision`].
35038 ///
35039 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35040 /// tokens for more than one scope.
35041 ///
35042 /// Usually there is more than one suitable scope to authorize an operation, some of which may
35043 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35044 /// sufficient, a read-write scope will do as well.
35045 pub fn add_scope<St>(mut self, scope: St) -> ProvisioningCreateAccountTicketCall<'a, C>
35046 where
35047 St: AsRef<str>,
35048 {
35049 self._scopes.insert(String::from(scope.as_ref()));
35050 self
35051 }
35052 /// Identifies the authorization scope(s) for the method you are building.
35053 ///
35054 /// See [`Self::add_scope()`] for details.
35055 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProvisioningCreateAccountTicketCall<'a, C>
35056 where
35057 I: IntoIterator<Item = St>,
35058 St: AsRef<str>,
35059 {
35060 self._scopes
35061 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35062 self
35063 }
35064
35065 /// Removes all scopes, and no default scope will be used either.
35066 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35067 /// for details).
35068 pub fn clear_scopes(mut self) -> ProvisioningCreateAccountTicketCall<'a, C> {
35069 self._scopes.clear();
35070 self
35071 }
35072}
35073
35074/// Provision account.
35075///
35076/// A builder for the *createAccountTree* method supported by a *provisioning* resource.
35077/// It is not used directly, but through a [`ProvisioningMethods`] instance.
35078///
35079/// # Example
35080///
35081/// Instantiate a resource method builder
35082///
35083/// ```test_harness,no_run
35084/// # extern crate hyper;
35085/// # extern crate hyper_rustls;
35086/// # extern crate google_analytics3 as analytics3;
35087/// use analytics3::api::AccountTreeRequest;
35088/// # async fn dox() {
35089/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35090///
35091/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35092/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
35093/// # secret,
35094/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35095/// # ).build().await.unwrap();
35096///
35097/// # let client = hyper_util::client::legacy::Client::builder(
35098/// # hyper_util::rt::TokioExecutor::new()
35099/// # )
35100/// # .build(
35101/// # hyper_rustls::HttpsConnectorBuilder::new()
35102/// # .with_native_roots()
35103/// # .unwrap()
35104/// # .https_or_http()
35105/// # .enable_http1()
35106/// # .build()
35107/// # );
35108/// # let mut hub = Analytics::new(client, auth);
35109/// // As the method needs a request, you would usually fill it with the desired information
35110/// // into the respective structure. Some of the parts shown here might not be applicable !
35111/// // Values shown here are possibly random and not representative !
35112/// let mut req = AccountTreeRequest::default();
35113///
35114/// // You can configure optional parameters by calling the respective setters at will, and
35115/// // execute the final call using `doit()`.
35116/// // Values shown here are possibly random and not representative !
35117/// let result = hub.provisioning().create_account_tree(req)
35118/// .doit().await;
35119/// # }
35120/// ```
35121pub struct ProvisioningCreateAccountTreeCall<'a, C>
35122where
35123 C: 'a,
35124{
35125 hub: &'a Analytics<C>,
35126 _request: AccountTreeRequest,
35127 _delegate: Option<&'a mut dyn common::Delegate>,
35128 _additional_params: HashMap<String, String>,
35129 _scopes: BTreeSet<String>,
35130}
35131
35132impl<'a, C> common::CallBuilder for ProvisioningCreateAccountTreeCall<'a, C> {}
35133
35134impl<'a, C> ProvisioningCreateAccountTreeCall<'a, C>
35135where
35136 C: common::Connector,
35137{
35138 /// Perform the operation you have build so far.
35139 pub async fn doit(mut self) -> common::Result<(common::Response, AccountTreeResponse)> {
35140 use std::borrow::Cow;
35141 use std::io::{Read, Seek};
35142
35143 use common::{url::Params, ToParts};
35144 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35145
35146 let mut dd = common::DefaultDelegate;
35147 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35148 dlg.begin(common::MethodInfo {
35149 id: "analytics.provisioning.createAccountTree",
35150 http_method: hyper::Method::POST,
35151 });
35152
35153 for &field in ["alt"].iter() {
35154 if self._additional_params.contains_key(field) {
35155 dlg.finished(false);
35156 return Err(common::Error::FieldClash(field));
35157 }
35158 }
35159
35160 let mut params = Params::with_capacity(3 + self._additional_params.len());
35161
35162 params.extend(self._additional_params.iter());
35163
35164 params.push("alt", "json");
35165 let mut url = self.hub._base_url.clone() + "provisioning/createAccountTree";
35166 if self._scopes.is_empty() {
35167 self._scopes.insert(Scope::Provision.as_ref().to_string());
35168 }
35169
35170 let url = params.parse_with_url(&url);
35171
35172 let mut json_mime_type = mime::APPLICATION_JSON;
35173 let mut request_value_reader = {
35174 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
35175 common::remove_json_null_values(&mut value);
35176 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
35177 serde_json::to_writer(&mut dst, &value).unwrap();
35178 dst
35179 };
35180 let request_size = request_value_reader
35181 .seek(std::io::SeekFrom::End(0))
35182 .unwrap();
35183 request_value_reader
35184 .seek(std::io::SeekFrom::Start(0))
35185 .unwrap();
35186
35187 loop {
35188 let token = match self
35189 .hub
35190 .auth
35191 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35192 .await
35193 {
35194 Ok(token) => token,
35195 Err(e) => match dlg.token(e) {
35196 Ok(token) => token,
35197 Err(e) => {
35198 dlg.finished(false);
35199 return Err(common::Error::MissingToken(e));
35200 }
35201 },
35202 };
35203 request_value_reader
35204 .seek(std::io::SeekFrom::Start(0))
35205 .unwrap();
35206 let mut req_result = {
35207 let client = &self.hub.client;
35208 dlg.pre_request();
35209 let mut req_builder = hyper::Request::builder()
35210 .method(hyper::Method::POST)
35211 .uri(url.as_str())
35212 .header(USER_AGENT, self.hub._user_agent.clone());
35213
35214 if let Some(token) = token.as_ref() {
35215 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35216 }
35217
35218 let request = req_builder
35219 .header(CONTENT_TYPE, json_mime_type.to_string())
35220 .header(CONTENT_LENGTH, request_size as u64)
35221 .body(common::to_body(
35222 request_value_reader.get_ref().clone().into(),
35223 ));
35224
35225 client.request(request.unwrap()).await
35226 };
35227
35228 match req_result {
35229 Err(err) => {
35230 if let common::Retry::After(d) = dlg.http_error(&err) {
35231 sleep(d).await;
35232 continue;
35233 }
35234 dlg.finished(false);
35235 return Err(common::Error::HttpError(err));
35236 }
35237 Ok(res) => {
35238 let (mut parts, body) = res.into_parts();
35239 let mut body = common::Body::new(body);
35240 if !parts.status.is_success() {
35241 let bytes = common::to_bytes(body).await.unwrap_or_default();
35242 let error = serde_json::from_str(&common::to_string(&bytes));
35243 let response = common::to_response(parts, bytes.into());
35244
35245 if let common::Retry::After(d) =
35246 dlg.http_failure(&response, error.as_ref().ok())
35247 {
35248 sleep(d).await;
35249 continue;
35250 }
35251
35252 dlg.finished(false);
35253
35254 return Err(match error {
35255 Ok(value) => common::Error::BadRequest(value),
35256 _ => common::Error::Failure(response),
35257 });
35258 }
35259 let response = {
35260 let bytes = common::to_bytes(body).await.unwrap_or_default();
35261 let encoded = common::to_string(&bytes);
35262 match serde_json::from_str(&encoded) {
35263 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35264 Err(error) => {
35265 dlg.response_json_decode_error(&encoded, &error);
35266 return Err(common::Error::JsonDecodeError(
35267 encoded.to_string(),
35268 error,
35269 ));
35270 }
35271 }
35272 };
35273
35274 dlg.finished(true);
35275 return Ok(response);
35276 }
35277 }
35278 }
35279 }
35280
35281 ///
35282 /// Sets the *request* property to the given value.
35283 ///
35284 /// Even though the property as already been set when instantiating this call,
35285 /// we provide this method for API completeness.
35286 pub fn request(
35287 mut self,
35288 new_value: AccountTreeRequest,
35289 ) -> ProvisioningCreateAccountTreeCall<'a, C> {
35290 self._request = new_value;
35291 self
35292 }
35293 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35294 /// while executing the actual API request.
35295 ///
35296 /// ````text
35297 /// It should be used to handle progress information, and to implement a certain level of resilience.
35298 /// ````
35299 ///
35300 /// Sets the *delegate* property to the given value.
35301 pub fn delegate(
35302 mut self,
35303 new_value: &'a mut dyn common::Delegate,
35304 ) -> ProvisioningCreateAccountTreeCall<'a, C> {
35305 self._delegate = Some(new_value);
35306 self
35307 }
35308
35309 /// Set any additional parameter of the query string used in the request.
35310 /// It should be used to set parameters which are not yet available through their own
35311 /// setters.
35312 ///
35313 /// Please note that this method must not be used to set any of the known parameters
35314 /// which have their own setter method. If done anyway, the request will fail.
35315 ///
35316 /// # Additional Parameters
35317 ///
35318 /// * *alt* (query-string) - Data format for the response.
35319 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35320 /// * *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.
35321 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35322 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35323 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
35324 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
35325 pub fn param<T>(mut self, name: T, value: T) -> ProvisioningCreateAccountTreeCall<'a, C>
35326 where
35327 T: AsRef<str>,
35328 {
35329 self._additional_params
35330 .insert(name.as_ref().to_string(), value.as_ref().to_string());
35331 self
35332 }
35333
35334 /// Identifies the authorization scope for the method you are building.
35335 ///
35336 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35337 /// [`Scope::Provision`].
35338 ///
35339 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35340 /// tokens for more than one scope.
35341 ///
35342 /// Usually there is more than one suitable scope to authorize an operation, some of which may
35343 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35344 /// sufficient, a read-write scope will do as well.
35345 pub fn add_scope<St>(mut self, scope: St) -> ProvisioningCreateAccountTreeCall<'a, C>
35346 where
35347 St: AsRef<str>,
35348 {
35349 self._scopes.insert(String::from(scope.as_ref()));
35350 self
35351 }
35352 /// Identifies the authorization scope(s) for the method you are building.
35353 ///
35354 /// See [`Self::add_scope()`] for details.
35355 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProvisioningCreateAccountTreeCall<'a, C>
35356 where
35357 I: IntoIterator<Item = St>,
35358 St: AsRef<str>,
35359 {
35360 self._scopes
35361 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35362 self
35363 }
35364
35365 /// Removes all scopes, and no default scope will be used either.
35366 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35367 /// for details).
35368 pub fn clear_scopes(mut self) -> ProvisioningCreateAccountTreeCall<'a, C> {
35369 self._scopes.clear();
35370 self
35371 }
35372}
35373
35374/// Insert or update a user deletion requests.
35375///
35376/// A builder for the *userDeletionRequest.upsert* method supported by a *userDeletion* resource.
35377/// It is not used directly, but through a [`UserDeletionMethods`] instance.
35378///
35379/// # Example
35380///
35381/// Instantiate a resource method builder
35382///
35383/// ```test_harness,no_run
35384/// # extern crate hyper;
35385/// # extern crate hyper_rustls;
35386/// # extern crate google_analytics3 as analytics3;
35387/// use analytics3::api::UserDeletionRequest;
35388/// # async fn dox() {
35389/// # use analytics3::{Analytics, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35390///
35391/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35392/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
35393/// # secret,
35394/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35395/// # ).build().await.unwrap();
35396///
35397/// # let client = hyper_util::client::legacy::Client::builder(
35398/// # hyper_util::rt::TokioExecutor::new()
35399/// # )
35400/// # .build(
35401/// # hyper_rustls::HttpsConnectorBuilder::new()
35402/// # .with_native_roots()
35403/// # .unwrap()
35404/// # .https_or_http()
35405/// # .enable_http1()
35406/// # .build()
35407/// # );
35408/// # let mut hub = Analytics::new(client, auth);
35409/// // As the method needs a request, you would usually fill it with the desired information
35410/// // into the respective structure. Some of the parts shown here might not be applicable !
35411/// // Values shown here are possibly random and not representative !
35412/// let mut req = UserDeletionRequest::default();
35413///
35414/// // You can configure optional parameters by calling the respective setters at will, and
35415/// // execute the final call using `doit()`.
35416/// // Values shown here are possibly random and not representative !
35417/// let result = hub.user_deletion().user_deletion_request_upsert(req)
35418/// .doit().await;
35419/// # }
35420/// ```
35421pub struct UserDeletionUserDeletionRequestUpsertCall<'a, C>
35422where
35423 C: 'a,
35424{
35425 hub: &'a Analytics<C>,
35426 _request: UserDeletionRequest,
35427 _delegate: Option<&'a mut dyn common::Delegate>,
35428 _additional_params: HashMap<String, String>,
35429 _scopes: BTreeSet<String>,
35430}
35431
35432impl<'a, C> common::CallBuilder for UserDeletionUserDeletionRequestUpsertCall<'a, C> {}
35433
35434impl<'a, C> UserDeletionUserDeletionRequestUpsertCall<'a, C>
35435where
35436 C: common::Connector,
35437{
35438 /// Perform the operation you have build so far.
35439 pub async fn doit(mut self) -> common::Result<(common::Response, UserDeletionRequest)> {
35440 use std::borrow::Cow;
35441 use std::io::{Read, Seek};
35442
35443 use common::{url::Params, ToParts};
35444 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35445
35446 let mut dd = common::DefaultDelegate;
35447 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35448 dlg.begin(common::MethodInfo {
35449 id: "analytics.userDeletion.userDeletionRequest.upsert",
35450 http_method: hyper::Method::POST,
35451 });
35452
35453 for &field in ["alt"].iter() {
35454 if self._additional_params.contains_key(field) {
35455 dlg.finished(false);
35456 return Err(common::Error::FieldClash(field));
35457 }
35458 }
35459
35460 let mut params = Params::with_capacity(3 + self._additional_params.len());
35461
35462 params.extend(self._additional_params.iter());
35463
35464 params.push("alt", "json");
35465 let mut url = self.hub._base_url.clone() + "userDeletion/userDeletionRequests:upsert";
35466 if self._scopes.is_empty() {
35467 self._scopes
35468 .insert(Scope::UserDeletion.as_ref().to_string());
35469 }
35470
35471 let url = params.parse_with_url(&url);
35472
35473 let mut json_mime_type = mime::APPLICATION_JSON;
35474 let mut request_value_reader = {
35475 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
35476 common::remove_json_null_values(&mut value);
35477 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
35478 serde_json::to_writer(&mut dst, &value).unwrap();
35479 dst
35480 };
35481 let request_size = request_value_reader
35482 .seek(std::io::SeekFrom::End(0))
35483 .unwrap();
35484 request_value_reader
35485 .seek(std::io::SeekFrom::Start(0))
35486 .unwrap();
35487
35488 loop {
35489 let token = match self
35490 .hub
35491 .auth
35492 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35493 .await
35494 {
35495 Ok(token) => token,
35496 Err(e) => match dlg.token(e) {
35497 Ok(token) => token,
35498 Err(e) => {
35499 dlg.finished(false);
35500 return Err(common::Error::MissingToken(e));
35501 }
35502 },
35503 };
35504 request_value_reader
35505 .seek(std::io::SeekFrom::Start(0))
35506 .unwrap();
35507 let mut req_result = {
35508 let client = &self.hub.client;
35509 dlg.pre_request();
35510 let mut req_builder = hyper::Request::builder()
35511 .method(hyper::Method::POST)
35512 .uri(url.as_str())
35513 .header(USER_AGENT, self.hub._user_agent.clone());
35514
35515 if let Some(token) = token.as_ref() {
35516 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35517 }
35518
35519 let request = req_builder
35520 .header(CONTENT_TYPE, json_mime_type.to_string())
35521 .header(CONTENT_LENGTH, request_size as u64)
35522 .body(common::to_body(
35523 request_value_reader.get_ref().clone().into(),
35524 ));
35525
35526 client.request(request.unwrap()).await
35527 };
35528
35529 match req_result {
35530 Err(err) => {
35531 if let common::Retry::After(d) = dlg.http_error(&err) {
35532 sleep(d).await;
35533 continue;
35534 }
35535 dlg.finished(false);
35536 return Err(common::Error::HttpError(err));
35537 }
35538 Ok(res) => {
35539 let (mut parts, body) = res.into_parts();
35540 let mut body = common::Body::new(body);
35541 if !parts.status.is_success() {
35542 let bytes = common::to_bytes(body).await.unwrap_or_default();
35543 let error = serde_json::from_str(&common::to_string(&bytes));
35544 let response = common::to_response(parts, bytes.into());
35545
35546 if let common::Retry::After(d) =
35547 dlg.http_failure(&response, error.as_ref().ok())
35548 {
35549 sleep(d).await;
35550 continue;
35551 }
35552
35553 dlg.finished(false);
35554
35555 return Err(match error {
35556 Ok(value) => common::Error::BadRequest(value),
35557 _ => common::Error::Failure(response),
35558 });
35559 }
35560 let response = {
35561 let bytes = common::to_bytes(body).await.unwrap_or_default();
35562 let encoded = common::to_string(&bytes);
35563 match serde_json::from_str(&encoded) {
35564 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35565 Err(error) => {
35566 dlg.response_json_decode_error(&encoded, &error);
35567 return Err(common::Error::JsonDecodeError(
35568 encoded.to_string(),
35569 error,
35570 ));
35571 }
35572 }
35573 };
35574
35575 dlg.finished(true);
35576 return Ok(response);
35577 }
35578 }
35579 }
35580 }
35581
35582 ///
35583 /// Sets the *request* property to the given value.
35584 ///
35585 /// Even though the property as already been set when instantiating this call,
35586 /// we provide this method for API completeness.
35587 pub fn request(
35588 mut self,
35589 new_value: UserDeletionRequest,
35590 ) -> UserDeletionUserDeletionRequestUpsertCall<'a, C> {
35591 self._request = new_value;
35592 self
35593 }
35594 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35595 /// while executing the actual API request.
35596 ///
35597 /// ````text
35598 /// It should be used to handle progress information, and to implement a certain level of resilience.
35599 /// ````
35600 ///
35601 /// Sets the *delegate* property to the given value.
35602 pub fn delegate(
35603 mut self,
35604 new_value: &'a mut dyn common::Delegate,
35605 ) -> UserDeletionUserDeletionRequestUpsertCall<'a, C> {
35606 self._delegate = Some(new_value);
35607 self
35608 }
35609
35610 /// Set any additional parameter of the query string used in the request.
35611 /// It should be used to set parameters which are not yet available through their own
35612 /// setters.
35613 ///
35614 /// Please note that this method must not be used to set any of the known parameters
35615 /// which have their own setter method. If done anyway, the request will fail.
35616 ///
35617 /// # Additional Parameters
35618 ///
35619 /// * *alt* (query-string) - Data format for the response.
35620 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35621 /// * *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.
35622 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35623 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35624 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
35625 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
35626 pub fn param<T>(mut self, name: T, value: T) -> UserDeletionUserDeletionRequestUpsertCall<'a, C>
35627 where
35628 T: AsRef<str>,
35629 {
35630 self._additional_params
35631 .insert(name.as_ref().to_string(), value.as_ref().to_string());
35632 self
35633 }
35634
35635 /// Identifies the authorization scope for the method you are building.
35636 ///
35637 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35638 /// [`Scope::UserDeletion`].
35639 ///
35640 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35641 /// tokens for more than one scope.
35642 ///
35643 /// Usually there is more than one suitable scope to authorize an operation, some of which may
35644 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35645 /// sufficient, a read-write scope will do as well.
35646 pub fn add_scope<St>(mut self, scope: St) -> UserDeletionUserDeletionRequestUpsertCall<'a, C>
35647 where
35648 St: AsRef<str>,
35649 {
35650 self._scopes.insert(String::from(scope.as_ref()));
35651 self
35652 }
35653 /// Identifies the authorization scope(s) for the method you are building.
35654 ///
35655 /// See [`Self::add_scope()`] for details.
35656 pub fn add_scopes<I, St>(
35657 mut self,
35658 scopes: I,
35659 ) -> UserDeletionUserDeletionRequestUpsertCall<'a, C>
35660 where
35661 I: IntoIterator<Item = St>,
35662 St: AsRef<str>,
35663 {
35664 self._scopes
35665 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35666 self
35667 }
35668
35669 /// Removes all scopes, and no default scope will be used either.
35670 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35671 /// for details).
35672 pub fn clear_scopes(mut self) -> UserDeletionUserDeletionRequestUpsertCall<'a, C> {
35673 self._scopes.clear();
35674 self
35675 }
35676}