google_analyticsdata1_beta/
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    Analytic,
18
19    /// See and download your Google Analytics data
20    AnalyticReadonly,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::Analytic => "https://www.googleapis.com/auth/analytics",
27            Scope::AnalyticReadonly => "https://www.googleapis.com/auth/analytics.readonly",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::AnalyticReadonly
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all AnalyticsData related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_analyticsdata1_beta as analyticsdata1_beta;
53/// use analyticsdata1_beta::api::AudienceExport;
54/// use analyticsdata1_beta::{Result, Error};
55/// # async fn dox() {
56/// use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace  `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67///     .with_native_roots()
68///     .unwrap()
69///     .https_only()
70///     .enable_http2()
71///     .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75///     secret,
76///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77///     yup_oauth2::client::CustomHyperClientBuilder::from(
78///         hyper_util::client::legacy::Client::builder(executor).build(connector),
79///     ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83///     hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86///     hyper_rustls::HttpsConnectorBuilder::new()
87///         .with_native_roots()
88///         .unwrap()
89///         .https_or_http()
90///         .enable_http2()
91///         .build()
92/// );
93/// let mut hub = AnalyticsData::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = AudienceExport::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.properties().audience_exports_create(req, "parent")
103///              .doit().await;
104///
105/// match result {
106///     Err(e) => match e {
107///         // The Error enum provides details about what exactly happened.
108///         // You can also just use its `Debug`, `Display` or `Error` traits
109///          Error::HttpError(_)
110///         |Error::Io(_)
111///         |Error::MissingAPIKey
112///         |Error::MissingToken(_)
113///         |Error::Cancelled
114///         |Error::UploadSizeLimitExceeded(_, _)
115///         |Error::Failure(_)
116///         |Error::BadRequest(_)
117///         |Error::FieldClash(_)
118///         |Error::JsonDecodeError(_, _) => println!("{}", e),
119///     },
120///     Ok(res) => println!("Success: {:?}", res),
121/// }
122/// # }
123/// ```
124#[derive(Clone)]
125pub struct AnalyticsData<C> {
126    pub client: common::Client<C>,
127    pub auth: Box<dyn common::GetToken>,
128    _user_agent: String,
129    _base_url: String,
130    _root_url: String,
131}
132
133impl<C> common::Hub for AnalyticsData<C> {}
134
135impl<'a, C> AnalyticsData<C> {
136    pub fn new<A: 'static + common::GetToken>(
137        client: common::Client<C>,
138        auth: A,
139    ) -> AnalyticsData<C> {
140        AnalyticsData {
141            client,
142            auth: Box::new(auth),
143            _user_agent: "google-api-rust-client/7.0.0".to_string(),
144            _base_url: "https://analyticsdata.googleapis.com/".to_string(),
145            _root_url: "https://analyticsdata.googleapis.com/".to_string(),
146        }
147    }
148
149    pub fn properties(&'a self) -> PropertyMethods<'a, C> {
150        PropertyMethods { hub: self }
151    }
152
153    /// Set the user-agent header field to use in all requests to the server.
154    /// It defaults to `google-api-rust-client/7.0.0`.
155    ///
156    /// Returns the previously set user-agent.
157    pub fn user_agent(&mut self, agent_name: String) -> String {
158        std::mem::replace(&mut self._user_agent, agent_name)
159    }
160
161    /// Set the base url to use in all requests to the server.
162    /// It defaults to `https://analyticsdata.googleapis.com/`.
163    ///
164    /// Returns the previously set base url.
165    pub fn base_url(&mut self, new_base_url: String) -> String {
166        std::mem::replace(&mut self._base_url, new_base_url)
167    }
168
169    /// Set the root url to use in all requests to the server.
170    /// It defaults to `https://analyticsdata.googleapis.com/`.
171    ///
172    /// Returns the previously set root url.
173    pub fn root_url(&mut self, new_root_url: String) -> String {
174        std::mem::replace(&mut self._root_url, new_root_url)
175    }
176}
177
178// ############
179// SCHEMAS ###
180// ##########
181/// A metric actively restricted in creating the report.
182///
183/// This type is not used in any activity, and only used as *part* of another schema.
184///
185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
186#[serde_with::serde_as]
187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
188pub struct ActiveMetricRestriction {
189    /// The name of the restricted metric.
190    #[serde(rename = "metricName")]
191    pub metric_name: Option<String>,
192    /// The reason for this metric's restriction.
193    #[serde(rename = "restrictedMetricTypes")]
194    pub restricted_metric_types: Option<Vec<String>>,
195}
196
197impl common::Part for ActiveMetricRestriction {}
198
199/// An audience export is a list of users in an audience at the time of the list’s creation. One audience may have multiple audience exports created for different days.
200///
201/// # Activities
202///
203/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
204/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
205///
206/// * [audience exports create properties](PropertyAudienceExportCreateCall) (request)
207/// * [audience exports get properties](PropertyAudienceExportGetCall) (response)
208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
209#[serde_with::serde_as]
210#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
211pub struct AudienceExport {
212    /// Required. The audience resource name. This resource name identifies the audience being listed and is shared between the Analytics Data & Admin APIs. Format: `properties/{property}/audiences/{audience}`
213    pub audience: Option<String>,
214    /// Output only. The descriptive display name for this audience. For example, "Purchasers".
215    #[serde(rename = "audienceDisplayName")]
216    pub audience_display_name: Option<String>,
217    /// Output only. The time when CreateAudienceExport was called and the AudienceExport began the `CREATING` state.
218    #[serde(rename = "beginCreatingTime")]
219    pub begin_creating_time: Option<chrono::DateTime<chrono::offset::Utc>>,
220    /// Output only. The total quota tokens charged during creation of the AudienceExport. Because this token count is based on activity from the `CREATING` state, this tokens charged will be fixed once an AudienceExport enters the `ACTIVE` or `FAILED` states.
221    #[serde(rename = "creationQuotaTokensCharged")]
222    pub creation_quota_tokens_charged: Option<i32>,
223    /// Required. The dimensions requested and displayed in the query response.
224    pub dimensions: Option<Vec<V1betaAudienceDimension>>,
225    /// Output only. Error message is populated when an audience export fails during creation. A common reason for such a failure is quota exhaustion.
226    #[serde(rename = "errorMessage")]
227    pub error_message: Option<String>,
228    /// Output only. Identifier. The audience export resource name assigned during creation. This resource name identifies this `AudienceExport`. Format: `properties/{property}/audienceExports/{audience_export}`
229    pub name: Option<String>,
230    /// Output only. The percentage completed for this audience export ranging between 0 to 100.
231    #[serde(rename = "percentageCompleted")]
232    pub percentage_completed: Option<f64>,
233    /// Output only. The total number of rows in the AudienceExport result.
234    #[serde(rename = "rowCount")]
235    pub row_count: Option<i32>,
236    /// Output only. The current state for this AudienceExport.
237    pub state: Option<String>,
238}
239
240impl common::RequestValue for AudienceExport {}
241impl common::ResponseResult for AudienceExport {}
242
243/// The batch request containing multiple pivot report requests.
244///
245/// # Activities
246///
247/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
248/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
249///
250/// * [batch run pivot reports properties](PropertyBatchRunPivotReportCall) (request)
251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
252#[serde_with::serde_as]
253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
254pub struct BatchRunPivotReportsRequest {
255    /// Individual requests. Each request has a separate pivot report response. Each batch request is allowed up to 5 requests.
256    pub requests: Option<Vec<RunPivotReportRequest>>,
257}
258
259impl common::RequestValue for BatchRunPivotReportsRequest {}
260
261/// The batch response containing multiple pivot reports.
262///
263/// # Activities
264///
265/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
266/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
267///
268/// * [batch run pivot reports properties](PropertyBatchRunPivotReportCall) (response)
269#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
270#[serde_with::serde_as]
271#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
272pub struct BatchRunPivotReportsResponse {
273    /// Identifies what kind of resource this message is. This `kind` is always the fixed string "analyticsData#batchRunPivotReports". Useful to distinguish between response types in JSON.
274    pub kind: Option<String>,
275    /// Individual responses. Each response has a separate pivot report request.
276    #[serde(rename = "pivotReports")]
277    pub pivot_reports: Option<Vec<RunPivotReportResponse>>,
278}
279
280impl common::ResponseResult for BatchRunPivotReportsResponse {}
281
282/// The batch request containing multiple report requests.
283///
284/// # Activities
285///
286/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
287/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
288///
289/// * [batch run reports properties](PropertyBatchRunReportCall) (request)
290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
291#[serde_with::serde_as]
292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
293pub struct BatchRunReportsRequest {
294    /// Individual requests. Each request has a separate report response. Each batch request is allowed up to 5 requests.
295    pub requests: Option<Vec<RunReportRequest>>,
296}
297
298impl common::RequestValue for BatchRunReportsRequest {}
299
300/// The batch response containing multiple reports.
301///
302/// # Activities
303///
304/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
305/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
306///
307/// * [batch run reports properties](PropertyBatchRunReportCall) (response)
308#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
309#[serde_with::serde_as]
310#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
311pub struct BatchRunReportsResponse {
312    /// Identifies what kind of resource this message is. This `kind` is always the fixed string "analyticsData#batchRunReports". Useful to distinguish between response types in JSON.
313    pub kind: Option<String>,
314    /// Individual responses. Each response has a separate report request.
315    pub reports: Option<Vec<RunReportResponse>>,
316}
317
318impl common::ResponseResult for BatchRunReportsResponse {}
319
320/// To express that the result needs to be between two numbers (inclusive).
321///
322/// This type is not used in any activity, and only used as *part* of another schema.
323///
324#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
325#[serde_with::serde_as]
326#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
327pub struct BetweenFilter {
328    /// Begins with this number.
329    #[serde(rename = "fromValue")]
330    pub from_value: Option<NumericValue>,
331    /// Ends with this number.
332    #[serde(rename = "toValue")]
333    pub to_value: Option<NumericValue>,
334}
335
336impl common::Part for BetweenFilter {}
337
338/// Used to convert a dimension value to a single case.
339///
340/// This type is not used in any activity, and only used as *part* of another schema.
341///
342#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
343#[serde_with::serde_as]
344#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
345pub struct CaseExpression {
346    /// Name of a dimension. The name must refer back to a name in dimensions field of the request.
347    #[serde(rename = "dimensionName")]
348    pub dimension_name: Option<String>,
349}
350
351impl common::Part for CaseExpression {}
352
353/// The request for compatibility information for a report’s dimensions and metrics. Check compatibility provides a preview of the compatibility of a report; fields shared with the `runReport` request should be the same values as in your `runReport` request.
354///
355/// # Activities
356///
357/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
358/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
359///
360/// * [check compatibility properties](PropertyCheckCompatibilityCall) (request)
361#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
362#[serde_with::serde_as]
363#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
364pub struct CheckCompatibilityRequest {
365    /// Filters the dimensions and metrics in the response to just this compatibility. Commonly used as `”compatibilityFilter”: “COMPATIBLE”` to only return compatible dimensions & metrics.
366    #[serde(rename = "compatibilityFilter")]
367    pub compatibility_filter: Option<String>,
368    /// The filter clause of dimensions. `dimensionFilter` should be the same value as in your `runReport` request.
369    #[serde(rename = "dimensionFilter")]
370    pub dimension_filter: Option<FilterExpression>,
371    /// The dimensions in this report. `dimensions` should be the same value as in your `runReport` request.
372    pub dimensions: Option<Vec<Dimension>>,
373    /// The filter clause of metrics. `metricFilter` should be the same value as in your `runReport` request
374    #[serde(rename = "metricFilter")]
375    pub metric_filter: Option<FilterExpression>,
376    /// The metrics in this report. `metrics` should be the same value as in your `runReport` request.
377    pub metrics: Option<Vec<Metric>>,
378}
379
380impl common::RequestValue for CheckCompatibilityRequest {}
381
382/// The compatibility response with the compatibility of each dimension & metric.
383///
384/// # Activities
385///
386/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
387/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
388///
389/// * [check compatibility properties](PropertyCheckCompatibilityCall) (response)
390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
391#[serde_with::serde_as]
392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
393pub struct CheckCompatibilityResponse {
394    /// The compatibility of each dimension.
395    #[serde(rename = "dimensionCompatibilities")]
396    pub dimension_compatibilities: Option<Vec<DimensionCompatibility>>,
397    /// The compatibility of each metric.
398    #[serde(rename = "metricCompatibilities")]
399    pub metric_compatibilities: Option<Vec<MetricCompatibility>>,
400}
401
402impl common::ResponseResult for CheckCompatibilityResponse {}
403
404/// Defines a cohort selection criteria. A cohort is a group of users who share a common characteristic. For example, users with the same `firstSessionDate` belong to the same cohort.
405///
406/// This type is not used in any activity, and only used as *part* of another schema.
407///
408#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
409#[serde_with::serde_as]
410#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
411pub struct Cohort {
412    /// The cohort selects users whose first touch date is between start date and end date defined in the `dateRange`. This `dateRange` does not specify the full date range of event data that is present in a cohort report. In a cohort report, this `dateRange` is extended by the granularity and offset present in the `cohortsRange`; event data for the extended reporting date range is present in a cohort report. In a cohort request, this `dateRange` is required and the `dateRanges` in the `RunReportRequest` or `RunPivotReportRequest` must be unspecified. This `dateRange` should generally be aligned with the cohort's granularity. If `CohortsRange` uses daily granularity, this `dateRange` can be a single day. If `CohortsRange` uses weekly granularity, this `dateRange` can be aligned to a week boundary, starting at Sunday and ending Saturday. If `CohortsRange` uses monthly granularity, this `dateRange` can be aligned to a month, starting at the first and ending on the last day of the month.
413    #[serde(rename = "dateRange")]
414    pub date_range: Option<DateRange>,
415    /// Dimension used by the cohort. Required and only supports `firstSessionDate`.
416    pub dimension: Option<String>,
417    /// Assigns a name to this cohort. The dimension `cohort` is valued to this name in a report response. If set, cannot begin with `cohort_` or `RESERVED_`. If not set, cohorts are named by their zero based index `cohort_0`, `cohort_1`, etc.
418    pub name: Option<String>,
419}
420
421impl common::Part for Cohort {}
422
423/// Optional settings of a cohort report.
424///
425/// This type is not used in any activity, and only used as *part* of another schema.
426///
427#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
428#[serde_with::serde_as]
429#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
430pub struct CohortReportSettings {
431    /// If true, accumulates the result from first touch day to the end day. Not supported in `RunReportRequest`.
432    pub accumulate: Option<bool>,
433}
434
435impl common::Part for CohortReportSettings {}
436
437/// The specification of cohorts for a cohort report. Cohort reports create a time series of user retention for the cohort. For example, you could select the cohort of users that were acquired in the first week of September and follow that cohort for the next six weeks. Selecting the users acquired in the first week of September cohort is specified in the `cohort` object. Following that cohort for the next six weeks is specified in the `cohortsRange` object. For examples, see [Cohort Report Examples](https://developers.google.com/analytics/devguides/reporting/data/v1/advanced#cohort_report_examples). The report response could show a weekly time series where say your app has retained 60% of this cohort after three weeks and 25% of this cohort after six weeks. These two percentages can be calculated by the metric `cohortActiveUsers/cohortTotalUsers` and will be separate rows in the report.
438///
439/// This type is not used in any activity, and only used as *part* of another schema.
440///
441#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
442#[serde_with::serde_as]
443#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
444pub struct CohortSpec {
445    /// Optional settings for a cohort report.
446    #[serde(rename = "cohortReportSettings")]
447    pub cohort_report_settings: Option<CohortReportSettings>,
448    /// Defines the selection criteria to group users into cohorts. Most cohort reports define only a single cohort. If multiple cohorts are specified, each cohort can be recognized in the report by their name.
449    pub cohorts: Option<Vec<Cohort>>,
450    /// Cohort reports follow cohorts over an extended reporting date range. This range specifies an offset duration to follow the cohorts over.
451    #[serde(rename = "cohortsRange")]
452    pub cohorts_range: Option<CohortsRange>,
453}
454
455impl common::Part for CohortSpec {}
456
457/// Configures the extended reporting date range for a cohort report. Specifies an offset duration to follow the cohorts over.
458///
459/// This type is not used in any activity, and only used as *part* of another schema.
460///
461#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
462#[serde_with::serde_as]
463#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
464pub struct CohortsRange {
465    /// Required. `endOffset` specifies the end date of the extended reporting date range for a cohort report. `endOffset` can be any positive integer but is commonly set to 5 to 10 so that reports contain data on the cohort for the next several granularity time periods. If `granularity` is `DAILY`, the `endDate` of the extended reporting date range is `endDate` of the cohort plus `endOffset` days. If `granularity` is `WEEKLY`, the `endDate` of the extended reporting date range is `endDate` of the cohort plus `endOffset * 7` days. If `granularity` is `MONTHLY`, the `endDate` of the extended reporting date range is `endDate` of the cohort plus `endOffset * 30` days.
466    #[serde(rename = "endOffset")]
467    pub end_offset: Option<i32>,
468    /// Required. The granularity used to interpret the `startOffset` and `endOffset` for the extended reporting date range for a cohort report.
469    pub granularity: Option<String>,
470    /// `startOffset` specifies the start date of the extended reporting date range for a cohort report. `startOffset` is commonly set to 0 so that reports contain data from the acquisition of the cohort forward. If `granularity` is `DAILY`, the `startDate` of the extended reporting date range is `startDate` of the cohort plus `startOffset` days. If `granularity` is `WEEKLY`, the `startDate` of the extended reporting date range is `startDate` of the cohort plus `startOffset * 7` days. If `granularity` is `MONTHLY`, the `startDate` of the extended reporting date range is `startDate` of the cohort plus `startOffset * 30` days.
471    #[serde(rename = "startOffset")]
472    pub start_offset: Option<i32>,
473}
474
475impl common::Part for CohortsRange {}
476
477/// Defines an individual comparison. Most requests will include multiple comparisons so that the report compares between the comparisons.
478///
479/// This type is not used in any activity, and only used as *part* of another schema.
480///
481#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
482#[serde_with::serde_as]
483#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
484pub struct Comparison {
485    /// A saved comparison identified by the comparison's resource name. For example, 'comparisons/1234'.
486    pub comparison: Option<String>,
487    /// A basic comparison.
488    #[serde(rename = "dimensionFilter")]
489    pub dimension_filter: Option<FilterExpression>,
490    /// Each comparison produces separate rows in the response. In the response, this comparison is identified by this name. If name is unspecified, we will use the saved comparisons display name.
491    pub name: Option<String>,
492}
493
494impl common::Part for Comparison {}
495
496/// The metadata for a single comparison.
497///
498/// This type is not used in any activity, and only used as *part* of another schema.
499///
500#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
501#[serde_with::serde_as]
502#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
503pub struct ComparisonMetadata {
504    /// This comparison’s resource name. Useable in [Comparison](#Comparison)’s `comparison` field. For example, ‘comparisons/1234’.
505    #[serde(rename = "apiName")]
506    pub api_name: Option<String>,
507    /// This comparison's description.
508    pub description: Option<String>,
509    /// This comparison's name within the Google Analytics user interface.
510    #[serde(rename = "uiName")]
511    pub ui_name: Option<String>,
512}
513
514impl common::Part for ComparisonMetadata {}
515
516/// Used to combine dimension values to a single dimension.
517///
518/// This type is not used in any activity, and only used as *part* of another schema.
519///
520#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
521#[serde_with::serde_as]
522#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
523pub struct ConcatenateExpression {
524    /// The delimiter placed between dimension names. Delimiters are often single characters such as "|" or "," but can be longer strings. If a dimension value contains the delimiter, both will be present in response with no distinction. For example if dimension 1 value = "US,FR", dimension 2 value = "JP", and delimiter = ",", then the response will contain "US,FR,JP".
525    pub delimiter: Option<String>,
526    /// Names of dimensions. The names must refer back to names in the dimensions field of the request.
527    #[serde(rename = "dimensionNames")]
528    pub dimension_names: Option<Vec<String>>,
529}
530
531impl common::Part for ConcatenateExpression {}
532
533/// A contiguous set of days: `startDate`, `startDate + 1`, ..., `endDate`. Requests are allowed up to 4 date ranges.
534///
535/// This type is not used in any activity, and only used as *part* of another schema.
536///
537#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
538#[serde_with::serde_as]
539#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
540pub struct DateRange {
541    /// The inclusive end date for the query in the format `YYYY-MM-DD`. Cannot be before `start_date`. The format `NdaysAgo`, `yesterday`, or `today` is also accepted, and in that case, the date is inferred based on the property's reporting time zone.
542    #[serde(rename = "endDate")]
543    pub end_date: Option<String>,
544    /// Assigns a name to this date range. The dimension `dateRange` is valued to this name in a report response. If set, cannot begin with `date_range_` or `RESERVED_`. If not set, date ranges are named by their zero based index in the request: `date_range_0`, `date_range_1`, etc.
545    pub name: Option<String>,
546    /// The inclusive start date for the query in the format `YYYY-MM-DD`. Cannot be after `end_date`. The format `NdaysAgo`, `yesterday`, or `today` is also accepted, and in that case, the date is inferred based on the property's reporting time zone.
547    #[serde(rename = "startDate")]
548    pub start_date: Option<String>,
549}
550
551impl common::Part for DateRange {}
552
553/// Dimensions are attributes of your data. For example, the dimension city indicates the city from which an event originates. Dimension values in report responses are strings; for example, the city could be "Paris" or "New York". Requests are allowed up to 9 dimensions.
554///
555/// This type is not used in any activity, and only used as *part* of another schema.
556///
557#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
558#[serde_with::serde_as]
559#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
560pub struct Dimension {
561    /// One dimension can be the result of an expression of multiple dimensions. For example, dimension "country, city": concatenate(country, ", ", city).
562    #[serde(rename = "dimensionExpression")]
563    pub dimension_expression: Option<DimensionExpression>,
564    /// The name of the dimension. See the [API Dimensions](https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema#dimensions) for the list of dimension names supported by core reporting methods such as `runReport` and `batchRunReports`. See [Realtime Dimensions](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-api-schema#dimensions) for the list of dimension names supported by the `runRealtimeReport` method. See [Funnel Dimensions](https://developers.google.com/analytics/devguides/reporting/data/v1/exploration-api-schema#dimensions) for the list of dimension names supported by the `runFunnelReport` method. If `dimensionExpression` is specified, `name` can be any string that you would like within the allowed character set. For example if a `dimensionExpression` concatenates `country` and `city`, you could call that dimension `countryAndCity`. Dimension names that you choose must match the regular expression `^[a-zA-Z0-9_]$`. Dimensions are referenced by `name` in `dimensionFilter`, `orderBys`, `dimensionExpression`, and `pivots`.
565    pub name: Option<String>,
566}
567
568impl common::Part for Dimension {}
569
570/// The compatibility for a single dimension.
571///
572/// This type is not used in any activity, and only used as *part* of another schema.
573///
574#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
575#[serde_with::serde_as]
576#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
577pub struct DimensionCompatibility {
578    /// The compatibility of this dimension. If the compatibility is COMPATIBLE, this dimension can be successfully added to the report.
579    pub compatibility: Option<String>,
580    /// The dimension metadata contains the API name for this compatibility information. The dimension metadata also contains other helpful information like the UI name and description.
581    #[serde(rename = "dimensionMetadata")]
582    pub dimension_metadata: Option<DimensionMetadata>,
583}
584
585impl common::Part for DimensionCompatibility {}
586
587/// Used to express a dimension which is the result of a formula of multiple dimensions. Example usages: 1) lower_case(dimension) 2) concatenate(dimension1, symbol, dimension2).
588///
589/// This type is not used in any activity, and only used as *part* of another schema.
590///
591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
592#[serde_with::serde_as]
593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
594pub struct DimensionExpression {
595    /// Used to combine dimension values to a single dimension. For example, dimension "country, city": concatenate(country, ", ", city).
596    pub concatenate: Option<ConcatenateExpression>,
597    /// Used to convert a dimension value to lower case.
598    #[serde(rename = "lowerCase")]
599    pub lower_case: Option<CaseExpression>,
600    /// Used to convert a dimension value to upper case.
601    #[serde(rename = "upperCase")]
602    pub upper_case: Option<CaseExpression>,
603}
604
605impl common::Part for DimensionExpression {}
606
607/// Describes a dimension column in the report. Dimensions requested in a report produce column entries within rows and DimensionHeaders. However, dimensions used exclusively within filters or expressions do not produce columns in a report; correspondingly, those dimensions do not produce headers.
608///
609/// This type is not used in any activity, and only used as *part* of another schema.
610///
611#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
612#[serde_with::serde_as]
613#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
614pub struct DimensionHeader {
615    /// The dimension's name.
616    pub name: Option<String>,
617}
618
619impl common::Part for DimensionHeader {}
620
621/// Explains a dimension.
622///
623/// This type is not used in any activity, and only used as *part* of another schema.
624///
625#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
626#[serde_with::serde_as]
627#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
628pub struct DimensionMetadata {
629    /// This dimension’s name. Useable in [Dimension](#Dimension)’s `name`. For example, `eventName`.
630    #[serde(rename = "apiName")]
631    pub api_name: Option<String>,
632    /// The display name of the category that this dimension belongs to. Similar dimensions and metrics are categorized together.
633    pub category: Option<String>,
634    /// True if the dimension is custom to this property. This includes user, event, & item scoped custom dimensions; to learn more about custom dimensions, see https://support.google.com/analytics/answer/14240153. This also include custom channel groups; to learn more about custom channel groups, see https://support.google.com/analytics/answer/13051316.
635    #[serde(rename = "customDefinition")]
636    pub custom_definition: Option<bool>,
637    /// Still usable but deprecated names for this dimension. If populated, this dimension is available by either `apiName` or one of `deprecatedApiNames` for a period of time. After the deprecation period, the dimension will be available only by `apiName`.
638    #[serde(rename = "deprecatedApiNames")]
639    pub deprecated_api_names: Option<Vec<String>>,
640    /// Description of how this dimension is used and calculated.
641    pub description: Option<String>,
642    /// This dimension's name within the Google Analytics user interface. For example, `Event name`.
643    #[serde(rename = "uiName")]
644    pub ui_name: Option<String>,
645}
646
647impl common::Part for DimensionMetadata {}
648
649/// Sorts by dimension values.
650///
651/// This type is not used in any activity, and only used as *part* of another schema.
652///
653#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
654#[serde_with::serde_as]
655#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
656pub struct DimensionOrderBy {
657    /// A dimension name in the request to order by.
658    #[serde(rename = "dimensionName")]
659    pub dimension_name: Option<String>,
660    /// Controls the rule for dimension value ordering.
661    #[serde(rename = "orderType")]
662    pub order_type: Option<String>,
663}
664
665impl common::Part for DimensionOrderBy {}
666
667/// The value of a dimension.
668///
669/// This type is not used in any activity, and only used as *part* of another schema.
670///
671#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
672#[serde_with::serde_as]
673#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
674pub struct DimensionValue {
675    /// Value as a string if the dimension type is a string.
676    pub value: Option<String>,
677}
678
679impl common::Part for DimensionValue {}
680
681/// Filter for empty values.
682///
683/// This type is not used in any activity, and only used as *part* of another schema.
684///
685#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
686#[serde_with::serde_as]
687#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
688pub struct EmptyFilter {
689    _never_set: Option<bool>,
690}
691
692impl common::Part for EmptyFilter {}
693
694/// An expression to filter dimension or metric values.
695///
696/// This type is not used in any activity, and only used as *part* of another schema.
697///
698#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
699#[serde_with::serde_as]
700#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
701pub struct Filter {
702    /// A filter for two values.
703    #[serde(rename = "betweenFilter")]
704    pub between_filter: Option<BetweenFilter>,
705    /// A filter for empty values such as "(not set)" and "" values.
706    #[serde(rename = "emptyFilter")]
707    pub empty_filter: Option<EmptyFilter>,
708    /// The dimension name or metric name. In most methods, dimensions & metrics can be used for the first time in this field. However in a RunPivotReportRequest, this field must be additionally specified by name in the RunPivotReportRequest's dimensions or metrics.
709    #[serde(rename = "fieldName")]
710    pub field_name: Option<String>,
711    /// A filter for in list values.
712    #[serde(rename = "inListFilter")]
713    pub in_list_filter: Option<InListFilter>,
714    /// A filter for numeric or date values.
715    #[serde(rename = "numericFilter")]
716    pub numeric_filter: Option<NumericFilter>,
717    /// Strings related filter.
718    #[serde(rename = "stringFilter")]
719    pub string_filter: Option<StringFilter>,
720}
721
722impl common::Part for Filter {}
723
724/// To express dimension or metric filters. The fields in the same FilterExpression need to be either all dimensions or all metrics.
725///
726/// This type is not used in any activity, and only used as *part* of another schema.
727///
728#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
729#[serde_with::serde_as]
730#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
731pub struct FilterExpression {
732    /// The FilterExpressions in and_group have an AND relationship.
733    #[serde(rename = "andGroup")]
734    pub and_group: Option<FilterExpressionList>,
735    /// A primitive filter. In the same FilterExpression, all of the filter's field names need to be either all dimensions or all metrics.
736    pub filter: Option<Filter>,
737    /// The FilterExpression is NOT of not_expression.
738    #[serde(rename = "notExpression")]
739    pub not_expression: Option<Option<Box<FilterExpression>>>,
740    /// The FilterExpressions in or_group have an OR relationship.
741    #[serde(rename = "orGroup")]
742    pub or_group: Option<FilterExpressionList>,
743}
744
745impl common::Part for FilterExpression {}
746
747/// A list of filter expressions.
748///
749/// This type is not used in any activity, and only used as *part* of another schema.
750///
751#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
752#[serde_with::serde_as]
753#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
754pub struct FilterExpressionList {
755    /// A list of filter expressions.
756    pub expressions: Option<Vec<FilterExpression>>,
757}
758
759impl common::Part for FilterExpressionList {}
760
761/// The result needs to be in a list of string values.
762///
763/// This type is not used in any activity, and only used as *part* of another schema.
764///
765#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
766#[serde_with::serde_as]
767#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
768pub struct InListFilter {
769    /// If true, the string value is case sensitive.
770    #[serde(rename = "caseSensitive")]
771    pub case_sensitive: Option<bool>,
772    /// The list of string values. Must be non-empty.
773    pub values: Option<Vec<String>>,
774}
775
776impl common::Part for InListFilter {}
777
778/// A list of all audience exports for a property.
779///
780/// # Activities
781///
782/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
783/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
784///
785/// * [audience exports list properties](PropertyAudienceExportListCall) (response)
786#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
787#[serde_with::serde_as]
788#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
789pub struct ListAudienceExportsResponse {
790    /// Each audience export for a property.
791    #[serde(rename = "audienceExports")]
792    pub audience_exports: Option<Vec<AudienceExport>>,
793    /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
794    #[serde(rename = "nextPageToken")]
795    pub next_page_token: Option<String>,
796}
797
798impl common::ResponseResult for ListAudienceExportsResponse {}
799
800/// The dimensions, metrics and comparisons currently accepted in reporting methods.
801///
802/// # Activities
803///
804/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
805/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
806///
807/// * [get metadata properties](PropertyGetMetadataCall) (response)
808#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
809#[serde_with::serde_as]
810#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
811pub struct Metadata {
812    /// The comparison descriptions.
813    pub comparisons: Option<Vec<ComparisonMetadata>>,
814    /// The dimension descriptions.
815    pub dimensions: Option<Vec<DimensionMetadata>>,
816    /// The metric descriptions.
817    pub metrics: Option<Vec<MetricMetadata>>,
818    /// Resource name of this metadata.
819    pub name: Option<String>,
820}
821
822impl common::ResponseResult for Metadata {}
823
824/// The quantitative measurements of a report. For example, the metric `eventCount` is the total number of events. Requests are allowed up to 10 metrics.
825///
826/// This type is not used in any activity, and only used as *part* of another schema.
827///
828#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
829#[serde_with::serde_as]
830#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
831pub struct Metric {
832    /// A mathematical expression for derived metrics. For example, the metric Event count per user is `eventCount/totalUsers`.
833    pub expression: Option<String>,
834    /// Indicates if a metric is invisible in the report response. If a metric is invisible, the metric will not produce a column in the response, but can be used in `metricFilter`, `orderBys`, or a metric `expression`.
835    pub invisible: Option<bool>,
836    /// The name of the metric. See the [API Metrics](https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema#metrics) for the list of metric names supported by core reporting methods such as `runReport` and `batchRunReports`. See [Realtime Metrics](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-api-schema#metrics) for the list of metric names supported by the `runRealtimeReport` method. See [Funnel Metrics](https://developers.google.com/analytics/devguides/reporting/data/v1/exploration-api-schema#metrics) for the list of metric names supported by the `runFunnelReport` method. If `expression` is specified, `name` can be any string that you would like within the allowed character set. For example if `expression` is `screenPageViews/sessions`, you could call that metric's name = `viewsPerSession`. Metric names that you choose must match the regular expression `^[a-zA-Z0-9_]$`. Metrics are referenced by `name` in `metricFilter`, `orderBys`, and metric `expression`.
837    pub name: Option<String>,
838}
839
840impl common::Part for Metric {}
841
842/// The compatibility for a single metric.
843///
844/// This type is not used in any activity, and only used as *part* of another schema.
845///
846#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
847#[serde_with::serde_as]
848#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
849pub struct MetricCompatibility {
850    /// The compatibility of this metric. If the compatibility is COMPATIBLE, this metric can be successfully added to the report.
851    pub compatibility: Option<String>,
852    /// The metric metadata contains the API name for this compatibility information. The metric metadata also contains other helpful information like the UI name and description.
853    #[serde(rename = "metricMetadata")]
854    pub metric_metadata: Option<MetricMetadata>,
855}
856
857impl common::Part for MetricCompatibility {}
858
859/// Describes a metric column in the report. Visible metrics requested in a report produce column entries within rows and MetricHeaders. However, metrics used exclusively within filters or expressions do not produce columns in a report; correspondingly, those metrics do not produce headers.
860///
861/// This type is not used in any activity, and only used as *part* of another schema.
862///
863#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
864#[serde_with::serde_as]
865#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
866pub struct MetricHeader {
867    /// The metric's name.
868    pub name: Option<String>,
869    /// The metric's data type.
870    #[serde(rename = "type")]
871    pub type_: Option<String>,
872}
873
874impl common::Part for MetricHeader {}
875
876/// Explains a metric.
877///
878/// This type is not used in any activity, and only used as *part* of another schema.
879///
880#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
881#[serde_with::serde_as]
882#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
883pub struct MetricMetadata {
884    /// A metric name. Useable in [Metric](#Metric)’s `name`. For example, `eventCount`.
885    #[serde(rename = "apiName")]
886    pub api_name: Option<String>,
887    /// If reasons are specified, your access is blocked to this metric for this property. API requests from you to this property for this metric will succeed; however, the report will contain only zeros for this metric. API requests with metric filters on blocked metrics will fail. If reasons are empty, you have access to this metric. To learn more, see [Access and data-restriction management](https://support.google.com/analytics/answer/10851388).
888    #[serde(rename = "blockedReasons")]
889    pub blocked_reasons: Option<Vec<String>>,
890    /// The display name of the category that this metrics belongs to. Similar dimensions and metrics are categorized together.
891    pub category: Option<String>,
892    /// True if the metric is a custom metric for this property.
893    #[serde(rename = "customDefinition")]
894    pub custom_definition: Option<bool>,
895    /// Still usable but deprecated names for this metric. If populated, this metric is available by either `apiName` or one of `deprecatedApiNames` for a period of time. After the deprecation period, the metric will be available only by `apiName`.
896    #[serde(rename = "deprecatedApiNames")]
897    pub deprecated_api_names: Option<Vec<String>>,
898    /// Description of how this metric is used and calculated.
899    pub description: Option<String>,
900    /// The mathematical expression for this derived metric. Can be used in [Metric](#Metric)’s `expression` field for equivalent reports. Most metrics are not expressions, and for non-expressions, this field is empty.
901    pub expression: Option<String>,
902    /// The type of this metric.
903    #[serde(rename = "type")]
904    pub type_: Option<String>,
905    /// This metric's name within the Google Analytics user interface. For example, `Event count`.
906    #[serde(rename = "uiName")]
907    pub ui_name: Option<String>,
908}
909
910impl common::Part for MetricMetadata {}
911
912/// Sorts by metric values.
913///
914/// This type is not used in any activity, and only used as *part* of another schema.
915///
916#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
917#[serde_with::serde_as]
918#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
919pub struct MetricOrderBy {
920    /// A metric name in the request to order by.
921    #[serde(rename = "metricName")]
922    pub metric_name: Option<String>,
923}
924
925impl common::Part for MetricOrderBy {}
926
927/// The value of a metric.
928///
929/// This type is not used in any activity, and only used as *part* of another schema.
930///
931#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
932#[serde_with::serde_as]
933#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
934pub struct MetricValue {
935    /// Measurement value. See MetricHeader for type.
936    pub value: Option<String>,
937}
938
939impl common::Part for MetricValue {}
940
941/// A contiguous set of minutes: `startMinutesAgo`, `startMinutesAgo + 1`, ..., `endMinutesAgo`. Requests are allowed up to 2 minute ranges.
942///
943/// This type is not used in any activity, and only used as *part* of another schema.
944///
945#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
946#[serde_with::serde_as]
947#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
948pub struct MinuteRange {
949    /// The inclusive end minute for the query as a number of minutes before now. Cannot be before `startMinutesAgo`. For example, `"endMinutesAgo": 15` specifies the report should include event data from prior to 15 minutes ago. If unspecified, `endMinutesAgo` is defaulted to 0. Standard Analytics properties can request any minute in the last 30 minutes of event data (`endMinutesAgo <= 29`), and 360 Analytics properties can request any minute in the last 60 minutes of event data (`endMinutesAgo <= 59`).
950    #[serde(rename = "endMinutesAgo")]
951    pub end_minutes_ago: Option<i32>,
952    /// Assigns a name to this minute range. The dimension `dateRange` is valued to this name in a report response. If set, cannot begin with `date_range_` or `RESERVED_`. If not set, minute ranges are named by their zero based index in the request: `date_range_0`, `date_range_1`, etc.
953    pub name: Option<String>,
954    /// The inclusive start minute for the query as a number of minutes before now. For example, `"startMinutesAgo": 29` specifies the report should include event data from 29 minutes ago and after. Cannot be after `endMinutesAgo`. If unspecified, `startMinutesAgo` is defaulted to 29. Standard Analytics properties can request up to the last 30 minutes of event data (`startMinutesAgo <= 29`), and 360 Analytics properties can request up to the last 60 minutes of event data (`startMinutesAgo <= 59`).
955    #[serde(rename = "startMinutesAgo")]
956    pub start_minutes_ago: Option<i32>,
957}
958
959impl common::Part for MinuteRange {}
960
961/// Filters for numeric or date values.
962///
963/// This type is not used in any activity, and only used as *part* of another schema.
964///
965#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
966#[serde_with::serde_as]
967#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
968pub struct NumericFilter {
969    /// The operation type for this filter.
970    pub operation: Option<String>,
971    /// A numeric value or a date value.
972    pub value: Option<NumericValue>,
973}
974
975impl common::Part for NumericFilter {}
976
977/// To represent a number.
978///
979/// This type is not used in any activity, and only used as *part* of another schema.
980///
981#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
982#[serde_with::serde_as]
983#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
984pub struct NumericValue {
985    /// Double value
986    #[serde(rename = "doubleValue")]
987    pub double_value: Option<f64>,
988    /// Integer value
989    #[serde(rename = "int64Value")]
990    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
991    pub int64_value: Option<i64>,
992}
993
994impl common::Part for NumericValue {}
995
996/// This resource represents a long-running operation that is the result of a network API call.
997///
998/// # Activities
999///
1000/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1001/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1002///
1003/// * [audience exports create properties](PropertyAudienceExportCreateCall) (response)
1004#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1005#[serde_with::serde_as]
1006#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1007pub struct Operation {
1008    /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
1009    pub done: Option<bool>,
1010    /// The error result of the operation in case of failure or cancellation.
1011    pub error: Option<Status>,
1012    /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
1013    pub metadata: Option<HashMap<String, serde_json::Value>>,
1014    /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
1015    pub name: Option<String>,
1016    /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
1017    pub response: Option<HashMap<String, serde_json::Value>>,
1018}
1019
1020impl common::ResponseResult for Operation {}
1021
1022/// Order bys define how rows will be sorted in the response. For example, ordering rows by descending event count is one ordering, and ordering rows by the event name string is a different ordering.
1023///
1024/// This type is not used in any activity, and only used as *part* of another schema.
1025///
1026#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1027#[serde_with::serde_as]
1028#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1029pub struct OrderBy {
1030    /// If true, sorts by descending order.
1031    pub desc: Option<bool>,
1032    /// Sorts results by a dimension's values.
1033    pub dimension: Option<DimensionOrderBy>,
1034    /// Sorts results by a metric's values.
1035    pub metric: Option<MetricOrderBy>,
1036    /// Sorts results by a metric's values within a pivot column group.
1037    pub pivot: Option<PivotOrderBy>,
1038}
1039
1040impl common::Part for OrderBy {}
1041
1042/// Describes the visible dimension columns and rows in the report response.
1043///
1044/// This type is not used in any activity, and only used as *part* of another schema.
1045///
1046#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1047#[serde_with::serde_as]
1048#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1049pub struct Pivot {
1050    /// Dimension names for visible columns in the report response. Including "dateRange" produces a date range column; for each row in the response, dimension values in the date range column will indicate the corresponding date range from the request.
1051    #[serde(rename = "fieldNames")]
1052    pub field_names: Option<Vec<String>>,
1053    /// The number of unique combinations of dimension values to return in this pivot. The `limit` parameter is required. A `limit` of 10,000 is common for single pivot requests. The product of the `limit` for each `pivot` in a `RunPivotReportRequest` must not exceed 250,000. For example, a two pivot request with `limit: 1000` in each pivot will fail because the product is `1,000,000`.
1054    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1055    pub limit: Option<i64>,
1056    /// Aggregate the metrics by dimensions in this pivot using the specified metric_aggregations.
1057    #[serde(rename = "metricAggregations")]
1058    pub metric_aggregations: Option<Vec<String>>,
1059    /// The row count of the start row. The first row is counted as row 0.
1060    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1061    pub offset: Option<i64>,
1062    /// Specifies how dimensions are ordered in the pivot. In the first Pivot, the OrderBys determine Row and PivotDimensionHeader ordering; in subsequent Pivots, the OrderBys determine only PivotDimensionHeader ordering. Dimensions specified in these OrderBys must be a subset of Pivot.field_names.
1063    #[serde(rename = "orderBys")]
1064    pub order_bys: Option<Vec<OrderBy>>,
1065}
1066
1067impl common::Part for Pivot {}
1068
1069/// Summarizes dimension values from a row for this pivot.
1070///
1071/// This type is not used in any activity, and only used as *part* of another schema.
1072///
1073#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1074#[serde_with::serde_as]
1075#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1076pub struct PivotDimensionHeader {
1077    /// Values of multiple dimensions in a pivot.
1078    #[serde(rename = "dimensionValues")]
1079    pub dimension_values: Option<Vec<DimensionValue>>,
1080}
1081
1082impl common::Part for PivotDimensionHeader {}
1083
1084/// Dimensions' values in a single pivot.
1085///
1086/// This type is not used in any activity, and only used as *part* of another schema.
1087///
1088#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1089#[serde_with::serde_as]
1090#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1091pub struct PivotHeader {
1092    /// The size is the same as the cardinality of the corresponding dimension combinations.
1093    #[serde(rename = "pivotDimensionHeaders")]
1094    pub pivot_dimension_headers: Option<Vec<PivotDimensionHeader>>,
1095    /// The cardinality of the pivot. The total number of rows for this pivot's fields regardless of how the parameters `offset` and `limit` are specified in the request.
1096    #[serde(rename = "rowCount")]
1097    pub row_count: Option<i32>,
1098}
1099
1100impl common::Part for PivotHeader {}
1101
1102/// Sorts by a pivot column group.
1103///
1104/// This type is not used in any activity, and only used as *part* of another schema.
1105///
1106#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1107#[serde_with::serde_as]
1108#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1109pub struct PivotOrderBy {
1110    /// In the response to order by, order rows by this column. Must be a metric name from the request.
1111    #[serde(rename = "metricName")]
1112    pub metric_name: Option<String>,
1113    /// Used to select a dimension name and value pivot. If multiple pivot selections are given, the sort occurs on rows where all pivot selection dimension name and value pairs match the row's dimension name and value pair.
1114    #[serde(rename = "pivotSelections")]
1115    pub pivot_selections: Option<Vec<PivotSelection>>,
1116}
1117
1118impl common::Part for PivotOrderBy {}
1119
1120/// A pair of dimension names and values. Rows with this dimension pivot pair are ordered by the metric's value. For example if pivots = {{"browser", "Chrome"}} and metric_name = "Sessions", then the rows will be sorted based on Sessions in Chrome. ---------|----------|----------------|----------|---------------- | Chrome | Chrome | Safari | Safari ---------|----------|----------------|----------|---------------- Country | Sessions | Pages/Sessions | Sessions | Pages/Sessions ---------|----------|----------------|----------|---------------- US | 2 | 2 | 3 | 1 ---------|----------|----------------|----------|---------------- Canada | 3 | 1 | 4 | 1 ---------|----------|----------------|----------|----------------
1121///
1122/// This type is not used in any activity, and only used as *part* of another schema.
1123///
1124#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1125#[serde_with::serde_as]
1126#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1127pub struct PivotSelection {
1128    /// Must be a dimension name from the request.
1129    #[serde(rename = "dimensionName")]
1130    pub dimension_name: Option<String>,
1131    /// Order by only when the named dimension is this value.
1132    #[serde(rename = "dimensionValue")]
1133    pub dimension_value: Option<String>,
1134}
1135
1136impl common::Part for PivotSelection {}
1137
1138/// Current state of all quotas for this Analytics Property. If any quota for a property is exhausted, all requests to that property will return Resource Exhausted errors.
1139///
1140/// This type is not used in any activity, and only used as *part* of another schema.
1141///
1142#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1143#[serde_with::serde_as]
1144#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1145pub struct PropertyQuota {
1146    /// Standard Analytics Properties can send up to 10 concurrent requests; Analytics 360 Properties can use up to 50 concurrent requests.
1147    #[serde(rename = "concurrentRequests")]
1148    pub concurrent_requests: Option<QuotaStatus>,
1149    /// Analytics Properties can send up to 120 requests with potentially thresholded dimensions per hour. In a batch request, each report request is individually counted for this quota if the request contains potentially thresholded dimensions.
1150    #[serde(rename = "potentiallyThresholdedRequestsPerHour")]
1151    pub potentially_thresholded_requests_per_hour: Option<QuotaStatus>,
1152    /// Standard Analytics Properties and cloud project pairs can have up to 10 server errors per hour; Analytics 360 Properties and cloud project pairs can have up to 50 server errors per hour.
1153    #[serde(rename = "serverErrorsPerProjectPerHour")]
1154    pub server_errors_per_project_per_hour: Option<QuotaStatus>,
1155    /// Standard Analytics Properties can use up to 200,000 tokens per day; Analytics 360 Properties can use 2,000,000 tokens per day. Most requests consume fewer than 10 tokens.
1156    #[serde(rename = "tokensPerDay")]
1157    pub tokens_per_day: Option<QuotaStatus>,
1158    /// Standard Analytics Properties can use up to 40,000 tokens per hour; Analytics 360 Properties can use 400,000 tokens per hour. An API request consumes a single number of tokens, and that number is deducted from all of the hourly, daily, and per project hourly quotas.
1159    #[serde(rename = "tokensPerHour")]
1160    pub tokens_per_hour: Option<QuotaStatus>,
1161    /// Analytics Properties can use up to 35% of their tokens per project per hour. This amounts to standard Analytics Properties can use up to 14,000 tokens per project per hour, and Analytics 360 Properties can use 140,000 tokens per project per hour. An API request consumes a single number of tokens, and that number is deducted from all of the hourly, daily, and per project hourly quotas.
1162    #[serde(rename = "tokensPerProjectPerHour")]
1163    pub tokens_per_project_per_hour: Option<QuotaStatus>,
1164}
1165
1166impl common::Part for PropertyQuota {}
1167
1168/// A request to list users in an audience export.
1169///
1170/// # Activities
1171///
1172/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1173/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1174///
1175/// * [audience exports query properties](PropertyAudienceExportQueryCall) (request)
1176#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1177#[serde_with::serde_as]
1178#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1179pub struct QueryAudienceExportRequest {
1180    /// Optional. The number of rows to return. If unspecified, 10,000 rows are returned. The API returns a maximum of 250,000 rows per request, no matter how many you ask for. `limit` must be positive. The API can also return fewer rows than the requested `limit`, if there aren't as many dimension values as the `limit`. To learn more about this pagination parameter, see [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
1181    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1182    pub limit: Option<i64>,
1183    /// Optional. The row count of the start row. The first row is counted as row 0. When paging, the first request does not specify offset; or equivalently, sets offset to 0; the first request returns the first `limit` of rows. The second request sets offset to the `limit` of the first request; the second request returns the second `limit` of rows. To learn more about this pagination parameter, see [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
1184    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1185    pub offset: Option<i64>,
1186}
1187
1188impl common::RequestValue for QueryAudienceExportRequest {}
1189
1190/// A list of users in an audience export.
1191///
1192/// # Activities
1193///
1194/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1195/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1196///
1197/// * [audience exports query properties](PropertyAudienceExportQueryCall) (response)
1198#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1199#[serde_with::serde_as]
1200#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1201pub struct QueryAudienceExportResponse {
1202    /// Configuration data about AudienceExport being queried. Returned to help interpret the audience rows in this response. For example, the dimensions in this AudienceExport correspond to the columns in the AudienceRows.
1203    #[serde(rename = "audienceExport")]
1204    pub audience_export: Option<AudienceExport>,
1205    /// Rows for each user in an audience export. The number of rows in this response will be less than or equal to request's page size.
1206    #[serde(rename = "audienceRows")]
1207    pub audience_rows: Option<Vec<V1betaAudienceRow>>,
1208    /// The total number of rows in the AudienceExport result. `rowCount` is independent of the number of rows returned in the response, the `limit` request parameter, and the `offset` request parameter. For example if a query returns 175 rows and includes `limit` of 50 in the API request, the response will contain `rowCount` of 175 but only 50 rows. To learn more about this pagination parameter, see [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
1209    #[serde(rename = "rowCount")]
1210    pub row_count: Option<i32>,
1211}
1212
1213impl common::ResponseResult for QueryAudienceExportResponse {}
1214
1215/// Current state for a particular quota group.
1216///
1217/// This type is not used in any activity, and only used as *part* of another schema.
1218///
1219#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1220#[serde_with::serde_as]
1221#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1222pub struct QuotaStatus {
1223    /// Quota consumed by this request.
1224    pub consumed: Option<i32>,
1225    /// Quota remaining after this request.
1226    pub remaining: Option<i32>,
1227}
1228
1229impl common::Part for QuotaStatus {}
1230
1231/// Response's metadata carrying additional information about the report content.
1232///
1233/// This type is not used in any activity, and only used as *part* of another schema.
1234///
1235#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1236#[serde_with::serde_as]
1237#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1238pub struct ResponseMetaData {
1239    /// The currency code used in this report. Intended to be used in formatting currency metrics like `purchaseRevenue` for visualization. If currency_code was specified in the request, this response parameter will echo the request parameter; otherwise, this response parameter is the property's current currency_code. Currency codes are string encodings of currency types from the ISO 4217 standard (https://en.wikipedia.org/wiki/ISO_4217); for example "USD", "EUR", "JPY". To learn more, see https://support.google.com/analytics/answer/9796179.
1240    #[serde(rename = "currencyCode")]
1241    pub currency_code: Option<String>,
1242    /// If true, indicates some buckets of dimension combinations are rolled into "(other)" row. This can happen for high cardinality reports. The metadata parameter dataLossFromOtherRow is populated based on the aggregated data table used in the report. The parameter will be accurately populated regardless of the filters and limits in the report. For example, the (other) row could be dropped from the report because the request contains a filter on sessionSource = google. This parameter will still be populated if data loss from other row was present in the input aggregate data used to generate this report. To learn more, see [About the (other) row and data sampling](https://support.google.com/analytics/answer/13208658#reports).
1243    #[serde(rename = "dataLossFromOtherRow")]
1244    pub data_loss_from_other_row: Option<bool>,
1245    /// If empty reason is specified, the report is empty for this reason.
1246    #[serde(rename = "emptyReason")]
1247    pub empty_reason: Option<String>,
1248    /// If this report results is [sampled](https://support.google.com/analytics/answer/13331292), this describes the percentage of events used in this report. One `samplingMetadatas` is populated for each date range. Each `samplingMetadatas` corresponds to a date range in order that date ranges were specified in the request. However if the results are not sampled, this field will not be defined.
1249    #[serde(rename = "samplingMetadatas")]
1250    pub sampling_metadatas: Option<Vec<SamplingMetadata>>,
1251    /// Describes the schema restrictions actively enforced in creating this report. To learn more, see [Access and data-restriction management](https://support.google.com/analytics/answer/10851388).
1252    #[serde(rename = "schemaRestrictionResponse")]
1253    pub schema_restriction_response: Option<SchemaRestrictionResponse>,
1254    /// If `subjectToThresholding` is true, this report is subject to thresholding and only returns data that meets the minimum aggregation thresholds. It is possible for a request to be subject to thresholding thresholding and no data is absent from the report, and this happens when all data is above the thresholds. To learn more, see [Data thresholds](https://support.google.com/analytics/answer/9383630).
1255    #[serde(rename = "subjectToThresholding")]
1256    pub subject_to_thresholding: Option<bool>,
1257    /// The property's current timezone. Intended to be used to interpret time-based dimensions like `hour` and `minute`. Formatted as strings from the IANA Time Zone database (https://www.iana.org/time-zones); for example "America/New_York" or "Asia/Tokyo".
1258    #[serde(rename = "timeZone")]
1259    pub time_zone: Option<String>,
1260}
1261
1262impl common::Part for ResponseMetaData {}
1263
1264/// Report data for each row. For example if RunReportRequest contains: ```none "dimensions": [ { "name": "eventName" }, { "name": "countryId" } ], "metrics": [ { "name": "eventCount" } ] ``` One row with 'in_app_purchase' as the eventName, 'JP' as the countryId, and 15 as the eventCount, would be: ```none "dimensionValues": [ { "value": "in_app_purchase" }, { "value": "JP" } ], "metricValues": [ { "value": "15" } ] ```
1265///
1266/// This type is not used in any activity, and only used as *part* of another schema.
1267///
1268#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1269#[serde_with::serde_as]
1270#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1271pub struct Row {
1272    /// List of requested dimension values. In a PivotReport, dimension_values are only listed for dimensions included in a pivot.
1273    #[serde(rename = "dimensionValues")]
1274    pub dimension_values: Option<Vec<DimensionValue>>,
1275    /// List of requested visible metric values.
1276    #[serde(rename = "metricValues")]
1277    pub metric_values: Option<Vec<MetricValue>>,
1278}
1279
1280impl common::Part for Row {}
1281
1282/// The request to generate a pivot report.
1283///
1284/// # Activities
1285///
1286/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1287/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1288///
1289/// * [run pivot report properties](PropertyRunPivotReportCall) (request)
1290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1291#[serde_with::serde_as]
1292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1293pub struct RunPivotReportRequest {
1294    /// Cohort group associated with this request. If there is a cohort group in the request the 'cohort' dimension must be present.
1295    #[serde(rename = "cohortSpec")]
1296    pub cohort_spec: Option<CohortSpec>,
1297    /// Optional. The configuration of comparisons requested and displayed. The request requires both a comparisons field and a comparisons dimension to receive a comparison column in the response.
1298    pub comparisons: Option<Vec<Comparison>>,
1299    /// A currency code in ISO4217 format, such as "AED", "USD", "JPY". If the field is empty, the report uses the property's default currency.
1300    #[serde(rename = "currencyCode")]
1301    pub currency_code: Option<String>,
1302    /// The date range to retrieve event data for the report. If multiple date ranges are specified, event data from each date range is used in the report. A special dimension with field name "dateRange" can be included in a Pivot's field names; if included, the report compares between date ranges. In a cohort request, this `dateRanges` must be unspecified.
1303    #[serde(rename = "dateRanges")]
1304    pub date_ranges: Option<Vec<DateRange>>,
1305    /// The filter clause of dimensions. Dimensions must be requested to be used in this filter. Metrics cannot be used in this filter.
1306    #[serde(rename = "dimensionFilter")]
1307    pub dimension_filter: Option<FilterExpression>,
1308    /// The dimensions requested. All defined dimensions must be used by one of the following: dimension_expression, dimension_filter, pivots, order_bys.
1309    pub dimensions: Option<Vec<Dimension>>,
1310    /// If false or unspecified, each row with all metrics equal to 0 will not be returned. If true, these rows will be returned if they are not separately removed by a filter. Regardless of this `keep_empty_rows` setting, only data recorded by the Google Analytics property can be displayed in a report. For example if a property never logs a `purchase` event, then a query for the `eventName` dimension and `eventCount` metric will not have a row eventName: "purchase" and eventCount: 0.
1311    #[serde(rename = "keepEmptyRows")]
1312    pub keep_empty_rows: Option<bool>,
1313    /// The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter.
1314    #[serde(rename = "metricFilter")]
1315    pub metric_filter: Option<FilterExpression>,
1316    /// The metrics requested, at least one metric needs to be specified. All defined metrics must be used by one of the following: metric_expression, metric_filter, order_bys.
1317    pub metrics: Option<Vec<Metric>>,
1318    /// Describes the visual format of the report's dimensions in columns or rows. The union of the fieldNames (dimension names) in all pivots must be a subset of dimension names defined in Dimensions. No two pivots can share a dimension. A dimension is only visible if it appears in a pivot.
1319    pub pivots: Option<Vec<Pivot>>,
1320    /// A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Within a batch request, this property should either be unspecified or consistent with the batch-level property. Example: properties/1234
1321    pub property: Option<String>,
1322    /// Toggles whether to return the current state of this Google Analytics property’s quota. Quota is returned in [PropertyQuota](#PropertyQuota).
1323    #[serde(rename = "returnPropertyQuota")]
1324    pub return_property_quota: Option<bool>,
1325}
1326
1327impl common::RequestValue for RunPivotReportRequest {}
1328
1329/// The response pivot report table corresponding to a pivot request.
1330///
1331/// # Activities
1332///
1333/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1334/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1335///
1336/// * [run pivot report properties](PropertyRunPivotReportCall) (response)
1337#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1338#[serde_with::serde_as]
1339#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1340pub struct RunPivotReportResponse {
1341    /// Aggregation of metric values. Can be totals, minimums, or maximums. The returned aggregations are controlled by the metric_aggregations in the pivot. The type of aggregation returned in each row is shown by the dimension_values which are set to "RESERVED_".
1342    pub aggregates: Option<Vec<Row>>,
1343    /// Describes dimension columns. The number of DimensionHeaders and ordering of DimensionHeaders matches the dimensions present in rows.
1344    #[serde(rename = "dimensionHeaders")]
1345    pub dimension_headers: Option<Vec<DimensionHeader>>,
1346    /// Identifies what kind of resource this message is. This `kind` is always the fixed string "analyticsData#runPivotReport". Useful to distinguish between response types in JSON.
1347    pub kind: Option<String>,
1348    /// Metadata for the report.
1349    pub metadata: Option<ResponseMetaData>,
1350    /// Describes metric columns. The number of MetricHeaders and ordering of MetricHeaders matches the metrics present in rows.
1351    #[serde(rename = "metricHeaders")]
1352    pub metric_headers: Option<Vec<MetricHeader>>,
1353    /// Summarizes the columns and rows created by a pivot. Each pivot in the request produces one header in the response. If we have a request like this: "pivots": [{ "fieldNames": ["country", "city"] }, { "fieldNames": "eventName" }] We will have the following `pivotHeaders` in the response: "pivotHeaders" : [{ "dimensionHeaders": [{ "dimensionValues": [ { "value": "United Kingdom" }, { "value": "London" } ] }, { "dimensionValues": [ { "value": "Japan" }, { "value": "Osaka" } ] }] }, { "dimensionHeaders": [{ "dimensionValues": [{ "value": "session_start" }] }, { "dimensionValues": [{ "value": "scroll" }] }] }]
1354    #[serde(rename = "pivotHeaders")]
1355    pub pivot_headers: Option<Vec<PivotHeader>>,
1356    /// This Google Analytics property's quota state including this request.
1357    #[serde(rename = "propertyQuota")]
1358    pub property_quota: Option<PropertyQuota>,
1359    /// Rows of dimension value combinations and metric values in the report.
1360    pub rows: Option<Vec<Row>>,
1361}
1362
1363impl common::ResponseResult for RunPivotReportResponse {}
1364
1365/// The request to generate a realtime report.
1366///
1367/// # Activities
1368///
1369/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1370/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1371///
1372/// * [run realtime report properties](PropertyRunRealtimeReportCall) (request)
1373#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1374#[serde_with::serde_as]
1375#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1376pub struct RunRealtimeReportRequest {
1377    /// The filter clause of dimensions. Metrics cannot be used in this filter.
1378    #[serde(rename = "dimensionFilter")]
1379    pub dimension_filter: Option<FilterExpression>,
1380    /// The dimensions requested and displayed.
1381    pub dimensions: Option<Vec<Dimension>>,
1382    /// The number of rows to return. If unspecified, 10,000 rows are returned. The API returns a maximum of 250,000 rows per request, no matter how many you ask for. `limit` must be positive. The API can also return fewer rows than the requested `limit`, if there aren't as many dimension values as the `limit`. For instance, there are fewer than 300 possible values for the dimension `country`, so when reporting on only `country`, you can't get more than 300 rows, even if you set `limit` to a higher value.
1383    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1384    pub limit: Option<i64>,
1385    /// Aggregation of metrics. Aggregated metric values will be shown in rows where the dimension_values are set to "RESERVED_(MetricAggregation)".
1386    #[serde(rename = "metricAggregations")]
1387    pub metric_aggregations: Option<Vec<String>>,
1388    /// The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Dimensions cannot be used in this filter.
1389    #[serde(rename = "metricFilter")]
1390    pub metric_filter: Option<FilterExpression>,
1391    /// The metrics requested and displayed.
1392    pub metrics: Option<Vec<Metric>>,
1393    /// The minute ranges of event data to read. If unspecified, one minute range for the last 30 minutes will be used. If multiple minute ranges are requested, each response row will contain a zero based minute range index. If two minute ranges overlap, the event data for the overlapping minutes is included in the response rows for both minute ranges.
1394    #[serde(rename = "minuteRanges")]
1395    pub minute_ranges: Option<Vec<MinuteRange>>,
1396    /// Specifies how rows are ordered in the response.
1397    #[serde(rename = "orderBys")]
1398    pub order_bys: Option<Vec<OrderBy>>,
1399    /// Toggles whether to return the current state of this Google Analytics property’s Realtime quota. Quota is returned in [PropertyQuota](#PropertyQuota).
1400    #[serde(rename = "returnPropertyQuota")]
1401    pub return_property_quota: Option<bool>,
1402}
1403
1404impl common::RequestValue for RunRealtimeReportRequest {}
1405
1406/// The response realtime report table corresponding to a request.
1407///
1408/// # Activities
1409///
1410/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1411/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1412///
1413/// * [run realtime report properties](PropertyRunRealtimeReportCall) (response)
1414#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1415#[serde_with::serde_as]
1416#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1417pub struct RunRealtimeReportResponse {
1418    /// Describes dimension columns. The number of DimensionHeaders and ordering of DimensionHeaders matches the dimensions present in rows.
1419    #[serde(rename = "dimensionHeaders")]
1420    pub dimension_headers: Option<Vec<DimensionHeader>>,
1421    /// Identifies what kind of resource this message is. This `kind` is always the fixed string "analyticsData#runRealtimeReport". Useful to distinguish between response types in JSON.
1422    pub kind: Option<String>,
1423    /// If requested, the maximum values of metrics.
1424    pub maximums: Option<Vec<Row>>,
1425    /// Describes metric columns. The number of MetricHeaders and ordering of MetricHeaders matches the metrics present in rows.
1426    #[serde(rename = "metricHeaders")]
1427    pub metric_headers: Option<Vec<MetricHeader>>,
1428    /// If requested, the minimum values of metrics.
1429    pub minimums: Option<Vec<Row>>,
1430    /// This Google Analytics property's Realtime quota state including this request.
1431    #[serde(rename = "propertyQuota")]
1432    pub property_quota: Option<PropertyQuota>,
1433    /// The total number of rows in the query result. `rowCount` is independent of the number of rows returned in the response and the `limit` request parameter. For example if a query returns 175 rows and includes `limit` of 50 in the API request, the response will contain `rowCount` of 175 but only 50 rows.
1434    #[serde(rename = "rowCount")]
1435    pub row_count: Option<i32>,
1436    /// Rows of dimension value combinations and metric values in the report.
1437    pub rows: Option<Vec<Row>>,
1438    /// If requested, the totaled values of metrics.
1439    pub totals: Option<Vec<Row>>,
1440}
1441
1442impl common::ResponseResult for RunRealtimeReportResponse {}
1443
1444/// The request to generate a report.
1445///
1446/// # Activities
1447///
1448/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1449/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1450///
1451/// * [run report properties](PropertyRunReportCall) (request)
1452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1453#[serde_with::serde_as]
1454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1455pub struct RunReportRequest {
1456    /// Cohort group associated with this request. If there is a cohort group in the request the 'cohort' dimension must be present.
1457    #[serde(rename = "cohortSpec")]
1458    pub cohort_spec: Option<CohortSpec>,
1459    /// Optional. The configuration of comparisons requested and displayed. The request only requires a comparisons field in order to receive a comparison column in the response.
1460    pub comparisons: Option<Vec<Comparison>>,
1461    /// A currency code in ISO4217 format, such as "AED", "USD", "JPY". If the field is empty, the report uses the property's default currency.
1462    #[serde(rename = "currencyCode")]
1463    pub currency_code: Option<String>,
1464    /// Date ranges of data to read. If multiple date ranges are requested, each response row will contain a zero based date range index. If two date ranges overlap, the event data for the overlapping days is included in the response rows for both date ranges. In a cohort request, this `dateRanges` must be unspecified.
1465    #[serde(rename = "dateRanges")]
1466    pub date_ranges: Option<Vec<DateRange>>,
1467    /// Dimension filters let you ask for only specific dimension values in the report. To learn more, see [Fundamentals of Dimension Filters](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#dimension_filters) for examples. Metrics cannot be used in this filter.
1468    #[serde(rename = "dimensionFilter")]
1469    pub dimension_filter: Option<FilterExpression>,
1470    /// The dimensions requested and displayed.
1471    pub dimensions: Option<Vec<Dimension>>,
1472    /// If false or unspecified, each row with all metrics equal to 0 will not be returned. If true, these rows will be returned if they are not separately removed by a filter. Regardless of this `keep_empty_rows` setting, only data recorded by the Google Analytics property can be displayed in a report. For example if a property never logs a `purchase` event, then a query for the `eventName` dimension and `eventCount` metric will not have a row eventName: "purchase" and eventCount: 0.
1473    #[serde(rename = "keepEmptyRows")]
1474    pub keep_empty_rows: Option<bool>,
1475    /// The number of rows to return. If unspecified, 10,000 rows are returned. The API returns a maximum of 250,000 rows per request, no matter how many you ask for. `limit` must be positive. The API can also return fewer rows than the requested `limit`, if there aren't as many dimension values as the `limit`. For instance, there are fewer than 300 possible values for the dimension `country`, so when reporting on only `country`, you can't get more than 300 rows, even if you set `limit` to a higher value. To learn more about this pagination parameter, see [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
1476    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1477    pub limit: Option<i64>,
1478    /// Aggregation of metrics. Aggregated metric values will be shown in rows where the dimension_values are set to "RESERVED_(MetricAggregation)". Aggregates including both comparisons and multiple date ranges will be aggregated based on the date ranges.
1479    #[serde(rename = "metricAggregations")]
1480    pub metric_aggregations: Option<Vec<String>>,
1481    /// The filter clause of metrics. Applied after aggregating the report's rows, similar to SQL having-clause. Dimensions cannot be used in this filter.
1482    #[serde(rename = "metricFilter")]
1483    pub metric_filter: Option<FilterExpression>,
1484    /// The metrics requested and displayed.
1485    pub metrics: Option<Vec<Metric>>,
1486    /// The row count of the start row. The first row is counted as row 0. When paging, the first request does not specify offset; or equivalently, sets offset to 0; the first request returns the first `limit` of rows. The second request sets offset to the `limit` of the first request; the second request returns the second `limit` of rows. To learn more about this pagination parameter, see [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
1487    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1488    pub offset: Option<i64>,
1489    /// Specifies how rows are ordered in the response. Requests including both comparisons and multiple date ranges will have order bys applied on the comparisons.
1490    #[serde(rename = "orderBys")]
1491    pub order_bys: Option<Vec<OrderBy>>,
1492    /// A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Within a batch request, this property should either be unspecified or consistent with the batch-level property. Example: properties/1234
1493    pub property: Option<String>,
1494    /// Toggles whether to return the current state of this Google Analytics property’s quota. Quota is returned in [PropertyQuota](#PropertyQuota).
1495    #[serde(rename = "returnPropertyQuota")]
1496    pub return_property_quota: Option<bool>,
1497}
1498
1499impl common::RequestValue for RunReportRequest {}
1500
1501/// The response report table corresponding to a request.
1502///
1503/// # Activities
1504///
1505/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1506/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1507///
1508/// * [run report properties](PropertyRunReportCall) (response)
1509#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1510#[serde_with::serde_as]
1511#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1512pub struct RunReportResponse {
1513    /// Describes dimension columns. The number of DimensionHeaders and ordering of DimensionHeaders matches the dimensions present in rows.
1514    #[serde(rename = "dimensionHeaders")]
1515    pub dimension_headers: Option<Vec<DimensionHeader>>,
1516    /// Identifies what kind of resource this message is. This `kind` is always the fixed string "analyticsData#runReport". Useful to distinguish between response types in JSON.
1517    pub kind: Option<String>,
1518    /// If requested, the maximum values of metrics.
1519    pub maximums: Option<Vec<Row>>,
1520    /// Metadata for the report.
1521    pub metadata: Option<ResponseMetaData>,
1522    /// Describes metric columns. The number of MetricHeaders and ordering of MetricHeaders matches the metrics present in rows.
1523    #[serde(rename = "metricHeaders")]
1524    pub metric_headers: Option<Vec<MetricHeader>>,
1525    /// If requested, the minimum values of metrics.
1526    pub minimums: Option<Vec<Row>>,
1527    /// This Google Analytics property's quota state including this request.
1528    #[serde(rename = "propertyQuota")]
1529    pub property_quota: Option<PropertyQuota>,
1530    /// The total number of rows in the query result. `rowCount` is independent of the number of rows returned in the response, the `limit` request parameter, and the `offset` request parameter. For example if a query returns 175 rows and includes `limit` of 50 in the API request, the response will contain `rowCount` of 175 but only 50 rows. To learn more about this pagination parameter, see [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
1531    #[serde(rename = "rowCount")]
1532    pub row_count: Option<i32>,
1533    /// Rows of dimension value combinations and metric values in the report.
1534    pub rows: Option<Vec<Row>>,
1535    /// If requested, the totaled values of metrics.
1536    pub totals: Option<Vec<Row>>,
1537}
1538
1539impl common::ResponseResult for RunReportResponse {}
1540
1541/// If this report results is [sampled](https://support.google.com/analytics/answer/13331292), this describes the percentage of events used in this report. Sampling is the practice of analyzing a subset of all data in order to uncover the meaningful information in the larger data set.
1542///
1543/// This type is not used in any activity, and only used as *part* of another schema.
1544///
1545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1546#[serde_with::serde_as]
1547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1548pub struct SamplingMetadata {
1549    /// The total number of events read in this sampled report for a date range. This is the size of the subset this property's data that was analyzed in this report.
1550    #[serde(rename = "samplesReadCount")]
1551    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1552    pub samples_read_count: Option<i64>,
1553    /// The total number of events present in this property's data that could have been analyzed in this report for a date range. Sampling uncovers the meaningful information about the larger data set, and this is the size of the larger data set. To calculate the percentage of available data that was used in this report, compute `samplesReadCount/samplingSpaceSize`.
1554    #[serde(rename = "samplingSpaceSize")]
1555    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1556    pub sampling_space_size: Option<i64>,
1557}
1558
1559impl common::Part for SamplingMetadata {}
1560
1561/// The schema restrictions actively enforced in creating this report. To learn more, see [Access and data-restriction management](https://support.google.com/analytics/answer/10851388).
1562///
1563/// This type is not used in any activity, and only used as *part* of another schema.
1564///
1565#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1566#[serde_with::serde_as]
1567#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1568pub struct SchemaRestrictionResponse {
1569    /// All restrictions actively enforced in creating the report. For example, `purchaseRevenue` always has the restriction type `REVENUE_DATA`. However, this active response restriction is only populated if the user's custom role disallows access to `REVENUE_DATA`.
1570    #[serde(rename = "activeMetricRestrictions")]
1571    pub active_metric_restrictions: Option<Vec<ActiveMetricRestriction>>,
1572}
1573
1574impl common::Part for SchemaRestrictionResponse {}
1575
1576/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
1577///
1578/// This type is not used in any activity, and only used as *part* of another schema.
1579///
1580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1581#[serde_with::serde_as]
1582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1583pub struct Status {
1584    /// The status code, which should be an enum value of google.rpc.Code.
1585    pub code: Option<i32>,
1586    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1587    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1588    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
1589    pub message: Option<String>,
1590}
1591
1592impl common::Part for Status {}
1593
1594/// The filter for string
1595///
1596/// This type is not used in any activity, and only used as *part* of another schema.
1597///
1598#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1599#[serde_with::serde_as]
1600#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1601pub struct StringFilter {
1602    /// If true, the string value is case sensitive.
1603    #[serde(rename = "caseSensitive")]
1604    pub case_sensitive: Option<bool>,
1605    /// The match type for this filter.
1606    #[serde(rename = "matchType")]
1607    pub match_type: Option<String>,
1608    /// The string value used for the matching.
1609    pub value: Option<String>,
1610}
1611
1612impl common::Part for StringFilter {}
1613
1614/// An audience dimension is a user attribute. Specific user attributed are requested and then later returned in the `QueryAudienceExportResponse`.
1615///
1616/// This type is not used in any activity, and only used as *part* of another schema.
1617///
1618#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1619#[serde_with::serde_as]
1620#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1621pub struct V1betaAudienceDimension {
1622    /// Optional. The API name of the dimension. See the [API Dimensions](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-api-schema#dimensions) for the list of dimension names.
1623    #[serde(rename = "dimensionName")]
1624    pub dimension_name: Option<String>,
1625}
1626
1627impl common::Part for V1betaAudienceDimension {}
1628
1629/// The value of a dimension.
1630///
1631/// This type is not used in any activity, and only used as *part* of another schema.
1632///
1633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1634#[serde_with::serde_as]
1635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1636pub struct V1betaAudienceDimensionValue {
1637    /// Value as a string if the dimension type is a string.
1638    pub value: Option<String>,
1639}
1640
1641impl common::Part for V1betaAudienceDimensionValue {}
1642
1643/// Dimension value attributes for the audience user row.
1644///
1645/// This type is not used in any activity, and only used as *part* of another schema.
1646///
1647#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1648#[serde_with::serde_as]
1649#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1650pub struct V1betaAudienceRow {
1651    /// Each dimension value attribute for an audience user. One dimension value will be added for each dimension column requested.
1652    #[serde(rename = "dimensionValues")]
1653    pub dimension_values: Option<Vec<V1betaAudienceDimensionValue>>,
1654}
1655
1656impl common::Part for V1betaAudienceRow {}
1657
1658// ###################
1659// MethodBuilders ###
1660// #################
1661
1662/// A builder providing access to all methods supported on *property* resources.
1663/// It is not used directly, but through the [`AnalyticsData`] hub.
1664///
1665/// # Example
1666///
1667/// Instantiate a resource builder
1668///
1669/// ```test_harness,no_run
1670/// extern crate hyper;
1671/// extern crate hyper_rustls;
1672/// extern crate google_analyticsdata1_beta as analyticsdata1_beta;
1673///
1674/// # async fn dox() {
1675/// use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1676///
1677/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1678/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1679///     .with_native_roots()
1680///     .unwrap()
1681///     .https_only()
1682///     .enable_http2()
1683///     .build();
1684///
1685/// let executor = hyper_util::rt::TokioExecutor::new();
1686/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1687///     secret,
1688///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1689///     yup_oauth2::client::CustomHyperClientBuilder::from(
1690///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1691///     ),
1692/// ).build().await.unwrap();
1693///
1694/// let client = hyper_util::client::legacy::Client::builder(
1695///     hyper_util::rt::TokioExecutor::new()
1696/// )
1697/// .build(
1698///     hyper_rustls::HttpsConnectorBuilder::new()
1699///         .with_native_roots()
1700///         .unwrap()
1701///         .https_or_http()
1702///         .enable_http2()
1703///         .build()
1704/// );
1705/// let mut hub = AnalyticsData::new(client, auth);
1706/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1707/// // like `audience_exports_create(...)`, `audience_exports_get(...)`, `audience_exports_list(...)`, `audience_exports_query(...)`, `batch_run_pivot_reports(...)`, `batch_run_reports(...)`, `check_compatibility(...)`, `get_metadata(...)`, `run_pivot_report(...)`, `run_realtime_report(...)` and `run_report(...)`
1708/// // to build up your call.
1709/// let rb = hub.properties();
1710/// # }
1711/// ```
1712pub struct PropertyMethods<'a, C>
1713where
1714    C: 'a,
1715{
1716    hub: &'a AnalyticsData<C>,
1717}
1718
1719impl<'a, C> common::MethodsBuilder for PropertyMethods<'a, C> {}
1720
1721impl<'a, C> PropertyMethods<'a, C> {
1722    /// Create a builder to help you perform the following task:
1723    ///
1724    /// Creates an audience export for later retrieval. This method quickly returns the audience export's resource name and initiates a long running asynchronous request to form an audience export. To export the users in an audience export, first create the audience export through this method and then send the audience resource name to the `QueryAudienceExport` method. See [Creating an Audience Export](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-basics) for an introduction to Audience Exports with examples. An audience export is a snapshot of the users currently in the audience at the time of audience export creation. Creating audience exports for one audience on different days will return different results as users enter and exit the audience. Audiences in Google Analytics 4 allow you to segment your users in the ways that are important to your business. To learn more, see https://support.google.com/analytics/answer/9267572. Audience exports contain the users in each audience. Audience Export APIs have some methods at alpha and other methods at beta stability. The intention is to advance methods to beta stability after some feedback and adoption. To give your feedback on this API, complete the [Google Analytics Audience Export API Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
1725    ///
1726    /// # Arguments
1727    ///
1728    /// * `request` - No description provided.
1729    /// * `parent` - Required. The parent resource where this audience export will be created. Format: `properties/{property}`
1730    pub fn audience_exports_create(
1731        &self,
1732        request: AudienceExport,
1733        parent: &str,
1734    ) -> PropertyAudienceExportCreateCall<'a, C> {
1735        PropertyAudienceExportCreateCall {
1736            hub: self.hub,
1737            _request: request,
1738            _parent: parent.to_string(),
1739            _delegate: Default::default(),
1740            _additional_params: Default::default(),
1741            _scopes: Default::default(),
1742        }
1743    }
1744
1745    /// Create a builder to help you perform the following task:
1746    ///
1747    /// Gets configuration metadata about a specific audience export. This method can be used to understand an audience export after it has been created. See [Creating an Audience Export](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-basics) for an introduction to Audience Exports with examples. Audience Export APIs have some methods at alpha and other methods at beta stability. The intention is to advance methods to beta stability after some feedback and adoption. To give your feedback on this API, complete the [Google Analytics Audience Export API Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
1748    ///
1749    /// # Arguments
1750    ///
1751    /// * `name` - Required. The audience export resource name. Format: `properties/{property}/audienceExports/{audience_export}`
1752    pub fn audience_exports_get(&self, name: &str) -> PropertyAudienceExportGetCall<'a, C> {
1753        PropertyAudienceExportGetCall {
1754            hub: self.hub,
1755            _name: name.to_string(),
1756            _delegate: Default::default(),
1757            _additional_params: Default::default(),
1758            _scopes: Default::default(),
1759        }
1760    }
1761
1762    /// Create a builder to help you perform the following task:
1763    ///
1764    /// Lists all audience exports for a property. This method can be used for you to find and reuse existing audience exports rather than creating unnecessary new audience exports. The same audience can have multiple audience exports that represent the export of users that were in an audience on different days. See [Creating an Audience Export](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-basics) for an introduction to Audience Exports with examples. Audience Export APIs have some methods at alpha and other methods at beta stability. The intention is to advance methods to beta stability after some feedback and adoption. To give your feedback on this API, complete the [Google Analytics Audience Export API Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
1765    ///
1766    /// # Arguments
1767    ///
1768    /// * `parent` - Required. All audience exports for this property will be listed in the response. Format: `properties/{property}`
1769    pub fn audience_exports_list(&self, parent: &str) -> PropertyAudienceExportListCall<'a, C> {
1770        PropertyAudienceExportListCall {
1771            hub: self.hub,
1772            _parent: parent.to_string(),
1773            _page_token: Default::default(),
1774            _page_size: Default::default(),
1775            _delegate: Default::default(),
1776            _additional_params: Default::default(),
1777            _scopes: Default::default(),
1778        }
1779    }
1780
1781    /// Create a builder to help you perform the following task:
1782    ///
1783    /// Retrieves an audience export of users. After creating an audience, the users are not immediately available for exporting. First, a request to `CreateAudienceExport` is necessary to create an audience export of users, and then second, this method is used to retrieve the users in the audience export. See [Creating an Audience Export](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-basics) for an introduction to Audience Exports with examples. Audiences in Google Analytics 4 allow you to segment your users in the ways that are important to your business. To learn more, see https://support.google.com/analytics/answer/9267572. Audience Export APIs have some methods at alpha and other methods at beta stability. The intention is to advance methods to beta stability after some feedback and adoption. To give your feedback on this API, complete the [Google Analytics Audience Export API Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
1784    ///
1785    /// # Arguments
1786    ///
1787    /// * `request` - No description provided.
1788    /// * `name` - Required. The name of the audience export to retrieve users from. Format: `properties/{property}/audienceExports/{audience_export}`
1789    pub fn audience_exports_query(
1790        &self,
1791        request: QueryAudienceExportRequest,
1792        name: &str,
1793    ) -> PropertyAudienceExportQueryCall<'a, C> {
1794        PropertyAudienceExportQueryCall {
1795            hub: self.hub,
1796            _request: request,
1797            _name: name.to_string(),
1798            _delegate: Default::default(),
1799            _additional_params: Default::default(),
1800            _scopes: Default::default(),
1801        }
1802    }
1803
1804    /// Create a builder to help you perform the following task:
1805    ///
1806    /// Returns multiple pivot reports in a batch. All reports must be for the same Google Analytics property.
1807    ///
1808    /// # Arguments
1809    ///
1810    /// * `request` - No description provided.
1811    /// * `property` - A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). This property must be specified for the batch. The property within RunPivotReportRequest may either be unspecified or consistent with this property. Example: properties/1234
1812    pub fn batch_run_pivot_reports(
1813        &self,
1814        request: BatchRunPivotReportsRequest,
1815        property: &str,
1816    ) -> PropertyBatchRunPivotReportCall<'a, C> {
1817        PropertyBatchRunPivotReportCall {
1818            hub: self.hub,
1819            _request: request,
1820            _property: property.to_string(),
1821            _delegate: Default::default(),
1822            _additional_params: Default::default(),
1823            _scopes: Default::default(),
1824        }
1825    }
1826
1827    /// Create a builder to help you perform the following task:
1828    ///
1829    /// Returns multiple reports in a batch. All reports must be for the same Google Analytics property.
1830    ///
1831    /// # Arguments
1832    ///
1833    /// * `request` - No description provided.
1834    /// * `property` - A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). This property must be specified for the batch. The property within RunReportRequest may either be unspecified or consistent with this property. Example: properties/1234
1835    pub fn batch_run_reports(
1836        &self,
1837        request: BatchRunReportsRequest,
1838        property: &str,
1839    ) -> PropertyBatchRunReportCall<'a, C> {
1840        PropertyBatchRunReportCall {
1841            hub: self.hub,
1842            _request: request,
1843            _property: property.to_string(),
1844            _delegate: Default::default(),
1845            _additional_params: Default::default(),
1846            _scopes: Default::default(),
1847        }
1848    }
1849
1850    /// Create a builder to help you perform the following task:
1851    ///
1852    /// This compatibility method lists dimensions and metrics that can be added to a report request and maintain compatibility. This method fails if the request's dimensions and metrics are incompatible. In Google Analytics, reports fail if they request incompatible dimensions and/or metrics; in that case, you will need to remove dimensions and/or metrics from the incompatible report until the report is compatible. The Realtime and Core reports have different compatibility rules. This method checks compatibility for Core reports.
1853    ///
1854    /// # Arguments
1855    ///
1856    /// * `request` - No description provided.
1857    /// * `property` - A Google Analytics property identifier whose events are tracked. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). `property` should be the same value as in your `runReport` request. Example: properties/1234
1858    pub fn check_compatibility(
1859        &self,
1860        request: CheckCompatibilityRequest,
1861        property: &str,
1862    ) -> PropertyCheckCompatibilityCall<'a, C> {
1863        PropertyCheckCompatibilityCall {
1864            hub: self.hub,
1865            _request: request,
1866            _property: property.to_string(),
1867            _delegate: Default::default(),
1868            _additional_params: Default::default(),
1869            _scopes: Default::default(),
1870        }
1871    }
1872
1873    /// Create a builder to help you perform the following task:
1874    ///
1875    /// Returns metadata for dimensions and metrics available in reporting methods. Used to explore the dimensions and metrics. In this method, a Google Analytics property identifier is specified in the request, and the metadata response includes Custom dimensions and metrics as well as Universal metadata. For example if a custom metric with parameter name `levels_unlocked` is registered to a property, the Metadata response will contain `customEvent:levels_unlocked`. Universal metadata are dimensions and metrics applicable to any property such as `country` and `totalUsers`.
1876    ///
1877    /// # Arguments
1878    ///
1879    /// * `name` - Required. The resource name of the metadata to retrieve. This name field is specified in the URL path and not URL parameters. Property is a numeric Google Analytics property identifier. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Example: properties/1234/metadata Set the Property ID to 0 for dimensions and metrics common to all properties. In this special mode, this method will not return custom dimensions and metrics.
1880    pub fn get_metadata(&self, name: &str) -> PropertyGetMetadataCall<'a, C> {
1881        PropertyGetMetadataCall {
1882            hub: self.hub,
1883            _name: name.to_string(),
1884            _delegate: Default::default(),
1885            _additional_params: Default::default(),
1886            _scopes: Default::default(),
1887        }
1888    }
1889
1890    /// Create a builder to help you perform the following task:
1891    ///
1892    /// Returns a customized pivot report of your Google Analytics event data. Pivot reports are more advanced and expressive formats than regular reports. In a pivot report, dimensions are only visible if they are included in a pivot. Multiple pivots can be specified to further dissect your data.
1893    ///
1894    /// # Arguments
1895    ///
1896    /// * `request` - No description provided.
1897    /// * `property` - A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Within a batch request, this property should either be unspecified or consistent with the batch-level property. Example: properties/1234
1898    pub fn run_pivot_report(
1899        &self,
1900        request: RunPivotReportRequest,
1901        property: &str,
1902    ) -> PropertyRunPivotReportCall<'a, C> {
1903        PropertyRunPivotReportCall {
1904            hub: self.hub,
1905            _request: request,
1906            _property: property.to_string(),
1907            _delegate: Default::default(),
1908            _additional_params: Default::default(),
1909            _scopes: Default::default(),
1910        }
1911    }
1912
1913    /// Create a builder to help you perform the following task:
1914    ///
1915    /// Returns a customized report of realtime event data for your property. Events appear in realtime reports seconds after they have been sent to the Google Analytics. Realtime reports show events and usage data for the periods of time ranging from the present moment to 30 minutes ago (up to 60 minutes for Google Analytics 360 properties). For a guide to constructing realtime requests & understanding responses, see [Creating a Realtime Report](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-basics).
1916    ///
1917    /// # Arguments
1918    ///
1919    /// * `request` - No description provided.
1920    /// * `property` - A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Example: properties/1234
1921    pub fn run_realtime_report(
1922        &self,
1923        request: RunRealtimeReportRequest,
1924        property: &str,
1925    ) -> PropertyRunRealtimeReportCall<'a, C> {
1926        PropertyRunRealtimeReportCall {
1927            hub: self.hub,
1928            _request: request,
1929            _property: property.to_string(),
1930            _delegate: Default::default(),
1931            _additional_params: Default::default(),
1932            _scopes: Default::default(),
1933        }
1934    }
1935
1936    /// Create a builder to help you perform the following task:
1937    ///
1938    /// Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the Google Analytics tracking code. The data returned from the API is as a table with columns for the requested dimensions and metrics. Metrics are individual measurements of user activity on your property, such as active users or event count. Dimensions break down metrics across some common criteria, such as country or event name. For a guide to constructing requests & understanding responses, see [Creating a Report](https://developers.google.com/analytics/devguides/reporting/data/v1/basics).
1939    ///
1940    /// # Arguments
1941    ///
1942    /// * `request` - No description provided.
1943    /// * `property` - A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Within a batch request, this property should either be unspecified or consistent with the batch-level property. Example: properties/1234
1944    pub fn run_report(
1945        &self,
1946        request: RunReportRequest,
1947        property: &str,
1948    ) -> PropertyRunReportCall<'a, C> {
1949        PropertyRunReportCall {
1950            hub: self.hub,
1951            _request: request,
1952            _property: property.to_string(),
1953            _delegate: Default::default(),
1954            _additional_params: Default::default(),
1955            _scopes: Default::default(),
1956        }
1957    }
1958}
1959
1960// ###################
1961// CallBuilders   ###
1962// #################
1963
1964/// Creates an audience export for later retrieval. This method quickly returns the audience export's resource name and initiates a long running asynchronous request to form an audience export. To export the users in an audience export, first create the audience export through this method and then send the audience resource name to the `QueryAudienceExport` method. See [Creating an Audience Export](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-basics) for an introduction to Audience Exports with examples. An audience export is a snapshot of the users currently in the audience at the time of audience export creation. Creating audience exports for one audience on different days will return different results as users enter and exit the audience. Audiences in Google Analytics 4 allow you to segment your users in the ways that are important to your business. To learn more, see https://support.google.com/analytics/answer/9267572. Audience exports contain the users in each audience. Audience Export APIs have some methods at alpha and other methods at beta stability. The intention is to advance methods to beta stability after some feedback and adoption. To give your feedback on this API, complete the [Google Analytics Audience Export API Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
1965///
1966/// A builder for the *audienceExports.create* method supported by a *property* resource.
1967/// It is not used directly, but through a [`PropertyMethods`] instance.
1968///
1969/// # Example
1970///
1971/// Instantiate a resource method builder
1972///
1973/// ```test_harness,no_run
1974/// # extern crate hyper;
1975/// # extern crate hyper_rustls;
1976/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
1977/// use analyticsdata1_beta::api::AudienceExport;
1978/// # async fn dox() {
1979/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1980///
1981/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1982/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1983/// #     .with_native_roots()
1984/// #     .unwrap()
1985/// #     .https_only()
1986/// #     .enable_http2()
1987/// #     .build();
1988///
1989/// # let executor = hyper_util::rt::TokioExecutor::new();
1990/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1991/// #     secret,
1992/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1993/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1994/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1995/// #     ),
1996/// # ).build().await.unwrap();
1997///
1998/// # let client = hyper_util::client::legacy::Client::builder(
1999/// #     hyper_util::rt::TokioExecutor::new()
2000/// # )
2001/// # .build(
2002/// #     hyper_rustls::HttpsConnectorBuilder::new()
2003/// #         .with_native_roots()
2004/// #         .unwrap()
2005/// #         .https_or_http()
2006/// #         .enable_http2()
2007/// #         .build()
2008/// # );
2009/// # let mut hub = AnalyticsData::new(client, auth);
2010/// // As the method needs a request, you would usually fill it with the desired information
2011/// // into the respective structure. Some of the parts shown here might not be applicable !
2012/// // Values shown here are possibly random and not representative !
2013/// let mut req = AudienceExport::default();
2014///
2015/// // You can configure optional parameters by calling the respective setters at will, and
2016/// // execute the final call using `doit()`.
2017/// // Values shown here are possibly random and not representative !
2018/// let result = hub.properties().audience_exports_create(req, "parent")
2019///              .doit().await;
2020/// # }
2021/// ```
2022pub struct PropertyAudienceExportCreateCall<'a, C>
2023where
2024    C: 'a,
2025{
2026    hub: &'a AnalyticsData<C>,
2027    _request: AudienceExport,
2028    _parent: String,
2029    _delegate: Option<&'a mut dyn common::Delegate>,
2030    _additional_params: HashMap<String, String>,
2031    _scopes: BTreeSet<String>,
2032}
2033
2034impl<'a, C> common::CallBuilder for PropertyAudienceExportCreateCall<'a, C> {}
2035
2036impl<'a, C> PropertyAudienceExportCreateCall<'a, C>
2037where
2038    C: common::Connector,
2039{
2040    /// Perform the operation you have build so far.
2041    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2042        use std::borrow::Cow;
2043        use std::io::{Read, Seek};
2044
2045        use common::{url::Params, ToParts};
2046        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2047
2048        let mut dd = common::DefaultDelegate;
2049        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2050        dlg.begin(common::MethodInfo {
2051            id: "analyticsdata.properties.audienceExports.create",
2052            http_method: hyper::Method::POST,
2053        });
2054
2055        for &field in ["alt", "parent"].iter() {
2056            if self._additional_params.contains_key(field) {
2057                dlg.finished(false);
2058                return Err(common::Error::FieldClash(field));
2059            }
2060        }
2061
2062        let mut params = Params::with_capacity(4 + self._additional_params.len());
2063        params.push("parent", self._parent);
2064
2065        params.extend(self._additional_params.iter());
2066
2067        params.push("alt", "json");
2068        let mut url = self.hub._base_url.clone() + "v1beta/{+parent}/audienceExports";
2069        if self._scopes.is_empty() {
2070            self._scopes
2071                .insert(Scope::AnalyticReadonly.as_ref().to_string());
2072        }
2073
2074        #[allow(clippy::single_element_loop)]
2075        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2076            url = params.uri_replacement(url, param_name, find_this, true);
2077        }
2078        {
2079            let to_remove = ["parent"];
2080            params.remove_params(&to_remove);
2081        }
2082
2083        let url = params.parse_with_url(&url);
2084
2085        let mut json_mime_type = mime::APPLICATION_JSON;
2086        let mut request_value_reader = {
2087            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2088            common::remove_json_null_values(&mut value);
2089            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2090            serde_json::to_writer(&mut dst, &value).unwrap();
2091            dst
2092        };
2093        let request_size = request_value_reader
2094            .seek(std::io::SeekFrom::End(0))
2095            .unwrap();
2096        request_value_reader
2097            .seek(std::io::SeekFrom::Start(0))
2098            .unwrap();
2099
2100        loop {
2101            let token = match self
2102                .hub
2103                .auth
2104                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2105                .await
2106            {
2107                Ok(token) => token,
2108                Err(e) => match dlg.token(e) {
2109                    Ok(token) => token,
2110                    Err(e) => {
2111                        dlg.finished(false);
2112                        return Err(common::Error::MissingToken(e));
2113                    }
2114                },
2115            };
2116            request_value_reader
2117                .seek(std::io::SeekFrom::Start(0))
2118                .unwrap();
2119            let mut req_result = {
2120                let client = &self.hub.client;
2121                dlg.pre_request();
2122                let mut req_builder = hyper::Request::builder()
2123                    .method(hyper::Method::POST)
2124                    .uri(url.as_str())
2125                    .header(USER_AGENT, self.hub._user_agent.clone());
2126
2127                if let Some(token) = token.as_ref() {
2128                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2129                }
2130
2131                let request = req_builder
2132                    .header(CONTENT_TYPE, json_mime_type.to_string())
2133                    .header(CONTENT_LENGTH, request_size as u64)
2134                    .body(common::to_body(
2135                        request_value_reader.get_ref().clone().into(),
2136                    ));
2137
2138                client.request(request.unwrap()).await
2139            };
2140
2141            match req_result {
2142                Err(err) => {
2143                    if let common::Retry::After(d) = dlg.http_error(&err) {
2144                        sleep(d).await;
2145                        continue;
2146                    }
2147                    dlg.finished(false);
2148                    return Err(common::Error::HttpError(err));
2149                }
2150                Ok(res) => {
2151                    let (mut parts, body) = res.into_parts();
2152                    let mut body = common::Body::new(body);
2153                    if !parts.status.is_success() {
2154                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2155                        let error = serde_json::from_str(&common::to_string(&bytes));
2156                        let response = common::to_response(parts, bytes.into());
2157
2158                        if let common::Retry::After(d) =
2159                            dlg.http_failure(&response, error.as_ref().ok())
2160                        {
2161                            sleep(d).await;
2162                            continue;
2163                        }
2164
2165                        dlg.finished(false);
2166
2167                        return Err(match error {
2168                            Ok(value) => common::Error::BadRequest(value),
2169                            _ => common::Error::Failure(response),
2170                        });
2171                    }
2172                    let response = {
2173                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2174                        let encoded = common::to_string(&bytes);
2175                        match serde_json::from_str(&encoded) {
2176                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2177                            Err(error) => {
2178                                dlg.response_json_decode_error(&encoded, &error);
2179                                return Err(common::Error::JsonDecodeError(
2180                                    encoded.to_string(),
2181                                    error,
2182                                ));
2183                            }
2184                        }
2185                    };
2186
2187                    dlg.finished(true);
2188                    return Ok(response);
2189                }
2190            }
2191        }
2192    }
2193
2194    ///
2195    /// Sets the *request* property to the given value.
2196    ///
2197    /// Even though the property as already been set when instantiating this call,
2198    /// we provide this method for API completeness.
2199    pub fn request(mut self, new_value: AudienceExport) -> PropertyAudienceExportCreateCall<'a, C> {
2200        self._request = new_value;
2201        self
2202    }
2203    /// Required. The parent resource where this audience export will be created. Format: `properties/{property}`
2204    ///
2205    /// Sets the *parent* path property to the given value.
2206    ///
2207    /// Even though the property as already been set when instantiating this call,
2208    /// we provide this method for API completeness.
2209    pub fn parent(mut self, new_value: &str) -> PropertyAudienceExportCreateCall<'a, C> {
2210        self._parent = new_value.to_string();
2211        self
2212    }
2213    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2214    /// while executing the actual API request.
2215    ///
2216    /// ````text
2217    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2218    /// ````
2219    ///
2220    /// Sets the *delegate* property to the given value.
2221    pub fn delegate(
2222        mut self,
2223        new_value: &'a mut dyn common::Delegate,
2224    ) -> PropertyAudienceExportCreateCall<'a, C> {
2225        self._delegate = Some(new_value);
2226        self
2227    }
2228
2229    /// Set any additional parameter of the query string used in the request.
2230    /// It should be used to set parameters which are not yet available through their own
2231    /// setters.
2232    ///
2233    /// Please note that this method must not be used to set any of the known parameters
2234    /// which have their own setter method. If done anyway, the request will fail.
2235    ///
2236    /// # Additional Parameters
2237    ///
2238    /// * *$.xgafv* (query-string) - V1 error format.
2239    /// * *access_token* (query-string) - OAuth access token.
2240    /// * *alt* (query-string) - Data format for response.
2241    /// * *callback* (query-string) - JSONP
2242    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2243    /// * *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.
2244    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2245    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2246    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2247    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2248    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2249    pub fn param<T>(mut self, name: T, value: T) -> PropertyAudienceExportCreateCall<'a, C>
2250    where
2251        T: AsRef<str>,
2252    {
2253        self._additional_params
2254            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2255        self
2256    }
2257
2258    /// Identifies the authorization scope for the method you are building.
2259    ///
2260    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2261    /// [`Scope::AnalyticReadonly`].
2262    ///
2263    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2264    /// tokens for more than one scope.
2265    ///
2266    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2267    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2268    /// sufficient, a read-write scope will do as well.
2269    pub fn add_scope<St>(mut self, scope: St) -> PropertyAudienceExportCreateCall<'a, C>
2270    where
2271        St: AsRef<str>,
2272    {
2273        self._scopes.insert(String::from(scope.as_ref()));
2274        self
2275    }
2276    /// Identifies the authorization scope(s) for the method you are building.
2277    ///
2278    /// See [`Self::add_scope()`] for details.
2279    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyAudienceExportCreateCall<'a, C>
2280    where
2281        I: IntoIterator<Item = St>,
2282        St: AsRef<str>,
2283    {
2284        self._scopes
2285            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2286        self
2287    }
2288
2289    /// Removes all scopes, and no default scope will be used either.
2290    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2291    /// for details).
2292    pub fn clear_scopes(mut self) -> PropertyAudienceExportCreateCall<'a, C> {
2293        self._scopes.clear();
2294        self
2295    }
2296}
2297
2298/// Gets configuration metadata about a specific audience export. This method can be used to understand an audience export after it has been created. See [Creating an Audience Export](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-basics) for an introduction to Audience Exports with examples. Audience Export APIs have some methods at alpha and other methods at beta stability. The intention is to advance methods to beta stability after some feedback and adoption. To give your feedback on this API, complete the [Google Analytics Audience Export API Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
2299///
2300/// A builder for the *audienceExports.get* method supported by a *property* resource.
2301/// It is not used directly, but through a [`PropertyMethods`] instance.
2302///
2303/// # Example
2304///
2305/// Instantiate a resource method builder
2306///
2307/// ```test_harness,no_run
2308/// # extern crate hyper;
2309/// # extern crate hyper_rustls;
2310/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
2311/// # async fn dox() {
2312/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2313///
2314/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2315/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2316/// #     .with_native_roots()
2317/// #     .unwrap()
2318/// #     .https_only()
2319/// #     .enable_http2()
2320/// #     .build();
2321///
2322/// # let executor = hyper_util::rt::TokioExecutor::new();
2323/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2324/// #     secret,
2325/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2326/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2327/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2328/// #     ),
2329/// # ).build().await.unwrap();
2330///
2331/// # let client = hyper_util::client::legacy::Client::builder(
2332/// #     hyper_util::rt::TokioExecutor::new()
2333/// # )
2334/// # .build(
2335/// #     hyper_rustls::HttpsConnectorBuilder::new()
2336/// #         .with_native_roots()
2337/// #         .unwrap()
2338/// #         .https_or_http()
2339/// #         .enable_http2()
2340/// #         .build()
2341/// # );
2342/// # let mut hub = AnalyticsData::new(client, auth);
2343/// // You can configure optional parameters by calling the respective setters at will, and
2344/// // execute the final call using `doit()`.
2345/// // Values shown here are possibly random and not representative !
2346/// let result = hub.properties().audience_exports_get("name")
2347///              .doit().await;
2348/// # }
2349/// ```
2350pub struct PropertyAudienceExportGetCall<'a, C>
2351where
2352    C: 'a,
2353{
2354    hub: &'a AnalyticsData<C>,
2355    _name: String,
2356    _delegate: Option<&'a mut dyn common::Delegate>,
2357    _additional_params: HashMap<String, String>,
2358    _scopes: BTreeSet<String>,
2359}
2360
2361impl<'a, C> common::CallBuilder for PropertyAudienceExportGetCall<'a, C> {}
2362
2363impl<'a, C> PropertyAudienceExportGetCall<'a, C>
2364where
2365    C: common::Connector,
2366{
2367    /// Perform the operation you have build so far.
2368    pub async fn doit(mut self) -> common::Result<(common::Response, AudienceExport)> {
2369        use std::borrow::Cow;
2370        use std::io::{Read, Seek};
2371
2372        use common::{url::Params, ToParts};
2373        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2374
2375        let mut dd = common::DefaultDelegate;
2376        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2377        dlg.begin(common::MethodInfo {
2378            id: "analyticsdata.properties.audienceExports.get",
2379            http_method: hyper::Method::GET,
2380        });
2381
2382        for &field in ["alt", "name"].iter() {
2383            if self._additional_params.contains_key(field) {
2384                dlg.finished(false);
2385                return Err(common::Error::FieldClash(field));
2386            }
2387        }
2388
2389        let mut params = Params::with_capacity(3 + self._additional_params.len());
2390        params.push("name", self._name);
2391
2392        params.extend(self._additional_params.iter());
2393
2394        params.push("alt", "json");
2395        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
2396        if self._scopes.is_empty() {
2397            self._scopes
2398                .insert(Scope::AnalyticReadonly.as_ref().to_string());
2399        }
2400
2401        #[allow(clippy::single_element_loop)]
2402        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2403            url = params.uri_replacement(url, param_name, find_this, true);
2404        }
2405        {
2406            let to_remove = ["name"];
2407            params.remove_params(&to_remove);
2408        }
2409
2410        let url = params.parse_with_url(&url);
2411
2412        loop {
2413            let token = match self
2414                .hub
2415                .auth
2416                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2417                .await
2418            {
2419                Ok(token) => token,
2420                Err(e) => match dlg.token(e) {
2421                    Ok(token) => token,
2422                    Err(e) => {
2423                        dlg.finished(false);
2424                        return Err(common::Error::MissingToken(e));
2425                    }
2426                },
2427            };
2428            let mut req_result = {
2429                let client = &self.hub.client;
2430                dlg.pre_request();
2431                let mut req_builder = hyper::Request::builder()
2432                    .method(hyper::Method::GET)
2433                    .uri(url.as_str())
2434                    .header(USER_AGENT, self.hub._user_agent.clone());
2435
2436                if let Some(token) = token.as_ref() {
2437                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2438                }
2439
2440                let request = req_builder
2441                    .header(CONTENT_LENGTH, 0_u64)
2442                    .body(common::to_body::<String>(None));
2443
2444                client.request(request.unwrap()).await
2445            };
2446
2447            match req_result {
2448                Err(err) => {
2449                    if let common::Retry::After(d) = dlg.http_error(&err) {
2450                        sleep(d).await;
2451                        continue;
2452                    }
2453                    dlg.finished(false);
2454                    return Err(common::Error::HttpError(err));
2455                }
2456                Ok(res) => {
2457                    let (mut parts, body) = res.into_parts();
2458                    let mut body = common::Body::new(body);
2459                    if !parts.status.is_success() {
2460                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2461                        let error = serde_json::from_str(&common::to_string(&bytes));
2462                        let response = common::to_response(parts, bytes.into());
2463
2464                        if let common::Retry::After(d) =
2465                            dlg.http_failure(&response, error.as_ref().ok())
2466                        {
2467                            sleep(d).await;
2468                            continue;
2469                        }
2470
2471                        dlg.finished(false);
2472
2473                        return Err(match error {
2474                            Ok(value) => common::Error::BadRequest(value),
2475                            _ => common::Error::Failure(response),
2476                        });
2477                    }
2478                    let response = {
2479                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2480                        let encoded = common::to_string(&bytes);
2481                        match serde_json::from_str(&encoded) {
2482                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2483                            Err(error) => {
2484                                dlg.response_json_decode_error(&encoded, &error);
2485                                return Err(common::Error::JsonDecodeError(
2486                                    encoded.to_string(),
2487                                    error,
2488                                ));
2489                            }
2490                        }
2491                    };
2492
2493                    dlg.finished(true);
2494                    return Ok(response);
2495                }
2496            }
2497        }
2498    }
2499
2500    /// Required. The audience export resource name. Format: `properties/{property}/audienceExports/{audience_export}`
2501    ///
2502    /// Sets the *name* path property to the given value.
2503    ///
2504    /// Even though the property as already been set when instantiating this call,
2505    /// we provide this method for API completeness.
2506    pub fn name(mut self, new_value: &str) -> PropertyAudienceExportGetCall<'a, C> {
2507        self._name = new_value.to_string();
2508        self
2509    }
2510    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2511    /// while executing the actual API request.
2512    ///
2513    /// ````text
2514    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2515    /// ````
2516    ///
2517    /// Sets the *delegate* property to the given value.
2518    pub fn delegate(
2519        mut self,
2520        new_value: &'a mut dyn common::Delegate,
2521    ) -> PropertyAudienceExportGetCall<'a, C> {
2522        self._delegate = Some(new_value);
2523        self
2524    }
2525
2526    /// Set any additional parameter of the query string used in the request.
2527    /// It should be used to set parameters which are not yet available through their own
2528    /// setters.
2529    ///
2530    /// Please note that this method must not be used to set any of the known parameters
2531    /// which have their own setter method. If done anyway, the request will fail.
2532    ///
2533    /// # Additional Parameters
2534    ///
2535    /// * *$.xgafv* (query-string) - V1 error format.
2536    /// * *access_token* (query-string) - OAuth access token.
2537    /// * *alt* (query-string) - Data format for response.
2538    /// * *callback* (query-string) - JSONP
2539    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2540    /// * *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.
2541    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2542    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2543    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2544    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2545    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2546    pub fn param<T>(mut self, name: T, value: T) -> PropertyAudienceExportGetCall<'a, C>
2547    where
2548        T: AsRef<str>,
2549    {
2550        self._additional_params
2551            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2552        self
2553    }
2554
2555    /// Identifies the authorization scope for the method you are building.
2556    ///
2557    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2558    /// [`Scope::AnalyticReadonly`].
2559    ///
2560    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2561    /// tokens for more than one scope.
2562    ///
2563    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2564    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2565    /// sufficient, a read-write scope will do as well.
2566    pub fn add_scope<St>(mut self, scope: St) -> PropertyAudienceExportGetCall<'a, C>
2567    where
2568        St: AsRef<str>,
2569    {
2570        self._scopes.insert(String::from(scope.as_ref()));
2571        self
2572    }
2573    /// Identifies the authorization scope(s) for the method you are building.
2574    ///
2575    /// See [`Self::add_scope()`] for details.
2576    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyAudienceExportGetCall<'a, C>
2577    where
2578        I: IntoIterator<Item = St>,
2579        St: AsRef<str>,
2580    {
2581        self._scopes
2582            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2583        self
2584    }
2585
2586    /// Removes all scopes, and no default scope will be used either.
2587    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2588    /// for details).
2589    pub fn clear_scopes(mut self) -> PropertyAudienceExportGetCall<'a, C> {
2590        self._scopes.clear();
2591        self
2592    }
2593}
2594
2595/// Lists all audience exports for a property. This method can be used for you to find and reuse existing audience exports rather than creating unnecessary new audience exports. The same audience can have multiple audience exports that represent the export of users that were in an audience on different days. See [Creating an Audience Export](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-basics) for an introduction to Audience Exports with examples. Audience Export APIs have some methods at alpha and other methods at beta stability. The intention is to advance methods to beta stability after some feedback and adoption. To give your feedback on this API, complete the [Google Analytics Audience Export API Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
2596///
2597/// A builder for the *audienceExports.list* method supported by a *property* resource.
2598/// It is not used directly, but through a [`PropertyMethods`] instance.
2599///
2600/// # Example
2601///
2602/// Instantiate a resource method builder
2603///
2604/// ```test_harness,no_run
2605/// # extern crate hyper;
2606/// # extern crate hyper_rustls;
2607/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
2608/// # async fn dox() {
2609/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2610///
2611/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2612/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2613/// #     .with_native_roots()
2614/// #     .unwrap()
2615/// #     .https_only()
2616/// #     .enable_http2()
2617/// #     .build();
2618///
2619/// # let executor = hyper_util::rt::TokioExecutor::new();
2620/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2621/// #     secret,
2622/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2623/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2624/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2625/// #     ),
2626/// # ).build().await.unwrap();
2627///
2628/// # let client = hyper_util::client::legacy::Client::builder(
2629/// #     hyper_util::rt::TokioExecutor::new()
2630/// # )
2631/// # .build(
2632/// #     hyper_rustls::HttpsConnectorBuilder::new()
2633/// #         .with_native_roots()
2634/// #         .unwrap()
2635/// #         .https_or_http()
2636/// #         .enable_http2()
2637/// #         .build()
2638/// # );
2639/// # let mut hub = AnalyticsData::new(client, auth);
2640/// // You can configure optional parameters by calling the respective setters at will, and
2641/// // execute the final call using `doit()`.
2642/// // Values shown here are possibly random and not representative !
2643/// let result = hub.properties().audience_exports_list("parent")
2644///              .page_token("sanctus")
2645///              .page_size(-80)
2646///              .doit().await;
2647/// # }
2648/// ```
2649pub struct PropertyAudienceExportListCall<'a, C>
2650where
2651    C: 'a,
2652{
2653    hub: &'a AnalyticsData<C>,
2654    _parent: String,
2655    _page_token: Option<String>,
2656    _page_size: Option<i32>,
2657    _delegate: Option<&'a mut dyn common::Delegate>,
2658    _additional_params: HashMap<String, String>,
2659    _scopes: BTreeSet<String>,
2660}
2661
2662impl<'a, C> common::CallBuilder for PropertyAudienceExportListCall<'a, C> {}
2663
2664impl<'a, C> PropertyAudienceExportListCall<'a, C>
2665where
2666    C: common::Connector,
2667{
2668    /// Perform the operation you have build so far.
2669    pub async fn doit(mut self) -> common::Result<(common::Response, ListAudienceExportsResponse)> {
2670        use std::borrow::Cow;
2671        use std::io::{Read, Seek};
2672
2673        use common::{url::Params, ToParts};
2674        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2675
2676        let mut dd = common::DefaultDelegate;
2677        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2678        dlg.begin(common::MethodInfo {
2679            id: "analyticsdata.properties.audienceExports.list",
2680            http_method: hyper::Method::GET,
2681        });
2682
2683        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2684            if self._additional_params.contains_key(field) {
2685                dlg.finished(false);
2686                return Err(common::Error::FieldClash(field));
2687            }
2688        }
2689
2690        let mut params = Params::with_capacity(5 + self._additional_params.len());
2691        params.push("parent", self._parent);
2692        if let Some(value) = self._page_token.as_ref() {
2693            params.push("pageToken", value);
2694        }
2695        if let Some(value) = self._page_size.as_ref() {
2696            params.push("pageSize", value.to_string());
2697        }
2698
2699        params.extend(self._additional_params.iter());
2700
2701        params.push("alt", "json");
2702        let mut url = self.hub._base_url.clone() + "v1beta/{+parent}/audienceExports";
2703        if self._scopes.is_empty() {
2704            self._scopes
2705                .insert(Scope::AnalyticReadonly.as_ref().to_string());
2706        }
2707
2708        #[allow(clippy::single_element_loop)]
2709        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2710            url = params.uri_replacement(url, param_name, find_this, true);
2711        }
2712        {
2713            let to_remove = ["parent"];
2714            params.remove_params(&to_remove);
2715        }
2716
2717        let url = params.parse_with_url(&url);
2718
2719        loop {
2720            let token = match self
2721                .hub
2722                .auth
2723                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2724                .await
2725            {
2726                Ok(token) => token,
2727                Err(e) => match dlg.token(e) {
2728                    Ok(token) => token,
2729                    Err(e) => {
2730                        dlg.finished(false);
2731                        return Err(common::Error::MissingToken(e));
2732                    }
2733                },
2734            };
2735            let mut req_result = {
2736                let client = &self.hub.client;
2737                dlg.pre_request();
2738                let mut req_builder = hyper::Request::builder()
2739                    .method(hyper::Method::GET)
2740                    .uri(url.as_str())
2741                    .header(USER_AGENT, self.hub._user_agent.clone());
2742
2743                if let Some(token) = token.as_ref() {
2744                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2745                }
2746
2747                let request = req_builder
2748                    .header(CONTENT_LENGTH, 0_u64)
2749                    .body(common::to_body::<String>(None));
2750
2751                client.request(request.unwrap()).await
2752            };
2753
2754            match req_result {
2755                Err(err) => {
2756                    if let common::Retry::After(d) = dlg.http_error(&err) {
2757                        sleep(d).await;
2758                        continue;
2759                    }
2760                    dlg.finished(false);
2761                    return Err(common::Error::HttpError(err));
2762                }
2763                Ok(res) => {
2764                    let (mut parts, body) = res.into_parts();
2765                    let mut body = common::Body::new(body);
2766                    if !parts.status.is_success() {
2767                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2768                        let error = serde_json::from_str(&common::to_string(&bytes));
2769                        let response = common::to_response(parts, bytes.into());
2770
2771                        if let common::Retry::After(d) =
2772                            dlg.http_failure(&response, error.as_ref().ok())
2773                        {
2774                            sleep(d).await;
2775                            continue;
2776                        }
2777
2778                        dlg.finished(false);
2779
2780                        return Err(match error {
2781                            Ok(value) => common::Error::BadRequest(value),
2782                            _ => common::Error::Failure(response),
2783                        });
2784                    }
2785                    let response = {
2786                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2787                        let encoded = common::to_string(&bytes);
2788                        match serde_json::from_str(&encoded) {
2789                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2790                            Err(error) => {
2791                                dlg.response_json_decode_error(&encoded, &error);
2792                                return Err(common::Error::JsonDecodeError(
2793                                    encoded.to_string(),
2794                                    error,
2795                                ));
2796                            }
2797                        }
2798                    };
2799
2800                    dlg.finished(true);
2801                    return Ok(response);
2802                }
2803            }
2804        }
2805    }
2806
2807    /// Required. All audience exports for this property will be listed in the response. Format: `properties/{property}`
2808    ///
2809    /// Sets the *parent* path property to the given value.
2810    ///
2811    /// Even though the property as already been set when instantiating this call,
2812    /// we provide this method for API completeness.
2813    pub fn parent(mut self, new_value: &str) -> PropertyAudienceExportListCall<'a, C> {
2814        self._parent = new_value.to_string();
2815        self
2816    }
2817    /// Optional. A page token, received from a previous `ListAudienceExports` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAudienceExports` must match the call that provided the page token.
2818    ///
2819    /// Sets the *page token* query property to the given value.
2820    pub fn page_token(mut self, new_value: &str) -> PropertyAudienceExportListCall<'a, C> {
2821        self._page_token = Some(new_value.to_string());
2822        self
2823    }
2824    /// Optional. The maximum number of audience exports to return. The service may return fewer than this value. If unspecified, at most 200 audience exports will be returned. The maximum value is 1000 (higher values will be coerced to the maximum).
2825    ///
2826    /// Sets the *page size* query property to the given value.
2827    pub fn page_size(mut self, new_value: i32) -> PropertyAudienceExportListCall<'a, C> {
2828        self._page_size = Some(new_value);
2829        self
2830    }
2831    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2832    /// while executing the actual API request.
2833    ///
2834    /// ````text
2835    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2836    /// ````
2837    ///
2838    /// Sets the *delegate* property to the given value.
2839    pub fn delegate(
2840        mut self,
2841        new_value: &'a mut dyn common::Delegate,
2842    ) -> PropertyAudienceExportListCall<'a, C> {
2843        self._delegate = Some(new_value);
2844        self
2845    }
2846
2847    /// Set any additional parameter of the query string used in the request.
2848    /// It should be used to set parameters which are not yet available through their own
2849    /// setters.
2850    ///
2851    /// Please note that this method must not be used to set any of the known parameters
2852    /// which have their own setter method. If done anyway, the request will fail.
2853    ///
2854    /// # Additional Parameters
2855    ///
2856    /// * *$.xgafv* (query-string) - V1 error format.
2857    /// * *access_token* (query-string) - OAuth access token.
2858    /// * *alt* (query-string) - Data format for response.
2859    /// * *callback* (query-string) - JSONP
2860    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2861    /// * *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.
2862    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2863    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2864    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2865    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2866    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2867    pub fn param<T>(mut self, name: T, value: T) -> PropertyAudienceExportListCall<'a, C>
2868    where
2869        T: AsRef<str>,
2870    {
2871        self._additional_params
2872            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2873        self
2874    }
2875
2876    /// Identifies the authorization scope for the method you are building.
2877    ///
2878    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2879    /// [`Scope::AnalyticReadonly`].
2880    ///
2881    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2882    /// tokens for more than one scope.
2883    ///
2884    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2885    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2886    /// sufficient, a read-write scope will do as well.
2887    pub fn add_scope<St>(mut self, scope: St) -> PropertyAudienceExportListCall<'a, C>
2888    where
2889        St: AsRef<str>,
2890    {
2891        self._scopes.insert(String::from(scope.as_ref()));
2892        self
2893    }
2894    /// Identifies the authorization scope(s) for the method you are building.
2895    ///
2896    /// See [`Self::add_scope()`] for details.
2897    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyAudienceExportListCall<'a, C>
2898    where
2899        I: IntoIterator<Item = St>,
2900        St: AsRef<str>,
2901    {
2902        self._scopes
2903            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2904        self
2905    }
2906
2907    /// Removes all scopes, and no default scope will be used either.
2908    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2909    /// for details).
2910    pub fn clear_scopes(mut self) -> PropertyAudienceExportListCall<'a, C> {
2911        self._scopes.clear();
2912        self
2913    }
2914}
2915
2916/// Retrieves an audience export of users. After creating an audience, the users are not immediately available for exporting. First, a request to `CreateAudienceExport` is necessary to create an audience export of users, and then second, this method is used to retrieve the users in the audience export. See [Creating an Audience Export](https://developers.google.com/analytics/devguides/reporting/data/v1/audience-list-basics) for an introduction to Audience Exports with examples. Audiences in Google Analytics 4 allow you to segment your users in the ways that are important to your business. To learn more, see https://support.google.com/analytics/answer/9267572. Audience Export APIs have some methods at alpha and other methods at beta stability. The intention is to advance methods to beta stability after some feedback and adoption. To give your feedback on this API, complete the [Google Analytics Audience Export API Feedback](https://forms.gle/EeA5u5LW6PEggtCEA) form.
2917///
2918/// A builder for the *audienceExports.query* method supported by a *property* resource.
2919/// It is not used directly, but through a [`PropertyMethods`] instance.
2920///
2921/// # Example
2922///
2923/// Instantiate a resource method builder
2924///
2925/// ```test_harness,no_run
2926/// # extern crate hyper;
2927/// # extern crate hyper_rustls;
2928/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
2929/// use analyticsdata1_beta::api::QueryAudienceExportRequest;
2930/// # async fn dox() {
2931/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2932///
2933/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2934/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2935/// #     .with_native_roots()
2936/// #     .unwrap()
2937/// #     .https_only()
2938/// #     .enable_http2()
2939/// #     .build();
2940///
2941/// # let executor = hyper_util::rt::TokioExecutor::new();
2942/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2943/// #     secret,
2944/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2945/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2946/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2947/// #     ),
2948/// # ).build().await.unwrap();
2949///
2950/// # let client = hyper_util::client::legacy::Client::builder(
2951/// #     hyper_util::rt::TokioExecutor::new()
2952/// # )
2953/// # .build(
2954/// #     hyper_rustls::HttpsConnectorBuilder::new()
2955/// #         .with_native_roots()
2956/// #         .unwrap()
2957/// #         .https_or_http()
2958/// #         .enable_http2()
2959/// #         .build()
2960/// # );
2961/// # let mut hub = AnalyticsData::new(client, auth);
2962/// // As the method needs a request, you would usually fill it with the desired information
2963/// // into the respective structure. Some of the parts shown here might not be applicable !
2964/// // Values shown here are possibly random and not representative !
2965/// let mut req = QueryAudienceExportRequest::default();
2966///
2967/// // You can configure optional parameters by calling the respective setters at will, and
2968/// // execute the final call using `doit()`.
2969/// // Values shown here are possibly random and not representative !
2970/// let result = hub.properties().audience_exports_query(req, "name")
2971///              .doit().await;
2972/// # }
2973/// ```
2974pub struct PropertyAudienceExportQueryCall<'a, C>
2975where
2976    C: 'a,
2977{
2978    hub: &'a AnalyticsData<C>,
2979    _request: QueryAudienceExportRequest,
2980    _name: String,
2981    _delegate: Option<&'a mut dyn common::Delegate>,
2982    _additional_params: HashMap<String, String>,
2983    _scopes: BTreeSet<String>,
2984}
2985
2986impl<'a, C> common::CallBuilder for PropertyAudienceExportQueryCall<'a, C> {}
2987
2988impl<'a, C> PropertyAudienceExportQueryCall<'a, C>
2989where
2990    C: common::Connector,
2991{
2992    /// Perform the operation you have build so far.
2993    pub async fn doit(mut self) -> common::Result<(common::Response, QueryAudienceExportResponse)> {
2994        use std::borrow::Cow;
2995        use std::io::{Read, Seek};
2996
2997        use common::{url::Params, ToParts};
2998        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2999
3000        let mut dd = common::DefaultDelegate;
3001        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3002        dlg.begin(common::MethodInfo {
3003            id: "analyticsdata.properties.audienceExports.query",
3004            http_method: hyper::Method::POST,
3005        });
3006
3007        for &field in ["alt", "name"].iter() {
3008            if self._additional_params.contains_key(field) {
3009                dlg.finished(false);
3010                return Err(common::Error::FieldClash(field));
3011            }
3012        }
3013
3014        let mut params = Params::with_capacity(4 + self._additional_params.len());
3015        params.push("name", self._name);
3016
3017        params.extend(self._additional_params.iter());
3018
3019        params.push("alt", "json");
3020        let mut url = self.hub._base_url.clone() + "v1beta/{+name}:query";
3021        if self._scopes.is_empty() {
3022            self._scopes
3023                .insert(Scope::AnalyticReadonly.as_ref().to_string());
3024        }
3025
3026        #[allow(clippy::single_element_loop)]
3027        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3028            url = params.uri_replacement(url, param_name, find_this, true);
3029        }
3030        {
3031            let to_remove = ["name"];
3032            params.remove_params(&to_remove);
3033        }
3034
3035        let url = params.parse_with_url(&url);
3036
3037        let mut json_mime_type = mime::APPLICATION_JSON;
3038        let mut request_value_reader = {
3039            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3040            common::remove_json_null_values(&mut value);
3041            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3042            serde_json::to_writer(&mut dst, &value).unwrap();
3043            dst
3044        };
3045        let request_size = request_value_reader
3046            .seek(std::io::SeekFrom::End(0))
3047            .unwrap();
3048        request_value_reader
3049            .seek(std::io::SeekFrom::Start(0))
3050            .unwrap();
3051
3052        loop {
3053            let token = match self
3054                .hub
3055                .auth
3056                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3057                .await
3058            {
3059                Ok(token) => token,
3060                Err(e) => match dlg.token(e) {
3061                    Ok(token) => token,
3062                    Err(e) => {
3063                        dlg.finished(false);
3064                        return Err(common::Error::MissingToken(e));
3065                    }
3066                },
3067            };
3068            request_value_reader
3069                .seek(std::io::SeekFrom::Start(0))
3070                .unwrap();
3071            let mut req_result = {
3072                let client = &self.hub.client;
3073                dlg.pre_request();
3074                let mut req_builder = hyper::Request::builder()
3075                    .method(hyper::Method::POST)
3076                    .uri(url.as_str())
3077                    .header(USER_AGENT, self.hub._user_agent.clone());
3078
3079                if let Some(token) = token.as_ref() {
3080                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3081                }
3082
3083                let request = req_builder
3084                    .header(CONTENT_TYPE, json_mime_type.to_string())
3085                    .header(CONTENT_LENGTH, request_size as u64)
3086                    .body(common::to_body(
3087                        request_value_reader.get_ref().clone().into(),
3088                    ));
3089
3090                client.request(request.unwrap()).await
3091            };
3092
3093            match req_result {
3094                Err(err) => {
3095                    if let common::Retry::After(d) = dlg.http_error(&err) {
3096                        sleep(d).await;
3097                        continue;
3098                    }
3099                    dlg.finished(false);
3100                    return Err(common::Error::HttpError(err));
3101                }
3102                Ok(res) => {
3103                    let (mut parts, body) = res.into_parts();
3104                    let mut body = common::Body::new(body);
3105                    if !parts.status.is_success() {
3106                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3107                        let error = serde_json::from_str(&common::to_string(&bytes));
3108                        let response = common::to_response(parts, bytes.into());
3109
3110                        if let common::Retry::After(d) =
3111                            dlg.http_failure(&response, error.as_ref().ok())
3112                        {
3113                            sleep(d).await;
3114                            continue;
3115                        }
3116
3117                        dlg.finished(false);
3118
3119                        return Err(match error {
3120                            Ok(value) => common::Error::BadRequest(value),
3121                            _ => common::Error::Failure(response),
3122                        });
3123                    }
3124                    let response = {
3125                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3126                        let encoded = common::to_string(&bytes);
3127                        match serde_json::from_str(&encoded) {
3128                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3129                            Err(error) => {
3130                                dlg.response_json_decode_error(&encoded, &error);
3131                                return Err(common::Error::JsonDecodeError(
3132                                    encoded.to_string(),
3133                                    error,
3134                                ));
3135                            }
3136                        }
3137                    };
3138
3139                    dlg.finished(true);
3140                    return Ok(response);
3141                }
3142            }
3143        }
3144    }
3145
3146    ///
3147    /// Sets the *request* property to the given value.
3148    ///
3149    /// Even though the property as already been set when instantiating this call,
3150    /// we provide this method for API completeness.
3151    pub fn request(
3152        mut self,
3153        new_value: QueryAudienceExportRequest,
3154    ) -> PropertyAudienceExportQueryCall<'a, C> {
3155        self._request = new_value;
3156        self
3157    }
3158    /// Required. The name of the audience export to retrieve users from. Format: `properties/{property}/audienceExports/{audience_export}`
3159    ///
3160    /// Sets the *name* path property to the given value.
3161    ///
3162    /// Even though the property as already been set when instantiating this call,
3163    /// we provide this method for API completeness.
3164    pub fn name(mut self, new_value: &str) -> PropertyAudienceExportQueryCall<'a, C> {
3165        self._name = new_value.to_string();
3166        self
3167    }
3168    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3169    /// while executing the actual API request.
3170    ///
3171    /// ````text
3172    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3173    /// ````
3174    ///
3175    /// Sets the *delegate* property to the given value.
3176    pub fn delegate(
3177        mut self,
3178        new_value: &'a mut dyn common::Delegate,
3179    ) -> PropertyAudienceExportQueryCall<'a, C> {
3180        self._delegate = Some(new_value);
3181        self
3182    }
3183
3184    /// Set any additional parameter of the query string used in the request.
3185    /// It should be used to set parameters which are not yet available through their own
3186    /// setters.
3187    ///
3188    /// Please note that this method must not be used to set any of the known parameters
3189    /// which have their own setter method. If done anyway, the request will fail.
3190    ///
3191    /// # Additional Parameters
3192    ///
3193    /// * *$.xgafv* (query-string) - V1 error format.
3194    /// * *access_token* (query-string) - OAuth access token.
3195    /// * *alt* (query-string) - Data format for response.
3196    /// * *callback* (query-string) - JSONP
3197    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3198    /// * *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.
3199    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3200    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3201    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3202    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3203    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3204    pub fn param<T>(mut self, name: T, value: T) -> PropertyAudienceExportQueryCall<'a, C>
3205    where
3206        T: AsRef<str>,
3207    {
3208        self._additional_params
3209            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3210        self
3211    }
3212
3213    /// Identifies the authorization scope for the method you are building.
3214    ///
3215    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3216    /// [`Scope::AnalyticReadonly`].
3217    ///
3218    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3219    /// tokens for more than one scope.
3220    ///
3221    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3222    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3223    /// sufficient, a read-write scope will do as well.
3224    pub fn add_scope<St>(mut self, scope: St) -> PropertyAudienceExportQueryCall<'a, C>
3225    where
3226        St: AsRef<str>,
3227    {
3228        self._scopes.insert(String::from(scope.as_ref()));
3229        self
3230    }
3231    /// Identifies the authorization scope(s) for the method you are building.
3232    ///
3233    /// See [`Self::add_scope()`] for details.
3234    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyAudienceExportQueryCall<'a, C>
3235    where
3236        I: IntoIterator<Item = St>,
3237        St: AsRef<str>,
3238    {
3239        self._scopes
3240            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3241        self
3242    }
3243
3244    /// Removes all scopes, and no default scope will be used either.
3245    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3246    /// for details).
3247    pub fn clear_scopes(mut self) -> PropertyAudienceExportQueryCall<'a, C> {
3248        self._scopes.clear();
3249        self
3250    }
3251}
3252
3253/// Returns multiple pivot reports in a batch. All reports must be for the same Google Analytics property.
3254///
3255/// A builder for the *batchRunPivotReports* method supported by a *property* resource.
3256/// It is not used directly, but through a [`PropertyMethods`] instance.
3257///
3258/// # Example
3259///
3260/// Instantiate a resource method builder
3261///
3262/// ```test_harness,no_run
3263/// # extern crate hyper;
3264/// # extern crate hyper_rustls;
3265/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
3266/// use analyticsdata1_beta::api::BatchRunPivotReportsRequest;
3267/// # async fn dox() {
3268/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3269///
3270/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3271/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3272/// #     .with_native_roots()
3273/// #     .unwrap()
3274/// #     .https_only()
3275/// #     .enable_http2()
3276/// #     .build();
3277///
3278/// # let executor = hyper_util::rt::TokioExecutor::new();
3279/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3280/// #     secret,
3281/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3282/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3283/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3284/// #     ),
3285/// # ).build().await.unwrap();
3286///
3287/// # let client = hyper_util::client::legacy::Client::builder(
3288/// #     hyper_util::rt::TokioExecutor::new()
3289/// # )
3290/// # .build(
3291/// #     hyper_rustls::HttpsConnectorBuilder::new()
3292/// #         .with_native_roots()
3293/// #         .unwrap()
3294/// #         .https_or_http()
3295/// #         .enable_http2()
3296/// #         .build()
3297/// # );
3298/// # let mut hub = AnalyticsData::new(client, auth);
3299/// // As the method needs a request, you would usually fill it with the desired information
3300/// // into the respective structure. Some of the parts shown here might not be applicable !
3301/// // Values shown here are possibly random and not representative !
3302/// let mut req = BatchRunPivotReportsRequest::default();
3303///
3304/// // You can configure optional parameters by calling the respective setters at will, and
3305/// // execute the final call using `doit()`.
3306/// // Values shown here are possibly random and not representative !
3307/// let result = hub.properties().batch_run_pivot_reports(req, "property")
3308///              .doit().await;
3309/// # }
3310/// ```
3311pub struct PropertyBatchRunPivotReportCall<'a, C>
3312where
3313    C: 'a,
3314{
3315    hub: &'a AnalyticsData<C>,
3316    _request: BatchRunPivotReportsRequest,
3317    _property: String,
3318    _delegate: Option<&'a mut dyn common::Delegate>,
3319    _additional_params: HashMap<String, String>,
3320    _scopes: BTreeSet<String>,
3321}
3322
3323impl<'a, C> common::CallBuilder for PropertyBatchRunPivotReportCall<'a, C> {}
3324
3325impl<'a, C> PropertyBatchRunPivotReportCall<'a, C>
3326where
3327    C: common::Connector,
3328{
3329    /// Perform the operation you have build so far.
3330    pub async fn doit(
3331        mut self,
3332    ) -> common::Result<(common::Response, BatchRunPivotReportsResponse)> {
3333        use std::borrow::Cow;
3334        use std::io::{Read, Seek};
3335
3336        use common::{url::Params, ToParts};
3337        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3338
3339        let mut dd = common::DefaultDelegate;
3340        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3341        dlg.begin(common::MethodInfo {
3342            id: "analyticsdata.properties.batchRunPivotReports",
3343            http_method: hyper::Method::POST,
3344        });
3345
3346        for &field in ["alt", "property"].iter() {
3347            if self._additional_params.contains_key(field) {
3348                dlg.finished(false);
3349                return Err(common::Error::FieldClash(field));
3350            }
3351        }
3352
3353        let mut params = Params::with_capacity(4 + self._additional_params.len());
3354        params.push("property", self._property);
3355
3356        params.extend(self._additional_params.iter());
3357
3358        params.push("alt", "json");
3359        let mut url = self.hub._base_url.clone() + "v1beta/{+property}:batchRunPivotReports";
3360        if self._scopes.is_empty() {
3361            self._scopes
3362                .insert(Scope::AnalyticReadonly.as_ref().to_string());
3363        }
3364
3365        #[allow(clippy::single_element_loop)]
3366        for &(find_this, param_name) in [("{+property}", "property")].iter() {
3367            url = params.uri_replacement(url, param_name, find_this, true);
3368        }
3369        {
3370            let to_remove = ["property"];
3371            params.remove_params(&to_remove);
3372        }
3373
3374        let url = params.parse_with_url(&url);
3375
3376        let mut json_mime_type = mime::APPLICATION_JSON;
3377        let mut request_value_reader = {
3378            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3379            common::remove_json_null_values(&mut value);
3380            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3381            serde_json::to_writer(&mut dst, &value).unwrap();
3382            dst
3383        };
3384        let request_size = request_value_reader
3385            .seek(std::io::SeekFrom::End(0))
3386            .unwrap();
3387        request_value_reader
3388            .seek(std::io::SeekFrom::Start(0))
3389            .unwrap();
3390
3391        loop {
3392            let token = match self
3393                .hub
3394                .auth
3395                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3396                .await
3397            {
3398                Ok(token) => token,
3399                Err(e) => match dlg.token(e) {
3400                    Ok(token) => token,
3401                    Err(e) => {
3402                        dlg.finished(false);
3403                        return Err(common::Error::MissingToken(e));
3404                    }
3405                },
3406            };
3407            request_value_reader
3408                .seek(std::io::SeekFrom::Start(0))
3409                .unwrap();
3410            let mut req_result = {
3411                let client = &self.hub.client;
3412                dlg.pre_request();
3413                let mut req_builder = hyper::Request::builder()
3414                    .method(hyper::Method::POST)
3415                    .uri(url.as_str())
3416                    .header(USER_AGENT, self.hub._user_agent.clone());
3417
3418                if let Some(token) = token.as_ref() {
3419                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3420                }
3421
3422                let request = req_builder
3423                    .header(CONTENT_TYPE, json_mime_type.to_string())
3424                    .header(CONTENT_LENGTH, request_size as u64)
3425                    .body(common::to_body(
3426                        request_value_reader.get_ref().clone().into(),
3427                    ));
3428
3429                client.request(request.unwrap()).await
3430            };
3431
3432            match req_result {
3433                Err(err) => {
3434                    if let common::Retry::After(d) = dlg.http_error(&err) {
3435                        sleep(d).await;
3436                        continue;
3437                    }
3438                    dlg.finished(false);
3439                    return Err(common::Error::HttpError(err));
3440                }
3441                Ok(res) => {
3442                    let (mut parts, body) = res.into_parts();
3443                    let mut body = common::Body::new(body);
3444                    if !parts.status.is_success() {
3445                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3446                        let error = serde_json::from_str(&common::to_string(&bytes));
3447                        let response = common::to_response(parts, bytes.into());
3448
3449                        if let common::Retry::After(d) =
3450                            dlg.http_failure(&response, error.as_ref().ok())
3451                        {
3452                            sleep(d).await;
3453                            continue;
3454                        }
3455
3456                        dlg.finished(false);
3457
3458                        return Err(match error {
3459                            Ok(value) => common::Error::BadRequest(value),
3460                            _ => common::Error::Failure(response),
3461                        });
3462                    }
3463                    let response = {
3464                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3465                        let encoded = common::to_string(&bytes);
3466                        match serde_json::from_str(&encoded) {
3467                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3468                            Err(error) => {
3469                                dlg.response_json_decode_error(&encoded, &error);
3470                                return Err(common::Error::JsonDecodeError(
3471                                    encoded.to_string(),
3472                                    error,
3473                                ));
3474                            }
3475                        }
3476                    };
3477
3478                    dlg.finished(true);
3479                    return Ok(response);
3480                }
3481            }
3482        }
3483    }
3484
3485    ///
3486    /// Sets the *request* property to the given value.
3487    ///
3488    /// Even though the property as already been set when instantiating this call,
3489    /// we provide this method for API completeness.
3490    pub fn request(
3491        mut self,
3492        new_value: BatchRunPivotReportsRequest,
3493    ) -> PropertyBatchRunPivotReportCall<'a, C> {
3494        self._request = new_value;
3495        self
3496    }
3497    /// A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). This property must be specified for the batch. The property within RunPivotReportRequest may either be unspecified or consistent with this property. Example: properties/1234
3498    ///
3499    /// Sets the *property* path property to the given value.
3500    ///
3501    /// Even though the property as already been set when instantiating this call,
3502    /// we provide this method for API completeness.
3503    pub fn property(mut self, new_value: &str) -> PropertyBatchRunPivotReportCall<'a, C> {
3504        self._property = new_value.to_string();
3505        self
3506    }
3507    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3508    /// while executing the actual API request.
3509    ///
3510    /// ````text
3511    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3512    /// ````
3513    ///
3514    /// Sets the *delegate* property to the given value.
3515    pub fn delegate(
3516        mut self,
3517        new_value: &'a mut dyn common::Delegate,
3518    ) -> PropertyBatchRunPivotReportCall<'a, C> {
3519        self._delegate = Some(new_value);
3520        self
3521    }
3522
3523    /// Set any additional parameter of the query string used in the request.
3524    /// It should be used to set parameters which are not yet available through their own
3525    /// setters.
3526    ///
3527    /// Please note that this method must not be used to set any of the known parameters
3528    /// which have their own setter method. If done anyway, the request will fail.
3529    ///
3530    /// # Additional Parameters
3531    ///
3532    /// * *$.xgafv* (query-string) - V1 error format.
3533    /// * *access_token* (query-string) - OAuth access token.
3534    /// * *alt* (query-string) - Data format for response.
3535    /// * *callback* (query-string) - JSONP
3536    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3537    /// * *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.
3538    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3539    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3540    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3541    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3542    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3543    pub fn param<T>(mut self, name: T, value: T) -> PropertyBatchRunPivotReportCall<'a, C>
3544    where
3545        T: AsRef<str>,
3546    {
3547        self._additional_params
3548            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3549        self
3550    }
3551
3552    /// Identifies the authorization scope for the method you are building.
3553    ///
3554    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3555    /// [`Scope::AnalyticReadonly`].
3556    ///
3557    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3558    /// tokens for more than one scope.
3559    ///
3560    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3561    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3562    /// sufficient, a read-write scope will do as well.
3563    pub fn add_scope<St>(mut self, scope: St) -> PropertyBatchRunPivotReportCall<'a, C>
3564    where
3565        St: AsRef<str>,
3566    {
3567        self._scopes.insert(String::from(scope.as_ref()));
3568        self
3569    }
3570    /// Identifies the authorization scope(s) for the method you are building.
3571    ///
3572    /// See [`Self::add_scope()`] for details.
3573    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyBatchRunPivotReportCall<'a, C>
3574    where
3575        I: IntoIterator<Item = St>,
3576        St: AsRef<str>,
3577    {
3578        self._scopes
3579            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3580        self
3581    }
3582
3583    /// Removes all scopes, and no default scope will be used either.
3584    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3585    /// for details).
3586    pub fn clear_scopes(mut self) -> PropertyBatchRunPivotReportCall<'a, C> {
3587        self._scopes.clear();
3588        self
3589    }
3590}
3591
3592/// Returns multiple reports in a batch. All reports must be for the same Google Analytics property.
3593///
3594/// A builder for the *batchRunReports* method supported by a *property* resource.
3595/// It is not used directly, but through a [`PropertyMethods`] instance.
3596///
3597/// # Example
3598///
3599/// Instantiate a resource method builder
3600///
3601/// ```test_harness,no_run
3602/// # extern crate hyper;
3603/// # extern crate hyper_rustls;
3604/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
3605/// use analyticsdata1_beta::api::BatchRunReportsRequest;
3606/// # async fn dox() {
3607/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3608///
3609/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3610/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3611/// #     .with_native_roots()
3612/// #     .unwrap()
3613/// #     .https_only()
3614/// #     .enable_http2()
3615/// #     .build();
3616///
3617/// # let executor = hyper_util::rt::TokioExecutor::new();
3618/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3619/// #     secret,
3620/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3621/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3622/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3623/// #     ),
3624/// # ).build().await.unwrap();
3625///
3626/// # let client = hyper_util::client::legacy::Client::builder(
3627/// #     hyper_util::rt::TokioExecutor::new()
3628/// # )
3629/// # .build(
3630/// #     hyper_rustls::HttpsConnectorBuilder::new()
3631/// #         .with_native_roots()
3632/// #         .unwrap()
3633/// #         .https_or_http()
3634/// #         .enable_http2()
3635/// #         .build()
3636/// # );
3637/// # let mut hub = AnalyticsData::new(client, auth);
3638/// // As the method needs a request, you would usually fill it with the desired information
3639/// // into the respective structure. Some of the parts shown here might not be applicable !
3640/// // Values shown here are possibly random and not representative !
3641/// let mut req = BatchRunReportsRequest::default();
3642///
3643/// // You can configure optional parameters by calling the respective setters at will, and
3644/// // execute the final call using `doit()`.
3645/// // Values shown here are possibly random and not representative !
3646/// let result = hub.properties().batch_run_reports(req, "property")
3647///              .doit().await;
3648/// # }
3649/// ```
3650pub struct PropertyBatchRunReportCall<'a, C>
3651where
3652    C: 'a,
3653{
3654    hub: &'a AnalyticsData<C>,
3655    _request: BatchRunReportsRequest,
3656    _property: String,
3657    _delegate: Option<&'a mut dyn common::Delegate>,
3658    _additional_params: HashMap<String, String>,
3659    _scopes: BTreeSet<String>,
3660}
3661
3662impl<'a, C> common::CallBuilder for PropertyBatchRunReportCall<'a, C> {}
3663
3664impl<'a, C> PropertyBatchRunReportCall<'a, C>
3665where
3666    C: common::Connector,
3667{
3668    /// Perform the operation you have build so far.
3669    pub async fn doit(mut self) -> common::Result<(common::Response, BatchRunReportsResponse)> {
3670        use std::borrow::Cow;
3671        use std::io::{Read, Seek};
3672
3673        use common::{url::Params, ToParts};
3674        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3675
3676        let mut dd = common::DefaultDelegate;
3677        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3678        dlg.begin(common::MethodInfo {
3679            id: "analyticsdata.properties.batchRunReports",
3680            http_method: hyper::Method::POST,
3681        });
3682
3683        for &field in ["alt", "property"].iter() {
3684            if self._additional_params.contains_key(field) {
3685                dlg.finished(false);
3686                return Err(common::Error::FieldClash(field));
3687            }
3688        }
3689
3690        let mut params = Params::with_capacity(4 + self._additional_params.len());
3691        params.push("property", self._property);
3692
3693        params.extend(self._additional_params.iter());
3694
3695        params.push("alt", "json");
3696        let mut url = self.hub._base_url.clone() + "v1beta/{+property}:batchRunReports";
3697        if self._scopes.is_empty() {
3698            self._scopes
3699                .insert(Scope::AnalyticReadonly.as_ref().to_string());
3700        }
3701
3702        #[allow(clippy::single_element_loop)]
3703        for &(find_this, param_name) in [("{+property}", "property")].iter() {
3704            url = params.uri_replacement(url, param_name, find_this, true);
3705        }
3706        {
3707            let to_remove = ["property"];
3708            params.remove_params(&to_remove);
3709        }
3710
3711        let url = params.parse_with_url(&url);
3712
3713        let mut json_mime_type = mime::APPLICATION_JSON;
3714        let mut request_value_reader = {
3715            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3716            common::remove_json_null_values(&mut value);
3717            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3718            serde_json::to_writer(&mut dst, &value).unwrap();
3719            dst
3720        };
3721        let request_size = request_value_reader
3722            .seek(std::io::SeekFrom::End(0))
3723            .unwrap();
3724        request_value_reader
3725            .seek(std::io::SeekFrom::Start(0))
3726            .unwrap();
3727
3728        loop {
3729            let token = match self
3730                .hub
3731                .auth
3732                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3733                .await
3734            {
3735                Ok(token) => token,
3736                Err(e) => match dlg.token(e) {
3737                    Ok(token) => token,
3738                    Err(e) => {
3739                        dlg.finished(false);
3740                        return Err(common::Error::MissingToken(e));
3741                    }
3742                },
3743            };
3744            request_value_reader
3745                .seek(std::io::SeekFrom::Start(0))
3746                .unwrap();
3747            let mut req_result = {
3748                let client = &self.hub.client;
3749                dlg.pre_request();
3750                let mut req_builder = hyper::Request::builder()
3751                    .method(hyper::Method::POST)
3752                    .uri(url.as_str())
3753                    .header(USER_AGENT, self.hub._user_agent.clone());
3754
3755                if let Some(token) = token.as_ref() {
3756                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3757                }
3758
3759                let request = req_builder
3760                    .header(CONTENT_TYPE, json_mime_type.to_string())
3761                    .header(CONTENT_LENGTH, request_size as u64)
3762                    .body(common::to_body(
3763                        request_value_reader.get_ref().clone().into(),
3764                    ));
3765
3766                client.request(request.unwrap()).await
3767            };
3768
3769            match req_result {
3770                Err(err) => {
3771                    if let common::Retry::After(d) = dlg.http_error(&err) {
3772                        sleep(d).await;
3773                        continue;
3774                    }
3775                    dlg.finished(false);
3776                    return Err(common::Error::HttpError(err));
3777                }
3778                Ok(res) => {
3779                    let (mut parts, body) = res.into_parts();
3780                    let mut body = common::Body::new(body);
3781                    if !parts.status.is_success() {
3782                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3783                        let error = serde_json::from_str(&common::to_string(&bytes));
3784                        let response = common::to_response(parts, bytes.into());
3785
3786                        if let common::Retry::After(d) =
3787                            dlg.http_failure(&response, error.as_ref().ok())
3788                        {
3789                            sleep(d).await;
3790                            continue;
3791                        }
3792
3793                        dlg.finished(false);
3794
3795                        return Err(match error {
3796                            Ok(value) => common::Error::BadRequest(value),
3797                            _ => common::Error::Failure(response),
3798                        });
3799                    }
3800                    let response = {
3801                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3802                        let encoded = common::to_string(&bytes);
3803                        match serde_json::from_str(&encoded) {
3804                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3805                            Err(error) => {
3806                                dlg.response_json_decode_error(&encoded, &error);
3807                                return Err(common::Error::JsonDecodeError(
3808                                    encoded.to_string(),
3809                                    error,
3810                                ));
3811                            }
3812                        }
3813                    };
3814
3815                    dlg.finished(true);
3816                    return Ok(response);
3817                }
3818            }
3819        }
3820    }
3821
3822    ///
3823    /// Sets the *request* property to the given value.
3824    ///
3825    /// Even though the property as already been set when instantiating this call,
3826    /// we provide this method for API completeness.
3827    pub fn request(
3828        mut self,
3829        new_value: BatchRunReportsRequest,
3830    ) -> PropertyBatchRunReportCall<'a, C> {
3831        self._request = new_value;
3832        self
3833    }
3834    /// A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). This property must be specified for the batch. The property within RunReportRequest may either be unspecified or consistent with this property. Example: properties/1234
3835    ///
3836    /// Sets the *property* path property to the given value.
3837    ///
3838    /// Even though the property as already been set when instantiating this call,
3839    /// we provide this method for API completeness.
3840    pub fn property(mut self, new_value: &str) -> PropertyBatchRunReportCall<'a, C> {
3841        self._property = new_value.to_string();
3842        self
3843    }
3844    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3845    /// while executing the actual API request.
3846    ///
3847    /// ````text
3848    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3849    /// ````
3850    ///
3851    /// Sets the *delegate* property to the given value.
3852    pub fn delegate(
3853        mut self,
3854        new_value: &'a mut dyn common::Delegate,
3855    ) -> PropertyBatchRunReportCall<'a, C> {
3856        self._delegate = Some(new_value);
3857        self
3858    }
3859
3860    /// Set any additional parameter of the query string used in the request.
3861    /// It should be used to set parameters which are not yet available through their own
3862    /// setters.
3863    ///
3864    /// Please note that this method must not be used to set any of the known parameters
3865    /// which have their own setter method. If done anyway, the request will fail.
3866    ///
3867    /// # Additional Parameters
3868    ///
3869    /// * *$.xgafv* (query-string) - V1 error format.
3870    /// * *access_token* (query-string) - OAuth access token.
3871    /// * *alt* (query-string) - Data format for response.
3872    /// * *callback* (query-string) - JSONP
3873    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3874    /// * *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.
3875    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3876    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3877    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3878    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3879    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3880    pub fn param<T>(mut self, name: T, value: T) -> PropertyBatchRunReportCall<'a, C>
3881    where
3882        T: AsRef<str>,
3883    {
3884        self._additional_params
3885            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3886        self
3887    }
3888
3889    /// Identifies the authorization scope for the method you are building.
3890    ///
3891    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3892    /// [`Scope::AnalyticReadonly`].
3893    ///
3894    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3895    /// tokens for more than one scope.
3896    ///
3897    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3898    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3899    /// sufficient, a read-write scope will do as well.
3900    pub fn add_scope<St>(mut self, scope: St) -> PropertyBatchRunReportCall<'a, C>
3901    where
3902        St: AsRef<str>,
3903    {
3904        self._scopes.insert(String::from(scope.as_ref()));
3905        self
3906    }
3907    /// Identifies the authorization scope(s) for the method you are building.
3908    ///
3909    /// See [`Self::add_scope()`] for details.
3910    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyBatchRunReportCall<'a, C>
3911    where
3912        I: IntoIterator<Item = St>,
3913        St: AsRef<str>,
3914    {
3915        self._scopes
3916            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3917        self
3918    }
3919
3920    /// Removes all scopes, and no default scope will be used either.
3921    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3922    /// for details).
3923    pub fn clear_scopes(mut self) -> PropertyBatchRunReportCall<'a, C> {
3924        self._scopes.clear();
3925        self
3926    }
3927}
3928
3929/// This compatibility method lists dimensions and metrics that can be added to a report request and maintain compatibility. This method fails if the request's dimensions and metrics are incompatible. In Google Analytics, reports fail if they request incompatible dimensions and/or metrics; in that case, you will need to remove dimensions and/or metrics from the incompatible report until the report is compatible. The Realtime and Core reports have different compatibility rules. This method checks compatibility for Core reports.
3930///
3931/// A builder for the *checkCompatibility* method supported by a *property* resource.
3932/// It is not used directly, but through a [`PropertyMethods`] instance.
3933///
3934/// # Example
3935///
3936/// Instantiate a resource method builder
3937///
3938/// ```test_harness,no_run
3939/// # extern crate hyper;
3940/// # extern crate hyper_rustls;
3941/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
3942/// use analyticsdata1_beta::api::CheckCompatibilityRequest;
3943/// # async fn dox() {
3944/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3945///
3946/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3947/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3948/// #     .with_native_roots()
3949/// #     .unwrap()
3950/// #     .https_only()
3951/// #     .enable_http2()
3952/// #     .build();
3953///
3954/// # let executor = hyper_util::rt::TokioExecutor::new();
3955/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3956/// #     secret,
3957/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3958/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3959/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3960/// #     ),
3961/// # ).build().await.unwrap();
3962///
3963/// # let client = hyper_util::client::legacy::Client::builder(
3964/// #     hyper_util::rt::TokioExecutor::new()
3965/// # )
3966/// # .build(
3967/// #     hyper_rustls::HttpsConnectorBuilder::new()
3968/// #         .with_native_roots()
3969/// #         .unwrap()
3970/// #         .https_or_http()
3971/// #         .enable_http2()
3972/// #         .build()
3973/// # );
3974/// # let mut hub = AnalyticsData::new(client, auth);
3975/// // As the method needs a request, you would usually fill it with the desired information
3976/// // into the respective structure. Some of the parts shown here might not be applicable !
3977/// // Values shown here are possibly random and not representative !
3978/// let mut req = CheckCompatibilityRequest::default();
3979///
3980/// // You can configure optional parameters by calling the respective setters at will, and
3981/// // execute the final call using `doit()`.
3982/// // Values shown here are possibly random and not representative !
3983/// let result = hub.properties().check_compatibility(req, "property")
3984///              .doit().await;
3985/// # }
3986/// ```
3987pub struct PropertyCheckCompatibilityCall<'a, C>
3988where
3989    C: 'a,
3990{
3991    hub: &'a AnalyticsData<C>,
3992    _request: CheckCompatibilityRequest,
3993    _property: String,
3994    _delegate: Option<&'a mut dyn common::Delegate>,
3995    _additional_params: HashMap<String, String>,
3996    _scopes: BTreeSet<String>,
3997}
3998
3999impl<'a, C> common::CallBuilder for PropertyCheckCompatibilityCall<'a, C> {}
4000
4001impl<'a, C> PropertyCheckCompatibilityCall<'a, C>
4002where
4003    C: common::Connector,
4004{
4005    /// Perform the operation you have build so far.
4006    pub async fn doit(mut self) -> common::Result<(common::Response, CheckCompatibilityResponse)> {
4007        use std::borrow::Cow;
4008        use std::io::{Read, Seek};
4009
4010        use common::{url::Params, ToParts};
4011        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4012
4013        let mut dd = common::DefaultDelegate;
4014        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4015        dlg.begin(common::MethodInfo {
4016            id: "analyticsdata.properties.checkCompatibility",
4017            http_method: hyper::Method::POST,
4018        });
4019
4020        for &field in ["alt", "property"].iter() {
4021            if self._additional_params.contains_key(field) {
4022                dlg.finished(false);
4023                return Err(common::Error::FieldClash(field));
4024            }
4025        }
4026
4027        let mut params = Params::with_capacity(4 + self._additional_params.len());
4028        params.push("property", self._property);
4029
4030        params.extend(self._additional_params.iter());
4031
4032        params.push("alt", "json");
4033        let mut url = self.hub._base_url.clone() + "v1beta/{+property}:checkCompatibility";
4034        if self._scopes.is_empty() {
4035            self._scopes
4036                .insert(Scope::AnalyticReadonly.as_ref().to_string());
4037        }
4038
4039        #[allow(clippy::single_element_loop)]
4040        for &(find_this, param_name) in [("{+property}", "property")].iter() {
4041            url = params.uri_replacement(url, param_name, find_this, true);
4042        }
4043        {
4044            let to_remove = ["property"];
4045            params.remove_params(&to_remove);
4046        }
4047
4048        let url = params.parse_with_url(&url);
4049
4050        let mut json_mime_type = mime::APPLICATION_JSON;
4051        let mut request_value_reader = {
4052            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4053            common::remove_json_null_values(&mut value);
4054            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4055            serde_json::to_writer(&mut dst, &value).unwrap();
4056            dst
4057        };
4058        let request_size = request_value_reader
4059            .seek(std::io::SeekFrom::End(0))
4060            .unwrap();
4061        request_value_reader
4062            .seek(std::io::SeekFrom::Start(0))
4063            .unwrap();
4064
4065        loop {
4066            let token = match self
4067                .hub
4068                .auth
4069                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4070                .await
4071            {
4072                Ok(token) => token,
4073                Err(e) => match dlg.token(e) {
4074                    Ok(token) => token,
4075                    Err(e) => {
4076                        dlg.finished(false);
4077                        return Err(common::Error::MissingToken(e));
4078                    }
4079                },
4080            };
4081            request_value_reader
4082                .seek(std::io::SeekFrom::Start(0))
4083                .unwrap();
4084            let mut req_result = {
4085                let client = &self.hub.client;
4086                dlg.pre_request();
4087                let mut req_builder = hyper::Request::builder()
4088                    .method(hyper::Method::POST)
4089                    .uri(url.as_str())
4090                    .header(USER_AGENT, self.hub._user_agent.clone());
4091
4092                if let Some(token) = token.as_ref() {
4093                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4094                }
4095
4096                let request = req_builder
4097                    .header(CONTENT_TYPE, json_mime_type.to_string())
4098                    .header(CONTENT_LENGTH, request_size as u64)
4099                    .body(common::to_body(
4100                        request_value_reader.get_ref().clone().into(),
4101                    ));
4102
4103                client.request(request.unwrap()).await
4104            };
4105
4106            match req_result {
4107                Err(err) => {
4108                    if let common::Retry::After(d) = dlg.http_error(&err) {
4109                        sleep(d).await;
4110                        continue;
4111                    }
4112                    dlg.finished(false);
4113                    return Err(common::Error::HttpError(err));
4114                }
4115                Ok(res) => {
4116                    let (mut parts, body) = res.into_parts();
4117                    let mut body = common::Body::new(body);
4118                    if !parts.status.is_success() {
4119                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4120                        let error = serde_json::from_str(&common::to_string(&bytes));
4121                        let response = common::to_response(parts, bytes.into());
4122
4123                        if let common::Retry::After(d) =
4124                            dlg.http_failure(&response, error.as_ref().ok())
4125                        {
4126                            sleep(d).await;
4127                            continue;
4128                        }
4129
4130                        dlg.finished(false);
4131
4132                        return Err(match error {
4133                            Ok(value) => common::Error::BadRequest(value),
4134                            _ => common::Error::Failure(response),
4135                        });
4136                    }
4137                    let response = {
4138                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4139                        let encoded = common::to_string(&bytes);
4140                        match serde_json::from_str(&encoded) {
4141                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4142                            Err(error) => {
4143                                dlg.response_json_decode_error(&encoded, &error);
4144                                return Err(common::Error::JsonDecodeError(
4145                                    encoded.to_string(),
4146                                    error,
4147                                ));
4148                            }
4149                        }
4150                    };
4151
4152                    dlg.finished(true);
4153                    return Ok(response);
4154                }
4155            }
4156        }
4157    }
4158
4159    ///
4160    /// Sets the *request* property to the given value.
4161    ///
4162    /// Even though the property as already been set when instantiating this call,
4163    /// we provide this method for API completeness.
4164    pub fn request(
4165        mut self,
4166        new_value: CheckCompatibilityRequest,
4167    ) -> PropertyCheckCompatibilityCall<'a, C> {
4168        self._request = new_value;
4169        self
4170    }
4171    /// A Google Analytics property identifier whose events are tracked. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). `property` should be the same value as in your `runReport` request. Example: properties/1234
4172    ///
4173    /// Sets the *property* path property to the given value.
4174    ///
4175    /// Even though the property as already been set when instantiating this call,
4176    /// we provide this method for API completeness.
4177    pub fn property(mut self, new_value: &str) -> PropertyCheckCompatibilityCall<'a, C> {
4178        self._property = new_value.to_string();
4179        self
4180    }
4181    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4182    /// while executing the actual API request.
4183    ///
4184    /// ````text
4185    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4186    /// ````
4187    ///
4188    /// Sets the *delegate* property to the given value.
4189    pub fn delegate(
4190        mut self,
4191        new_value: &'a mut dyn common::Delegate,
4192    ) -> PropertyCheckCompatibilityCall<'a, C> {
4193        self._delegate = Some(new_value);
4194        self
4195    }
4196
4197    /// Set any additional parameter of the query string used in the request.
4198    /// It should be used to set parameters which are not yet available through their own
4199    /// setters.
4200    ///
4201    /// Please note that this method must not be used to set any of the known parameters
4202    /// which have their own setter method. If done anyway, the request will fail.
4203    ///
4204    /// # Additional Parameters
4205    ///
4206    /// * *$.xgafv* (query-string) - V1 error format.
4207    /// * *access_token* (query-string) - OAuth access token.
4208    /// * *alt* (query-string) - Data format for response.
4209    /// * *callback* (query-string) - JSONP
4210    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4211    /// * *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.
4212    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4213    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4214    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4215    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4216    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4217    pub fn param<T>(mut self, name: T, value: T) -> PropertyCheckCompatibilityCall<'a, C>
4218    where
4219        T: AsRef<str>,
4220    {
4221        self._additional_params
4222            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4223        self
4224    }
4225
4226    /// Identifies the authorization scope for the method you are building.
4227    ///
4228    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4229    /// [`Scope::AnalyticReadonly`].
4230    ///
4231    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4232    /// tokens for more than one scope.
4233    ///
4234    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4235    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4236    /// sufficient, a read-write scope will do as well.
4237    pub fn add_scope<St>(mut self, scope: St) -> PropertyCheckCompatibilityCall<'a, C>
4238    where
4239        St: AsRef<str>,
4240    {
4241        self._scopes.insert(String::from(scope.as_ref()));
4242        self
4243    }
4244    /// Identifies the authorization scope(s) for the method you are building.
4245    ///
4246    /// See [`Self::add_scope()`] for details.
4247    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyCheckCompatibilityCall<'a, C>
4248    where
4249        I: IntoIterator<Item = St>,
4250        St: AsRef<str>,
4251    {
4252        self._scopes
4253            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4254        self
4255    }
4256
4257    /// Removes all scopes, and no default scope will be used either.
4258    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4259    /// for details).
4260    pub fn clear_scopes(mut self) -> PropertyCheckCompatibilityCall<'a, C> {
4261        self._scopes.clear();
4262        self
4263    }
4264}
4265
4266/// Returns metadata for dimensions and metrics available in reporting methods. Used to explore the dimensions and metrics. In this method, a Google Analytics property identifier is specified in the request, and the metadata response includes Custom dimensions and metrics as well as Universal metadata. For example if a custom metric with parameter name `levels_unlocked` is registered to a property, the Metadata response will contain `customEvent:levels_unlocked`. Universal metadata are dimensions and metrics applicable to any property such as `country` and `totalUsers`.
4267///
4268/// A builder for the *getMetadata* method supported by a *property* resource.
4269/// It is not used directly, but through a [`PropertyMethods`] instance.
4270///
4271/// # Example
4272///
4273/// Instantiate a resource method builder
4274///
4275/// ```test_harness,no_run
4276/// # extern crate hyper;
4277/// # extern crate hyper_rustls;
4278/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
4279/// # async fn dox() {
4280/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4281///
4282/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4283/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4284/// #     .with_native_roots()
4285/// #     .unwrap()
4286/// #     .https_only()
4287/// #     .enable_http2()
4288/// #     .build();
4289///
4290/// # let executor = hyper_util::rt::TokioExecutor::new();
4291/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4292/// #     secret,
4293/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4294/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4295/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4296/// #     ),
4297/// # ).build().await.unwrap();
4298///
4299/// # let client = hyper_util::client::legacy::Client::builder(
4300/// #     hyper_util::rt::TokioExecutor::new()
4301/// # )
4302/// # .build(
4303/// #     hyper_rustls::HttpsConnectorBuilder::new()
4304/// #         .with_native_roots()
4305/// #         .unwrap()
4306/// #         .https_or_http()
4307/// #         .enable_http2()
4308/// #         .build()
4309/// # );
4310/// # let mut hub = AnalyticsData::new(client, auth);
4311/// // You can configure optional parameters by calling the respective setters at will, and
4312/// // execute the final call using `doit()`.
4313/// // Values shown here are possibly random and not representative !
4314/// let result = hub.properties().get_metadata("name")
4315///              .doit().await;
4316/// # }
4317/// ```
4318pub struct PropertyGetMetadataCall<'a, C>
4319where
4320    C: 'a,
4321{
4322    hub: &'a AnalyticsData<C>,
4323    _name: String,
4324    _delegate: Option<&'a mut dyn common::Delegate>,
4325    _additional_params: HashMap<String, String>,
4326    _scopes: BTreeSet<String>,
4327}
4328
4329impl<'a, C> common::CallBuilder for PropertyGetMetadataCall<'a, C> {}
4330
4331impl<'a, C> PropertyGetMetadataCall<'a, C>
4332where
4333    C: common::Connector,
4334{
4335    /// Perform the operation you have build so far.
4336    pub async fn doit(mut self) -> common::Result<(common::Response, Metadata)> {
4337        use std::borrow::Cow;
4338        use std::io::{Read, Seek};
4339
4340        use common::{url::Params, ToParts};
4341        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4342
4343        let mut dd = common::DefaultDelegate;
4344        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4345        dlg.begin(common::MethodInfo {
4346            id: "analyticsdata.properties.getMetadata",
4347            http_method: hyper::Method::GET,
4348        });
4349
4350        for &field in ["alt", "name"].iter() {
4351            if self._additional_params.contains_key(field) {
4352                dlg.finished(false);
4353                return Err(common::Error::FieldClash(field));
4354            }
4355        }
4356
4357        let mut params = Params::with_capacity(3 + self._additional_params.len());
4358        params.push("name", self._name);
4359
4360        params.extend(self._additional_params.iter());
4361
4362        params.push("alt", "json");
4363        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
4364        if self._scopes.is_empty() {
4365            self._scopes
4366                .insert(Scope::AnalyticReadonly.as_ref().to_string());
4367        }
4368
4369        #[allow(clippy::single_element_loop)]
4370        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4371            url = params.uri_replacement(url, param_name, find_this, true);
4372        }
4373        {
4374            let to_remove = ["name"];
4375            params.remove_params(&to_remove);
4376        }
4377
4378        let url = params.parse_with_url(&url);
4379
4380        loop {
4381            let token = match self
4382                .hub
4383                .auth
4384                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4385                .await
4386            {
4387                Ok(token) => token,
4388                Err(e) => match dlg.token(e) {
4389                    Ok(token) => token,
4390                    Err(e) => {
4391                        dlg.finished(false);
4392                        return Err(common::Error::MissingToken(e));
4393                    }
4394                },
4395            };
4396            let mut req_result = {
4397                let client = &self.hub.client;
4398                dlg.pre_request();
4399                let mut req_builder = hyper::Request::builder()
4400                    .method(hyper::Method::GET)
4401                    .uri(url.as_str())
4402                    .header(USER_AGENT, self.hub._user_agent.clone());
4403
4404                if let Some(token) = token.as_ref() {
4405                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4406                }
4407
4408                let request = req_builder
4409                    .header(CONTENT_LENGTH, 0_u64)
4410                    .body(common::to_body::<String>(None));
4411
4412                client.request(request.unwrap()).await
4413            };
4414
4415            match req_result {
4416                Err(err) => {
4417                    if let common::Retry::After(d) = dlg.http_error(&err) {
4418                        sleep(d).await;
4419                        continue;
4420                    }
4421                    dlg.finished(false);
4422                    return Err(common::Error::HttpError(err));
4423                }
4424                Ok(res) => {
4425                    let (mut parts, body) = res.into_parts();
4426                    let mut body = common::Body::new(body);
4427                    if !parts.status.is_success() {
4428                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4429                        let error = serde_json::from_str(&common::to_string(&bytes));
4430                        let response = common::to_response(parts, bytes.into());
4431
4432                        if let common::Retry::After(d) =
4433                            dlg.http_failure(&response, error.as_ref().ok())
4434                        {
4435                            sleep(d).await;
4436                            continue;
4437                        }
4438
4439                        dlg.finished(false);
4440
4441                        return Err(match error {
4442                            Ok(value) => common::Error::BadRequest(value),
4443                            _ => common::Error::Failure(response),
4444                        });
4445                    }
4446                    let response = {
4447                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4448                        let encoded = common::to_string(&bytes);
4449                        match serde_json::from_str(&encoded) {
4450                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4451                            Err(error) => {
4452                                dlg.response_json_decode_error(&encoded, &error);
4453                                return Err(common::Error::JsonDecodeError(
4454                                    encoded.to_string(),
4455                                    error,
4456                                ));
4457                            }
4458                        }
4459                    };
4460
4461                    dlg.finished(true);
4462                    return Ok(response);
4463                }
4464            }
4465        }
4466    }
4467
4468    /// Required. The resource name of the metadata to retrieve. This name field is specified in the URL path and not URL parameters. Property is a numeric Google Analytics property identifier. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Example: properties/1234/metadata Set the Property ID to 0 for dimensions and metrics common to all properties. In this special mode, this method will not return custom dimensions and metrics.
4469    ///
4470    /// Sets the *name* path property to the given value.
4471    ///
4472    /// Even though the property as already been set when instantiating this call,
4473    /// we provide this method for API completeness.
4474    pub fn name(mut self, new_value: &str) -> PropertyGetMetadataCall<'a, C> {
4475        self._name = new_value.to_string();
4476        self
4477    }
4478    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4479    /// while executing the actual API request.
4480    ///
4481    /// ````text
4482    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4483    /// ````
4484    ///
4485    /// Sets the *delegate* property to the given value.
4486    pub fn delegate(
4487        mut self,
4488        new_value: &'a mut dyn common::Delegate,
4489    ) -> PropertyGetMetadataCall<'a, C> {
4490        self._delegate = Some(new_value);
4491        self
4492    }
4493
4494    /// Set any additional parameter of the query string used in the request.
4495    /// It should be used to set parameters which are not yet available through their own
4496    /// setters.
4497    ///
4498    /// Please note that this method must not be used to set any of the known parameters
4499    /// which have their own setter method. If done anyway, the request will fail.
4500    ///
4501    /// # Additional Parameters
4502    ///
4503    /// * *$.xgafv* (query-string) - V1 error format.
4504    /// * *access_token* (query-string) - OAuth access token.
4505    /// * *alt* (query-string) - Data format for response.
4506    /// * *callback* (query-string) - JSONP
4507    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4508    /// * *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.
4509    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4510    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4511    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4512    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4513    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4514    pub fn param<T>(mut self, name: T, value: T) -> PropertyGetMetadataCall<'a, C>
4515    where
4516        T: AsRef<str>,
4517    {
4518        self._additional_params
4519            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4520        self
4521    }
4522
4523    /// Identifies the authorization scope for the method you are building.
4524    ///
4525    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4526    /// [`Scope::AnalyticReadonly`].
4527    ///
4528    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4529    /// tokens for more than one scope.
4530    ///
4531    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4532    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4533    /// sufficient, a read-write scope will do as well.
4534    pub fn add_scope<St>(mut self, scope: St) -> PropertyGetMetadataCall<'a, C>
4535    where
4536        St: AsRef<str>,
4537    {
4538        self._scopes.insert(String::from(scope.as_ref()));
4539        self
4540    }
4541    /// Identifies the authorization scope(s) for the method you are building.
4542    ///
4543    /// See [`Self::add_scope()`] for details.
4544    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyGetMetadataCall<'a, C>
4545    where
4546        I: IntoIterator<Item = St>,
4547        St: AsRef<str>,
4548    {
4549        self._scopes
4550            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4551        self
4552    }
4553
4554    /// Removes all scopes, and no default scope will be used either.
4555    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4556    /// for details).
4557    pub fn clear_scopes(mut self) -> PropertyGetMetadataCall<'a, C> {
4558        self._scopes.clear();
4559        self
4560    }
4561}
4562
4563/// Returns a customized pivot report of your Google Analytics event data. Pivot reports are more advanced and expressive formats than regular reports. In a pivot report, dimensions are only visible if they are included in a pivot. Multiple pivots can be specified to further dissect your data.
4564///
4565/// A builder for the *runPivotReport* method supported by a *property* resource.
4566/// It is not used directly, but through a [`PropertyMethods`] instance.
4567///
4568/// # Example
4569///
4570/// Instantiate a resource method builder
4571///
4572/// ```test_harness,no_run
4573/// # extern crate hyper;
4574/// # extern crate hyper_rustls;
4575/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
4576/// use analyticsdata1_beta::api::RunPivotReportRequest;
4577/// # async fn dox() {
4578/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4579///
4580/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4581/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4582/// #     .with_native_roots()
4583/// #     .unwrap()
4584/// #     .https_only()
4585/// #     .enable_http2()
4586/// #     .build();
4587///
4588/// # let executor = hyper_util::rt::TokioExecutor::new();
4589/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4590/// #     secret,
4591/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4592/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4593/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4594/// #     ),
4595/// # ).build().await.unwrap();
4596///
4597/// # let client = hyper_util::client::legacy::Client::builder(
4598/// #     hyper_util::rt::TokioExecutor::new()
4599/// # )
4600/// # .build(
4601/// #     hyper_rustls::HttpsConnectorBuilder::new()
4602/// #         .with_native_roots()
4603/// #         .unwrap()
4604/// #         .https_or_http()
4605/// #         .enable_http2()
4606/// #         .build()
4607/// # );
4608/// # let mut hub = AnalyticsData::new(client, auth);
4609/// // As the method needs a request, you would usually fill it with the desired information
4610/// // into the respective structure. Some of the parts shown here might not be applicable !
4611/// // Values shown here are possibly random and not representative !
4612/// let mut req = RunPivotReportRequest::default();
4613///
4614/// // You can configure optional parameters by calling the respective setters at will, and
4615/// // execute the final call using `doit()`.
4616/// // Values shown here are possibly random and not representative !
4617/// let result = hub.properties().run_pivot_report(req, "property")
4618///              .doit().await;
4619/// # }
4620/// ```
4621pub struct PropertyRunPivotReportCall<'a, C>
4622where
4623    C: 'a,
4624{
4625    hub: &'a AnalyticsData<C>,
4626    _request: RunPivotReportRequest,
4627    _property: String,
4628    _delegate: Option<&'a mut dyn common::Delegate>,
4629    _additional_params: HashMap<String, String>,
4630    _scopes: BTreeSet<String>,
4631}
4632
4633impl<'a, C> common::CallBuilder for PropertyRunPivotReportCall<'a, C> {}
4634
4635impl<'a, C> PropertyRunPivotReportCall<'a, C>
4636where
4637    C: common::Connector,
4638{
4639    /// Perform the operation you have build so far.
4640    pub async fn doit(mut self) -> common::Result<(common::Response, RunPivotReportResponse)> {
4641        use std::borrow::Cow;
4642        use std::io::{Read, Seek};
4643
4644        use common::{url::Params, ToParts};
4645        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4646
4647        let mut dd = common::DefaultDelegate;
4648        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4649        dlg.begin(common::MethodInfo {
4650            id: "analyticsdata.properties.runPivotReport",
4651            http_method: hyper::Method::POST,
4652        });
4653
4654        for &field in ["alt", "property"].iter() {
4655            if self._additional_params.contains_key(field) {
4656                dlg.finished(false);
4657                return Err(common::Error::FieldClash(field));
4658            }
4659        }
4660
4661        let mut params = Params::with_capacity(4 + self._additional_params.len());
4662        params.push("property", self._property);
4663
4664        params.extend(self._additional_params.iter());
4665
4666        params.push("alt", "json");
4667        let mut url = self.hub._base_url.clone() + "v1beta/{+property}:runPivotReport";
4668        if self._scopes.is_empty() {
4669            self._scopes
4670                .insert(Scope::AnalyticReadonly.as_ref().to_string());
4671        }
4672
4673        #[allow(clippy::single_element_loop)]
4674        for &(find_this, param_name) in [("{+property}", "property")].iter() {
4675            url = params.uri_replacement(url, param_name, find_this, true);
4676        }
4677        {
4678            let to_remove = ["property"];
4679            params.remove_params(&to_remove);
4680        }
4681
4682        let url = params.parse_with_url(&url);
4683
4684        let mut json_mime_type = mime::APPLICATION_JSON;
4685        let mut request_value_reader = {
4686            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4687            common::remove_json_null_values(&mut value);
4688            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4689            serde_json::to_writer(&mut dst, &value).unwrap();
4690            dst
4691        };
4692        let request_size = request_value_reader
4693            .seek(std::io::SeekFrom::End(0))
4694            .unwrap();
4695        request_value_reader
4696            .seek(std::io::SeekFrom::Start(0))
4697            .unwrap();
4698
4699        loop {
4700            let token = match self
4701                .hub
4702                .auth
4703                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4704                .await
4705            {
4706                Ok(token) => token,
4707                Err(e) => match dlg.token(e) {
4708                    Ok(token) => token,
4709                    Err(e) => {
4710                        dlg.finished(false);
4711                        return Err(common::Error::MissingToken(e));
4712                    }
4713                },
4714            };
4715            request_value_reader
4716                .seek(std::io::SeekFrom::Start(0))
4717                .unwrap();
4718            let mut req_result = {
4719                let client = &self.hub.client;
4720                dlg.pre_request();
4721                let mut req_builder = hyper::Request::builder()
4722                    .method(hyper::Method::POST)
4723                    .uri(url.as_str())
4724                    .header(USER_AGENT, self.hub._user_agent.clone());
4725
4726                if let Some(token) = token.as_ref() {
4727                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4728                }
4729
4730                let request = req_builder
4731                    .header(CONTENT_TYPE, json_mime_type.to_string())
4732                    .header(CONTENT_LENGTH, request_size as u64)
4733                    .body(common::to_body(
4734                        request_value_reader.get_ref().clone().into(),
4735                    ));
4736
4737                client.request(request.unwrap()).await
4738            };
4739
4740            match req_result {
4741                Err(err) => {
4742                    if let common::Retry::After(d) = dlg.http_error(&err) {
4743                        sleep(d).await;
4744                        continue;
4745                    }
4746                    dlg.finished(false);
4747                    return Err(common::Error::HttpError(err));
4748                }
4749                Ok(res) => {
4750                    let (mut parts, body) = res.into_parts();
4751                    let mut body = common::Body::new(body);
4752                    if !parts.status.is_success() {
4753                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4754                        let error = serde_json::from_str(&common::to_string(&bytes));
4755                        let response = common::to_response(parts, bytes.into());
4756
4757                        if let common::Retry::After(d) =
4758                            dlg.http_failure(&response, error.as_ref().ok())
4759                        {
4760                            sleep(d).await;
4761                            continue;
4762                        }
4763
4764                        dlg.finished(false);
4765
4766                        return Err(match error {
4767                            Ok(value) => common::Error::BadRequest(value),
4768                            _ => common::Error::Failure(response),
4769                        });
4770                    }
4771                    let response = {
4772                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4773                        let encoded = common::to_string(&bytes);
4774                        match serde_json::from_str(&encoded) {
4775                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4776                            Err(error) => {
4777                                dlg.response_json_decode_error(&encoded, &error);
4778                                return Err(common::Error::JsonDecodeError(
4779                                    encoded.to_string(),
4780                                    error,
4781                                ));
4782                            }
4783                        }
4784                    };
4785
4786                    dlg.finished(true);
4787                    return Ok(response);
4788                }
4789            }
4790        }
4791    }
4792
4793    ///
4794    /// Sets the *request* property to the given value.
4795    ///
4796    /// Even though the property as already been set when instantiating this call,
4797    /// we provide this method for API completeness.
4798    pub fn request(
4799        mut self,
4800        new_value: RunPivotReportRequest,
4801    ) -> PropertyRunPivotReportCall<'a, C> {
4802        self._request = new_value;
4803        self
4804    }
4805    /// A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Within a batch request, this property should either be unspecified or consistent with the batch-level property. Example: properties/1234
4806    ///
4807    /// Sets the *property* path property to the given value.
4808    ///
4809    /// Even though the property as already been set when instantiating this call,
4810    /// we provide this method for API completeness.
4811    pub fn property(mut self, new_value: &str) -> PropertyRunPivotReportCall<'a, C> {
4812        self._property = new_value.to_string();
4813        self
4814    }
4815    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4816    /// while executing the actual API request.
4817    ///
4818    /// ````text
4819    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4820    /// ````
4821    ///
4822    /// Sets the *delegate* property to the given value.
4823    pub fn delegate(
4824        mut self,
4825        new_value: &'a mut dyn common::Delegate,
4826    ) -> PropertyRunPivotReportCall<'a, C> {
4827        self._delegate = Some(new_value);
4828        self
4829    }
4830
4831    /// Set any additional parameter of the query string used in the request.
4832    /// It should be used to set parameters which are not yet available through their own
4833    /// setters.
4834    ///
4835    /// Please note that this method must not be used to set any of the known parameters
4836    /// which have their own setter method. If done anyway, the request will fail.
4837    ///
4838    /// # Additional Parameters
4839    ///
4840    /// * *$.xgafv* (query-string) - V1 error format.
4841    /// * *access_token* (query-string) - OAuth access token.
4842    /// * *alt* (query-string) - Data format for response.
4843    /// * *callback* (query-string) - JSONP
4844    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4845    /// * *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.
4846    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4847    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4848    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4849    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4850    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4851    pub fn param<T>(mut self, name: T, value: T) -> PropertyRunPivotReportCall<'a, C>
4852    where
4853        T: AsRef<str>,
4854    {
4855        self._additional_params
4856            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4857        self
4858    }
4859
4860    /// Identifies the authorization scope for the method you are building.
4861    ///
4862    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4863    /// [`Scope::AnalyticReadonly`].
4864    ///
4865    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4866    /// tokens for more than one scope.
4867    ///
4868    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4869    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4870    /// sufficient, a read-write scope will do as well.
4871    pub fn add_scope<St>(mut self, scope: St) -> PropertyRunPivotReportCall<'a, C>
4872    where
4873        St: AsRef<str>,
4874    {
4875        self._scopes.insert(String::from(scope.as_ref()));
4876        self
4877    }
4878    /// Identifies the authorization scope(s) for the method you are building.
4879    ///
4880    /// See [`Self::add_scope()`] for details.
4881    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyRunPivotReportCall<'a, C>
4882    where
4883        I: IntoIterator<Item = St>,
4884        St: AsRef<str>,
4885    {
4886        self._scopes
4887            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4888        self
4889    }
4890
4891    /// Removes all scopes, and no default scope will be used either.
4892    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4893    /// for details).
4894    pub fn clear_scopes(mut self) -> PropertyRunPivotReportCall<'a, C> {
4895        self._scopes.clear();
4896        self
4897    }
4898}
4899
4900/// Returns a customized report of realtime event data for your property. Events appear in realtime reports seconds after they have been sent to the Google Analytics. Realtime reports show events and usage data for the periods of time ranging from the present moment to 30 minutes ago (up to 60 minutes for Google Analytics 360 properties). For a guide to constructing realtime requests & understanding responses, see [Creating a Realtime Report](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-basics).
4901///
4902/// A builder for the *runRealtimeReport* method supported by a *property* resource.
4903/// It is not used directly, but through a [`PropertyMethods`] instance.
4904///
4905/// # Example
4906///
4907/// Instantiate a resource method builder
4908///
4909/// ```test_harness,no_run
4910/// # extern crate hyper;
4911/// # extern crate hyper_rustls;
4912/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
4913/// use analyticsdata1_beta::api::RunRealtimeReportRequest;
4914/// # async fn dox() {
4915/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4916///
4917/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4918/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4919/// #     .with_native_roots()
4920/// #     .unwrap()
4921/// #     .https_only()
4922/// #     .enable_http2()
4923/// #     .build();
4924///
4925/// # let executor = hyper_util::rt::TokioExecutor::new();
4926/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4927/// #     secret,
4928/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4929/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4930/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4931/// #     ),
4932/// # ).build().await.unwrap();
4933///
4934/// # let client = hyper_util::client::legacy::Client::builder(
4935/// #     hyper_util::rt::TokioExecutor::new()
4936/// # )
4937/// # .build(
4938/// #     hyper_rustls::HttpsConnectorBuilder::new()
4939/// #         .with_native_roots()
4940/// #         .unwrap()
4941/// #         .https_or_http()
4942/// #         .enable_http2()
4943/// #         .build()
4944/// # );
4945/// # let mut hub = AnalyticsData::new(client, auth);
4946/// // As the method needs a request, you would usually fill it with the desired information
4947/// // into the respective structure. Some of the parts shown here might not be applicable !
4948/// // Values shown here are possibly random and not representative !
4949/// let mut req = RunRealtimeReportRequest::default();
4950///
4951/// // You can configure optional parameters by calling the respective setters at will, and
4952/// // execute the final call using `doit()`.
4953/// // Values shown here are possibly random and not representative !
4954/// let result = hub.properties().run_realtime_report(req, "property")
4955///              .doit().await;
4956/// # }
4957/// ```
4958pub struct PropertyRunRealtimeReportCall<'a, C>
4959where
4960    C: 'a,
4961{
4962    hub: &'a AnalyticsData<C>,
4963    _request: RunRealtimeReportRequest,
4964    _property: String,
4965    _delegate: Option<&'a mut dyn common::Delegate>,
4966    _additional_params: HashMap<String, String>,
4967    _scopes: BTreeSet<String>,
4968}
4969
4970impl<'a, C> common::CallBuilder for PropertyRunRealtimeReportCall<'a, C> {}
4971
4972impl<'a, C> PropertyRunRealtimeReportCall<'a, C>
4973where
4974    C: common::Connector,
4975{
4976    /// Perform the operation you have build so far.
4977    pub async fn doit(mut self) -> common::Result<(common::Response, RunRealtimeReportResponse)> {
4978        use std::borrow::Cow;
4979        use std::io::{Read, Seek};
4980
4981        use common::{url::Params, ToParts};
4982        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4983
4984        let mut dd = common::DefaultDelegate;
4985        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4986        dlg.begin(common::MethodInfo {
4987            id: "analyticsdata.properties.runRealtimeReport",
4988            http_method: hyper::Method::POST,
4989        });
4990
4991        for &field in ["alt", "property"].iter() {
4992            if self._additional_params.contains_key(field) {
4993                dlg.finished(false);
4994                return Err(common::Error::FieldClash(field));
4995            }
4996        }
4997
4998        let mut params = Params::with_capacity(4 + self._additional_params.len());
4999        params.push("property", self._property);
5000
5001        params.extend(self._additional_params.iter());
5002
5003        params.push("alt", "json");
5004        let mut url = self.hub._base_url.clone() + "v1beta/{+property}:runRealtimeReport";
5005        if self._scopes.is_empty() {
5006            self._scopes
5007                .insert(Scope::AnalyticReadonly.as_ref().to_string());
5008        }
5009
5010        #[allow(clippy::single_element_loop)]
5011        for &(find_this, param_name) in [("{+property}", "property")].iter() {
5012            url = params.uri_replacement(url, param_name, find_this, true);
5013        }
5014        {
5015            let to_remove = ["property"];
5016            params.remove_params(&to_remove);
5017        }
5018
5019        let url = params.parse_with_url(&url);
5020
5021        let mut json_mime_type = mime::APPLICATION_JSON;
5022        let mut request_value_reader = {
5023            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5024            common::remove_json_null_values(&mut value);
5025            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5026            serde_json::to_writer(&mut dst, &value).unwrap();
5027            dst
5028        };
5029        let request_size = request_value_reader
5030            .seek(std::io::SeekFrom::End(0))
5031            .unwrap();
5032        request_value_reader
5033            .seek(std::io::SeekFrom::Start(0))
5034            .unwrap();
5035
5036        loop {
5037            let token = match self
5038                .hub
5039                .auth
5040                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5041                .await
5042            {
5043                Ok(token) => token,
5044                Err(e) => match dlg.token(e) {
5045                    Ok(token) => token,
5046                    Err(e) => {
5047                        dlg.finished(false);
5048                        return Err(common::Error::MissingToken(e));
5049                    }
5050                },
5051            };
5052            request_value_reader
5053                .seek(std::io::SeekFrom::Start(0))
5054                .unwrap();
5055            let mut req_result = {
5056                let client = &self.hub.client;
5057                dlg.pre_request();
5058                let mut req_builder = hyper::Request::builder()
5059                    .method(hyper::Method::POST)
5060                    .uri(url.as_str())
5061                    .header(USER_AGENT, self.hub._user_agent.clone());
5062
5063                if let Some(token) = token.as_ref() {
5064                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5065                }
5066
5067                let request = req_builder
5068                    .header(CONTENT_TYPE, json_mime_type.to_string())
5069                    .header(CONTENT_LENGTH, request_size as u64)
5070                    .body(common::to_body(
5071                        request_value_reader.get_ref().clone().into(),
5072                    ));
5073
5074                client.request(request.unwrap()).await
5075            };
5076
5077            match req_result {
5078                Err(err) => {
5079                    if let common::Retry::After(d) = dlg.http_error(&err) {
5080                        sleep(d).await;
5081                        continue;
5082                    }
5083                    dlg.finished(false);
5084                    return Err(common::Error::HttpError(err));
5085                }
5086                Ok(res) => {
5087                    let (mut parts, body) = res.into_parts();
5088                    let mut body = common::Body::new(body);
5089                    if !parts.status.is_success() {
5090                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5091                        let error = serde_json::from_str(&common::to_string(&bytes));
5092                        let response = common::to_response(parts, bytes.into());
5093
5094                        if let common::Retry::After(d) =
5095                            dlg.http_failure(&response, error.as_ref().ok())
5096                        {
5097                            sleep(d).await;
5098                            continue;
5099                        }
5100
5101                        dlg.finished(false);
5102
5103                        return Err(match error {
5104                            Ok(value) => common::Error::BadRequest(value),
5105                            _ => common::Error::Failure(response),
5106                        });
5107                    }
5108                    let response = {
5109                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5110                        let encoded = common::to_string(&bytes);
5111                        match serde_json::from_str(&encoded) {
5112                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5113                            Err(error) => {
5114                                dlg.response_json_decode_error(&encoded, &error);
5115                                return Err(common::Error::JsonDecodeError(
5116                                    encoded.to_string(),
5117                                    error,
5118                                ));
5119                            }
5120                        }
5121                    };
5122
5123                    dlg.finished(true);
5124                    return Ok(response);
5125                }
5126            }
5127        }
5128    }
5129
5130    ///
5131    /// Sets the *request* property to the given value.
5132    ///
5133    /// Even though the property as already been set when instantiating this call,
5134    /// we provide this method for API completeness.
5135    pub fn request(
5136        mut self,
5137        new_value: RunRealtimeReportRequest,
5138    ) -> PropertyRunRealtimeReportCall<'a, C> {
5139        self._request = new_value;
5140        self
5141    }
5142    /// A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Example: properties/1234
5143    ///
5144    /// Sets the *property* path property to the given value.
5145    ///
5146    /// Even though the property as already been set when instantiating this call,
5147    /// we provide this method for API completeness.
5148    pub fn property(mut self, new_value: &str) -> PropertyRunRealtimeReportCall<'a, C> {
5149        self._property = new_value.to_string();
5150        self
5151    }
5152    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5153    /// while executing the actual API request.
5154    ///
5155    /// ````text
5156    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5157    /// ````
5158    ///
5159    /// Sets the *delegate* property to the given value.
5160    pub fn delegate(
5161        mut self,
5162        new_value: &'a mut dyn common::Delegate,
5163    ) -> PropertyRunRealtimeReportCall<'a, C> {
5164        self._delegate = Some(new_value);
5165        self
5166    }
5167
5168    /// Set any additional parameter of the query string used in the request.
5169    /// It should be used to set parameters which are not yet available through their own
5170    /// setters.
5171    ///
5172    /// Please note that this method must not be used to set any of the known parameters
5173    /// which have their own setter method. If done anyway, the request will fail.
5174    ///
5175    /// # Additional Parameters
5176    ///
5177    /// * *$.xgafv* (query-string) - V1 error format.
5178    /// * *access_token* (query-string) - OAuth access token.
5179    /// * *alt* (query-string) - Data format for response.
5180    /// * *callback* (query-string) - JSONP
5181    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5182    /// * *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.
5183    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5184    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5185    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5186    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5187    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5188    pub fn param<T>(mut self, name: T, value: T) -> PropertyRunRealtimeReportCall<'a, C>
5189    where
5190        T: AsRef<str>,
5191    {
5192        self._additional_params
5193            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5194        self
5195    }
5196
5197    /// Identifies the authorization scope for the method you are building.
5198    ///
5199    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5200    /// [`Scope::AnalyticReadonly`].
5201    ///
5202    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5203    /// tokens for more than one scope.
5204    ///
5205    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5206    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5207    /// sufficient, a read-write scope will do as well.
5208    pub fn add_scope<St>(mut self, scope: St) -> PropertyRunRealtimeReportCall<'a, C>
5209    where
5210        St: AsRef<str>,
5211    {
5212        self._scopes.insert(String::from(scope.as_ref()));
5213        self
5214    }
5215    /// Identifies the authorization scope(s) for the method you are building.
5216    ///
5217    /// See [`Self::add_scope()`] for details.
5218    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyRunRealtimeReportCall<'a, C>
5219    where
5220        I: IntoIterator<Item = St>,
5221        St: AsRef<str>,
5222    {
5223        self._scopes
5224            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5225        self
5226    }
5227
5228    /// Removes all scopes, and no default scope will be used either.
5229    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5230    /// for details).
5231    pub fn clear_scopes(mut self) -> PropertyRunRealtimeReportCall<'a, C> {
5232        self._scopes.clear();
5233        self
5234    }
5235}
5236
5237/// Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the Google Analytics tracking code. The data returned from the API is as a table with columns for the requested dimensions and metrics. Metrics are individual measurements of user activity on your property, such as active users or event count. Dimensions break down metrics across some common criteria, such as country or event name. For a guide to constructing requests & understanding responses, see [Creating a Report](https://developers.google.com/analytics/devguides/reporting/data/v1/basics).
5238///
5239/// A builder for the *runReport* method supported by a *property* resource.
5240/// It is not used directly, but through a [`PropertyMethods`] instance.
5241///
5242/// # Example
5243///
5244/// Instantiate a resource method builder
5245///
5246/// ```test_harness,no_run
5247/// # extern crate hyper;
5248/// # extern crate hyper_rustls;
5249/// # extern crate google_analyticsdata1_beta as analyticsdata1_beta;
5250/// use analyticsdata1_beta::api::RunReportRequest;
5251/// # async fn dox() {
5252/// # use analyticsdata1_beta::{AnalyticsData, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5253///
5254/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5255/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5256/// #     .with_native_roots()
5257/// #     .unwrap()
5258/// #     .https_only()
5259/// #     .enable_http2()
5260/// #     .build();
5261///
5262/// # let executor = hyper_util::rt::TokioExecutor::new();
5263/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5264/// #     secret,
5265/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5266/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5267/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5268/// #     ),
5269/// # ).build().await.unwrap();
5270///
5271/// # let client = hyper_util::client::legacy::Client::builder(
5272/// #     hyper_util::rt::TokioExecutor::new()
5273/// # )
5274/// # .build(
5275/// #     hyper_rustls::HttpsConnectorBuilder::new()
5276/// #         .with_native_roots()
5277/// #         .unwrap()
5278/// #         .https_or_http()
5279/// #         .enable_http2()
5280/// #         .build()
5281/// # );
5282/// # let mut hub = AnalyticsData::new(client, auth);
5283/// // As the method needs a request, you would usually fill it with the desired information
5284/// // into the respective structure. Some of the parts shown here might not be applicable !
5285/// // Values shown here are possibly random and not representative !
5286/// let mut req = RunReportRequest::default();
5287///
5288/// // You can configure optional parameters by calling the respective setters at will, and
5289/// // execute the final call using `doit()`.
5290/// // Values shown here are possibly random and not representative !
5291/// let result = hub.properties().run_report(req, "property")
5292///              .doit().await;
5293/// # }
5294/// ```
5295pub struct PropertyRunReportCall<'a, C>
5296where
5297    C: 'a,
5298{
5299    hub: &'a AnalyticsData<C>,
5300    _request: RunReportRequest,
5301    _property: String,
5302    _delegate: Option<&'a mut dyn common::Delegate>,
5303    _additional_params: HashMap<String, String>,
5304    _scopes: BTreeSet<String>,
5305}
5306
5307impl<'a, C> common::CallBuilder for PropertyRunReportCall<'a, C> {}
5308
5309impl<'a, C> PropertyRunReportCall<'a, C>
5310where
5311    C: common::Connector,
5312{
5313    /// Perform the operation you have build so far.
5314    pub async fn doit(mut self) -> common::Result<(common::Response, RunReportResponse)> {
5315        use std::borrow::Cow;
5316        use std::io::{Read, Seek};
5317
5318        use common::{url::Params, ToParts};
5319        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5320
5321        let mut dd = common::DefaultDelegate;
5322        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5323        dlg.begin(common::MethodInfo {
5324            id: "analyticsdata.properties.runReport",
5325            http_method: hyper::Method::POST,
5326        });
5327
5328        for &field in ["alt", "property"].iter() {
5329            if self._additional_params.contains_key(field) {
5330                dlg.finished(false);
5331                return Err(common::Error::FieldClash(field));
5332            }
5333        }
5334
5335        let mut params = Params::with_capacity(4 + self._additional_params.len());
5336        params.push("property", self._property);
5337
5338        params.extend(self._additional_params.iter());
5339
5340        params.push("alt", "json");
5341        let mut url = self.hub._base_url.clone() + "v1beta/{+property}:runReport";
5342        if self._scopes.is_empty() {
5343            self._scopes
5344                .insert(Scope::AnalyticReadonly.as_ref().to_string());
5345        }
5346
5347        #[allow(clippy::single_element_loop)]
5348        for &(find_this, param_name) in [("{+property}", "property")].iter() {
5349            url = params.uri_replacement(url, param_name, find_this, true);
5350        }
5351        {
5352            let to_remove = ["property"];
5353            params.remove_params(&to_remove);
5354        }
5355
5356        let url = params.parse_with_url(&url);
5357
5358        let mut json_mime_type = mime::APPLICATION_JSON;
5359        let mut request_value_reader = {
5360            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5361            common::remove_json_null_values(&mut value);
5362            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5363            serde_json::to_writer(&mut dst, &value).unwrap();
5364            dst
5365        };
5366        let request_size = request_value_reader
5367            .seek(std::io::SeekFrom::End(0))
5368            .unwrap();
5369        request_value_reader
5370            .seek(std::io::SeekFrom::Start(0))
5371            .unwrap();
5372
5373        loop {
5374            let token = match self
5375                .hub
5376                .auth
5377                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5378                .await
5379            {
5380                Ok(token) => token,
5381                Err(e) => match dlg.token(e) {
5382                    Ok(token) => token,
5383                    Err(e) => {
5384                        dlg.finished(false);
5385                        return Err(common::Error::MissingToken(e));
5386                    }
5387                },
5388            };
5389            request_value_reader
5390                .seek(std::io::SeekFrom::Start(0))
5391                .unwrap();
5392            let mut req_result = {
5393                let client = &self.hub.client;
5394                dlg.pre_request();
5395                let mut req_builder = hyper::Request::builder()
5396                    .method(hyper::Method::POST)
5397                    .uri(url.as_str())
5398                    .header(USER_AGENT, self.hub._user_agent.clone());
5399
5400                if let Some(token) = token.as_ref() {
5401                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5402                }
5403
5404                let request = req_builder
5405                    .header(CONTENT_TYPE, json_mime_type.to_string())
5406                    .header(CONTENT_LENGTH, request_size as u64)
5407                    .body(common::to_body(
5408                        request_value_reader.get_ref().clone().into(),
5409                    ));
5410
5411                client.request(request.unwrap()).await
5412            };
5413
5414            match req_result {
5415                Err(err) => {
5416                    if let common::Retry::After(d) = dlg.http_error(&err) {
5417                        sleep(d).await;
5418                        continue;
5419                    }
5420                    dlg.finished(false);
5421                    return Err(common::Error::HttpError(err));
5422                }
5423                Ok(res) => {
5424                    let (mut parts, body) = res.into_parts();
5425                    let mut body = common::Body::new(body);
5426                    if !parts.status.is_success() {
5427                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5428                        let error = serde_json::from_str(&common::to_string(&bytes));
5429                        let response = common::to_response(parts, bytes.into());
5430
5431                        if let common::Retry::After(d) =
5432                            dlg.http_failure(&response, error.as_ref().ok())
5433                        {
5434                            sleep(d).await;
5435                            continue;
5436                        }
5437
5438                        dlg.finished(false);
5439
5440                        return Err(match error {
5441                            Ok(value) => common::Error::BadRequest(value),
5442                            _ => common::Error::Failure(response),
5443                        });
5444                    }
5445                    let response = {
5446                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5447                        let encoded = common::to_string(&bytes);
5448                        match serde_json::from_str(&encoded) {
5449                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5450                            Err(error) => {
5451                                dlg.response_json_decode_error(&encoded, &error);
5452                                return Err(common::Error::JsonDecodeError(
5453                                    encoded.to_string(),
5454                                    error,
5455                                ));
5456                            }
5457                        }
5458                    };
5459
5460                    dlg.finished(true);
5461                    return Ok(response);
5462                }
5463            }
5464        }
5465    }
5466
5467    ///
5468    /// Sets the *request* property to the given value.
5469    ///
5470    /// Even though the property as already been set when instantiating this call,
5471    /// we provide this method for API completeness.
5472    pub fn request(mut self, new_value: RunReportRequest) -> PropertyRunReportCall<'a, C> {
5473        self._request = new_value;
5474        self
5475    }
5476    /// A Google Analytics property identifier whose events are tracked. Specified in the URL path and not the body. To learn more, see [where to find your Property ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id). Within a batch request, this property should either be unspecified or consistent with the batch-level property. Example: properties/1234
5477    ///
5478    /// Sets the *property* path property to the given value.
5479    ///
5480    /// Even though the property as already been set when instantiating this call,
5481    /// we provide this method for API completeness.
5482    pub fn property(mut self, new_value: &str) -> PropertyRunReportCall<'a, C> {
5483        self._property = new_value.to_string();
5484        self
5485    }
5486    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5487    /// while executing the actual API request.
5488    ///
5489    /// ````text
5490    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5491    /// ````
5492    ///
5493    /// Sets the *delegate* property to the given value.
5494    pub fn delegate(
5495        mut self,
5496        new_value: &'a mut dyn common::Delegate,
5497    ) -> PropertyRunReportCall<'a, C> {
5498        self._delegate = Some(new_value);
5499        self
5500    }
5501
5502    /// Set any additional parameter of the query string used in the request.
5503    /// It should be used to set parameters which are not yet available through their own
5504    /// setters.
5505    ///
5506    /// Please note that this method must not be used to set any of the known parameters
5507    /// which have their own setter method. If done anyway, the request will fail.
5508    ///
5509    /// # Additional Parameters
5510    ///
5511    /// * *$.xgafv* (query-string) - V1 error format.
5512    /// * *access_token* (query-string) - OAuth access token.
5513    /// * *alt* (query-string) - Data format for response.
5514    /// * *callback* (query-string) - JSONP
5515    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5516    /// * *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.
5517    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5518    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5519    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5520    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5521    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5522    pub fn param<T>(mut self, name: T, value: T) -> PropertyRunReportCall<'a, C>
5523    where
5524        T: AsRef<str>,
5525    {
5526        self._additional_params
5527            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5528        self
5529    }
5530
5531    /// Identifies the authorization scope for the method you are building.
5532    ///
5533    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5534    /// [`Scope::AnalyticReadonly`].
5535    ///
5536    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5537    /// tokens for more than one scope.
5538    ///
5539    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5540    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5541    /// sufficient, a read-write scope will do as well.
5542    pub fn add_scope<St>(mut self, scope: St) -> PropertyRunReportCall<'a, C>
5543    where
5544        St: AsRef<str>,
5545    {
5546        self._scopes.insert(String::from(scope.as_ref()));
5547        self
5548    }
5549    /// Identifies the authorization scope(s) for the method you are building.
5550    ///
5551    /// See [`Self::add_scope()`] for details.
5552    pub fn add_scopes<I, St>(mut self, scopes: I) -> PropertyRunReportCall<'a, C>
5553    where
5554        I: IntoIterator<Item = St>,
5555        St: AsRef<str>,
5556    {
5557        self._scopes
5558            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5559        self
5560    }
5561
5562    /// Removes all scopes, and no default scope will be used either.
5563    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5564    /// for details).
5565    pub fn clear_scopes(mut self) -> PropertyRunReportCall<'a, C> {
5566        self._scopes.clear();
5567        self
5568    }
5569}