google_doubleclickbidmanager1d1/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 reports in DoubleClick Bid Manager
17 Full,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::Full => "https://www.googleapis.com/auth/doubleclickbidmanager",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::Full
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all DoubleClickBidManager related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_doubleclickbidmanager1d1 as doubleclickbidmanager1d1;
49/// use doubleclickbidmanager1d1::api::Query;
50/// use doubleclickbidmanager1d1::{Result, Error};
51/// # async fn dox() {
52/// use doubleclickbidmanager1d1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = DoubleClickBidManager::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = Query::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.queries().createquery(req)
99/// .asynchronous(true)
100/// .doit().await;
101///
102/// match result {
103/// Err(e) => match e {
104/// // The Error enum provides details about what exactly happened.
105/// // You can also just use its `Debug`, `Display` or `Error` traits
106/// Error::HttpError(_)
107/// |Error::Io(_)
108/// |Error::MissingAPIKey
109/// |Error::MissingToken(_)
110/// |Error::Cancelled
111/// |Error::UploadSizeLimitExceeded(_, _)
112/// |Error::Failure(_)
113/// |Error::BadRequest(_)
114/// |Error::FieldClash(_)
115/// |Error::JsonDecodeError(_, _) => println!("{}", e),
116/// },
117/// Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct DoubleClickBidManager<C> {
123 pub client: common::Client<C>,
124 pub auth: Box<dyn common::GetToken>,
125 _user_agent: String,
126 _base_url: String,
127 _root_url: String,
128}
129
130impl<C> common::Hub for DoubleClickBidManager<C> {}
131
132impl<'a, C> DoubleClickBidManager<C> {
133 pub fn new<A: 'static + common::GetToken>(
134 client: common::Client<C>,
135 auth: A,
136 ) -> DoubleClickBidManager<C> {
137 DoubleClickBidManager {
138 client,
139 auth: Box::new(auth),
140 _user_agent: "google-api-rust-client/7.0.0".to_string(),
141 _base_url: "https://doubleclickbidmanager.googleapis.com/doubleclickbidmanager/v1.1/"
142 .to_string(),
143 _root_url: "https://doubleclickbidmanager.googleapis.com/".to_string(),
144 }
145 }
146
147 pub fn queries(&'a self) -> QueryMethods<'a, C> {
148 QueryMethods { hub: self }
149 }
150 pub fn reports(&'a self) -> ReportMethods<'a, C> {
151 ReportMethods { hub: self }
152 }
153
154 /// Set the user-agent header field to use in all requests to the server.
155 /// It defaults to `google-api-rust-client/7.0.0`.
156 ///
157 /// Returns the previously set user-agent.
158 pub fn user_agent(&mut self, agent_name: String) -> String {
159 std::mem::replace(&mut self._user_agent, agent_name)
160 }
161
162 /// Set the base url to use in all requests to the server.
163 /// It defaults to `https://doubleclickbidmanager.googleapis.com/doubleclickbidmanager/v1.1/`.
164 ///
165 /// Returns the previously set base url.
166 pub fn base_url(&mut self, new_base_url: String) -> String {
167 std::mem::replace(&mut self._base_url, new_base_url)
168 }
169
170 /// Set the root url to use in all requests to the server.
171 /// It defaults to `https://doubleclickbidmanager.googleapis.com/`.
172 ///
173 /// Returns the previously set root url.
174 pub fn root_url(&mut self, new_root_url: String) -> String {
175 std::mem::replace(&mut self._root_url, new_root_url)
176 }
177}
178
179// ############
180// SCHEMAS ###
181// ##########
182/// A channel grouping defines a set of rules that can be used to categorize events in a path report.
183///
184/// This type is not used in any activity, and only used as *part* of another schema.
185///
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct ChannelGrouping {
190 /// The name to apply to an event that does not match any of the rules in the channel grouping.
191 #[serde(rename = "fallbackName")]
192 pub fallback_name: Option<String>,
193 /// Channel Grouping name.
194 pub name: Option<String>,
195 /// Rules within Channel Grouping. There is a limit of 100 rules that can be set per channel grouping.
196 pub rules: Option<Vec<Rule>>,
197}
198
199impl common::Part for ChannelGrouping {}
200
201/// DisjunctiveMatchStatement that OR's all contained filters.
202///
203/// This type is not used in any activity, and only used as *part* of another schema.
204///
205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
206#[serde_with::serde_as]
207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
208pub struct DisjunctiveMatchStatement {
209 /// Filters. There is a limit of 100 filters that can be set per disjunctive match statement.
210 #[serde(rename = "eventFilters")]
211 pub event_filters: Option<Vec<EventFilter>>,
212}
213
214impl common::Part for DisjunctiveMatchStatement {}
215
216/// Defines the type of filter to be applied to the path, a DV360 event dimension filter.
217///
218/// This type is not used in any activity, and only used as *part* of another schema.
219///
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct EventFilter {
224 /// Filter on a dimension.
225 #[serde(rename = "dimensionFilter")]
226 pub dimension_filter: Option<PathQueryOptionsFilter>,
227}
228
229impl common::Part for EventFilter {}
230
231/// Filter used to match traffic data in your report.
232///
233/// This type is not used in any activity, and only used as *part* of another schema.
234///
235#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
236#[serde_with::serde_as]
237#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
238pub struct FilterPair {
239 /// Filter type.
240 #[serde(rename = "type")]
241 pub type_: Option<String>,
242 /// Filter value.
243 pub value: Option<String>,
244}
245
246impl common::Part for FilterPair {}
247
248/// List queries response.
249///
250/// # Activities
251///
252/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
253/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
254///
255/// * [listqueries queries](QueryListqueryCall) (response)
256#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
257#[serde_with::serde_as]
258#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
259pub struct ListQueriesResponse {
260 /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#listQueriesResponse".
261 pub kind: Option<String>,
262 /// Next page's pagination token if one exists.
263 #[serde(rename = "nextPageToken")]
264 pub next_page_token: Option<String>,
265 /// Retrieved queries.
266 pub queries: Option<Vec<Query>>,
267}
268
269impl common::ResponseResult for ListQueriesResponse {}
270
271/// List reports response.
272///
273/// # Activities
274///
275/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
276/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
277///
278/// * [listreports reports](ReportListreportCall) (response)
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct ListReportsResponse {
283 /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#listReportsResponse".
284 pub kind: Option<String>,
285 /// Next page's pagination token if one exists.
286 #[serde(rename = "nextPageToken")]
287 pub next_page_token: Option<String>,
288 /// Retrieved reports.
289 pub reports: Option<Vec<Report>>,
290}
291
292impl common::ResponseResult for ListReportsResponse {}
293
294/// Additional query options.
295///
296/// This type is not used in any activity, and only used as *part* of another schema.
297///
298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
299#[serde_with::serde_as]
300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
301pub struct Options {
302 /// Set to true and filter your report by `FILTER_INSERTION_ORDER` or `FILTER_LINE_ITEM` to include data for audience lists specifically targeted by those items.
303 #[serde(rename = "includeOnlyTargetedUserLists")]
304 pub include_only_targeted_user_lists: Option<bool>,
305 /// Options that contain Path Filters and Custom Channel Groupings.
306 #[serde(rename = "pathQueryOptions")]
307 pub path_query_options: Option<PathQueryOptions>,
308}
309
310impl common::Part for Options {}
311
312/// Parameters of a query or report.
313///
314/// This type is not used in any activity, and only used as *part* of another schema.
315///
316#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
317#[serde_with::serde_as]
318#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
319pub struct Parameters {
320 /// Filters used to match traffic data in your report.
321 pub filters: Option<Vec<FilterPair>>,
322 /// Data is grouped by the filters listed in this field.
323 #[serde(rename = "groupBys")]
324 pub group_bys: Option<Vec<String>>,
325 /// Deprecated. This field is no longer in use.
326 #[serde(rename = "includeInviteData")]
327 pub include_invite_data: Option<bool>,
328 /// Metrics to include as columns in your report.
329 pub metrics: Option<Vec<String>>,
330 /// Additional query options.
331 pub options: Option<Options>,
332 /// Report type.
333 #[serde(rename = "type")]
334 pub type_: Option<String>,
335}
336
337impl common::Part for Parameters {}
338
339/// Path filters specify which paths to include in a report. A path is the result of combining DV360 events based on User ID to create a workflow of users' actions. When a path filter is set, the resulting report will only include paths that match the specified event at the specified position. All other paths will be excluded.
340///
341/// This type is not used in any activity, and only used as *part* of another schema.
342///
343#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
344#[serde_with::serde_as]
345#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
346pub struct PathFilter {
347 /// Filter on an event to be applied to some part of the path.
348 #[serde(rename = "eventFilters")]
349 pub event_filters: Option<Vec<EventFilter>>,
350 /// Indicates the position of the path the filter should match to (first, last, or any event in path).
351 #[serde(rename = "pathMatchPosition")]
352 pub path_match_position: Option<String>,
353}
354
355impl common::Part for PathFilter {}
356
357/// Path Query Options for Report Options.
358///
359/// This type is not used in any activity, and only used as *part* of another schema.
360///
361#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
362#[serde_with::serde_as]
363#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
364pub struct PathQueryOptions {
365 /// Custom Channel Groupings.
366 #[serde(rename = "channelGrouping")]
367 pub channel_grouping: Option<ChannelGrouping>,
368 /// Path Filters. There is a limit of 100 path filters that can be set per report.
369 #[serde(rename = "pathFilters")]
370 pub path_filters: Option<Vec<PathFilter>>,
371}
372
373impl common::Part for PathQueryOptions {}
374
375/// Dimension Filter on path events.
376///
377/// This type is not used in any activity, and only used as *part* of another schema.
378///
379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
380#[serde_with::serde_as]
381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
382pub struct PathQueryOptionsFilter {
383 /// Dimension the filter is applied to.
384 pub filter: Option<String>,
385 /// Indicates how the filter should be matched to the value.
386 #[serde(rename = "match")]
387 pub match_: Option<String>,
388 /// Value to filter on.
389 pub values: Option<Vec<String>>,
390}
391
392impl common::Part for PathQueryOptionsFilter {}
393
394/// Represents a query.
395///
396/// # Activities
397///
398/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
399/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
400///
401/// * [createquery queries](QueryCreatequeryCall) (request|response)
402/// * [getquery queries](QueryGetqueryCall) (response)
403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
404#[serde_with::serde_as]
405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
406pub struct Query {
407 /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#query".
408 pub kind: Option<String>,
409 /// Query metadata.
410 pub metadata: Option<QueryMetadata>,
411 /// Query parameters.
412 pub params: Option<Parameters>,
413 /// Query ID.
414 #[serde(rename = "queryId")]
415 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
416 pub query_id: Option<i64>,
417 /// The ending time for the data that is shown in the report. Note, reportDataEndTimeMs is required if metadata.dataRange is CUSTOM_DATES and ignored otherwise.
418 #[serde(rename = "reportDataEndTimeMs")]
419 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
420 pub report_data_end_time_ms: Option<i64>,
421 /// The starting time for the data that is shown in the report. Note, reportDataStartTimeMs is required if metadata.dataRange is CUSTOM_DATES and ignored otherwise.
422 #[serde(rename = "reportDataStartTimeMs")]
423 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
424 pub report_data_start_time_ms: Option<i64>,
425 /// Information on how often and when to run a query.
426 pub schedule: Option<QuerySchedule>,
427 /// Canonical timezone code for report data time. Defaults to America/New_York.
428 #[serde(rename = "timezoneCode")]
429 pub timezone_code: Option<String>,
430}
431
432impl common::RequestValue for Query {}
433impl common::ResponseResult for Query {}
434
435/// Query metadata.
436///
437/// This type is not used in any activity, and only used as *part* of another schema.
438///
439#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
440#[serde_with::serde_as]
441#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
442pub struct QueryMetadata {
443 /// Range of report data.
444 #[serde(rename = "dataRange")]
445 pub data_range: Option<String>,
446 /// Format of the generated report.
447 pub format: Option<String>,
448 /// The path to the location in Google Cloud Storage where the latest report is stored.
449 #[serde(rename = "googleCloudStoragePathForLatestReport")]
450 pub google_cloud_storage_path_for_latest_report: Option<String>,
451 /// The path in Google Drive for the latest report.
452 #[serde(rename = "googleDrivePathForLatestReport")]
453 pub google_drive_path_for_latest_report: Option<String>,
454 /// The time when the latest report started to run.
455 #[serde(rename = "latestReportRunTimeMs")]
456 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
457 pub latest_report_run_time_ms: Option<i64>,
458 /// Locale of the generated reports. Valid values are cs CZECH de GERMAN en ENGLISH es SPANISH fr FRENCH it ITALIAN ja JAPANESE ko KOREAN pl POLISH pt-BR BRAZILIAN_PORTUGUESE ru RUSSIAN tr TURKISH uk UKRAINIAN zh-CN CHINA_CHINESE zh-TW TAIWAN_CHINESE An locale string not in the list above will generate reports in English.
459 pub locale: Option<String>,
460 /// Number of reports that have been generated for the query.
461 #[serde(rename = "reportCount")]
462 pub report_count: Option<i32>,
463 /// Whether the latest report is currently running.
464 pub running: Option<bool>,
465 /// Whether to send an email notification when a report is ready. Default to false.
466 #[serde(rename = "sendNotification")]
467 pub send_notification: Option<bool>,
468 /// List of email addresses which are sent email notifications when the report is finished. Separate from sendNotification.
469 #[serde(rename = "shareEmailAddress")]
470 pub share_email_address: Option<Vec<String>>,
471 /// Query title. It is used to name the reports generated from this query.
472 pub title: Option<String>,
473}
474
475impl common::Part for QueryMetadata {}
476
477/// Information on how frequently and when to run a query.
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 QuerySchedule {
485 /// Datetime to periodically run the query until.
486 #[serde(rename = "endTimeMs")]
487 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
488 pub end_time_ms: Option<i64>,
489 /// How often the query is run.
490 pub frequency: Option<String>,
491 /// Time of day at which a new report will be generated, represented as minutes past midnight. Range is 0 to 1439. Only applies to scheduled reports.
492 #[serde(rename = "nextRunMinuteOfDay")]
493 pub next_run_minute_of_day: Option<i32>,
494 /// Canonical timezone code for report generation time. Defaults to America/New_York.
495 #[serde(rename = "nextRunTimezoneCode")]
496 pub next_run_timezone_code: Option<String>,
497 /// When to start running the query. Not applicable to `ONE_TIME` frequency.
498 #[serde(rename = "startTimeMs")]
499 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
500 pub start_time_ms: Option<i64>,
501}
502
503impl common::Part for QuerySchedule {}
504
505/// Represents a report.
506///
507/// # Activities
508///
509/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
510/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
511///
512/// * [listreports reports](ReportListreportCall) (none)
513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
514#[serde_with::serde_as]
515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
516pub struct Report {
517 /// Key used to identify a report.
518 pub key: Option<ReportKey>,
519 /// Report metadata.
520 pub metadata: Option<ReportMetadata>,
521 /// Report parameters.
522 pub params: Option<Parameters>,
523}
524
525impl common::Resource for Report {}
526
527/// An explanation of a report failure.
528///
529/// This type is not used in any activity, and only used as *part* of another schema.
530///
531#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
532#[serde_with::serde_as]
533#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
534pub struct ReportFailure {
535 /// Error code that shows why the report was not created.
536 #[serde(rename = "errorCode")]
537 pub error_code: Option<String>,
538}
539
540impl common::Part for ReportFailure {}
541
542/// Key used to identify a report.
543///
544/// This type is not used in any activity, and only used as *part* of another schema.
545///
546#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
547#[serde_with::serde_as]
548#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
549pub struct ReportKey {
550 /// Query ID.
551 #[serde(rename = "queryId")]
552 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
553 pub query_id: Option<i64>,
554 /// Report ID.
555 #[serde(rename = "reportId")]
556 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
557 pub report_id: Option<i64>,
558}
559
560impl common::Part for ReportKey {}
561
562/// Report metadata.
563///
564/// This type is not used in any activity, and only used as *part* of another schema.
565///
566#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
567#[serde_with::serde_as]
568#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
569pub struct ReportMetadata {
570 /// The path to the location in Google Cloud Storage where the report is stored.
571 #[serde(rename = "googleCloudStoragePath")]
572 pub google_cloud_storage_path: Option<String>,
573 /// The ending time for the data that is shown in the report.
574 #[serde(rename = "reportDataEndTimeMs")]
575 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
576 pub report_data_end_time_ms: Option<i64>,
577 /// The starting time for the data that is shown in the report.
578 #[serde(rename = "reportDataStartTimeMs")]
579 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
580 pub report_data_start_time_ms: Option<i64>,
581 /// Report status.
582 pub status: Option<ReportStatus>,
583}
584
585impl common::Part for ReportMetadata {}
586
587/// Report status.
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 ReportStatus {
595 /// If the report failed, this records the cause.
596 pub failure: Option<ReportFailure>,
597 /// The time when this report either completed successfully or failed.
598 #[serde(rename = "finishTimeMs")]
599 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
600 pub finish_time_ms: Option<i64>,
601 /// The file type of the report.
602 pub format: Option<String>,
603 /// The state of the report.
604 pub state: Option<String>,
605}
606
607impl common::Part for ReportStatus {}
608
609/// A Rule defines a name, and a boolean expression in [conjunctive normal form](http: //mathworld.wolfram.com/ConjunctiveNormalForm.html){.external} that can be // applied to a path event to determine if that name should be applied.
610///
611/// This type is not used in any activity, and only used as *part* of another schema.
612///
613#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
614#[serde_with::serde_as]
615#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
616pub struct Rule {
617 /// no description provided
618 #[serde(rename = "disjunctiveMatchStatements")]
619 pub disjunctive_match_statements: Option<Vec<DisjunctiveMatchStatement>>,
620 /// Rule name.
621 pub name: Option<String>,
622}
623
624impl common::Part for Rule {}
625
626/// Request to run a stored query to generate a report.
627///
628/// # Activities
629///
630/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
631/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
632///
633/// * [runquery queries](QueryRunqueryCall) (request)
634#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
635#[serde_with::serde_as]
636#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
637pub struct RunQueryRequest {
638 /// Report data range used to generate the report.
639 #[serde(rename = "dataRange")]
640 pub data_range: Option<String>,
641 /// The ending time for the data that is shown in the report. Note, reportDataEndTimeMs is required if dataRange is CUSTOM_DATES and ignored otherwise.
642 #[serde(rename = "reportDataEndTimeMs")]
643 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
644 pub report_data_end_time_ms: Option<i64>,
645 /// The starting time for the data that is shown in the report. Note, reportDataStartTimeMs is required if dataRange is CUSTOM_DATES and ignored otherwise.
646 #[serde(rename = "reportDataStartTimeMs")]
647 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
648 pub report_data_start_time_ms: Option<i64>,
649 /// Canonical timezone code for report data time. Defaults to America/New_York.
650 #[serde(rename = "timezoneCode")]
651 pub timezone_code: Option<String>,
652}
653
654impl common::RequestValue for RunQueryRequest {}
655
656// ###################
657// MethodBuilders ###
658// #################
659
660/// A builder providing access to all methods supported on *query* resources.
661/// It is not used directly, but through the [`DoubleClickBidManager`] hub.
662///
663/// # Example
664///
665/// Instantiate a resource builder
666///
667/// ```test_harness,no_run
668/// extern crate hyper;
669/// extern crate hyper_rustls;
670/// extern crate google_doubleclickbidmanager1d1 as doubleclickbidmanager1d1;
671///
672/// # async fn dox() {
673/// use doubleclickbidmanager1d1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
674///
675/// let secret: yup_oauth2::ApplicationSecret = Default::default();
676/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
677/// .with_native_roots()
678/// .unwrap()
679/// .https_only()
680/// .enable_http2()
681/// .build();
682///
683/// let executor = hyper_util::rt::TokioExecutor::new();
684/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
685/// secret,
686/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
687/// yup_oauth2::client::CustomHyperClientBuilder::from(
688/// hyper_util::client::legacy::Client::builder(executor).build(connector),
689/// ),
690/// ).build().await.unwrap();
691///
692/// let client = hyper_util::client::legacy::Client::builder(
693/// hyper_util::rt::TokioExecutor::new()
694/// )
695/// .build(
696/// hyper_rustls::HttpsConnectorBuilder::new()
697/// .with_native_roots()
698/// .unwrap()
699/// .https_or_http()
700/// .enable_http2()
701/// .build()
702/// );
703/// let mut hub = DoubleClickBidManager::new(client, auth);
704/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
705/// // like `createquery(...)`, `deletequery(...)`, `getquery(...)`, `listqueries(...)` and `runquery(...)`
706/// // to build up your call.
707/// let rb = hub.queries();
708/// # }
709/// ```
710pub struct QueryMethods<'a, C>
711where
712 C: 'a,
713{
714 hub: &'a DoubleClickBidManager<C>,
715}
716
717impl<'a, C> common::MethodsBuilder for QueryMethods<'a, C> {}
718
719impl<'a, C> QueryMethods<'a, C> {
720 /// Create a builder to help you perform the following task:
721 ///
722 /// Creates a query.
723 ///
724 /// # Arguments
725 ///
726 /// * `request` - No description provided.
727 pub fn createquery(&self, request: Query) -> QueryCreatequeryCall<'a, C> {
728 QueryCreatequeryCall {
729 hub: self.hub,
730 _request: request,
731 _asynchronous: Default::default(),
732 _delegate: Default::default(),
733 _additional_params: Default::default(),
734 _scopes: Default::default(),
735 }
736 }
737
738 /// Create a builder to help you perform the following task:
739 ///
740 /// Deletes a stored query as well as the associated stored reports.
741 ///
742 /// # Arguments
743 ///
744 /// * `queryId` - Query ID to delete.
745 pub fn deletequery(&self, query_id: i64) -> QueryDeletequeryCall<'a, C> {
746 QueryDeletequeryCall {
747 hub: self.hub,
748 _query_id: query_id,
749 _delegate: Default::default(),
750 _additional_params: Default::default(),
751 _scopes: Default::default(),
752 }
753 }
754
755 /// Create a builder to help you perform the following task:
756 ///
757 /// Retrieves a stored query.
758 ///
759 /// # Arguments
760 ///
761 /// * `queryId` - Query ID to retrieve.
762 pub fn getquery(&self, query_id: i64) -> QueryGetqueryCall<'a, C> {
763 QueryGetqueryCall {
764 hub: self.hub,
765 _query_id: query_id,
766 _delegate: Default::default(),
767 _additional_params: Default::default(),
768 _scopes: Default::default(),
769 }
770 }
771
772 /// Create a builder to help you perform the following task:
773 ///
774 /// Retrieves stored queries.
775 pub fn listqueries(&self) -> QueryListqueryCall<'a, C> {
776 QueryListqueryCall {
777 hub: self.hub,
778 _page_token: Default::default(),
779 _page_size: Default::default(),
780 _delegate: Default::default(),
781 _additional_params: Default::default(),
782 _scopes: Default::default(),
783 }
784 }
785
786 /// Create a builder to help you perform the following task:
787 ///
788 /// Runs a stored query to generate a report.
789 ///
790 /// # Arguments
791 ///
792 /// * `request` - No description provided.
793 /// * `queryId` - Query ID to run.
794 pub fn runquery(&self, request: RunQueryRequest, query_id: i64) -> QueryRunqueryCall<'a, C> {
795 QueryRunqueryCall {
796 hub: self.hub,
797 _request: request,
798 _query_id: query_id,
799 _asynchronous: Default::default(),
800 _delegate: Default::default(),
801 _additional_params: Default::default(),
802 _scopes: Default::default(),
803 }
804 }
805}
806
807/// A builder providing access to all methods supported on *report* resources.
808/// It is not used directly, but through the [`DoubleClickBidManager`] hub.
809///
810/// # Example
811///
812/// Instantiate a resource builder
813///
814/// ```test_harness,no_run
815/// extern crate hyper;
816/// extern crate hyper_rustls;
817/// extern crate google_doubleclickbidmanager1d1 as doubleclickbidmanager1d1;
818///
819/// # async fn dox() {
820/// use doubleclickbidmanager1d1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
821///
822/// let secret: yup_oauth2::ApplicationSecret = Default::default();
823/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
824/// .with_native_roots()
825/// .unwrap()
826/// .https_only()
827/// .enable_http2()
828/// .build();
829///
830/// let executor = hyper_util::rt::TokioExecutor::new();
831/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
832/// secret,
833/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
834/// yup_oauth2::client::CustomHyperClientBuilder::from(
835/// hyper_util::client::legacy::Client::builder(executor).build(connector),
836/// ),
837/// ).build().await.unwrap();
838///
839/// let client = hyper_util::client::legacy::Client::builder(
840/// hyper_util::rt::TokioExecutor::new()
841/// )
842/// .build(
843/// hyper_rustls::HttpsConnectorBuilder::new()
844/// .with_native_roots()
845/// .unwrap()
846/// .https_or_http()
847/// .enable_http2()
848/// .build()
849/// );
850/// let mut hub = DoubleClickBidManager::new(client, auth);
851/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
852/// // like `listreports(...)`
853/// // to build up your call.
854/// let rb = hub.reports();
855/// # }
856/// ```
857pub struct ReportMethods<'a, C>
858where
859 C: 'a,
860{
861 hub: &'a DoubleClickBidManager<C>,
862}
863
864impl<'a, C> common::MethodsBuilder for ReportMethods<'a, C> {}
865
866impl<'a, C> ReportMethods<'a, C> {
867 /// Create a builder to help you perform the following task:
868 ///
869 /// Retrieves stored reports.
870 ///
871 /// # Arguments
872 ///
873 /// * `queryId` - Query ID with which the reports are associated.
874 pub fn listreports(&self, query_id: i64) -> ReportListreportCall<'a, C> {
875 ReportListreportCall {
876 hub: self.hub,
877 _query_id: query_id,
878 _page_token: Default::default(),
879 _page_size: Default::default(),
880 _delegate: Default::default(),
881 _additional_params: Default::default(),
882 _scopes: Default::default(),
883 }
884 }
885}
886
887// ###################
888// CallBuilders ###
889// #################
890
891/// Creates a query.
892///
893/// A builder for the *createquery* method supported by a *query* resource.
894/// It is not used directly, but through a [`QueryMethods`] instance.
895///
896/// # Example
897///
898/// Instantiate a resource method builder
899///
900/// ```test_harness,no_run
901/// # extern crate hyper;
902/// # extern crate hyper_rustls;
903/// # extern crate google_doubleclickbidmanager1d1 as doubleclickbidmanager1d1;
904/// use doubleclickbidmanager1d1::api::Query;
905/// # async fn dox() {
906/// # use doubleclickbidmanager1d1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
907///
908/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
909/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
910/// # .with_native_roots()
911/// # .unwrap()
912/// # .https_only()
913/// # .enable_http2()
914/// # .build();
915///
916/// # let executor = hyper_util::rt::TokioExecutor::new();
917/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
918/// # secret,
919/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
920/// # yup_oauth2::client::CustomHyperClientBuilder::from(
921/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
922/// # ),
923/// # ).build().await.unwrap();
924///
925/// # let client = hyper_util::client::legacy::Client::builder(
926/// # hyper_util::rt::TokioExecutor::new()
927/// # )
928/// # .build(
929/// # hyper_rustls::HttpsConnectorBuilder::new()
930/// # .with_native_roots()
931/// # .unwrap()
932/// # .https_or_http()
933/// # .enable_http2()
934/// # .build()
935/// # );
936/// # let mut hub = DoubleClickBidManager::new(client, auth);
937/// // As the method needs a request, you would usually fill it with the desired information
938/// // into the respective structure. Some of the parts shown here might not be applicable !
939/// // Values shown here are possibly random and not representative !
940/// let mut req = Query::default();
941///
942/// // You can configure optional parameters by calling the respective setters at will, and
943/// // execute the final call using `doit()`.
944/// // Values shown here are possibly random and not representative !
945/// let result = hub.queries().createquery(req)
946/// .asynchronous(true)
947/// .doit().await;
948/// # }
949/// ```
950pub struct QueryCreatequeryCall<'a, C>
951where
952 C: 'a,
953{
954 hub: &'a DoubleClickBidManager<C>,
955 _request: Query,
956 _asynchronous: Option<bool>,
957 _delegate: Option<&'a mut dyn common::Delegate>,
958 _additional_params: HashMap<String, String>,
959 _scopes: BTreeSet<String>,
960}
961
962impl<'a, C> common::CallBuilder for QueryCreatequeryCall<'a, C> {}
963
964impl<'a, C> QueryCreatequeryCall<'a, C>
965where
966 C: common::Connector,
967{
968 /// Perform the operation you have build so far.
969 pub async fn doit(mut self) -> common::Result<(common::Response, Query)> {
970 use std::borrow::Cow;
971 use std::io::{Read, Seek};
972
973 use common::{url::Params, ToParts};
974 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
975
976 let mut dd = common::DefaultDelegate;
977 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
978 dlg.begin(common::MethodInfo {
979 id: "doubleclickbidmanager.queries.createquery",
980 http_method: hyper::Method::POST,
981 });
982
983 for &field in ["alt", "asynchronous"].iter() {
984 if self._additional_params.contains_key(field) {
985 dlg.finished(false);
986 return Err(common::Error::FieldClash(field));
987 }
988 }
989
990 let mut params = Params::with_capacity(4 + self._additional_params.len());
991 if let Some(value) = self._asynchronous.as_ref() {
992 params.push("asynchronous", value.to_string());
993 }
994
995 params.extend(self._additional_params.iter());
996
997 params.push("alt", "json");
998 let mut url = self.hub._base_url.clone() + "query";
999 if self._scopes.is_empty() {
1000 self._scopes.insert(Scope::Full.as_ref().to_string());
1001 }
1002
1003 let url = params.parse_with_url(&url);
1004
1005 let mut json_mime_type = mime::APPLICATION_JSON;
1006 let mut request_value_reader = {
1007 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1008 common::remove_json_null_values(&mut value);
1009 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1010 serde_json::to_writer(&mut dst, &value).unwrap();
1011 dst
1012 };
1013 let request_size = request_value_reader
1014 .seek(std::io::SeekFrom::End(0))
1015 .unwrap();
1016 request_value_reader
1017 .seek(std::io::SeekFrom::Start(0))
1018 .unwrap();
1019
1020 loop {
1021 let token = match self
1022 .hub
1023 .auth
1024 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1025 .await
1026 {
1027 Ok(token) => token,
1028 Err(e) => match dlg.token(e) {
1029 Ok(token) => token,
1030 Err(e) => {
1031 dlg.finished(false);
1032 return Err(common::Error::MissingToken(e));
1033 }
1034 },
1035 };
1036 request_value_reader
1037 .seek(std::io::SeekFrom::Start(0))
1038 .unwrap();
1039 let mut req_result = {
1040 let client = &self.hub.client;
1041 dlg.pre_request();
1042 let mut req_builder = hyper::Request::builder()
1043 .method(hyper::Method::POST)
1044 .uri(url.as_str())
1045 .header(USER_AGENT, self.hub._user_agent.clone());
1046
1047 if let Some(token) = token.as_ref() {
1048 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1049 }
1050
1051 let request = req_builder
1052 .header(CONTENT_TYPE, json_mime_type.to_string())
1053 .header(CONTENT_LENGTH, request_size as u64)
1054 .body(common::to_body(
1055 request_value_reader.get_ref().clone().into(),
1056 ));
1057
1058 client.request(request.unwrap()).await
1059 };
1060
1061 match req_result {
1062 Err(err) => {
1063 if let common::Retry::After(d) = dlg.http_error(&err) {
1064 sleep(d).await;
1065 continue;
1066 }
1067 dlg.finished(false);
1068 return Err(common::Error::HttpError(err));
1069 }
1070 Ok(res) => {
1071 let (mut parts, body) = res.into_parts();
1072 let mut body = common::Body::new(body);
1073 if !parts.status.is_success() {
1074 let bytes = common::to_bytes(body).await.unwrap_or_default();
1075 let error = serde_json::from_str(&common::to_string(&bytes));
1076 let response = common::to_response(parts, bytes.into());
1077
1078 if let common::Retry::After(d) =
1079 dlg.http_failure(&response, error.as_ref().ok())
1080 {
1081 sleep(d).await;
1082 continue;
1083 }
1084
1085 dlg.finished(false);
1086
1087 return Err(match error {
1088 Ok(value) => common::Error::BadRequest(value),
1089 _ => common::Error::Failure(response),
1090 });
1091 }
1092 let response = {
1093 let bytes = common::to_bytes(body).await.unwrap_or_default();
1094 let encoded = common::to_string(&bytes);
1095 match serde_json::from_str(&encoded) {
1096 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1097 Err(error) => {
1098 dlg.response_json_decode_error(&encoded, &error);
1099 return Err(common::Error::JsonDecodeError(
1100 encoded.to_string(),
1101 error,
1102 ));
1103 }
1104 }
1105 };
1106
1107 dlg.finished(true);
1108 return Ok(response);
1109 }
1110 }
1111 }
1112 }
1113
1114 ///
1115 /// Sets the *request* property to the given value.
1116 ///
1117 /// Even though the property as already been set when instantiating this call,
1118 /// we provide this method for API completeness.
1119 pub fn request(mut self, new_value: Query) -> QueryCreatequeryCall<'a, C> {
1120 self._request = new_value;
1121 self
1122 }
1123 /// If true, tries to run the query asynchronously. Only applicable when the frequency is ONE_TIME.
1124 ///
1125 /// Sets the *asynchronous* query property to the given value.
1126 pub fn asynchronous(mut self, new_value: bool) -> QueryCreatequeryCall<'a, C> {
1127 self._asynchronous = Some(new_value);
1128 self
1129 }
1130 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1131 /// while executing the actual API request.
1132 ///
1133 /// ````text
1134 /// It should be used to handle progress information, and to implement a certain level of resilience.
1135 /// ````
1136 ///
1137 /// Sets the *delegate* property to the given value.
1138 pub fn delegate(
1139 mut self,
1140 new_value: &'a mut dyn common::Delegate,
1141 ) -> QueryCreatequeryCall<'a, C> {
1142 self._delegate = Some(new_value);
1143 self
1144 }
1145
1146 /// Set any additional parameter of the query string used in the request.
1147 /// It should be used to set parameters which are not yet available through their own
1148 /// setters.
1149 ///
1150 /// Please note that this method must not be used to set any of the known parameters
1151 /// which have their own setter method. If done anyway, the request will fail.
1152 ///
1153 /// # Additional Parameters
1154 ///
1155 /// * *$.xgafv* (query-string) - V1 error format.
1156 /// * *access_token* (query-string) - OAuth access token.
1157 /// * *alt* (query-string) - Data format for response.
1158 /// * *callback* (query-string) - JSONP
1159 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1160 /// * *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.
1161 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1162 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1163 /// * *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.
1164 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1165 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1166 pub fn param<T>(mut self, name: T, value: T) -> QueryCreatequeryCall<'a, C>
1167 where
1168 T: AsRef<str>,
1169 {
1170 self._additional_params
1171 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1172 self
1173 }
1174
1175 /// Identifies the authorization scope for the method you are building.
1176 ///
1177 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1178 /// [`Scope::Full`].
1179 ///
1180 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1181 /// tokens for more than one scope.
1182 ///
1183 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1184 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1185 /// sufficient, a read-write scope will do as well.
1186 pub fn add_scope<St>(mut self, scope: St) -> QueryCreatequeryCall<'a, C>
1187 where
1188 St: AsRef<str>,
1189 {
1190 self._scopes.insert(String::from(scope.as_ref()));
1191 self
1192 }
1193 /// Identifies the authorization scope(s) for the method you are building.
1194 ///
1195 /// See [`Self::add_scope()`] for details.
1196 pub fn add_scopes<I, St>(mut self, scopes: I) -> QueryCreatequeryCall<'a, C>
1197 where
1198 I: IntoIterator<Item = St>,
1199 St: AsRef<str>,
1200 {
1201 self._scopes
1202 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1203 self
1204 }
1205
1206 /// Removes all scopes, and no default scope will be used either.
1207 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1208 /// for details).
1209 pub fn clear_scopes(mut self) -> QueryCreatequeryCall<'a, C> {
1210 self._scopes.clear();
1211 self
1212 }
1213}
1214
1215/// Deletes a stored query as well as the associated stored reports.
1216///
1217/// A builder for the *deletequery* method supported by a *query* resource.
1218/// It is not used directly, but through a [`QueryMethods`] instance.
1219///
1220/// # Example
1221///
1222/// Instantiate a resource method builder
1223///
1224/// ```test_harness,no_run
1225/// # extern crate hyper;
1226/// # extern crate hyper_rustls;
1227/// # extern crate google_doubleclickbidmanager1d1 as doubleclickbidmanager1d1;
1228/// # async fn dox() {
1229/// # use doubleclickbidmanager1d1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1230///
1231/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1232/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1233/// # .with_native_roots()
1234/// # .unwrap()
1235/// # .https_only()
1236/// # .enable_http2()
1237/// # .build();
1238///
1239/// # let executor = hyper_util::rt::TokioExecutor::new();
1240/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1241/// # secret,
1242/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1243/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1244/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1245/// # ),
1246/// # ).build().await.unwrap();
1247///
1248/// # let client = hyper_util::client::legacy::Client::builder(
1249/// # hyper_util::rt::TokioExecutor::new()
1250/// # )
1251/// # .build(
1252/// # hyper_rustls::HttpsConnectorBuilder::new()
1253/// # .with_native_roots()
1254/// # .unwrap()
1255/// # .https_or_http()
1256/// # .enable_http2()
1257/// # .build()
1258/// # );
1259/// # let mut hub = DoubleClickBidManager::new(client, auth);
1260/// // You can configure optional parameters by calling the respective setters at will, and
1261/// // execute the final call using `doit()`.
1262/// // Values shown here are possibly random and not representative !
1263/// let result = hub.queries().deletequery(-20)
1264/// .doit().await;
1265/// # }
1266/// ```
1267pub struct QueryDeletequeryCall<'a, C>
1268where
1269 C: 'a,
1270{
1271 hub: &'a DoubleClickBidManager<C>,
1272 _query_id: i64,
1273 _delegate: Option<&'a mut dyn common::Delegate>,
1274 _additional_params: HashMap<String, String>,
1275 _scopes: BTreeSet<String>,
1276}
1277
1278impl<'a, C> common::CallBuilder for QueryDeletequeryCall<'a, C> {}
1279
1280impl<'a, C> QueryDeletequeryCall<'a, C>
1281where
1282 C: common::Connector,
1283{
1284 /// Perform the operation you have build so far.
1285 pub async fn doit(mut self) -> common::Result<common::Response> {
1286 use std::borrow::Cow;
1287 use std::io::{Read, Seek};
1288
1289 use common::{url::Params, ToParts};
1290 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1291
1292 let mut dd = common::DefaultDelegate;
1293 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1294 dlg.begin(common::MethodInfo {
1295 id: "doubleclickbidmanager.queries.deletequery",
1296 http_method: hyper::Method::DELETE,
1297 });
1298
1299 for &field in ["queryId"].iter() {
1300 if self._additional_params.contains_key(field) {
1301 dlg.finished(false);
1302 return Err(common::Error::FieldClash(field));
1303 }
1304 }
1305
1306 let mut params = Params::with_capacity(2 + self._additional_params.len());
1307 params.push("queryId", self._query_id.to_string());
1308
1309 params.extend(self._additional_params.iter());
1310
1311 let mut url = self.hub._base_url.clone() + "query/{queryId}";
1312 if self._scopes.is_empty() {
1313 self._scopes.insert(Scope::Full.as_ref().to_string());
1314 }
1315
1316 #[allow(clippy::single_element_loop)]
1317 for &(find_this, param_name) in [("{queryId}", "queryId")].iter() {
1318 url = params.uri_replacement(url, param_name, find_this, false);
1319 }
1320 {
1321 let to_remove = ["queryId"];
1322 params.remove_params(&to_remove);
1323 }
1324
1325 let url = params.parse_with_url(&url);
1326
1327 loop {
1328 let token = match self
1329 .hub
1330 .auth
1331 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1332 .await
1333 {
1334 Ok(token) => token,
1335 Err(e) => match dlg.token(e) {
1336 Ok(token) => token,
1337 Err(e) => {
1338 dlg.finished(false);
1339 return Err(common::Error::MissingToken(e));
1340 }
1341 },
1342 };
1343 let mut req_result = {
1344 let client = &self.hub.client;
1345 dlg.pre_request();
1346 let mut req_builder = hyper::Request::builder()
1347 .method(hyper::Method::DELETE)
1348 .uri(url.as_str())
1349 .header(USER_AGENT, self.hub._user_agent.clone());
1350
1351 if let Some(token) = token.as_ref() {
1352 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1353 }
1354
1355 let request = req_builder
1356 .header(CONTENT_LENGTH, 0_u64)
1357 .body(common::to_body::<String>(None));
1358
1359 client.request(request.unwrap()).await
1360 };
1361
1362 match req_result {
1363 Err(err) => {
1364 if let common::Retry::After(d) = dlg.http_error(&err) {
1365 sleep(d).await;
1366 continue;
1367 }
1368 dlg.finished(false);
1369 return Err(common::Error::HttpError(err));
1370 }
1371 Ok(res) => {
1372 let (mut parts, body) = res.into_parts();
1373 let mut body = common::Body::new(body);
1374 if !parts.status.is_success() {
1375 let bytes = common::to_bytes(body).await.unwrap_or_default();
1376 let error = serde_json::from_str(&common::to_string(&bytes));
1377 let response = common::to_response(parts, bytes.into());
1378
1379 if let common::Retry::After(d) =
1380 dlg.http_failure(&response, error.as_ref().ok())
1381 {
1382 sleep(d).await;
1383 continue;
1384 }
1385
1386 dlg.finished(false);
1387
1388 return Err(match error {
1389 Ok(value) => common::Error::BadRequest(value),
1390 _ => common::Error::Failure(response),
1391 });
1392 }
1393 let response = common::Response::from_parts(parts, body);
1394
1395 dlg.finished(true);
1396 return Ok(response);
1397 }
1398 }
1399 }
1400 }
1401
1402 /// Query ID to delete.
1403 ///
1404 /// Sets the *query id* path property to the given value.
1405 ///
1406 /// Even though the property as already been set when instantiating this call,
1407 /// we provide this method for API completeness.
1408 pub fn query_id(mut self, new_value: i64) -> QueryDeletequeryCall<'a, C> {
1409 self._query_id = new_value;
1410 self
1411 }
1412 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1413 /// while executing the actual API request.
1414 ///
1415 /// ````text
1416 /// It should be used to handle progress information, and to implement a certain level of resilience.
1417 /// ````
1418 ///
1419 /// Sets the *delegate* property to the given value.
1420 pub fn delegate(
1421 mut self,
1422 new_value: &'a mut dyn common::Delegate,
1423 ) -> QueryDeletequeryCall<'a, C> {
1424 self._delegate = Some(new_value);
1425 self
1426 }
1427
1428 /// Set any additional parameter of the query string used in the request.
1429 /// It should be used to set parameters which are not yet available through their own
1430 /// setters.
1431 ///
1432 /// Please note that this method must not be used to set any of the known parameters
1433 /// which have their own setter method. If done anyway, the request will fail.
1434 ///
1435 /// # Additional Parameters
1436 ///
1437 /// * *$.xgafv* (query-string) - V1 error format.
1438 /// * *access_token* (query-string) - OAuth access token.
1439 /// * *alt* (query-string) - Data format for response.
1440 /// * *callback* (query-string) - JSONP
1441 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1442 /// * *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.
1443 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1444 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1445 /// * *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.
1446 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1447 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1448 pub fn param<T>(mut self, name: T, value: T) -> QueryDeletequeryCall<'a, C>
1449 where
1450 T: AsRef<str>,
1451 {
1452 self._additional_params
1453 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1454 self
1455 }
1456
1457 /// Identifies the authorization scope for the method you are building.
1458 ///
1459 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1460 /// [`Scope::Full`].
1461 ///
1462 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1463 /// tokens for more than one scope.
1464 ///
1465 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1466 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1467 /// sufficient, a read-write scope will do as well.
1468 pub fn add_scope<St>(mut self, scope: St) -> QueryDeletequeryCall<'a, C>
1469 where
1470 St: AsRef<str>,
1471 {
1472 self._scopes.insert(String::from(scope.as_ref()));
1473 self
1474 }
1475 /// Identifies the authorization scope(s) for the method you are building.
1476 ///
1477 /// See [`Self::add_scope()`] for details.
1478 pub fn add_scopes<I, St>(mut self, scopes: I) -> QueryDeletequeryCall<'a, C>
1479 where
1480 I: IntoIterator<Item = St>,
1481 St: AsRef<str>,
1482 {
1483 self._scopes
1484 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1485 self
1486 }
1487
1488 /// Removes all scopes, and no default scope will be used either.
1489 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1490 /// for details).
1491 pub fn clear_scopes(mut self) -> QueryDeletequeryCall<'a, C> {
1492 self._scopes.clear();
1493 self
1494 }
1495}
1496
1497/// Retrieves a stored query.
1498///
1499/// A builder for the *getquery* method supported by a *query* resource.
1500/// It is not used directly, but through a [`QueryMethods`] instance.
1501///
1502/// # Example
1503///
1504/// Instantiate a resource method builder
1505///
1506/// ```test_harness,no_run
1507/// # extern crate hyper;
1508/// # extern crate hyper_rustls;
1509/// # extern crate google_doubleclickbidmanager1d1 as doubleclickbidmanager1d1;
1510/// # async fn dox() {
1511/// # use doubleclickbidmanager1d1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1512///
1513/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1514/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1515/// # .with_native_roots()
1516/// # .unwrap()
1517/// # .https_only()
1518/// # .enable_http2()
1519/// # .build();
1520///
1521/// # let executor = hyper_util::rt::TokioExecutor::new();
1522/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1523/// # secret,
1524/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1525/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1526/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1527/// # ),
1528/// # ).build().await.unwrap();
1529///
1530/// # let client = hyper_util::client::legacy::Client::builder(
1531/// # hyper_util::rt::TokioExecutor::new()
1532/// # )
1533/// # .build(
1534/// # hyper_rustls::HttpsConnectorBuilder::new()
1535/// # .with_native_roots()
1536/// # .unwrap()
1537/// # .https_or_http()
1538/// # .enable_http2()
1539/// # .build()
1540/// # );
1541/// # let mut hub = DoubleClickBidManager::new(client, auth);
1542/// // You can configure optional parameters by calling the respective setters at will, and
1543/// // execute the final call using `doit()`.
1544/// // Values shown here are possibly random and not representative !
1545/// let result = hub.queries().getquery(-55)
1546/// .doit().await;
1547/// # }
1548/// ```
1549pub struct QueryGetqueryCall<'a, C>
1550where
1551 C: 'a,
1552{
1553 hub: &'a DoubleClickBidManager<C>,
1554 _query_id: i64,
1555 _delegate: Option<&'a mut dyn common::Delegate>,
1556 _additional_params: HashMap<String, String>,
1557 _scopes: BTreeSet<String>,
1558}
1559
1560impl<'a, C> common::CallBuilder for QueryGetqueryCall<'a, C> {}
1561
1562impl<'a, C> QueryGetqueryCall<'a, C>
1563where
1564 C: common::Connector,
1565{
1566 /// Perform the operation you have build so far.
1567 pub async fn doit(mut self) -> common::Result<(common::Response, Query)> {
1568 use std::borrow::Cow;
1569 use std::io::{Read, Seek};
1570
1571 use common::{url::Params, ToParts};
1572 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1573
1574 let mut dd = common::DefaultDelegate;
1575 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1576 dlg.begin(common::MethodInfo {
1577 id: "doubleclickbidmanager.queries.getquery",
1578 http_method: hyper::Method::GET,
1579 });
1580
1581 for &field in ["alt", "queryId"].iter() {
1582 if self._additional_params.contains_key(field) {
1583 dlg.finished(false);
1584 return Err(common::Error::FieldClash(field));
1585 }
1586 }
1587
1588 let mut params = Params::with_capacity(3 + self._additional_params.len());
1589 params.push("queryId", self._query_id.to_string());
1590
1591 params.extend(self._additional_params.iter());
1592
1593 params.push("alt", "json");
1594 let mut url = self.hub._base_url.clone() + "query/{queryId}";
1595 if self._scopes.is_empty() {
1596 self._scopes.insert(Scope::Full.as_ref().to_string());
1597 }
1598
1599 #[allow(clippy::single_element_loop)]
1600 for &(find_this, param_name) in [("{queryId}", "queryId")].iter() {
1601 url = params.uri_replacement(url, param_name, find_this, false);
1602 }
1603 {
1604 let to_remove = ["queryId"];
1605 params.remove_params(&to_remove);
1606 }
1607
1608 let url = params.parse_with_url(&url);
1609
1610 loop {
1611 let token = match self
1612 .hub
1613 .auth
1614 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1615 .await
1616 {
1617 Ok(token) => token,
1618 Err(e) => match dlg.token(e) {
1619 Ok(token) => token,
1620 Err(e) => {
1621 dlg.finished(false);
1622 return Err(common::Error::MissingToken(e));
1623 }
1624 },
1625 };
1626 let mut req_result = {
1627 let client = &self.hub.client;
1628 dlg.pre_request();
1629 let mut req_builder = hyper::Request::builder()
1630 .method(hyper::Method::GET)
1631 .uri(url.as_str())
1632 .header(USER_AGENT, self.hub._user_agent.clone());
1633
1634 if let Some(token) = token.as_ref() {
1635 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1636 }
1637
1638 let request = req_builder
1639 .header(CONTENT_LENGTH, 0_u64)
1640 .body(common::to_body::<String>(None));
1641
1642 client.request(request.unwrap()).await
1643 };
1644
1645 match req_result {
1646 Err(err) => {
1647 if let common::Retry::After(d) = dlg.http_error(&err) {
1648 sleep(d).await;
1649 continue;
1650 }
1651 dlg.finished(false);
1652 return Err(common::Error::HttpError(err));
1653 }
1654 Ok(res) => {
1655 let (mut parts, body) = res.into_parts();
1656 let mut body = common::Body::new(body);
1657 if !parts.status.is_success() {
1658 let bytes = common::to_bytes(body).await.unwrap_or_default();
1659 let error = serde_json::from_str(&common::to_string(&bytes));
1660 let response = common::to_response(parts, bytes.into());
1661
1662 if let common::Retry::After(d) =
1663 dlg.http_failure(&response, error.as_ref().ok())
1664 {
1665 sleep(d).await;
1666 continue;
1667 }
1668
1669 dlg.finished(false);
1670
1671 return Err(match error {
1672 Ok(value) => common::Error::BadRequest(value),
1673 _ => common::Error::Failure(response),
1674 });
1675 }
1676 let response = {
1677 let bytes = common::to_bytes(body).await.unwrap_or_default();
1678 let encoded = common::to_string(&bytes);
1679 match serde_json::from_str(&encoded) {
1680 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1681 Err(error) => {
1682 dlg.response_json_decode_error(&encoded, &error);
1683 return Err(common::Error::JsonDecodeError(
1684 encoded.to_string(),
1685 error,
1686 ));
1687 }
1688 }
1689 };
1690
1691 dlg.finished(true);
1692 return Ok(response);
1693 }
1694 }
1695 }
1696 }
1697
1698 /// Query ID to retrieve.
1699 ///
1700 /// Sets the *query id* path property to the given value.
1701 ///
1702 /// Even though the property as already been set when instantiating this call,
1703 /// we provide this method for API completeness.
1704 pub fn query_id(mut self, new_value: i64) -> QueryGetqueryCall<'a, C> {
1705 self._query_id = new_value;
1706 self
1707 }
1708 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1709 /// while executing the actual API request.
1710 ///
1711 /// ````text
1712 /// It should be used to handle progress information, and to implement a certain level of resilience.
1713 /// ````
1714 ///
1715 /// Sets the *delegate* property to the given value.
1716 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> QueryGetqueryCall<'a, C> {
1717 self._delegate = Some(new_value);
1718 self
1719 }
1720
1721 /// Set any additional parameter of the query string used in the request.
1722 /// It should be used to set parameters which are not yet available through their own
1723 /// setters.
1724 ///
1725 /// Please note that this method must not be used to set any of the known parameters
1726 /// which have their own setter method. If done anyway, the request will fail.
1727 ///
1728 /// # Additional Parameters
1729 ///
1730 /// * *$.xgafv* (query-string) - V1 error format.
1731 /// * *access_token* (query-string) - OAuth access token.
1732 /// * *alt* (query-string) - Data format for response.
1733 /// * *callback* (query-string) - JSONP
1734 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1735 /// * *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.
1736 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1737 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1738 /// * *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.
1739 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1740 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1741 pub fn param<T>(mut self, name: T, value: T) -> QueryGetqueryCall<'a, C>
1742 where
1743 T: AsRef<str>,
1744 {
1745 self._additional_params
1746 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1747 self
1748 }
1749
1750 /// Identifies the authorization scope for the method you are building.
1751 ///
1752 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1753 /// [`Scope::Full`].
1754 ///
1755 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1756 /// tokens for more than one scope.
1757 ///
1758 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1759 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1760 /// sufficient, a read-write scope will do as well.
1761 pub fn add_scope<St>(mut self, scope: St) -> QueryGetqueryCall<'a, C>
1762 where
1763 St: AsRef<str>,
1764 {
1765 self._scopes.insert(String::from(scope.as_ref()));
1766 self
1767 }
1768 /// Identifies the authorization scope(s) for the method you are building.
1769 ///
1770 /// See [`Self::add_scope()`] for details.
1771 pub fn add_scopes<I, St>(mut self, scopes: I) -> QueryGetqueryCall<'a, C>
1772 where
1773 I: IntoIterator<Item = St>,
1774 St: AsRef<str>,
1775 {
1776 self._scopes
1777 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1778 self
1779 }
1780
1781 /// Removes all scopes, and no default scope will be used either.
1782 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1783 /// for details).
1784 pub fn clear_scopes(mut self) -> QueryGetqueryCall<'a, C> {
1785 self._scopes.clear();
1786 self
1787 }
1788}
1789
1790/// Retrieves stored queries.
1791///
1792/// A builder for the *listqueries* method supported by a *query* resource.
1793/// It is not used directly, but through a [`QueryMethods`] instance.
1794///
1795/// # Example
1796///
1797/// Instantiate a resource method builder
1798///
1799/// ```test_harness,no_run
1800/// # extern crate hyper;
1801/// # extern crate hyper_rustls;
1802/// # extern crate google_doubleclickbidmanager1d1 as doubleclickbidmanager1d1;
1803/// # async fn dox() {
1804/// # use doubleclickbidmanager1d1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1805///
1806/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1807/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1808/// # .with_native_roots()
1809/// # .unwrap()
1810/// # .https_only()
1811/// # .enable_http2()
1812/// # .build();
1813///
1814/// # let executor = hyper_util::rt::TokioExecutor::new();
1815/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1816/// # secret,
1817/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1818/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1819/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1820/// # ),
1821/// # ).build().await.unwrap();
1822///
1823/// # let client = hyper_util::client::legacy::Client::builder(
1824/// # hyper_util::rt::TokioExecutor::new()
1825/// # )
1826/// # .build(
1827/// # hyper_rustls::HttpsConnectorBuilder::new()
1828/// # .with_native_roots()
1829/// # .unwrap()
1830/// # .https_or_http()
1831/// # .enable_http2()
1832/// # .build()
1833/// # );
1834/// # let mut hub = DoubleClickBidManager::new(client, auth);
1835/// // You can configure optional parameters by calling the respective setters at will, and
1836/// // execute the final call using `doit()`.
1837/// // Values shown here are possibly random and not representative !
1838/// let result = hub.queries().listqueries()
1839/// .page_token("gubergren")
1840/// .page_size(-51)
1841/// .doit().await;
1842/// # }
1843/// ```
1844pub struct QueryListqueryCall<'a, C>
1845where
1846 C: 'a,
1847{
1848 hub: &'a DoubleClickBidManager<C>,
1849 _page_token: Option<String>,
1850 _page_size: Option<i32>,
1851 _delegate: Option<&'a mut dyn common::Delegate>,
1852 _additional_params: HashMap<String, String>,
1853 _scopes: BTreeSet<String>,
1854}
1855
1856impl<'a, C> common::CallBuilder for QueryListqueryCall<'a, C> {}
1857
1858impl<'a, C> QueryListqueryCall<'a, C>
1859where
1860 C: common::Connector,
1861{
1862 /// Perform the operation you have build so far.
1863 pub async fn doit(mut self) -> common::Result<(common::Response, ListQueriesResponse)> {
1864 use std::borrow::Cow;
1865 use std::io::{Read, Seek};
1866
1867 use common::{url::Params, ToParts};
1868 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1869
1870 let mut dd = common::DefaultDelegate;
1871 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1872 dlg.begin(common::MethodInfo {
1873 id: "doubleclickbidmanager.queries.listqueries",
1874 http_method: hyper::Method::GET,
1875 });
1876
1877 for &field in ["alt", "pageToken", "pageSize"].iter() {
1878 if self._additional_params.contains_key(field) {
1879 dlg.finished(false);
1880 return Err(common::Error::FieldClash(field));
1881 }
1882 }
1883
1884 let mut params = Params::with_capacity(4 + self._additional_params.len());
1885 if let Some(value) = self._page_token.as_ref() {
1886 params.push("pageToken", value);
1887 }
1888 if let Some(value) = self._page_size.as_ref() {
1889 params.push("pageSize", value.to_string());
1890 }
1891
1892 params.extend(self._additional_params.iter());
1893
1894 params.push("alt", "json");
1895 let mut url = self.hub._base_url.clone() + "queries";
1896 if self._scopes.is_empty() {
1897 self._scopes.insert(Scope::Full.as_ref().to_string());
1898 }
1899
1900 let url = params.parse_with_url(&url);
1901
1902 loop {
1903 let token = match self
1904 .hub
1905 .auth
1906 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1907 .await
1908 {
1909 Ok(token) => token,
1910 Err(e) => match dlg.token(e) {
1911 Ok(token) => token,
1912 Err(e) => {
1913 dlg.finished(false);
1914 return Err(common::Error::MissingToken(e));
1915 }
1916 },
1917 };
1918 let mut req_result = {
1919 let client = &self.hub.client;
1920 dlg.pre_request();
1921 let mut req_builder = hyper::Request::builder()
1922 .method(hyper::Method::GET)
1923 .uri(url.as_str())
1924 .header(USER_AGENT, self.hub._user_agent.clone());
1925
1926 if let Some(token) = token.as_ref() {
1927 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1928 }
1929
1930 let request = req_builder
1931 .header(CONTENT_LENGTH, 0_u64)
1932 .body(common::to_body::<String>(None));
1933
1934 client.request(request.unwrap()).await
1935 };
1936
1937 match req_result {
1938 Err(err) => {
1939 if let common::Retry::After(d) = dlg.http_error(&err) {
1940 sleep(d).await;
1941 continue;
1942 }
1943 dlg.finished(false);
1944 return Err(common::Error::HttpError(err));
1945 }
1946 Ok(res) => {
1947 let (mut parts, body) = res.into_parts();
1948 let mut body = common::Body::new(body);
1949 if !parts.status.is_success() {
1950 let bytes = common::to_bytes(body).await.unwrap_or_default();
1951 let error = serde_json::from_str(&common::to_string(&bytes));
1952 let response = common::to_response(parts, bytes.into());
1953
1954 if let common::Retry::After(d) =
1955 dlg.http_failure(&response, error.as_ref().ok())
1956 {
1957 sleep(d).await;
1958 continue;
1959 }
1960
1961 dlg.finished(false);
1962
1963 return Err(match error {
1964 Ok(value) => common::Error::BadRequest(value),
1965 _ => common::Error::Failure(response),
1966 });
1967 }
1968 let response = {
1969 let bytes = common::to_bytes(body).await.unwrap_or_default();
1970 let encoded = common::to_string(&bytes);
1971 match serde_json::from_str(&encoded) {
1972 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1973 Err(error) => {
1974 dlg.response_json_decode_error(&encoded, &error);
1975 return Err(common::Error::JsonDecodeError(
1976 encoded.to_string(),
1977 error,
1978 ));
1979 }
1980 }
1981 };
1982
1983 dlg.finished(true);
1984 return Ok(response);
1985 }
1986 }
1987 }
1988 }
1989
1990 /// Optional pagination token.
1991 ///
1992 /// Sets the *page token* query property to the given value.
1993 pub fn page_token(mut self, new_value: &str) -> QueryListqueryCall<'a, C> {
1994 self._page_token = Some(new_value.to_string());
1995 self
1996 }
1997 /// Maximum number of results per page. Must be between 1 and 100. Defaults to 100 if unspecified.
1998 ///
1999 /// Sets the *page size* query property to the given value.
2000 pub fn page_size(mut self, new_value: i32) -> QueryListqueryCall<'a, C> {
2001 self._page_size = Some(new_value);
2002 self
2003 }
2004 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2005 /// while executing the actual API request.
2006 ///
2007 /// ````text
2008 /// It should be used to handle progress information, and to implement a certain level of resilience.
2009 /// ````
2010 ///
2011 /// Sets the *delegate* property to the given value.
2012 pub fn delegate(
2013 mut self,
2014 new_value: &'a mut dyn common::Delegate,
2015 ) -> QueryListqueryCall<'a, C> {
2016 self._delegate = Some(new_value);
2017 self
2018 }
2019
2020 /// Set any additional parameter of the query string used in the request.
2021 /// It should be used to set parameters which are not yet available through their own
2022 /// setters.
2023 ///
2024 /// Please note that this method must not be used to set any of the known parameters
2025 /// which have their own setter method. If done anyway, the request will fail.
2026 ///
2027 /// # Additional Parameters
2028 ///
2029 /// * *$.xgafv* (query-string) - V1 error format.
2030 /// * *access_token* (query-string) - OAuth access token.
2031 /// * *alt* (query-string) - Data format for response.
2032 /// * *callback* (query-string) - JSONP
2033 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2034 /// * *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.
2035 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2036 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2037 /// * *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.
2038 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2039 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2040 pub fn param<T>(mut self, name: T, value: T) -> QueryListqueryCall<'a, C>
2041 where
2042 T: AsRef<str>,
2043 {
2044 self._additional_params
2045 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2046 self
2047 }
2048
2049 /// Identifies the authorization scope for the method you are building.
2050 ///
2051 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2052 /// [`Scope::Full`].
2053 ///
2054 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2055 /// tokens for more than one scope.
2056 ///
2057 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2058 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2059 /// sufficient, a read-write scope will do as well.
2060 pub fn add_scope<St>(mut self, scope: St) -> QueryListqueryCall<'a, C>
2061 where
2062 St: AsRef<str>,
2063 {
2064 self._scopes.insert(String::from(scope.as_ref()));
2065 self
2066 }
2067 /// Identifies the authorization scope(s) for the method you are building.
2068 ///
2069 /// See [`Self::add_scope()`] for details.
2070 pub fn add_scopes<I, St>(mut self, scopes: I) -> QueryListqueryCall<'a, C>
2071 where
2072 I: IntoIterator<Item = St>,
2073 St: AsRef<str>,
2074 {
2075 self._scopes
2076 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2077 self
2078 }
2079
2080 /// Removes all scopes, and no default scope will be used either.
2081 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2082 /// for details).
2083 pub fn clear_scopes(mut self) -> QueryListqueryCall<'a, C> {
2084 self._scopes.clear();
2085 self
2086 }
2087}
2088
2089/// Runs a stored query to generate a report.
2090///
2091/// A builder for the *runquery* method supported by a *query* resource.
2092/// It is not used directly, but through a [`QueryMethods`] instance.
2093///
2094/// # Example
2095///
2096/// Instantiate a resource method builder
2097///
2098/// ```test_harness,no_run
2099/// # extern crate hyper;
2100/// # extern crate hyper_rustls;
2101/// # extern crate google_doubleclickbidmanager1d1 as doubleclickbidmanager1d1;
2102/// use doubleclickbidmanager1d1::api::RunQueryRequest;
2103/// # async fn dox() {
2104/// # use doubleclickbidmanager1d1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2105///
2106/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2107/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2108/// # .with_native_roots()
2109/// # .unwrap()
2110/// # .https_only()
2111/// # .enable_http2()
2112/// # .build();
2113///
2114/// # let executor = hyper_util::rt::TokioExecutor::new();
2115/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2116/// # secret,
2117/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2118/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2119/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2120/// # ),
2121/// # ).build().await.unwrap();
2122///
2123/// # let client = hyper_util::client::legacy::Client::builder(
2124/// # hyper_util::rt::TokioExecutor::new()
2125/// # )
2126/// # .build(
2127/// # hyper_rustls::HttpsConnectorBuilder::new()
2128/// # .with_native_roots()
2129/// # .unwrap()
2130/// # .https_or_http()
2131/// # .enable_http2()
2132/// # .build()
2133/// # );
2134/// # let mut hub = DoubleClickBidManager::new(client, auth);
2135/// // As the method needs a request, you would usually fill it with the desired information
2136/// // into the respective structure. Some of the parts shown here might not be applicable !
2137/// // Values shown here are possibly random and not representative !
2138/// let mut req = RunQueryRequest::default();
2139///
2140/// // You can configure optional parameters by calling the respective setters at will, and
2141/// // execute the final call using `doit()`.
2142/// // Values shown here are possibly random and not representative !
2143/// let result = hub.queries().runquery(req, -12)
2144/// .asynchronous(false)
2145/// .doit().await;
2146/// # }
2147/// ```
2148pub struct QueryRunqueryCall<'a, C>
2149where
2150 C: 'a,
2151{
2152 hub: &'a DoubleClickBidManager<C>,
2153 _request: RunQueryRequest,
2154 _query_id: i64,
2155 _asynchronous: Option<bool>,
2156 _delegate: Option<&'a mut dyn common::Delegate>,
2157 _additional_params: HashMap<String, String>,
2158 _scopes: BTreeSet<String>,
2159}
2160
2161impl<'a, C> common::CallBuilder for QueryRunqueryCall<'a, C> {}
2162
2163impl<'a, C> QueryRunqueryCall<'a, C>
2164where
2165 C: common::Connector,
2166{
2167 /// Perform the operation you have build so far.
2168 pub async fn doit(mut self) -> common::Result<common::Response> {
2169 use std::borrow::Cow;
2170 use std::io::{Read, Seek};
2171
2172 use common::{url::Params, ToParts};
2173 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2174
2175 let mut dd = common::DefaultDelegate;
2176 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2177 dlg.begin(common::MethodInfo {
2178 id: "doubleclickbidmanager.queries.runquery",
2179 http_method: hyper::Method::POST,
2180 });
2181
2182 for &field in ["queryId", "asynchronous"].iter() {
2183 if self._additional_params.contains_key(field) {
2184 dlg.finished(false);
2185 return Err(common::Error::FieldClash(field));
2186 }
2187 }
2188
2189 let mut params = Params::with_capacity(4 + self._additional_params.len());
2190 params.push("queryId", self._query_id.to_string());
2191 if let Some(value) = self._asynchronous.as_ref() {
2192 params.push("asynchronous", value.to_string());
2193 }
2194
2195 params.extend(self._additional_params.iter());
2196
2197 let mut url = self.hub._base_url.clone() + "query/{queryId}";
2198 if self._scopes.is_empty() {
2199 self._scopes.insert(Scope::Full.as_ref().to_string());
2200 }
2201
2202 #[allow(clippy::single_element_loop)]
2203 for &(find_this, param_name) in [("{queryId}", "queryId")].iter() {
2204 url = params.uri_replacement(url, param_name, find_this, false);
2205 }
2206 {
2207 let to_remove = ["queryId"];
2208 params.remove_params(&to_remove);
2209 }
2210
2211 let url = params.parse_with_url(&url);
2212
2213 let mut json_mime_type = mime::APPLICATION_JSON;
2214 let mut request_value_reader = {
2215 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2216 common::remove_json_null_values(&mut value);
2217 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2218 serde_json::to_writer(&mut dst, &value).unwrap();
2219 dst
2220 };
2221 let request_size = request_value_reader
2222 .seek(std::io::SeekFrom::End(0))
2223 .unwrap();
2224 request_value_reader
2225 .seek(std::io::SeekFrom::Start(0))
2226 .unwrap();
2227
2228 loop {
2229 let token = match self
2230 .hub
2231 .auth
2232 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2233 .await
2234 {
2235 Ok(token) => token,
2236 Err(e) => match dlg.token(e) {
2237 Ok(token) => token,
2238 Err(e) => {
2239 dlg.finished(false);
2240 return Err(common::Error::MissingToken(e));
2241 }
2242 },
2243 };
2244 request_value_reader
2245 .seek(std::io::SeekFrom::Start(0))
2246 .unwrap();
2247 let mut req_result = {
2248 let client = &self.hub.client;
2249 dlg.pre_request();
2250 let mut req_builder = hyper::Request::builder()
2251 .method(hyper::Method::POST)
2252 .uri(url.as_str())
2253 .header(USER_AGENT, self.hub._user_agent.clone());
2254
2255 if let Some(token) = token.as_ref() {
2256 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2257 }
2258
2259 let request = req_builder
2260 .header(CONTENT_TYPE, json_mime_type.to_string())
2261 .header(CONTENT_LENGTH, request_size as u64)
2262 .body(common::to_body(
2263 request_value_reader.get_ref().clone().into(),
2264 ));
2265
2266 client.request(request.unwrap()).await
2267 };
2268
2269 match req_result {
2270 Err(err) => {
2271 if let common::Retry::After(d) = dlg.http_error(&err) {
2272 sleep(d).await;
2273 continue;
2274 }
2275 dlg.finished(false);
2276 return Err(common::Error::HttpError(err));
2277 }
2278 Ok(res) => {
2279 let (mut parts, body) = res.into_parts();
2280 let mut body = common::Body::new(body);
2281 if !parts.status.is_success() {
2282 let bytes = common::to_bytes(body).await.unwrap_or_default();
2283 let error = serde_json::from_str(&common::to_string(&bytes));
2284 let response = common::to_response(parts, bytes.into());
2285
2286 if let common::Retry::After(d) =
2287 dlg.http_failure(&response, error.as_ref().ok())
2288 {
2289 sleep(d).await;
2290 continue;
2291 }
2292
2293 dlg.finished(false);
2294
2295 return Err(match error {
2296 Ok(value) => common::Error::BadRequest(value),
2297 _ => common::Error::Failure(response),
2298 });
2299 }
2300 let response = common::Response::from_parts(parts, body);
2301
2302 dlg.finished(true);
2303 return Ok(response);
2304 }
2305 }
2306 }
2307 }
2308
2309 ///
2310 /// Sets the *request* property to the given value.
2311 ///
2312 /// Even though the property as already been set when instantiating this call,
2313 /// we provide this method for API completeness.
2314 pub fn request(mut self, new_value: RunQueryRequest) -> QueryRunqueryCall<'a, C> {
2315 self._request = new_value;
2316 self
2317 }
2318 /// Query ID to run.
2319 ///
2320 /// Sets the *query id* path property to the given value.
2321 ///
2322 /// Even though the property as already been set when instantiating this call,
2323 /// we provide this method for API completeness.
2324 pub fn query_id(mut self, new_value: i64) -> QueryRunqueryCall<'a, C> {
2325 self._query_id = new_value;
2326 self
2327 }
2328 /// If true, tries to run the query asynchronously.
2329 ///
2330 /// Sets the *asynchronous* query property to the given value.
2331 pub fn asynchronous(mut self, new_value: bool) -> QueryRunqueryCall<'a, C> {
2332 self._asynchronous = Some(new_value);
2333 self
2334 }
2335 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2336 /// while executing the actual API request.
2337 ///
2338 /// ````text
2339 /// It should be used to handle progress information, and to implement a certain level of resilience.
2340 /// ````
2341 ///
2342 /// Sets the *delegate* property to the given value.
2343 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> QueryRunqueryCall<'a, C> {
2344 self._delegate = Some(new_value);
2345 self
2346 }
2347
2348 /// Set any additional parameter of the query string used in the request.
2349 /// It should be used to set parameters which are not yet available through their own
2350 /// setters.
2351 ///
2352 /// Please note that this method must not be used to set any of the known parameters
2353 /// which have their own setter method. If done anyway, the request will fail.
2354 ///
2355 /// # Additional Parameters
2356 ///
2357 /// * *$.xgafv* (query-string) - V1 error format.
2358 /// * *access_token* (query-string) - OAuth access token.
2359 /// * *alt* (query-string) - Data format for response.
2360 /// * *callback* (query-string) - JSONP
2361 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2362 /// * *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.
2363 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2364 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2365 /// * *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.
2366 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2367 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2368 pub fn param<T>(mut self, name: T, value: T) -> QueryRunqueryCall<'a, C>
2369 where
2370 T: AsRef<str>,
2371 {
2372 self._additional_params
2373 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2374 self
2375 }
2376
2377 /// Identifies the authorization scope for the method you are building.
2378 ///
2379 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2380 /// [`Scope::Full`].
2381 ///
2382 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2383 /// tokens for more than one scope.
2384 ///
2385 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2386 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2387 /// sufficient, a read-write scope will do as well.
2388 pub fn add_scope<St>(mut self, scope: St) -> QueryRunqueryCall<'a, C>
2389 where
2390 St: AsRef<str>,
2391 {
2392 self._scopes.insert(String::from(scope.as_ref()));
2393 self
2394 }
2395 /// Identifies the authorization scope(s) for the method you are building.
2396 ///
2397 /// See [`Self::add_scope()`] for details.
2398 pub fn add_scopes<I, St>(mut self, scopes: I) -> QueryRunqueryCall<'a, C>
2399 where
2400 I: IntoIterator<Item = St>,
2401 St: AsRef<str>,
2402 {
2403 self._scopes
2404 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2405 self
2406 }
2407
2408 /// Removes all scopes, and no default scope will be used either.
2409 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2410 /// for details).
2411 pub fn clear_scopes(mut self) -> QueryRunqueryCall<'a, C> {
2412 self._scopes.clear();
2413 self
2414 }
2415}
2416
2417/// Retrieves stored reports.
2418///
2419/// A builder for the *listreports* method supported by a *report* resource.
2420/// It is not used directly, but through a [`ReportMethods`] instance.
2421///
2422/// # Example
2423///
2424/// Instantiate a resource method builder
2425///
2426/// ```test_harness,no_run
2427/// # extern crate hyper;
2428/// # extern crate hyper_rustls;
2429/// # extern crate google_doubleclickbidmanager1d1 as doubleclickbidmanager1d1;
2430/// # async fn dox() {
2431/// # use doubleclickbidmanager1d1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2432///
2433/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2434/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2435/// # .with_native_roots()
2436/// # .unwrap()
2437/// # .https_only()
2438/// # .enable_http2()
2439/// # .build();
2440///
2441/// # let executor = hyper_util::rt::TokioExecutor::new();
2442/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2443/// # secret,
2444/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2445/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2446/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2447/// # ),
2448/// # ).build().await.unwrap();
2449///
2450/// # let client = hyper_util::client::legacy::Client::builder(
2451/// # hyper_util::rt::TokioExecutor::new()
2452/// # )
2453/// # .build(
2454/// # hyper_rustls::HttpsConnectorBuilder::new()
2455/// # .with_native_roots()
2456/// # .unwrap()
2457/// # .https_or_http()
2458/// # .enable_http2()
2459/// # .build()
2460/// # );
2461/// # let mut hub = DoubleClickBidManager::new(client, auth);
2462/// // You can configure optional parameters by calling the respective setters at will, and
2463/// // execute the final call using `doit()`.
2464/// // Values shown here are possibly random and not representative !
2465/// let result = hub.reports().listreports(-4)
2466/// .page_token("ea")
2467/// .page_size(-55)
2468/// .doit().await;
2469/// # }
2470/// ```
2471pub struct ReportListreportCall<'a, C>
2472where
2473 C: 'a,
2474{
2475 hub: &'a DoubleClickBidManager<C>,
2476 _query_id: i64,
2477 _page_token: Option<String>,
2478 _page_size: Option<i32>,
2479 _delegate: Option<&'a mut dyn common::Delegate>,
2480 _additional_params: HashMap<String, String>,
2481 _scopes: BTreeSet<String>,
2482}
2483
2484impl<'a, C> common::CallBuilder for ReportListreportCall<'a, C> {}
2485
2486impl<'a, C> ReportListreportCall<'a, C>
2487where
2488 C: common::Connector,
2489{
2490 /// Perform the operation you have build so far.
2491 pub async fn doit(mut self) -> common::Result<(common::Response, ListReportsResponse)> {
2492 use std::borrow::Cow;
2493 use std::io::{Read, Seek};
2494
2495 use common::{url::Params, ToParts};
2496 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2497
2498 let mut dd = common::DefaultDelegate;
2499 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2500 dlg.begin(common::MethodInfo {
2501 id: "doubleclickbidmanager.reports.listreports",
2502 http_method: hyper::Method::GET,
2503 });
2504
2505 for &field in ["alt", "queryId", "pageToken", "pageSize"].iter() {
2506 if self._additional_params.contains_key(field) {
2507 dlg.finished(false);
2508 return Err(common::Error::FieldClash(field));
2509 }
2510 }
2511
2512 let mut params = Params::with_capacity(5 + self._additional_params.len());
2513 params.push("queryId", self._query_id.to_string());
2514 if let Some(value) = self._page_token.as_ref() {
2515 params.push("pageToken", value);
2516 }
2517 if let Some(value) = self._page_size.as_ref() {
2518 params.push("pageSize", value.to_string());
2519 }
2520
2521 params.extend(self._additional_params.iter());
2522
2523 params.push("alt", "json");
2524 let mut url = self.hub._base_url.clone() + "queries/{queryId}/reports";
2525 if self._scopes.is_empty() {
2526 self._scopes.insert(Scope::Full.as_ref().to_string());
2527 }
2528
2529 #[allow(clippy::single_element_loop)]
2530 for &(find_this, param_name) in [("{queryId}", "queryId")].iter() {
2531 url = params.uri_replacement(url, param_name, find_this, false);
2532 }
2533 {
2534 let to_remove = ["queryId"];
2535 params.remove_params(&to_remove);
2536 }
2537
2538 let url = params.parse_with_url(&url);
2539
2540 loop {
2541 let token = match self
2542 .hub
2543 .auth
2544 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2545 .await
2546 {
2547 Ok(token) => token,
2548 Err(e) => match dlg.token(e) {
2549 Ok(token) => token,
2550 Err(e) => {
2551 dlg.finished(false);
2552 return Err(common::Error::MissingToken(e));
2553 }
2554 },
2555 };
2556 let mut req_result = {
2557 let client = &self.hub.client;
2558 dlg.pre_request();
2559 let mut req_builder = hyper::Request::builder()
2560 .method(hyper::Method::GET)
2561 .uri(url.as_str())
2562 .header(USER_AGENT, self.hub._user_agent.clone());
2563
2564 if let Some(token) = token.as_ref() {
2565 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2566 }
2567
2568 let request = req_builder
2569 .header(CONTENT_LENGTH, 0_u64)
2570 .body(common::to_body::<String>(None));
2571
2572 client.request(request.unwrap()).await
2573 };
2574
2575 match req_result {
2576 Err(err) => {
2577 if let common::Retry::After(d) = dlg.http_error(&err) {
2578 sleep(d).await;
2579 continue;
2580 }
2581 dlg.finished(false);
2582 return Err(common::Error::HttpError(err));
2583 }
2584 Ok(res) => {
2585 let (mut parts, body) = res.into_parts();
2586 let mut body = common::Body::new(body);
2587 if !parts.status.is_success() {
2588 let bytes = common::to_bytes(body).await.unwrap_or_default();
2589 let error = serde_json::from_str(&common::to_string(&bytes));
2590 let response = common::to_response(parts, bytes.into());
2591
2592 if let common::Retry::After(d) =
2593 dlg.http_failure(&response, error.as_ref().ok())
2594 {
2595 sleep(d).await;
2596 continue;
2597 }
2598
2599 dlg.finished(false);
2600
2601 return Err(match error {
2602 Ok(value) => common::Error::BadRequest(value),
2603 _ => common::Error::Failure(response),
2604 });
2605 }
2606 let response = {
2607 let bytes = common::to_bytes(body).await.unwrap_or_default();
2608 let encoded = common::to_string(&bytes);
2609 match serde_json::from_str(&encoded) {
2610 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2611 Err(error) => {
2612 dlg.response_json_decode_error(&encoded, &error);
2613 return Err(common::Error::JsonDecodeError(
2614 encoded.to_string(),
2615 error,
2616 ));
2617 }
2618 }
2619 };
2620
2621 dlg.finished(true);
2622 return Ok(response);
2623 }
2624 }
2625 }
2626 }
2627
2628 /// Query ID with which the reports are associated.
2629 ///
2630 /// Sets the *query id* path property to the given value.
2631 ///
2632 /// Even though the property as already been set when instantiating this call,
2633 /// we provide this method for API completeness.
2634 pub fn query_id(mut self, new_value: i64) -> ReportListreportCall<'a, C> {
2635 self._query_id = new_value;
2636 self
2637 }
2638 /// Optional pagination token.
2639 ///
2640 /// Sets the *page token* query property to the given value.
2641 pub fn page_token(mut self, new_value: &str) -> ReportListreportCall<'a, C> {
2642 self._page_token = Some(new_value.to_string());
2643 self
2644 }
2645 /// Maximum number of results per page. Must be between 1 and 100. Defaults to 100 if unspecified.
2646 ///
2647 /// Sets the *page size* query property to the given value.
2648 pub fn page_size(mut self, new_value: i32) -> ReportListreportCall<'a, C> {
2649 self._page_size = Some(new_value);
2650 self
2651 }
2652 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2653 /// while executing the actual API request.
2654 ///
2655 /// ````text
2656 /// It should be used to handle progress information, and to implement a certain level of resilience.
2657 /// ````
2658 ///
2659 /// Sets the *delegate* property to the given value.
2660 pub fn delegate(
2661 mut self,
2662 new_value: &'a mut dyn common::Delegate,
2663 ) -> ReportListreportCall<'a, C> {
2664 self._delegate = Some(new_value);
2665 self
2666 }
2667
2668 /// Set any additional parameter of the query string used in the request.
2669 /// It should be used to set parameters which are not yet available through their own
2670 /// setters.
2671 ///
2672 /// Please note that this method must not be used to set any of the known parameters
2673 /// which have their own setter method. If done anyway, the request will fail.
2674 ///
2675 /// # Additional Parameters
2676 ///
2677 /// * *$.xgafv* (query-string) - V1 error format.
2678 /// * *access_token* (query-string) - OAuth access token.
2679 /// * *alt* (query-string) - Data format for response.
2680 /// * *callback* (query-string) - JSONP
2681 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2682 /// * *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.
2683 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2684 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2685 /// * *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.
2686 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2687 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2688 pub fn param<T>(mut self, name: T, value: T) -> ReportListreportCall<'a, C>
2689 where
2690 T: AsRef<str>,
2691 {
2692 self._additional_params
2693 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2694 self
2695 }
2696
2697 /// Identifies the authorization scope for the method you are building.
2698 ///
2699 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2700 /// [`Scope::Full`].
2701 ///
2702 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2703 /// tokens for more than one scope.
2704 ///
2705 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2706 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2707 /// sufficient, a read-write scope will do as well.
2708 pub fn add_scope<St>(mut self, scope: St) -> ReportListreportCall<'a, C>
2709 where
2710 St: AsRef<str>,
2711 {
2712 self._scopes.insert(String::from(scope.as_ref()));
2713 self
2714 }
2715 /// Identifies the authorization scope(s) for the method you are building.
2716 ///
2717 /// See [`Self::add_scope()`] for details.
2718 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportListreportCall<'a, C>
2719 where
2720 I: IntoIterator<Item = St>,
2721 St: AsRef<str>,
2722 {
2723 self._scopes
2724 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2725 self
2726 }
2727
2728 /// Removes all scopes, and no default scope will be used either.
2729 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2730 /// for details).
2731 pub fn clear_scopes(mut self) -> ReportListreportCall<'a, C> {
2732 self._scopes.clear();
2733 self
2734 }
2735}