use std::collections::HashMap; use std::cell::RefCell; use std::default::Default; use std::collections::BTreeMap; use serde_json as json; use std::io; use std::fs; use std::mem; use std::thread::sleep; use crate::client; // ############## // UTILITIES ### // ############ /// Identifies the an OAuth2 authorization scope. /// A scope is needed when requesting an /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Hash)] pub enum Scope { /// View monetary and non-monetary YouTube Analytics reports for your YouTube content YtAnalyticMonetaryReadonly, /// View YouTube Analytics reports for your YouTube content YtAnalyticReadonly, } impl AsRef for Scope { fn as_ref(&self) -> &str { match *self { Scope::YtAnalyticMonetaryReadonly => "https://www.googleapis.com/auth/yt-analytics-monetary.readonly", Scope::YtAnalyticReadonly => "https://www.googleapis.com/auth/yt-analytics.readonly", } } } impl Default for Scope { fn default() -> Scope { Scope::YtAnalyticMonetaryReadonly } } // ######## // HUB ### // ###### /// Central instance to access all YouTubeReporting related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_youtubereporting1 as youtubereporting1; /// use youtubereporting1::{Result, Error}; /// # async fn dox() { /// use std::default::Default; /// use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. /// let secret: oauth2::ApplicationSecret = Default::default(); /// // Instantiate the authenticator. It will choose a suitable authentication flow for you, /// // unless you replace `None` with the desired Flow. /// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about /// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and /// // retrieve them from storage. /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.jobs().reports_list("jobId") /// .start_time_before("gubergren") /// .start_time_at_or_after("eos") /// .page_token("dolor") /// .page_size(-17) /// .on_behalf_of_content_owner("ipsum") /// .created_after("invidunt") /// .doit().await; /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits /// Error::HttpError(_) /// |Error::Io(_) /// |Error::MissingAPIKey /// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) /// |Error::BadRequest(_) /// |Error::FieldClash(_) /// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } /// # } /// ``` #[derive(Clone)] pub struct YouTubeReporting<> { pub client: hyper::Client, hyper::body::Body>, pub auth: oauth2::authenticator::Authenticator>, _user_agent: String, _base_url: String, _root_url: String, } impl<'a, > client::Hub for YouTubeReporting<> {} impl<'a, > YouTubeReporting<> { pub fn new(client: hyper::Client, hyper::body::Body>, authenticator: oauth2::authenticator::Authenticator>) -> YouTubeReporting<> { YouTubeReporting { client, auth: authenticator, _user_agent: "google-api-rust-client/3.1.0".to_string(), _base_url: "https://youtubereporting.googleapis.com/".to_string(), _root_url: "https://youtubereporting.googleapis.com/".to_string(), } } pub fn jobs(&'a self) -> JobMethods<'a> { JobMethods { hub: &self } } pub fn media(&'a self) -> MediaMethods<'a> { MediaMethods { hub: &self } } pub fn report_types(&'a self) -> ReportTypeMethods<'a> { ReportTypeMethods { hub: &self } } /// Set the user-agent header field to use in all requests to the server. /// It defaults to `google-api-rust-client/3.1.0`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { mem::replace(&mut self._user_agent, agent_name) } /// Set the base url to use in all requests to the server. /// It defaults to `https://youtubereporting.googleapis.com/`. /// /// Returns the previously set base url. pub fn base_url(&mut self, new_base_url: String) -> String { mem::replace(&mut self._base_url, new_base_url) } /// Set the root url to use in all requests to the server. /// It defaults to `https://youtubereporting.googleapis.com/`. /// /// Returns the previously set root url. pub fn root_url(&mut self, new_root_url: String) -> String { mem::replace(&mut self._root_url, new_root_url) } } // ############ // SCHEMAS ### // ########## /// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } The JSON representation for `Empty` is empty JSON object `{}`. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete jobs](JobDeleteCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Empty { _never_set: Option } impl client::ResponseResult for Empty {} /// gdata /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataBlobstore2Info { /// gdata #[serde(rename="blobGeneration")] pub blob_generation: Option, /// gdata #[serde(rename="blobId")] pub blob_id: Option, /// gdata #[serde(rename="downloadReadHandle")] pub download_read_handle: Option, /// gdata #[serde(rename="readToken")] pub read_token: Option, /// gdata #[serde(rename="uploadMetadataContainer")] pub upload_metadata_container: Option, } impl client::Part for GdataBlobstore2Info {} /// gdata /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataCompositeMedia { /// gdata #[serde(rename="blobRef")] pub blob_ref: Option, /// gdata #[serde(rename="blobstore2Info")] pub blobstore2_info: Option, /// gdata #[serde(rename="cosmoBinaryReference")] pub cosmo_binary_reference: Option, /// gdata #[serde(rename="crc32cHash")] pub crc32c_hash: Option, /// gdata pub inline: Option, /// gdata pub length: Option, /// gdata #[serde(rename="md5Hash")] pub md5_hash: Option, /// gdata #[serde(rename="objectId")] pub object_id: Option, /// gdata pub path: Option, /// gdata #[serde(rename="referenceType")] pub reference_type: Option, /// gdata #[serde(rename="sha1Hash")] pub sha1_hash: Option, } impl client::Part for GdataCompositeMedia {} /// gdata /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataContentTypeInfo { /// gdata #[serde(rename="bestGuess")] pub best_guess: Option, /// gdata #[serde(rename="fromBytes")] pub from_bytes: Option, /// gdata #[serde(rename="fromFileName")] pub from_file_name: Option, /// gdata #[serde(rename="fromHeader")] pub from_header: Option, /// gdata #[serde(rename="fromUrlPath")] pub from_url_path: Option, } impl client::Part for GdataContentTypeInfo {} /// gdata /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataDiffChecksumsResponse { /// gdata #[serde(rename="checksumsLocation")] pub checksums_location: Option, /// gdata #[serde(rename="chunkSizeBytes")] pub chunk_size_bytes: Option, /// gdata #[serde(rename="objectLocation")] pub object_location: Option, /// gdata #[serde(rename="objectSizeBytes")] pub object_size_bytes: Option, /// gdata #[serde(rename="objectVersion")] pub object_version: Option, } impl client::Part for GdataDiffChecksumsResponse {} /// gdata /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataDiffDownloadResponse { /// gdata #[serde(rename="objectLocation")] pub object_location: Option, } impl client::Part for GdataDiffDownloadResponse {} /// gdata /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataDiffUploadRequest { /// gdata #[serde(rename="checksumsInfo")] pub checksums_info: Option, /// gdata #[serde(rename="objectInfo")] pub object_info: Option, /// gdata #[serde(rename="objectVersion")] pub object_version: Option, } impl client::Part for GdataDiffUploadRequest {} /// gdata /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataDiffUploadResponse { /// gdata #[serde(rename="objectVersion")] pub object_version: Option, /// gdata #[serde(rename="originalObject")] pub original_object: Option, } impl client::Part for GdataDiffUploadResponse {} /// gdata /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataDiffVersionResponse { /// gdata #[serde(rename="objectSizeBytes")] pub object_size_bytes: Option, /// gdata #[serde(rename="objectVersion")] pub object_version: Option, } impl client::Part for GdataDiffVersionResponse {} /// gdata /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataDownloadParameters { /// gdata #[serde(rename="allowGzipCompression")] pub allow_gzip_compression: Option, /// gdata #[serde(rename="ignoreRange")] pub ignore_range: Option, } impl client::Part for GdataDownloadParameters {} /// gdata /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [download media](MediaDownloadCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataMedia { /// gdata pub algorithm: Option, /// gdata #[serde(rename="bigstoreObjectRef")] pub bigstore_object_ref: Option, /// gdata #[serde(rename="blobRef")] pub blob_ref: Option, /// gdata #[serde(rename="blobstore2Info")] pub blobstore2_info: Option, /// gdata #[serde(rename="compositeMedia")] pub composite_media: Option>, /// gdata #[serde(rename="contentType")] pub content_type: Option, /// gdata #[serde(rename="contentTypeInfo")] pub content_type_info: Option, /// gdata #[serde(rename="cosmoBinaryReference")] pub cosmo_binary_reference: Option, /// gdata #[serde(rename="crc32cHash")] pub crc32c_hash: Option, /// gdata #[serde(rename="diffChecksumsResponse")] pub diff_checksums_response: Option, /// gdata #[serde(rename="diffDownloadResponse")] pub diff_download_response: Option, /// gdata #[serde(rename="diffUploadRequest")] pub diff_upload_request: Option, /// gdata #[serde(rename="diffUploadResponse")] pub diff_upload_response: Option, /// gdata #[serde(rename="diffVersionResponse")] pub diff_version_response: Option, /// gdata #[serde(rename="downloadParameters")] pub download_parameters: Option, /// gdata pub filename: Option, /// gdata pub hash: Option, /// gdata #[serde(rename="hashVerified")] pub hash_verified: Option, /// gdata pub inline: Option, /// gdata #[serde(rename="isPotentialRetry")] pub is_potential_retry: Option, /// gdata pub length: Option, /// gdata #[serde(rename="md5Hash")] pub md5_hash: Option, /// gdata #[serde(rename="mediaId")] pub media_id: Option, /// gdata #[serde(rename="objectId")] pub object_id: Option, /// gdata pub path: Option, /// gdata #[serde(rename="referenceType")] pub reference_type: Option, /// gdata #[serde(rename="sha1Hash")] pub sha1_hash: Option, /// gdata #[serde(rename="sha256Hash")] pub sha256_hash: Option, /// gdata pub timestamp: Option, /// gdata pub token: Option, } impl client::ResponseResult for GdataMedia {} /// gdata /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GdataObjectId { /// gdata #[serde(rename="bucketName")] pub bucket_name: Option, /// gdata pub generation: Option, /// gdata #[serde(rename="objectName")] pub object_name: Option, } impl client::Part for GdataObjectId {} /// A job creating reports of a specific type. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [reports get jobs](JobReportGetCall) (none) /// * [reports list jobs](JobReportListCall) (none) /// * [create jobs](JobCreateCall) (request|response) /// * [delete jobs](JobDeleteCall) (none) /// * [get jobs](JobGetCall) (response) /// * [list jobs](JobListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Job { /// The creation date/time of the job. #[serde(rename="createTime")] pub create_time: Option, /// The date/time when this job will expire/expired. After a job expired, no new reports are generated. #[serde(rename="expireTime")] pub expire_time: Option, /// The server-generated ID of the job (max. 40 characters). pub id: Option, /// The name of the job (max. 100 characters). pub name: Option, /// The type of reports this job creates. Corresponds to the ID of a ReportType. #[serde(rename="reportTypeId")] pub report_type_id: Option, /// True if this a system-managed job that cannot be modified by the user; otherwise false. #[serde(rename="systemManaged")] pub system_managed: Option, } impl client::RequestValue for Job {} impl client::Resource for Job {} impl client::ResponseResult for Job {} /// Response message for ReportingService.ListJobs. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list jobs](JobListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListJobsResponse { /// The list of jobs. pub jobs: Option>, /// A token to retrieve next page of results. Pass this value in the ListJobsRequest.page_token field in the subsequent call to `ListJobs` method to retrieve the next page of results. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for ListJobsResponse {} /// Response message for ReportingService.ListReportTypes. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list report types](ReportTypeListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListReportTypesResponse { /// A token to retrieve next page of results. Pass this value in the ListReportTypesRequest.page_token field in the subsequent call to `ListReportTypes` method to retrieve the next page of results. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// The list of report types. #[serde(rename="reportTypes")] pub report_types: Option>, } impl client::ResponseResult for ListReportTypesResponse {} /// Response message for ReportingService.ListReports. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [reports list jobs](JobReportListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListReportsResponse { /// A token to retrieve next page of results. Pass this value in the ListReportsRequest.page_token field in the subsequent call to `ListReports` method to retrieve the next page of results. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// The list of report types. pub reports: Option>, } impl client::ResponseResult for ListReportsResponse {} /// A report's metadata including the URL from which the report itself can be downloaded. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [reports get jobs](JobReportGetCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Report { /// The date/time when this report was created. #[serde(rename="createTime")] pub create_time: Option, /// The URL from which the report can be downloaded (max. 1000 characters). #[serde(rename="downloadUrl")] pub download_url: Option, /// The end of the time period that the report instance covers. The value is exclusive. #[serde(rename="endTime")] pub end_time: Option, /// The server-generated ID of the report. pub id: Option, /// The date/time when the job this report belongs to will expire/expired. #[serde(rename="jobExpireTime")] pub job_expire_time: Option, /// The ID of the job that created this report. #[serde(rename="jobId")] pub job_id: Option, /// The start of the time period that the report instance covers. The value is inclusive. #[serde(rename="startTime")] pub start_time: Option, } impl client::ResponseResult for Report {} /// A report type. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list report types](ReportTypeListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportType { /// The date/time when this report type was/will be deprecated. #[serde(rename="deprecateTime")] pub deprecate_time: Option, /// The ID of the report type (max. 100 characters). pub id: Option, /// The name of the report type (max. 100 characters). pub name: Option, /// True if this a system-managed report type; otherwise false. Reporting jobs for system-managed report types are created automatically and can thus not be used in the `CreateJob` method. #[serde(rename="systemManaged")] pub system_managed: Option, } impl client::Resource for ReportType {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *job* resources. /// It is not used directly, but through the `YouTubeReporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_youtubereporting1 as youtubereporting1; /// /// # async fn dox() { /// use std::default::Default; /// use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `reports_get(...)` and `reports_list(...)` /// // to build up your call. /// let rb = hub.jobs(); /// # } /// ``` pub struct JobMethods<'a> where { hub: &'a YouTubeReporting<>, } impl<'a> client::MethodsBuilder for JobMethods<'a> {} impl<'a> JobMethods<'a> { /// Create a builder to help you perform the following task: /// /// Gets the metadata of a specific report. /// /// # Arguments /// /// * `jobId` - The ID of the job. /// * `reportId` - The ID of the report to retrieve. pub fn reports_get(&self, job_id: &str, report_id: &str) -> JobReportGetCall<'a> { JobReportGetCall { hub: self.hub, _job_id: job_id.to_string(), _report_id: report_id.to_string(), _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists reports created by a specific job. Returns NOT_FOUND if the job does not exist. /// /// # Arguments /// /// * `jobId` - The ID of the job. pub fn reports_list(&self, job_id: &str) -> JobReportListCall<'a> { JobReportListCall { hub: self.hub, _job_id: job_id.to_string(), _start_time_before: Default::default(), _start_time_at_or_after: Default::default(), _page_token: Default::default(), _page_size: Default::default(), _on_behalf_of_content_owner: Default::default(), _created_after: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a job and returns it. /// /// # Arguments /// /// * `request` - No description provided. pub fn create(&self, request: Job) -> JobCreateCall<'a> { JobCreateCall { hub: self.hub, _request: request, _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a job. /// /// # Arguments /// /// * `jobId` - The ID of the job to delete. pub fn delete(&self, job_id: &str) -> JobDeleteCall<'a> { JobDeleteCall { hub: self.hub, _job_id: job_id.to_string(), _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a job. /// /// # Arguments /// /// * `jobId` - The ID of the job to retrieve. pub fn get(&self, job_id: &str) -> JobGetCall<'a> { JobGetCall { hub: self.hub, _job_id: job_id.to_string(), _on_behalf_of_content_owner: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists jobs. pub fn list(&self) -> JobListCall<'a> { JobListCall { hub: self.hub, _page_token: Default::default(), _page_size: Default::default(), _on_behalf_of_content_owner: Default::default(), _include_system_managed: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *media* resources. /// It is not used directly, but through the `YouTubeReporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_youtubereporting1 as youtubereporting1; /// /// # async fn dox() { /// use std::default::Default; /// use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `download(...)` /// // to build up your call. /// let rb = hub.media(); /// # } /// ``` pub struct MediaMethods<'a> where { hub: &'a YouTubeReporting<>, } impl<'a> client::MethodsBuilder for MediaMethods<'a> {} impl<'a> MediaMethods<'a> { /// Create a builder to help you perform the following task: /// /// Method for media download. Download is supported on the URI `/v1/media/{+name}?alt=media`. /// /// # Arguments /// /// * `resourceName` - Name of the media that is being downloaded. pub fn download(&self, resource_name: &str) -> MediaDownloadCall<'a> { MediaDownloadCall { hub: self.hub, _resource_name: resource_name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *reportType* resources. /// It is not used directly, but through the `YouTubeReporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_youtubereporting1 as youtubereporting1; /// /// # async fn dox() { /// use std::default::Default; /// use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `list(...)` /// // to build up your call. /// let rb = hub.report_types(); /// # } /// ``` pub struct ReportTypeMethods<'a> where { hub: &'a YouTubeReporting<>, } impl<'a> client::MethodsBuilder for ReportTypeMethods<'a> {} impl<'a> ReportTypeMethods<'a> { /// Create a builder to help you perform the following task: /// /// Lists report types. pub fn list(&self) -> ReportTypeListCall<'a> { ReportTypeListCall { hub: self.hub, _page_token: Default::default(), _page_size: Default::default(), _on_behalf_of_content_owner: Default::default(), _include_system_managed: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } // ################### // CallBuilders ### // ################# /// Gets the metadata of a specific report. /// /// A builder for the *reports.get* method supported by a *job* resource. /// It is not used directly, but through a `JobMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_youtubereporting1 as youtubereporting1; /// # async fn dox() { /// # use std::default::Default; /// # use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.jobs().reports_get("jobId", "reportId") /// .on_behalf_of_content_owner("ipsum") /// .doit().await; /// # } /// ``` pub struct JobReportGetCall<'a> where { hub: &'a YouTubeReporting<>, _job_id: String, _report_id: String, _on_behalf_of_content_owner: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for JobReportGetCall<'a> {} impl<'a> JobReportGetCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Report)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "youtubereporting.jobs.reports.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("jobId", self._job_id.to_string())); params.push(("reportId", self._report_id.to_string())); if let Some(value) = self._on_behalf_of_content_owner { params.push(("onBehalfOfContentOwner", value.to_string())); } for &field in ["alt", "jobId", "reportId", "onBehalfOfContentOwner"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/jobs/{jobId}/reports/{reportId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::YtAnalyticMonetaryReadonly.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{jobId}", "jobId"), ("{reportId}", "reportId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["reportId", "jobId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the job. /// /// Sets the *job id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn job_id(mut self, new_value: &str) -> JobReportGetCall<'a> { self._job_id = new_value.to_string(); self } /// The ID of the report to retrieve. /// /// Sets the *report id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn report_id(mut self, new_value: &str) -> JobReportGetCall<'a> { self._report_id = new_value.to_string(); self } /// The content owner's external ID on which behalf the user is acting on. If not set, the user is acting for himself (his own channel). /// /// Sets the *on behalf of content owner* query property to the given value. pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> JobReportGetCall<'a> { self._on_behalf_of_content_owner = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> JobReportGetCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> JobReportGetCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::YtAnalyticMonetaryReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> JobReportGetCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists reports created by a specific job. Returns NOT_FOUND if the job does not exist. /// /// A builder for the *reports.list* method supported by a *job* resource. /// It is not used directly, but through a `JobMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_youtubereporting1 as youtubereporting1; /// # async fn dox() { /// # use std::default::Default; /// # use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.jobs().reports_list("jobId") /// .start_time_before("ut") /// .start_time_at_or_after("gubergren") /// .page_token("rebum.") /// .page_size(-57) /// .on_behalf_of_content_owner("ipsum") /// .created_after("ipsum") /// .doit().await; /// # } /// ``` pub struct JobReportListCall<'a> where { hub: &'a YouTubeReporting<>, _job_id: String, _start_time_before: Option, _start_time_at_or_after: Option, _page_token: Option, _page_size: Option, _on_behalf_of_content_owner: Option, _created_after: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for JobReportListCall<'a> {} impl<'a> JobReportListCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ListReportsResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "youtubereporting.jobs.reports.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(9 + self._additional_params.len()); params.push(("jobId", self._job_id.to_string())); if let Some(value) = self._start_time_before { params.push(("startTimeBefore", value.to_string())); } if let Some(value) = self._start_time_at_or_after { params.push(("startTimeAtOrAfter", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } if let Some(value) = self._on_behalf_of_content_owner { params.push(("onBehalfOfContentOwner", value.to_string())); } if let Some(value) = self._created_after { params.push(("createdAfter", value.to_string())); } for &field in ["alt", "jobId", "startTimeBefore", "startTimeAtOrAfter", "pageToken", "pageSize", "onBehalfOfContentOwner", "createdAfter"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/jobs/{jobId}/reports"; if self._scopes.len() == 0 { self._scopes.insert(Scope::YtAnalyticMonetaryReadonly.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{jobId}", "jobId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["jobId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the job. /// /// Sets the *job id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn job_id(mut self, new_value: &str) -> JobReportListCall<'a> { self._job_id = new_value.to_string(); self } /// If set, only reports whose start time is smaller than the specified date/time are returned. /// /// Sets the *start time before* query property to the given value. pub fn start_time_before(mut self, new_value: &str) -> JobReportListCall<'a> { self._start_time_before = Some(new_value.to_string()); self } /// If set, only reports whose start time is greater than or equal the specified date/time are returned. /// /// Sets the *start time at or after* query property to the given value. pub fn start_time_at_or_after(mut self, new_value: &str) -> JobReportListCall<'a> { self._start_time_at_or_after = Some(new_value.to_string()); self } /// A token identifying a page of results the server should return. Typically, this is the value of ListReportsResponse.next_page_token returned in response to the previous call to the `ListReports` method. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> JobReportListCall<'a> { self._page_token = Some(new_value.to_string()); self } /// Requested page size. Server may return fewer report types than requested. If unspecified, server will pick an appropriate default. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> JobReportListCall<'a> { self._page_size = Some(new_value); self } /// The content owner's external ID on which behalf the user is acting on. If not set, the user is acting for himself (his own channel). /// /// Sets the *on behalf of content owner* query property to the given value. pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> JobReportListCall<'a> { self._on_behalf_of_content_owner = Some(new_value.to_string()); self } /// If set, only reports created after the specified date/time are returned. /// /// Sets the *created after* query property to the given value. pub fn created_after(mut self, new_value: &str) -> JobReportListCall<'a> { self._created_after = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> JobReportListCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> JobReportListCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::YtAnalyticMonetaryReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> JobReportListCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Creates a job and returns it. /// /// A builder for the *create* method supported by a *job* resource. /// It is not used directly, but through a `JobMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_youtubereporting1 as youtubereporting1; /// use youtubereporting1::api::Job; /// # async fn dox() { /// # use std::default::Default; /// # use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Job::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.jobs().create(req) /// .on_behalf_of_content_owner("est") /// .doit().await; /// # } /// ``` pub struct JobCreateCall<'a> where { hub: &'a YouTubeReporting<>, _request: Job, _on_behalf_of_content_owner: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for JobCreateCall<'a> {} impl<'a> JobCreateCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Job)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "youtubereporting.jobs.create", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); if let Some(value) = self._on_behalf_of_content_owner { params.push(("onBehalfOfContentOwner", value.to_string())); } for &field in ["alt", "onBehalfOfContentOwner"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/jobs"; if self._scopes.len() == 0 { self._scopes.insert(Scope::YtAnalyticMonetaryReadonly.as_ref().to_string(), ()); } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Job) -> JobCreateCall<'a> { self._request = new_value; self } /// The content owner's external ID on which behalf the user is acting on. If not set, the user is acting for himself (his own channel). /// /// Sets the *on behalf of content owner* query property to the given value. pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> JobCreateCall<'a> { self._on_behalf_of_content_owner = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> JobCreateCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> JobCreateCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::YtAnalyticMonetaryReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> JobCreateCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes a job. /// /// A builder for the *delete* method supported by a *job* resource. /// It is not used directly, but through a `JobMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_youtubereporting1 as youtubereporting1; /// # async fn dox() { /// # use std::default::Default; /// # use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.jobs().delete("jobId") /// .on_behalf_of_content_owner("ea") /// .doit().await; /// # } /// ``` pub struct JobDeleteCall<'a> where { hub: &'a YouTubeReporting<>, _job_id: String, _on_behalf_of_content_owner: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for JobDeleteCall<'a> {} impl<'a> JobDeleteCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Empty)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "youtubereporting.jobs.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("jobId", self._job_id.to_string())); if let Some(value) = self._on_behalf_of_content_owner { params.push(("onBehalfOfContentOwner", value.to_string())); } for &field in ["alt", "jobId", "onBehalfOfContentOwner"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/jobs/{jobId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::YtAnalyticMonetaryReadonly.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{jobId}", "jobId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["jobId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the job to delete. /// /// Sets the *job id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn job_id(mut self, new_value: &str) -> JobDeleteCall<'a> { self._job_id = new_value.to_string(); self } /// The content owner's external ID on which behalf the user is acting on. If not set, the user is acting for himself (his own channel). /// /// Sets the *on behalf of content owner* query property to the given value. pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> JobDeleteCall<'a> { self._on_behalf_of_content_owner = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> JobDeleteCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> JobDeleteCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::YtAnalyticMonetaryReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> JobDeleteCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets a job. /// /// A builder for the *get* method supported by a *job* resource. /// It is not used directly, but through a `JobMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_youtubereporting1 as youtubereporting1; /// # async fn dox() { /// # use std::default::Default; /// # use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.jobs().get("jobId") /// .on_behalf_of_content_owner("Lorem") /// .doit().await; /// # } /// ``` pub struct JobGetCall<'a> where { hub: &'a YouTubeReporting<>, _job_id: String, _on_behalf_of_content_owner: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for JobGetCall<'a> {} impl<'a> JobGetCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Job)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "youtubereporting.jobs.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("jobId", self._job_id.to_string())); if let Some(value) = self._on_behalf_of_content_owner { params.push(("onBehalfOfContentOwner", value.to_string())); } for &field in ["alt", "jobId", "onBehalfOfContentOwner"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/jobs/{jobId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::YtAnalyticMonetaryReadonly.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{jobId}", "jobId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["jobId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the job to retrieve. /// /// Sets the *job id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn job_id(mut self, new_value: &str) -> JobGetCall<'a> { self._job_id = new_value.to_string(); self } /// The content owner's external ID on which behalf the user is acting on. If not set, the user is acting for himself (his own channel). /// /// Sets the *on behalf of content owner* query property to the given value. pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> JobGetCall<'a> { self._on_behalf_of_content_owner = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> JobGetCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> JobGetCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::YtAnalyticMonetaryReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> JobGetCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists jobs. /// /// A builder for the *list* method supported by a *job* resource. /// It is not used directly, but through a `JobMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_youtubereporting1 as youtubereporting1; /// # async fn dox() { /// # use std::default::Default; /// # use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.jobs().list() /// .page_token("eos") /// .page_size(-86) /// .on_behalf_of_content_owner("sed") /// .include_system_managed(false) /// .doit().await; /// # } /// ``` pub struct JobListCall<'a> where { hub: &'a YouTubeReporting<>, _page_token: Option, _page_size: Option, _on_behalf_of_content_owner: Option, _include_system_managed: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for JobListCall<'a> {} impl<'a> JobListCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ListJobsResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "youtubereporting.jobs.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } if let Some(value) = self._on_behalf_of_content_owner { params.push(("onBehalfOfContentOwner", value.to_string())); } if let Some(value) = self._include_system_managed { params.push(("includeSystemManaged", value.to_string())); } for &field in ["alt", "pageToken", "pageSize", "onBehalfOfContentOwner", "includeSystemManaged"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/jobs"; if self._scopes.len() == 0 { self._scopes.insert(Scope::YtAnalyticMonetaryReadonly.as_ref().to_string(), ()); } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// A token identifying a page of results the server should return. Typically, this is the value of ListReportTypesResponse.next_page_token returned in response to the previous call to the `ListJobs` method. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> JobListCall<'a> { self._page_token = Some(new_value.to_string()); self } /// Requested page size. Server may return fewer jobs than requested. If unspecified, server will pick an appropriate default. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> JobListCall<'a> { self._page_size = Some(new_value); self } /// The content owner's external ID on which behalf the user is acting on. If not set, the user is acting for himself (his own channel). /// /// Sets the *on behalf of content owner* query property to the given value. pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> JobListCall<'a> { self._on_behalf_of_content_owner = Some(new_value.to_string()); self } /// If set to true, also system-managed jobs will be returned; otherwise only user-created jobs will be returned. System-managed jobs can neither be modified nor deleted. /// /// Sets the *include system managed* query property to the given value. pub fn include_system_managed(mut self, new_value: bool) -> JobListCall<'a> { self._include_system_managed = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> JobListCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> JobListCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::YtAnalyticMonetaryReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> JobListCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Method for media download. Download is supported on the URI `/v1/media/{+name}?alt=media`. /// /// This method supports **media download**. To enable it, adjust the builder like this: /// `.param("alt", "media")`. /// Please note that due to missing multi-part support on the server side, you will only receive the media, /// but not the `GdataMedia` structure that you would usually get. The latter will be a default value. /// /// A builder for the *download* method supported by a *media* resource. /// It is not used directly, but through a `MediaMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_youtubereporting1 as youtubereporting1; /// # async fn dox() { /// # use std::default::Default; /// # use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.media().download("resourceName") /// .doit().await; /// # } /// ``` pub struct MediaDownloadCall<'a> where { hub: &'a YouTubeReporting<>, _resource_name: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for MediaDownloadCall<'a> {} impl<'a> MediaDownloadCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, GdataMedia)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "youtubereporting.media.download", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len()); params.push(("resourceName", self._resource_name.to_string())); for &field in ["resourceName"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let (json_field_missing, enable_resource_parsing) = { let mut enable = true; let mut field_present = true; for &(name, ref value) in params.iter() { if name == "alt" { field_present = false; if >::as_ref(&value) != "json" { enable = false; } break; } } (field_present, enable) }; if json_field_missing { params.push(("alt", "json".to_string())); } let mut url = self.hub._base_url.clone() + "v1/media/{+resourceName}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::YtAnalyticMonetaryReadonly.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["resourceName"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = if enable_resource_parsing { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } } else { (res, Default::default()) }; dlg.finished(true); return Ok(result_value) } } } } /// Name of the media that is being downloaded. /// /// Sets the *resource name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn resource_name(mut self, new_value: &str) -> MediaDownloadCall<'a> { self._resource_name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MediaDownloadCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> MediaDownloadCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::YtAnalyticMonetaryReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> MediaDownloadCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists report types. /// /// A builder for the *list* method supported by a *reportType* resource. /// It is not used directly, but through a `ReportTypeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_youtubereporting1 as youtubereporting1; /// # async fn dox() { /// # use std::default::Default; /// # use youtubereporting1::{YouTubeReporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = YouTubeReporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.report_types().list() /// .page_token("no") /// .page_size(-15) /// .on_behalf_of_content_owner("kasd") /// .include_system_managed(true) /// .doit().await; /// # } /// ``` pub struct ReportTypeListCall<'a> where { hub: &'a YouTubeReporting<>, _page_token: Option, _page_size: Option, _on_behalf_of_content_owner: Option, _include_system_managed: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a> client::CallBuilder for ReportTypeListCall<'a> {} impl<'a> ReportTypeListCall<'a> { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ListReportTypesResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "youtubereporting.reportTypes.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } if let Some(value) = self._on_behalf_of_content_owner { params.push(("onBehalfOfContentOwner", value.to_string())); } if let Some(value) = self._include_system_managed { params.push(("includeSystemManaged", value.to_string())); } for &field in ["alt", "pageToken", "pageSize", "onBehalfOfContentOwner", "includeSystemManaged"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "v1/reportTypes"; if self._scopes.len() == 0 { self._scopes.insert(Scope::YtAnalyticMonetaryReadonly.as_ref().to_string(), ()); } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// A token identifying a page of results the server should return. Typically, this is the value of ListReportTypesResponse.next_page_token returned in response to the previous call to the `ListReportTypes` method. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ReportTypeListCall<'a> { self._page_token = Some(new_value.to_string()); self } /// Requested page size. Server may return fewer report types than requested. If unspecified, server will pick an appropriate default. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> ReportTypeListCall<'a> { self._page_size = Some(new_value); self } /// The content owner's external ID on which behalf the user is acting on. If not set, the user is acting for himself (his own channel). /// /// Sets the *on behalf of content owner* query property to the given value. pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> ReportTypeListCall<'a> { self._on_behalf_of_content_owner = Some(new_value.to_string()); self } /// If set to true, also system-managed report types will be returned; otherwise only the report types that can be used to create new reporting jobs will be returned. /// /// Sets the *include system managed* query property to the given value. pub fn include_system_managed(mut self, new_value: bool) -> ReportTypeListCall<'a> { self._include_system_managed = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportTypeListCall<'a> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> ReportTypeListCall<'a> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::YtAnalyticMonetaryReadonly`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportTypeListCall<'a> where T: Into>, S: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } }