#![allow(clippy::ptr_arg)] use std::collections::{BTreeSet, HashMap}; use tokio::time::sleep; // ############## // 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, Ord, PartialOrd, Hash, Debug, Clone, Copy)] pub enum Scope { /// Delete your Google Tag Manager containers DeleteContainer, /// Manage your Google Tag Manager container and its subcomponents, excluding versioning and publishing EditContainer, /// Manage your Google Tag Manager container versions EditContainerversion, /// View and manage your Google Tag Manager accounts ManageAccount, /// Manage user permissions of your Google Tag Manager account and container ManageUser, /// Publish your Google Tag Manager container versions Publish, /// View your Google Tag Manager container and its subcomponents Readonly, } impl AsRef for Scope { fn as_ref(&self) -> &str { match *self { Scope::DeleteContainer => { "https://www.googleapis.com/auth/tagmanager.delete.containers" } Scope::EditContainer => "https://www.googleapis.com/auth/tagmanager.edit.containers", Scope::EditContainerversion => { "https://www.googleapis.com/auth/tagmanager.edit.containerversions" } Scope::ManageAccount => "https://www.googleapis.com/auth/tagmanager.manage.accounts", Scope::ManageUser => "https://www.googleapis.com/auth/tagmanager.manage.users", Scope::Publish => "https://www.googleapis.com/auth/tagmanager.publish", Scope::Readonly => "https://www.googleapis.com/auth/tagmanager.readonly", } } } #[allow(clippy::derivable_impls)] impl Default for Scope { fn default() -> Scope { Scope::Readonly } } // ######## // HUB ### // ###### /// Central instance to access all TagManager related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Folder; /// use tagmanager1::{Result, Error}; /// # async fn dox() { /// use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. /// let secret: yup_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 = yup_oauth2::InstalledFlowAuthenticator::builder( /// secret, /// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// /// let client = hyper_util::client::legacy::Client::builder( /// hyper_util::rt::TokioExecutor::new() /// ) /// .build( /// hyper_rustls::HttpsConnectorBuilder::new() /// .with_native_roots() /// .unwrap() /// .https_or_http() /// .enable_http1() /// .build() /// ); /// let mut hub = TagManager::new(client, 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 = Folder::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.accounts().containers_move_folders_update(req, "accountId", "containerId", "folderId") /// .add_variable_id("gubergren") /// .add_trigger_id("eos") /// .add_tag_id("dolor") /// .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 TagManager { pub client: common::Client, pub auth: Box, _user_agent: String, _base_url: String, _root_url: String, } impl common::Hub for TagManager {} impl<'a, C> TagManager { pub fn new(client: common::Client, auth: A) -> TagManager { TagManager { client, auth: Box::new(auth), _user_agent: "google-api-rust-client/6.0.0".to_string(), _base_url: "https://tagmanager.googleapis.com/".to_string(), _root_url: "https://tagmanager.googleapis.com/".to_string(), } } pub fn accounts(&'a self) -> AccountMethods<'a, C> { AccountMethods { hub: self } } /// Set the user-agent header field to use in all requests to the server. /// It defaults to `google-api-rust-client/6.0.0`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { std::mem::replace(&mut self._user_agent, agent_name) } /// Set the base url to use in all requests to the server. /// It defaults to `https://tagmanager.googleapis.com/`. /// /// Returns the previously set base url. pub fn base_url(&mut self, new_base_url: String) -> String { std::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://tagmanager.googleapis.com/`. /// /// Returns the previously set root url. pub fn root_url(&mut self, new_root_url: String) -> String { std::mem::replace(&mut self._root_url, new_root_url) } } // ############ // SCHEMAS ### // ########## /// Represents a Google Tag Manager Account. /// /// # 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*). /// /// * [containers environments create accounts](AccountContainerEnvironmentCreateCall) (none) /// * [containers environments delete accounts](AccountContainerEnvironmentDeleteCall) (none) /// * [containers environments get accounts](AccountContainerEnvironmentGetCall) (none) /// * [containers environments list accounts](AccountContainerEnvironmentListCall) (none) /// * [containers environments update accounts](AccountContainerEnvironmentUpdateCall) (none) /// * [containers folders entities list accounts](AccountContainerFolderEntityListCall) (none) /// * [containers folders create accounts](AccountContainerFolderCreateCall) (none) /// * [containers folders delete accounts](AccountContainerFolderDeleteCall) (none) /// * [containers folders get accounts](AccountContainerFolderGetCall) (none) /// * [containers folders list accounts](AccountContainerFolderListCall) (none) /// * [containers folders update accounts](AccountContainerFolderUpdateCall) (none) /// * [containers move_folders update accounts](AccountContainerMoveFolderUpdateCall) (none) /// * [containers reauthorize_environments update accounts](AccountContainerReauthorizeEnvironmentUpdateCall) (none) /// * [containers tags create accounts](AccountContainerTagCreateCall) (none) /// * [containers tags delete accounts](AccountContainerTagDeleteCall) (none) /// * [containers tags get accounts](AccountContainerTagGetCall) (none) /// * [containers tags list accounts](AccountContainerTagListCall) (none) /// * [containers tags update accounts](AccountContainerTagUpdateCall) (none) /// * [containers triggers create accounts](AccountContainerTriggerCreateCall) (none) /// * [containers triggers delete accounts](AccountContainerTriggerDeleteCall) (none) /// * [containers triggers get accounts](AccountContainerTriggerGetCall) (none) /// * [containers triggers list accounts](AccountContainerTriggerListCall) (none) /// * [containers triggers update accounts](AccountContainerTriggerUpdateCall) (none) /// * [containers variables create accounts](AccountContainerVariableCreateCall) (none) /// * [containers variables delete accounts](AccountContainerVariableDeleteCall) (none) /// * [containers variables get accounts](AccountContainerVariableGetCall) (none) /// * [containers variables list accounts](AccountContainerVariableListCall) (none) /// * [containers variables update accounts](AccountContainerVariableUpdateCall) (none) /// * [containers versions create accounts](AccountContainerVersionCreateCall) (none) /// * [containers versions delete accounts](AccountContainerVersionDeleteCall) (none) /// * [containers versions get accounts](AccountContainerVersionGetCall) (none) /// * [containers versions list accounts](AccountContainerVersionListCall) (none) /// * [containers versions publish accounts](AccountContainerVersionPublishCall) (none) /// * [containers versions restore accounts](AccountContainerVersionRestoreCall) (none) /// * [containers versions undelete accounts](AccountContainerVersionUndeleteCall) (none) /// * [containers versions update accounts](AccountContainerVersionUpdateCall) (none) /// * [containers create accounts](AccountContainerCreateCall) (none) /// * [containers delete accounts](AccountContainerDeleteCall) (none) /// * [containers get accounts](AccountContainerGetCall) (none) /// * [containers list accounts](AccountContainerListCall) (none) /// * [containers update accounts](AccountContainerUpdateCall) (none) /// * [permissions create accounts](AccountPermissionCreateCall) (none) /// * [permissions delete accounts](AccountPermissionDeleteCall) (none) /// * [permissions get accounts](AccountPermissionGetCall) (none) /// * [permissions list accounts](AccountPermissionListCall) (none) /// * [permissions update accounts](AccountPermissionUpdateCall) (none) /// * [get accounts](AccountGetCall) (response) /// * [list accounts](AccountListCall) (none) /// * [update accounts](AccountUpdateCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Account { /// The Account ID uniquely identifies the GTM Account. #[serde(rename = "accountId")] pub account_id: Option, /// The fingerprint of the GTM Account as computed at storage time. This value is recomputed whenever the account is modified. pub fingerprint: Option, /// Account display name. @mutable tagmanager.accounts.create @mutable tagmanager.accounts.update pub name: Option, /// Whether the account shares data anonymously with Google and others. @mutable tagmanager.accounts.create @mutable tagmanager.accounts.update #[serde(rename = "shareData")] pub share_data: Option, } impl common::RequestValue for Account {} impl common::Resource for Account {} impl common::ResponseResult for Account {} /// Defines the Google Tag Manager Account access permissions. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct AccountAccess { /// List of Account permissions. Valid account permissions are read and manage. @mutable tagmanager.accounts.permissions.create @mutable tagmanager.accounts.permissions.update pub permission: Option>, } impl common::Part for AccountAccess {} /// Represents a predicate. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Condition { /// A list of named parameters (key/value), depending on the condition's type. Notes: - For binary operators, include parameters named arg0 and arg1 for specifying the left and right operands, respectively. - At this time, the left operand (arg0) must be a reference to a variable. - For case-insensitive Regex matching, include a boolean parameter named ignore_case that is set to true. If not specified or set to any other value, the matching will be case sensitive. - To negate an operator, include a boolean parameter named negate boolean parameter that is set to true. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update pub parameter: Option>, /// The type of operator for this condition. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "type")] pub type_: Option, } impl common::Part for Condition {} /// Represents a Google Tag Manager Container. /// /// # 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*). /// /// * [containers create accounts](AccountContainerCreateCall) (request|response) /// * [containers get accounts](AccountContainerGetCall) (response) /// * [containers update accounts](AccountContainerUpdateCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Container { /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// The Container ID uniquely identifies the GTM Container. #[serde(rename = "containerId")] pub container_id: Option, /// Optional list of domain names associated with the Container. @mutable tagmanager.accounts.containers.create @mutable tagmanager.accounts.containers.update #[serde(rename = "domainName")] pub domain_name: Option>, /// List of enabled built-in variables. Valid values include: pageUrl, pageHostname, pagePath, referrer, event, clickElement, clickClasses, clickId, clickTarget, clickUrl, clickText, formElement, formClasses, formId, formTarget, formUrl, formText, errorMessage, errorUrl, errorLine, newHistoryFragment, oldHistoryFragment, newHistoryState, oldHistoryState, historySource, containerVersion, debugMode, randomNumber, containerId. @mutable tagmanager.accounts.containers.create @mutable tagmanager.accounts.containers.update #[serde(rename = "enabledBuiltInVariable")] pub enabled_built_in_variable: Option>, /// The fingerprint of the GTM Container as computed at storage time. This value is recomputed whenever the account is modified. pub fingerprint: Option, /// Container display name. @mutable tagmanager.accounts.containers.create @mutable tagmanager.accounts.containers.update pub name: Option, /// Container Notes. @mutable tagmanager.accounts.containers.create @mutable tagmanager.accounts.containers.update pub notes: Option, /// Container Public ID. #[serde(rename = "publicId")] pub public_id: Option, /// Container Country ID. @mutable tagmanager.accounts.containers.create @mutable tagmanager.accounts.containers.update #[serde(rename = "timeZoneCountryId")] pub time_zone_country_id: Option, /// Container Time Zone ID. @mutable tagmanager.accounts.containers.create @mutable tagmanager.accounts.containers.update #[serde(rename = "timeZoneId")] pub time_zone_id: Option, /// List of Usage Contexts for the Container. Valid values include: web, android, ios. @mutable tagmanager.accounts.containers.create @mutable tagmanager.accounts.containers.update #[serde(rename = "usageContext")] pub usage_context: Option>, } impl common::RequestValue for Container {} impl common::ResponseResult for Container {} /// Defines the Google Tag Manager Container access permissions. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ContainerAccess { /// GTM Container ID. @mutable tagmanager.accounts.permissions.create @mutable tagmanager.accounts.permissions.update #[serde(rename = "containerId")] pub container_id: Option, /// List of Container permissions. Valid container permissions are: read, edit, delete, publish. @mutable tagmanager.accounts.permissions.create @mutable tagmanager.accounts.permissions.update pub permission: Option>, } impl common::Part for ContainerAccess {} /// Represents a Google Tag Manager Container Version. /// /// # 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*). /// /// * [containers versions get accounts](AccountContainerVersionGetCall) (response) /// * [containers versions restore accounts](AccountContainerVersionRestoreCall) (response) /// * [containers versions undelete accounts](AccountContainerVersionUndeleteCall) (response) /// * [containers versions update accounts](AccountContainerVersionUpdateCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ContainerVersion { /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// The container that this version was taken from. pub container: Option, /// GTM Container ID. #[serde(rename = "containerId")] pub container_id: Option, /// The Container Version ID uniquely identifies the GTM Container Version. #[serde(rename = "containerVersionId")] pub container_version_id: Option, /// A value of true indicates this container version has been deleted. pub deleted: Option, /// The fingerprint of the GTM Container Version as computed at storage time. This value is recomputed whenever the container version is modified. pub fingerprint: Option, /// The folders in the container that this version was taken from. pub folder: Option>, /// The macros in the container that this version was taken from. #[serde(rename = "macro")] pub macro_: Option>, /// Container version display name. @mutable tagmanager.accounts.containers.versions.update pub name: Option, /// User notes on how to apply this container version in the container. @mutable tagmanager.accounts.containers.versions.update pub notes: Option, /// The rules in the container that this version was taken from. pub rule: Option>, /// The tags in the container that this version was taken from. pub tag: Option>, /// The triggers in the container that this version was taken from. pub trigger: Option>, /// The variables in the container that this version was taken from. pub variable: Option>, } impl common::RequestValue for ContainerVersion {} impl common::ResponseResult for ContainerVersion {} /// Represents a Google Tag Manager Container Version Header. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ContainerVersionHeader { /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// GTM Container ID. #[serde(rename = "containerId")] pub container_id: Option, /// The Container Version ID uniquely identifies the GTM Container Version. #[serde(rename = "containerVersionId")] pub container_version_id: Option, /// A value of true indicates this container version has been deleted. pub deleted: Option, /// Container version display name. pub name: Option, /// Number of macros in the container version. #[serde(rename = "numMacros")] pub num_macros: Option, /// Number of rules in the container version. #[serde(rename = "numRules")] pub num_rules: Option, /// Number of tags in the container version. #[serde(rename = "numTags")] pub num_tags: Option, /// Number of triggers in the container version. #[serde(rename = "numTriggers")] pub num_triggers: Option, /// Number of variables in the container version. #[serde(rename = "numVariables")] pub num_variables: Option, } impl common::Part for ContainerVersionHeader {} /// Options for new container versions. /// /// # 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*). /// /// * [containers versions create accounts](AccountContainerVersionCreateCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct CreateContainerVersionRequestVersionOptions { /// The name of the container version to be created. pub name: Option, /// The notes of the container version to be created. pub notes: Option, /// The creation of this version may be for quick preview and shouldn't be saved. #[serde(rename = "quickPreview")] pub quick_preview: Option, } impl common::RequestValue for CreateContainerVersionRequestVersionOptions {} /// Create container versions response. /// /// # 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*). /// /// * [containers versions create accounts](AccountContainerVersionCreateCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct CreateContainerVersionResponse { /// Compiler errors or not. #[serde(rename = "compilerError")] pub compiler_error: Option, /// The container version created. #[serde(rename = "containerVersion")] pub container_version: Option, } impl common::ResponseResult for CreateContainerVersionResponse {} /// Represents a Google Tag Manager Environment. Note that a user can create, delete and update environments of type USER, but can only update the enable_debug and url fields of environments of other types. /// /// # 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*). /// /// * [containers environments create accounts](AccountContainerEnvironmentCreateCall) (request|response) /// * [containers environments get accounts](AccountContainerEnvironmentGetCall) (response) /// * [containers environments update accounts](AccountContainerEnvironmentUpdateCall) (request|response) /// * [containers reauthorize_environments update accounts](AccountContainerReauthorizeEnvironmentUpdateCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Environment { /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// The environment authorization code. #[serde(rename = "authorizationCode")] pub authorization_code: Option, /// The last update time-stamp for the authorization code. #[serde(rename = "authorizationTimestampMs")] #[serde_as(as = "Option")] pub authorization_timestamp_ms: Option, /// GTM Container ID. #[serde(rename = "containerId")] pub container_id: Option, /// no description provided #[serde(rename = "containerVersionId")] pub container_version_id: Option, /// The environment description. Can be set or changed only on USER type environments. @mutable tagmanager.accounts.containers.environments.create @mutable tagmanager.accounts.containers.environments.update pub description: Option, /// Whether or not to enable debug by default on for the environment. @mutable tagmanager.accounts.containers.environments.create @mutable tagmanager.accounts.containers.environments.update #[serde(rename = "enableDebug")] pub enable_debug: Option, /// GTM Environment ID uniquely identifies the GTM Environment. #[serde(rename = "environmentId")] pub environment_id: Option, /// The fingerprint of the GTM environment as computed at storage time. This value is recomputed whenever the environment is modified. pub fingerprint: Option, /// The environment display name. Can be set or changed only on USER type environments. @mutable tagmanager.accounts.containers.environments.create @mutable tagmanager.accounts.containers.environments.update pub name: Option, /// The type of this environment. #[serde(rename = "type")] pub type_: Option, /// Default preview page url for the environment. @mutable tagmanager.accounts.containers.environments.create @mutable tagmanager.accounts.containers.environments.update pub url: Option, } impl common::RequestValue for Environment {} impl common::ResponseResult for Environment {} /// Represents a Google Tag Manager Folder. /// /// # 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*). /// /// * [containers folders create accounts](AccountContainerFolderCreateCall) (request|response) /// * [containers folders get accounts](AccountContainerFolderGetCall) (response) /// * [containers folders update accounts](AccountContainerFolderUpdateCall) (request|response) /// * [containers move_folders update accounts](AccountContainerMoveFolderUpdateCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Folder { /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// GTM Container ID. #[serde(rename = "containerId")] pub container_id: Option, /// The fingerprint of the GTM Folder as computed at storage time. This value is recomputed whenever the folder is modified. pub fingerprint: Option, /// The Folder ID uniquely identifies the GTM Folder. #[serde(rename = "folderId")] pub folder_id: Option, /// Folder display name. @mutable tagmanager.accounts.containers.folders.create @mutable tagmanager.accounts.containers.folders.update pub name: Option, } impl common::RequestValue for Folder {} impl common::ResponseResult for Folder {} /// Represents a Google Tag Manager Folder’s contents. /// /// # 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*). /// /// * [containers folders entities list accounts](AccountContainerFolderEntityListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct FolderEntities { /// The list of tags inside the folder. pub tag: Option>, /// The list of triggers inside the folder. pub trigger: Option>, /// The list of variables inside the folder. pub variable: Option>, } impl common::ResponseResult for FolderEntities {} /// List AccountUsers Response. /// /// # 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*). /// /// * [permissions list accounts](AccountPermissionListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListAccountUsersResponse { /// All GTM AccountUsers of a GTM Account. #[serde(rename = "userAccess")] pub user_access: Option>, } impl common::ResponseResult for ListAccountUsersResponse {} /// List Accounts Response. /// /// # 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 accounts](AccountListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListAccountsResponse { /// List of GTM Accounts that a user has access to. pub accounts: Option>, } impl common::ResponseResult for ListAccountsResponse {} /// List container versions response. /// /// # 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*). /// /// * [containers versions list accounts](AccountContainerVersionListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListContainerVersionsResponse { /// All versions of a GTM Container. #[serde(rename = "containerVersion")] pub container_version: Option>, /// All container version headers of a GTM Container. #[serde(rename = "containerVersionHeader")] pub container_version_header: Option>, } impl common::ResponseResult for ListContainerVersionsResponse {} /// List Containers Response. /// /// # 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*). /// /// * [containers list accounts](AccountContainerListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListContainersResponse { /// All Containers of a GTM Account. pub containers: Option>, } impl common::ResponseResult for ListContainersResponse {} /// List Environments Response. /// /// # 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*). /// /// * [containers environments list accounts](AccountContainerEnvironmentListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListEnvironmentsResponse { /// All Environments of a GTM Container. pub environments: Option>, } impl common::ResponseResult for ListEnvironmentsResponse {} /// List Folders Response. /// /// # 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*). /// /// * [containers folders list accounts](AccountContainerFolderListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListFoldersResponse { /// All GTM Folders of a GTM Container. pub folders: Option>, } impl common::ResponseResult for ListFoldersResponse {} /// List Tags Response. /// /// # 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*). /// /// * [containers tags list accounts](AccountContainerTagListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListTagsResponse { /// All GTM Tags of a GTM Container. pub tags: Option>, } impl common::ResponseResult for ListTagsResponse {} /// List triggers response. /// /// # 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*). /// /// * [containers triggers list accounts](AccountContainerTriggerListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListTriggersResponse { /// All GTM Triggers of a GTM Container. pub triggers: Option>, } impl common::ResponseResult for ListTriggersResponse {} /// List Variables Response. /// /// # 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*). /// /// * [containers variables list accounts](AccountContainerVariableListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ListVariablesResponse { /// All GTM Variables of a GTM Container. pub variables: Option>, } impl common::ResponseResult for ListVariablesResponse {} /// Represents a Google Tag Manager Macro. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Macro { /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// GTM Container ID. #[serde(rename = "containerId")] pub container_id: Option, /// For mobile containers only: A list of rule IDs for disabling conditional macros; the macro is enabled if one of the enabling rules is true while all the disabling rules are false. Treated as an unordered set. @mutable tagmanager.accounts.containers.macros.create @mutable tagmanager.accounts.containers.macros.update #[serde(rename = "disablingRuleId")] pub disabling_rule_id: Option>, /// For mobile containers only: A list of rule IDs for enabling conditional macros; the macro is enabled if one of the enabling rules is true while all the disabling rules are false. Treated as an unordered set. @mutable tagmanager.accounts.containers.macros.create @mutable tagmanager.accounts.containers.macros.update #[serde(rename = "enablingRuleId")] pub enabling_rule_id: Option>, /// The fingerprint of the GTM Macro as computed at storage time. This value is recomputed whenever the macro is modified. pub fingerprint: Option, /// The Macro ID uniquely identifies the GTM Macro. #[serde(rename = "macroId")] pub macro_id: Option, /// Macro display name. @mutable tagmanager.accounts.containers.macros.create @mutable tagmanager.accounts.containers.macros.update pub name: Option, /// User notes on how to apply this macro in the container. @mutable tagmanager.accounts.containers.macros.create @mutable tagmanager.accounts.containers.macros.update pub notes: Option, /// The macro's parameters. @mutable tagmanager.accounts.containers.macros.create @mutable tagmanager.accounts.containers.macros.update pub parameter: Option>, /// Parent folder id. #[serde(rename = "parentFolderId")] pub parent_folder_id: Option, /// The end timestamp in milliseconds to schedule a macro. @mutable tagmanager.accounts.containers.macros.create @mutable tagmanager.accounts.containers.macros.update #[serde(rename = "scheduleEndMs")] #[serde_as(as = "Option")] pub schedule_end_ms: Option, /// The start timestamp in milliseconds to schedule a macro. @mutable tagmanager.accounts.containers.macros.create @mutable tagmanager.accounts.containers.macros.update #[serde(rename = "scheduleStartMs")] #[serde_as(as = "Option")] pub schedule_start_ms: Option, /// GTM Macro Type. @mutable tagmanager.accounts.containers.macros.create @mutable tagmanager.accounts.containers.macros.update #[serde(rename = "type")] pub type_: Option, } impl common::Part for Macro {} /// Represents a Google Tag Manager Parameter. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Parameter { /// The named key that uniquely identifies a parameter. Required for top-level parameters, as well as map values. Ignored for list values. @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update pub key: Option, /// This list parameter's parameters (keys will be ignored). @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update pub list: Option>, /// This map parameter's parameters (must have keys; keys must be unique). @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update pub map: Option>, /// The parameter type. Valid values are: - boolean: The value represents a boolean, represented as 'true' or 'false' - integer: The value represents a 64-bit signed integer value, in base 10 - list: A list of parameters should be specified - map: A map of parameters should be specified - template: The value represents any text; this can include variable references (even variable references that might return non-string types) - trigger_reference: The value represents a trigger, represented as the trigger id - tag_reference: The value represents a tag, represented as the tag name @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update #[serde(rename = "type")] pub type_: Option, /// A parameter's value (may contain variable references such as "{{myVariable}}") as appropriate to the specified type. @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update pub value: Option, } impl common::Part for Parameter {} /// Publish container version response. /// /// # 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*). /// /// * [containers versions publish accounts](AccountContainerVersionPublishCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct PublishContainerVersionResponse { /// Compiler errors or not. #[serde(rename = "compilerError")] pub compiler_error: Option, /// The container version created. #[serde(rename = "containerVersion")] pub container_version: Option, } impl common::ResponseResult for PublishContainerVersionResponse {} /// Represents a Google Tag Manager Rule. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Rule { /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// The list of conditions that make up this rule (implicit AND between them). @mutable tagmanager.accounts.containers.rules.create @mutable tagmanager.accounts.containers.rules.update pub condition: Option>, /// GTM Container ID. #[serde(rename = "containerId")] pub container_id: Option, /// The fingerprint of the GTM Rule as computed at storage time. This value is recomputed whenever the rule is modified. pub fingerprint: Option, /// Rule display name. @mutable tagmanager.accounts.containers.rules.create @mutable tagmanager.accounts.containers.rules.update pub name: Option, /// User notes on how to apply this rule in the container. @mutable tagmanager.accounts.containers.rules.create @mutable tagmanager.accounts.containers.rules.update pub notes: Option, /// The Rule ID uniquely identifies the GTM Rule. #[serde(rename = "ruleId")] pub rule_id: Option, } impl common::Part for Rule {} /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct SetupTag { /// If true, fire the main tag if and only if the setup tag fires successfully. If false, fire the main tag regardless of setup tag firing status. #[serde(rename = "stopOnSetupFailure")] pub stop_on_setup_failure: Option, /// The name of the setup tag. #[serde(rename = "tagName")] pub tag_name: Option, } impl common::Part for SetupTag {} /// Represents a Google Tag Manager Tag. /// /// # 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*). /// /// * [containers tags create accounts](AccountContainerTagCreateCall) (request|response) /// * [containers tags get accounts](AccountContainerTagGetCall) (response) /// * [containers tags update accounts](AccountContainerTagUpdateCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Tag { /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// Blocking rule IDs. If any of the listed rules evaluate to true, the tag will not fire. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update #[serde(rename = "blockingRuleId")] pub blocking_rule_id: Option>, /// Blocking trigger IDs. If any of the listed triggers evaluate to true, the tag will not fire. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update #[serde(rename = "blockingTriggerId")] pub blocking_trigger_id: Option>, /// GTM Container ID. #[serde(rename = "containerId")] pub container_id: Option, /// The fingerprint of the GTM Tag as computed at storage time. This value is recomputed whenever the tag is modified. pub fingerprint: Option, /// Firing rule IDs. A tag will fire when any of the listed rules are true and all of its blockingRuleIds (if any specified) are false. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update #[serde(rename = "firingRuleId")] pub firing_rule_id: Option>, /// Firing trigger IDs. A tag will fire when any of the listed triggers are true and all of its blockingTriggerIds (if any specified) are false. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update #[serde(rename = "firingTriggerId")] pub firing_trigger_id: Option>, /// If set to true, this tag will only fire in the live environment (e.g. not in preview or debug mode). @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update #[serde(rename = "liveOnly")] pub live_only: Option, /// Tag display name. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update pub name: Option, /// User notes on how to apply this tag in the container. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update pub notes: Option, /// The tag's parameters. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update pub parameter: Option>, /// Parent folder id. #[serde(rename = "parentFolderId")] pub parent_folder_id: Option, /// True if the tag is paused. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update pub paused: Option, /// User defined numeric priority of the tag. Tags are fired asynchronously in order of priority. Tags with higher numeric value fire first. A tag's priority can be a positive or negative value. The default value is 0. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update pub priority: Option, /// The end timestamp in milliseconds to schedule a tag. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update #[serde(rename = "scheduleEndMs")] #[serde_as(as = "Option")] pub schedule_end_ms: Option, /// The start timestamp in milliseconds to schedule a tag. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update #[serde(rename = "scheduleStartMs")] #[serde_as(as = "Option")] pub schedule_start_ms: Option, /// The list of setup tags. Currently we only allow one. #[serde(rename = "setupTag")] pub setup_tag: Option>, /// Option to fire this tag. #[serde(rename = "tagFiringOption")] pub tag_firing_option: Option, /// The Tag ID uniquely identifies the GTM Tag. #[serde(rename = "tagId")] pub tag_id: Option, /// The list of teardown tags. Currently we only allow one. #[serde(rename = "teardownTag")] pub teardown_tag: Option>, /// GTM Tag Type. @mutable tagmanager.accounts.containers.tags.create @mutable tagmanager.accounts.containers.tags.update #[serde(rename = "type")] pub type_: Option, } impl common::RequestValue for Tag {} impl common::ResponseResult for Tag {} /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct TeardownTag { /// If true, fire the teardown tag if and only if the main tag fires successfully. If false, fire the teardown tag regardless of main tag firing status. #[serde(rename = "stopTeardownOnFailure")] pub stop_teardown_on_failure: Option, /// The name of the teardown tag. #[serde(rename = "tagName")] pub tag_name: Option, } impl common::Part for TeardownTag {} /// Represents a Google Tag Manager Trigger /// /// # 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*). /// /// * [containers triggers create accounts](AccountContainerTriggerCreateCall) (request|response) /// * [containers triggers get accounts](AccountContainerTriggerGetCall) (response) /// * [containers triggers update accounts](AccountContainerTriggerUpdateCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Trigger { /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// Used in the case of auto event tracking. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "autoEventFilter")] pub auto_event_filter: Option>, /// Whether or not we should only fire tags if the form submit or link click event is not cancelled by some other event handler (e.g. because of validation). Only valid for Form Submission and Link Click triggers. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "checkValidation")] pub check_validation: Option, /// GTM Container ID. #[serde(rename = "containerId")] pub container_id: Option, /// A visibility trigger minimum continuous visible time (in milliseconds). Only valid for AMP Visibility trigger. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "continuousTimeMinMilliseconds")] pub continuous_time_min_milliseconds: Option, /// Used in the case of custom event, which is fired iff all Conditions are true. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "customEventFilter")] pub custom_event_filter: Option>, /// Name of the GTM event that is fired. Only valid for Timer triggers. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "eventName")] pub event_name: Option, /// The trigger will only fire iff all Conditions are true. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update pub filter: Option>, /// The fingerprint of the GTM Trigger as computed at storage time. This value is recomputed whenever the trigger is modified. pub fingerprint: Option, /// List of integer percentage values for scroll triggers. The trigger will fire when each percentage is reached when the view is scrolled horizontally. Only valid for AMP scroll triggers. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "horizontalScrollPercentageList")] pub horizontal_scroll_percentage_list: Option, /// Time between triggering recurring Timer Events (in milliseconds). Only valid for Timer triggers. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update pub interval: Option, /// Time between Timer Events to fire (in seconds). Only valid for AMP Timer trigger. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "intervalSeconds")] pub interval_seconds: Option, /// Limit of the number of GTM events this Timer Trigger will fire. If no limit is set, we will continue to fire GTM events until the user leaves the page. Only valid for Timer triggers. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update pub limit: Option, /// Max time to fire Timer Events (in seconds). Only valid for AMP Timer trigger. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "maxTimerLengthSeconds")] pub max_timer_length_seconds: Option, /// Trigger display name. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update pub name: Option, /// Additional parameters. @mutable tagmanager.accounts.containers.workspaces.triggers.create @mutable tagmanager.accounts.containers.workspaces.triggers.update pub parameter: Option>, /// Parent folder id. #[serde(rename = "parentFolderId")] pub parent_folder_id: Option, /// A click trigger CSS selector (i.e. "a", "button" etc.). Only valid for AMP Click trigger. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update pub selector: Option, /// A visibility trigger minimum total visible time (in milliseconds). Only valid for AMP Visibility trigger. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "totalTimeMinMilliseconds")] pub total_time_min_milliseconds: Option, /// The Trigger ID uniquely identifies the GTM Trigger. #[serde(rename = "triggerId")] pub trigger_id: Option, /// Defines the data layer event that causes this trigger. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "type")] pub type_: Option, /// Globally unique id of the trigger that auto-generates this (a Form Submit, Link Click or Timer listener) if any. Used to make incompatible auto-events work together with trigger filtering based on trigger ids. This value is populated during output generation since the tags implied by triggers don't exist until then. Only valid for Form Submit, Link Click and Timer triggers. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "uniqueTriggerId")] pub unique_trigger_id: Option, /// List of integer percentage values for scroll triggers. The trigger will fire when each percentage is reached when the view is scrolled vertically. Only valid for AMP scroll triggers. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "verticalScrollPercentageList")] pub vertical_scroll_percentage_list: Option, /// A visibility trigger CSS selector (i.e. "#id"). Only valid for AMP Visibility trigger. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "visibilitySelector")] pub visibility_selector: Option, /// A visibility trigger maximum percent visibility. Only valid for AMP Visibility trigger. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "visiblePercentageMax")] pub visible_percentage_max: Option, /// A visibility trigger minimum percent visibility. Only valid for AMP Visibility trigger. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "visiblePercentageMin")] pub visible_percentage_min: Option, /// Whether or not we should delay the form submissions or link opening until all of the tags have fired (by preventing the default action and later simulating the default action). Only valid for Form Submission and Link Click triggers. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "waitForTags")] pub wait_for_tags: Option, /// How long to wait (in milliseconds) for tags to fire when 'waits_for_tags' above evaluates to true. Only valid for Form Submission and Link Click triggers. @mutable tagmanager.accounts.containers.triggers.create @mutable tagmanager.accounts.containers.triggers.update #[serde(rename = "waitForTagsTimeout")] pub wait_for_tags_timeout: Option, } impl common::RequestValue for Trigger {} impl common::ResponseResult for Trigger {} /// Represents a user’s permissions to an account and its container. /// /// # 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*). /// /// * [permissions create accounts](AccountPermissionCreateCall) (request|response) /// * [permissions get accounts](AccountPermissionGetCall) (response) /// * [permissions update accounts](AccountPermissionUpdateCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct UserAccess { /// GTM Account access permissions. @mutable tagmanager.accounts.permissions.create @mutable tagmanager.accounts.permissions.update #[serde(rename = "accountAccess")] pub account_access: Option, /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// GTM Container access permissions. @mutable tagmanager.accounts.permissions.create @mutable tagmanager.accounts.permissions.update #[serde(rename = "containerAccess")] pub container_access: Option>, /// User's email address. @mutable tagmanager.accounts.permissions.create #[serde(rename = "emailAddress")] pub email_address: Option, /// Account Permission ID. #[serde(rename = "permissionId")] pub permission_id: Option, } impl common::RequestValue for UserAccess {} impl common::ResponseResult for UserAccess {} /// Represents a Google Tag Manager Variable. /// /// # 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*). /// /// * [containers variables create accounts](AccountContainerVariableCreateCall) (request|response) /// * [containers variables get accounts](AccountContainerVariableGetCall) (response) /// * [containers variables update accounts](AccountContainerVariableUpdateCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct Variable { /// GTM Account ID. #[serde(rename = "accountId")] pub account_id: Option, /// GTM Container ID. #[serde(rename = "containerId")] pub container_id: Option, /// For mobile containers only: A list of trigger IDs for disabling conditional variables; the variable is enabled if one of the enabling trigger is true while all the disabling trigger are false. Treated as an unordered set. @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update #[serde(rename = "disablingTriggerId")] pub disabling_trigger_id: Option>, /// For mobile containers only: A list of trigger IDs for enabling conditional variables; the variable is enabled if one of the enabling triggers is true while all the disabling triggers are false. Treated as an unordered set. @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update #[serde(rename = "enablingTriggerId")] pub enabling_trigger_id: Option>, /// The fingerprint of the GTM Variable as computed at storage time. This value is recomputed whenever the variable is modified. pub fingerprint: Option, /// Variable display name. @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update pub name: Option, /// User notes on how to apply this variable in the container. @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update pub notes: Option, /// The variable's parameters. @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update pub parameter: Option>, /// Parent folder id. #[serde(rename = "parentFolderId")] pub parent_folder_id: Option, /// The end timestamp in milliseconds to schedule a variable. @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update #[serde(rename = "scheduleEndMs")] #[serde_as(as = "Option")] pub schedule_end_ms: Option, /// The start timestamp in milliseconds to schedule a variable. @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update #[serde(rename = "scheduleStartMs")] #[serde_as(as = "Option")] pub schedule_start_ms: Option, /// GTM Variable Type. @mutable tagmanager.accounts.containers.variables.create @mutable tagmanager.accounts.containers.variables.update #[serde(rename = "type")] pub type_: Option, /// The Variable ID uniquely identifies the GTM Variable. #[serde(rename = "variableId")] pub variable_id: Option, } impl common::RequestValue for Variable {} impl common::ResponseResult for Variable {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *account* resources. /// It is not used directly, but through the [`TagManager`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_tagmanager1 as tagmanager1; /// /// # async fn dox() { /// use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// let secret: yup_oauth2::ApplicationSecret = Default::default(); /// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// secret, /// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// /// let client = hyper_util::client::legacy::Client::builder( /// hyper_util::rt::TokioExecutor::new() /// ) /// .build( /// hyper_rustls::HttpsConnectorBuilder::new() /// .with_native_roots() /// .unwrap() /// .https_or_http() /// .enable_http1() /// .build() /// ); /// let mut hub = TagManager::new(client, auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `containers_create(...)`, `containers_delete(...)`, `containers_environments_create(...)`, `containers_environments_delete(...)`, `containers_environments_get(...)`, `containers_environments_list(...)`, `containers_environments_update(...)`, `containers_folders_create(...)`, `containers_folders_delete(...)`, `containers_folders_entities_list(...)`, `containers_folders_get(...)`, `containers_folders_list(...)`, `containers_folders_update(...)`, `containers_get(...)`, `containers_list(...)`, `containers_move_folders_update(...)`, `containers_reauthorize_environments_update(...)`, `containers_tags_create(...)`, `containers_tags_delete(...)`, `containers_tags_get(...)`, `containers_tags_list(...)`, `containers_tags_update(...)`, `containers_triggers_create(...)`, `containers_triggers_delete(...)`, `containers_triggers_get(...)`, `containers_triggers_list(...)`, `containers_triggers_update(...)`, `containers_update(...)`, `containers_variables_create(...)`, `containers_variables_delete(...)`, `containers_variables_get(...)`, `containers_variables_list(...)`, `containers_variables_update(...)`, `containers_versions_create(...)`, `containers_versions_delete(...)`, `containers_versions_get(...)`, `containers_versions_list(...)`, `containers_versions_publish(...)`, `containers_versions_restore(...)`, `containers_versions_undelete(...)`, `containers_versions_update(...)`, `get(...)`, `list(...)`, `permissions_create(...)`, `permissions_delete(...)`, `permissions_get(...)`, `permissions_list(...)`, `permissions_update(...)` and `update(...)` /// // to build up your call. /// let rb = hub.accounts(); /// # } /// ``` pub struct AccountMethods<'a, C> where C: 'a, { hub: &'a TagManager, } impl<'a, C> common::MethodsBuilder for AccountMethods<'a, C> {} impl<'a, C> AccountMethods<'a, C> { /// Create a builder to help you perform the following task: /// /// Creates a GTM Environment. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_environments_create( &self, request: Environment, account_id: &str, container_id: &str, ) -> AccountContainerEnvironmentCreateCall<'a, C> { AccountContainerEnvironmentCreateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a GTM Environment. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `environmentId` - The GTM Environment ID. pub fn containers_environments_delete( &self, account_id: &str, container_id: &str, environment_id: &str, ) -> AccountContainerEnvironmentDeleteCall<'a, C> { AccountContainerEnvironmentDeleteCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _environment_id: environment_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a GTM Environment. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `environmentId` - The GTM Environment ID. pub fn containers_environments_get( &self, account_id: &str, container_id: &str, environment_id: &str, ) -> AccountContainerEnvironmentGetCall<'a, C> { AccountContainerEnvironmentGetCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _environment_id: environment_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all GTM Environments of a GTM Container. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_environments_list( &self, account_id: &str, container_id: &str, ) -> AccountContainerEnvironmentListCall<'a, C> { AccountContainerEnvironmentListCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a GTM Environment. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `environmentId` - The GTM Environment ID. pub fn containers_environments_update( &self, request: Environment, account_id: &str, container_id: &str, environment_id: &str, ) -> AccountContainerEnvironmentUpdateCall<'a, C> { AccountContainerEnvironmentUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _environment_id: environment_id.to_string(), _fingerprint: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// List all entities in a GTM Folder. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `folderId` - The GTM Folder ID. pub fn containers_folders_entities_list( &self, account_id: &str, container_id: &str, folder_id: &str, ) -> AccountContainerFolderEntityListCall<'a, C> { AccountContainerFolderEntityListCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _folder_id: folder_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a GTM Folder. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_folders_create( &self, request: Folder, account_id: &str, container_id: &str, ) -> AccountContainerFolderCreateCall<'a, C> { AccountContainerFolderCreateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a GTM Folder. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `folderId` - The GTM Folder ID. pub fn containers_folders_delete( &self, account_id: &str, container_id: &str, folder_id: &str, ) -> AccountContainerFolderDeleteCall<'a, C> { AccountContainerFolderDeleteCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _folder_id: folder_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a GTM Folder. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `folderId` - The GTM Folder ID. pub fn containers_folders_get( &self, account_id: &str, container_id: &str, folder_id: &str, ) -> AccountContainerFolderGetCall<'a, C> { AccountContainerFolderGetCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _folder_id: folder_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all GTM Folders of a Container. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_folders_list( &self, account_id: &str, container_id: &str, ) -> AccountContainerFolderListCall<'a, C> { AccountContainerFolderListCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a GTM Folder. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `folderId` - The GTM Folder ID. pub fn containers_folders_update( &self, request: Folder, account_id: &str, container_id: &str, folder_id: &str, ) -> AccountContainerFolderUpdateCall<'a, C> { AccountContainerFolderUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _folder_id: folder_id.to_string(), _fingerprint: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Moves entities to a GTM Folder. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `folderId` - The GTM Folder ID. pub fn containers_move_folders_update( &self, request: Folder, account_id: &str, container_id: &str, folder_id: &str, ) -> AccountContainerMoveFolderUpdateCall<'a, C> { AccountContainerMoveFolderUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _folder_id: folder_id.to_string(), _variable_id: Default::default(), _trigger_id: Default::default(), _tag_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Re-generates the authorization code for a GTM Environment. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `environmentId` - The GTM Environment ID. pub fn containers_reauthorize_environments_update( &self, request: Environment, account_id: &str, container_id: &str, environment_id: &str, ) -> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> { AccountContainerReauthorizeEnvironmentUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _environment_id: environment_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a GTM Tag. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_tags_create( &self, request: Tag, account_id: &str, container_id: &str, ) -> AccountContainerTagCreateCall<'a, C> { AccountContainerTagCreateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a GTM Tag. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `tagId` - The GTM Tag ID. pub fn containers_tags_delete( &self, account_id: &str, container_id: &str, tag_id: &str, ) -> AccountContainerTagDeleteCall<'a, C> { AccountContainerTagDeleteCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _tag_id: tag_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a GTM Tag. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `tagId` - The GTM Tag ID. pub fn containers_tags_get( &self, account_id: &str, container_id: &str, tag_id: &str, ) -> AccountContainerTagGetCall<'a, C> { AccountContainerTagGetCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _tag_id: tag_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all GTM Tags of a Container. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_tags_list( &self, account_id: &str, container_id: &str, ) -> AccountContainerTagListCall<'a, C> { AccountContainerTagListCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a GTM Tag. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `tagId` - The GTM Tag ID. pub fn containers_tags_update( &self, request: Tag, account_id: &str, container_id: &str, tag_id: &str, ) -> AccountContainerTagUpdateCall<'a, C> { AccountContainerTagUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _tag_id: tag_id.to_string(), _fingerprint: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a GTM Trigger. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_triggers_create( &self, request: Trigger, account_id: &str, container_id: &str, ) -> AccountContainerTriggerCreateCall<'a, C> { AccountContainerTriggerCreateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a GTM Trigger. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `triggerId` - The GTM Trigger ID. pub fn containers_triggers_delete( &self, account_id: &str, container_id: &str, trigger_id: &str, ) -> AccountContainerTriggerDeleteCall<'a, C> { AccountContainerTriggerDeleteCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _trigger_id: trigger_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a GTM Trigger. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `triggerId` - The GTM Trigger ID. pub fn containers_triggers_get( &self, account_id: &str, container_id: &str, trigger_id: &str, ) -> AccountContainerTriggerGetCall<'a, C> { AccountContainerTriggerGetCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _trigger_id: trigger_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all GTM Triggers of a Container. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_triggers_list( &self, account_id: &str, container_id: &str, ) -> AccountContainerTriggerListCall<'a, C> { AccountContainerTriggerListCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a GTM Trigger. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `triggerId` - The GTM Trigger ID. pub fn containers_triggers_update( &self, request: Trigger, account_id: &str, container_id: &str, trigger_id: &str, ) -> AccountContainerTriggerUpdateCall<'a, C> { AccountContainerTriggerUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _trigger_id: trigger_id.to_string(), _fingerprint: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a GTM Variable. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_variables_create( &self, request: Variable, account_id: &str, container_id: &str, ) -> AccountContainerVariableCreateCall<'a, C> { AccountContainerVariableCreateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a GTM Variable. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `variableId` - The GTM Variable ID. pub fn containers_variables_delete( &self, account_id: &str, container_id: &str, variable_id: &str, ) -> AccountContainerVariableDeleteCall<'a, C> { AccountContainerVariableDeleteCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _variable_id: variable_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a GTM Variable. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `variableId` - The GTM Variable ID. pub fn containers_variables_get( &self, account_id: &str, container_id: &str, variable_id: &str, ) -> AccountContainerVariableGetCall<'a, C> { AccountContainerVariableGetCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _variable_id: variable_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all GTM Variables of a Container. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_variables_list( &self, account_id: &str, container_id: &str, ) -> AccountContainerVariableListCall<'a, C> { AccountContainerVariableListCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a GTM Variable. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `variableId` - The GTM Variable ID. pub fn containers_variables_update( &self, request: Variable, account_id: &str, container_id: &str, variable_id: &str, ) -> AccountContainerVariableUpdateCall<'a, C> { AccountContainerVariableUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _variable_id: variable_id.to_string(), _fingerprint: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a Container Version. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_versions_create( &self, request: CreateContainerVersionRequestVersionOptions, account_id: &str, container_id: &str, ) -> AccountContainerVersionCreateCall<'a, C> { AccountContainerVersionCreateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a Container Version. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `containerVersionId` - The GTM Container Version ID. pub fn containers_versions_delete( &self, account_id: &str, container_id: &str, container_version_id: &str, ) -> AccountContainerVersionDeleteCall<'a, C> { AccountContainerVersionDeleteCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _container_version_id: container_version_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a Container Version. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `containerVersionId` - The GTM Container Version ID. Specify published to retrieve the currently published version. pub fn containers_versions_get( &self, account_id: &str, container_id: &str, container_version_id: &str, ) -> AccountContainerVersionGetCall<'a, C> { AccountContainerVersionGetCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _container_version_id: container_version_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all Container Versions of a GTM Container. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_versions_list( &self, account_id: &str, container_id: &str, ) -> AccountContainerVersionListCall<'a, C> { AccountContainerVersionListCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _include_deleted: Default::default(), _headers: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Publishes a Container Version. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `containerVersionId` - The GTM Container Version ID. pub fn containers_versions_publish( &self, account_id: &str, container_id: &str, container_version_id: &str, ) -> AccountContainerVersionPublishCall<'a, C> { AccountContainerVersionPublishCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _container_version_id: container_version_id.to_string(), _fingerprint: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Restores a Container Version. This will overwrite the container's current configuration (including its variables, triggers and tags). The operation will not have any effect on the version that is being served (i.e. the published version). /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `containerVersionId` - The GTM Container Version ID. pub fn containers_versions_restore( &self, account_id: &str, container_id: &str, container_version_id: &str, ) -> AccountContainerVersionRestoreCall<'a, C> { AccountContainerVersionRestoreCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _container_version_id: container_version_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Undeletes a Container Version. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `containerVersionId` - The GTM Container Version ID. pub fn containers_versions_undelete( &self, account_id: &str, container_id: &str, container_version_id: &str, ) -> AccountContainerVersionUndeleteCall<'a, C> { AccountContainerVersionUndeleteCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _container_version_id: container_version_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a Container Version. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. /// * `containerVersionId` - The GTM Container Version ID. pub fn containers_versions_update( &self, request: ContainerVersion, account_id: &str, container_id: &str, container_version_id: &str, ) -> AccountContainerVersionUpdateCall<'a, C> { AccountContainerVersionUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _container_version_id: container_version_id.to_string(), _fingerprint: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a Container. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. pub fn containers_create( &self, request: Container, account_id: &str, ) -> AccountContainerCreateCall<'a, C> { AccountContainerCreateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a Container. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_delete( &self, account_id: &str, container_id: &str, ) -> AccountContainerDeleteCall<'a, C> { AccountContainerDeleteCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a Container. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_get( &self, account_id: &str, container_id: &str, ) -> AccountContainerGetCall<'a, C> { AccountContainerGetCall { hub: self.hub, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all Containers that belongs to a GTM Account. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. pub fn containers_list(&self, account_id: &str) -> AccountContainerListCall<'a, C> { AccountContainerListCall { hub: self.hub, _account_id: account_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a Container. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `containerId` - The GTM Container ID. pub fn containers_update( &self, request: Container, account_id: &str, container_id: &str, ) -> AccountContainerUpdateCall<'a, C> { AccountContainerUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _container_id: container_id.to_string(), _fingerprint: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a user's Account & Container Permissions. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. pub fn permissions_create( &self, request: UserAccess, account_id: &str, ) -> AccountPermissionCreateCall<'a, C> { AccountPermissionCreateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Removes a user from the account, revoking access to it and all of its containers. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `permissionId` - The GTM User ID. pub fn permissions_delete( &self, account_id: &str, permission_id: &str, ) -> AccountPermissionDeleteCall<'a, C> { AccountPermissionDeleteCall { hub: self.hub, _account_id: account_id.to_string(), _permission_id: permission_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a user's Account & Container Permissions. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. /// * `permissionId` - The GTM User ID. pub fn permissions_get( &self, account_id: &str, permission_id: &str, ) -> AccountPermissionGetCall<'a, C> { AccountPermissionGetCall { hub: self.hub, _account_id: account_id.to_string(), _permission_id: permission_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// List all users that have access to the account along with Account and Container Permissions granted to each of them. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. pub fn permissions_list(&self, account_id: &str) -> AccountPermissionListCall<'a, C> { AccountPermissionListCall { hub: self.hub, _account_id: account_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a user's Account & Container Permissions. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. /// * `permissionId` - The GTM User ID. pub fn permissions_update( &self, request: UserAccess, account_id: &str, permission_id: &str, ) -> AccountPermissionUpdateCall<'a, C> { AccountPermissionUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _permission_id: permission_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a GTM Account. /// /// # Arguments /// /// * `accountId` - The GTM Account ID. pub fn get(&self, account_id: &str) -> AccountGetCall<'a, C> { AccountGetCall { hub: self.hub, _account_id: account_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists all GTM Accounts that a user has access to. pub fn list(&self) -> AccountListCall<'a, C> { AccountListCall { hub: self.hub, _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a GTM Account. /// /// # Arguments /// /// * `request` - No description provided. /// * `accountId` - The GTM Account ID. pub fn update(&self, request: Account, account_id: &str) -> AccountUpdateCall<'a, C> { AccountUpdateCall { hub: self.hub, _request: request, _account_id: account_id.to_string(), _fingerprint: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } // ################### // CallBuilders ### // ################# /// Creates a GTM Environment. /// /// A builder for the *containers.environments.create* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Environment; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Environment::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.accounts().containers_environments_create(req, "accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerEnvironmentCreateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Environment, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerEnvironmentCreateCall<'a, C> {} impl<'a, C> AccountContainerEnvironmentCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Environment)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.environments.create", http_method: hyper::Method::POST, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/environments"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Environment, ) -> AccountContainerEnvironmentCreateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerEnvironmentCreateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerEnvironmentCreateCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerEnvironmentCreateCall<'a, C> { 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) -> AccountContainerEnvironmentCreateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerEnvironmentCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerEnvironmentCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerEnvironmentCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes a GTM Environment. /// /// A builder for the *containers.environments.delete* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_environments_delete("accountId", "containerId", "environmentId") /// .doit().await; /// # } /// ``` pub struct AccountContainerEnvironmentDeleteCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _environment_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerEnvironmentDeleteCall<'a, C> {} impl<'a, C> AccountContainerEnvironmentDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.environments.delete", http_method: hyper::Method::DELETE, }); for &field in ["accountId", "containerId", "environmentId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("environmentId", self._environment_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/environments/{environmentId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{environmentId}", "environmentId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["environmentId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = common::Response::from_parts(parts, body); dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerEnvironmentDeleteCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerEnvironmentDeleteCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Environment ID. /// /// Sets the *environment 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 environment_id( mut self, new_value: &str, ) -> AccountContainerEnvironmentDeleteCall<'a, C> { self._environment_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerEnvironmentDeleteCall<'a, C> { 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) -> AccountContainerEnvironmentDeleteCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerEnvironmentDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerEnvironmentDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerEnvironmentDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets a GTM Environment. /// /// A builder for the *containers.environments.get* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_environments_get("accountId", "containerId", "environmentId") /// .doit().await; /// # } /// ``` pub struct AccountContainerEnvironmentGetCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _environment_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerEnvironmentGetCall<'a, C> {} impl<'a, C> AccountContainerEnvironmentGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Environment)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.environments.get", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId", "environmentId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("environmentId", self._environment_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/environments/{environmentId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{environmentId}", "environmentId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["environmentId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerEnvironmentGetCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerEnvironmentGetCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Environment ID. /// /// Sets the *environment 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 environment_id(mut self, new_value: &str) -> AccountContainerEnvironmentGetCall<'a, C> { self._environment_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerEnvironmentGetCall<'a, C> { 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) -> AccountContainerEnvironmentGetCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerEnvironmentGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerEnvironmentGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerEnvironmentGetCall<'a, C> { self._scopes.clear(); self } } /// Lists all GTM Environments of a GTM Container. /// /// A builder for the *containers.environments.list* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_environments_list("accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerEnvironmentListCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerEnvironmentListCall<'a, C> {} impl<'a, C> AccountContainerEnvironmentListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListEnvironmentsResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.environments.list", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/environments"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerEnvironmentListCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerEnvironmentListCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerEnvironmentListCall<'a, C> { 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) -> AccountContainerEnvironmentListCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerEnvironmentListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerEnvironmentListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerEnvironmentListCall<'a, C> { self._scopes.clear(); self } } /// Updates a GTM Environment. /// /// A builder for the *containers.environments.update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Environment; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Environment::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.accounts().containers_environments_update(req, "accountId", "containerId", "environmentId") /// .fingerprint("est") /// .doit().await; /// # } /// ``` pub struct AccountContainerEnvironmentUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Environment, _account_id: String, _container_id: String, _environment_id: String, _fingerprint: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerEnvironmentUpdateCall<'a, C> {} impl<'a, C> AccountContainerEnvironmentUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Environment)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.environments.update", http_method: hyper::Method::PUT, }); for &field in [ "alt", "accountId", "containerId", "environmentId", "fingerprint", ] .iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("environmentId", self._environment_id); if let Some(value) = self._fingerprint.as_ref() { params.push("fingerprint", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/environments/{environmentId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{environmentId}", "environmentId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["environmentId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Environment, ) -> AccountContainerEnvironmentUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerEnvironmentUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerEnvironmentUpdateCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Environment ID. /// /// Sets the *environment 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 environment_id( mut self, new_value: &str, ) -> AccountContainerEnvironmentUpdateCall<'a, C> { self._environment_id = new_value.to_string(); self } /// When provided, this fingerprint must match the fingerprint of the environment in storage. /// /// Sets the *fingerprint* query property to the given value. pub fn fingerprint(mut self, new_value: &str) -> AccountContainerEnvironmentUpdateCall<'a, C> { self._fingerprint = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerEnvironmentUpdateCall<'a, C> { 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) -> AccountContainerEnvironmentUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerEnvironmentUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerEnvironmentUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerEnvironmentUpdateCall<'a, C> { self._scopes.clear(); self } } /// List all entities in a GTM Folder. /// /// A builder for the *containers.folders.entities.list* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_folders_entities_list("accountId", "containerId", "folderId") /// .doit().await; /// # } /// ``` pub struct AccountContainerFolderEntityListCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _folder_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerFolderEntityListCall<'a, C> {} impl<'a, C> AccountContainerFolderEntityListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, FolderEntities)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.folders.entities.list", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId", "folderId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("folderId", self._folder_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/folders/{folderId}/entities"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{folderId}", "folderId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["folderId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerFolderEntityListCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerFolderEntityListCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Folder ID. /// /// Sets the *folder 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 folder_id(mut self, new_value: &str) -> AccountContainerFolderEntityListCall<'a, C> { self._folder_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerFolderEntityListCall<'a, C> { 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) -> AccountContainerFolderEntityListCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerFolderEntityListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerFolderEntityListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerFolderEntityListCall<'a, C> { self._scopes.clear(); self } } /// Creates a GTM Folder. /// /// A builder for the *containers.folders.create* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Folder; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Folder::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.accounts().containers_folders_create(req, "accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerFolderCreateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Folder, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerFolderCreateCall<'a, C> {} impl<'a, C> AccountContainerFolderCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.folders.create", http_method: hyper::Method::POST, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/folders"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Folder) -> AccountContainerFolderCreateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerFolderCreateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerFolderCreateCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerFolderCreateCall<'a, C> { 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) -> AccountContainerFolderCreateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerFolderCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerFolderCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerFolderCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes a GTM Folder. /// /// A builder for the *containers.folders.delete* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_folders_delete("accountId", "containerId", "folderId") /// .doit().await; /// # } /// ``` pub struct AccountContainerFolderDeleteCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _folder_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerFolderDeleteCall<'a, C> {} impl<'a, C> AccountContainerFolderDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.folders.delete", http_method: hyper::Method::DELETE, }); for &field in ["accountId", "containerId", "folderId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("folderId", self._folder_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/folders/{folderId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{folderId}", "folderId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["folderId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = common::Response::from_parts(parts, body); dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerFolderDeleteCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerFolderDeleteCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Folder ID. /// /// Sets the *folder 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 folder_id(mut self, new_value: &str) -> AccountContainerFolderDeleteCall<'a, C> { self._folder_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerFolderDeleteCall<'a, C> { 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) -> AccountContainerFolderDeleteCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerFolderDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerFolderDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerFolderDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets a GTM Folder. /// /// A builder for the *containers.folders.get* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_folders_get("accountId", "containerId", "folderId") /// .doit().await; /// # } /// ``` pub struct AccountContainerFolderGetCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _folder_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerFolderGetCall<'a, C> {} impl<'a, C> AccountContainerFolderGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.folders.get", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId", "folderId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("folderId", self._folder_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/folders/{folderId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{folderId}", "folderId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["folderId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerFolderGetCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerFolderGetCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Folder ID. /// /// Sets the *folder 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 folder_id(mut self, new_value: &str) -> AccountContainerFolderGetCall<'a, C> { self._folder_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerFolderGetCall<'a, C> { 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) -> AccountContainerFolderGetCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerFolderGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerFolderGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerFolderGetCall<'a, C> { self._scopes.clear(); self } } /// Lists all GTM Folders of a Container. /// /// A builder for the *containers.folders.list* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_folders_list("accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerFolderListCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerFolderListCall<'a, C> {} impl<'a, C> AccountContainerFolderListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListFoldersResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.folders.list", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/folders"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerFolderListCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerFolderListCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerFolderListCall<'a, C> { 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) -> AccountContainerFolderListCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerFolderListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerFolderListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerFolderListCall<'a, C> { self._scopes.clear(); self } } /// Updates a GTM Folder. /// /// A builder for the *containers.folders.update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Folder; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Folder::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.accounts().containers_folders_update(req, "accountId", "containerId", "folderId") /// .fingerprint("vero") /// .doit().await; /// # } /// ``` pub struct AccountContainerFolderUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Folder, _account_id: String, _container_id: String, _folder_id: String, _fingerprint: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerFolderUpdateCall<'a, C> {} impl<'a, C> AccountContainerFolderUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.folders.update", http_method: hyper::Method::PUT, }); for &field in ["alt", "accountId", "containerId", "folderId", "fingerprint"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("folderId", self._folder_id); if let Some(value) = self._fingerprint.as_ref() { params.push("fingerprint", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/folders/{folderId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{folderId}", "folderId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["folderId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Folder) -> AccountContainerFolderUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerFolderUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerFolderUpdateCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Folder ID. /// /// Sets the *folder 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 folder_id(mut self, new_value: &str) -> AccountContainerFolderUpdateCall<'a, C> { self._folder_id = new_value.to_string(); self } /// When provided, this fingerprint must match the fingerprint of the folder in storage. /// /// Sets the *fingerprint* query property to the given value. pub fn fingerprint(mut self, new_value: &str) -> AccountContainerFolderUpdateCall<'a, C> { self._fingerprint = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerFolderUpdateCall<'a, C> { 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) -> AccountContainerFolderUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerFolderUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerFolderUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerFolderUpdateCall<'a, C> { self._scopes.clear(); self } } /// Moves entities to a GTM Folder. /// /// A builder for the *containers.move_folders.update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Folder; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Folder::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.accounts().containers_move_folders_update(req, "accountId", "containerId", "folderId") /// .add_variable_id("dolore") /// .add_trigger_id("et") /// .add_tag_id("voluptua.") /// .doit().await; /// # } /// ``` pub struct AccountContainerMoveFolderUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Folder, _account_id: String, _container_id: String, _folder_id: String, _variable_id: Vec, _trigger_id: Vec, _tag_id: Vec, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerMoveFolderUpdateCall<'a, C> {} impl<'a, C> AccountContainerMoveFolderUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.move_folders.update", http_method: hyper::Method::PUT, }); for &field in [ "accountId", "containerId", "folderId", "variableId", "triggerId", "tagId", ] .iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(8 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("folderId", self._folder_id); if !self._variable_id.is_empty() { for f in self._variable_id.iter() { params.push("variableId", f); } } if !self._trigger_id.is_empty() { for f in self._trigger_id.iter() { params.push("triggerId", f); } } if !self._tag_id.is_empty() { for f in self._tag_id.iter() { params.push("tagId", f); } } params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/move_folders/{folderId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{folderId}", "folderId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["folderId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = common::Response::from_parts(parts, body); dlg.finished(true); return Ok(response); } } } } /// /// 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: Folder) -> AccountContainerMoveFolderUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerMoveFolderUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerMoveFolderUpdateCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Folder ID. /// /// Sets the *folder 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 folder_id(mut self, new_value: &str) -> AccountContainerMoveFolderUpdateCall<'a, C> { self._folder_id = new_value.to_string(); self } /// The variables to be moved to the folder. /// /// Append the given value to the *variable id* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_variable_id( mut self, new_value: &str, ) -> AccountContainerMoveFolderUpdateCall<'a, C> { self._variable_id.push(new_value.to_string()); self } /// The triggers to be moved to the folder. /// /// Append the given value to the *trigger id* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_trigger_id( mut self, new_value: &str, ) -> AccountContainerMoveFolderUpdateCall<'a, C> { self._trigger_id.push(new_value.to_string()); self } /// The tags to be moved to the folder. /// /// Append the given value to the *tag id* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_tag_id(mut self, new_value: &str) -> AccountContainerMoveFolderUpdateCall<'a, C> { self._tag_id.push(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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerMoveFolderUpdateCall<'a, C> { 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) -> AccountContainerMoveFolderUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerMoveFolderUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerMoveFolderUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerMoveFolderUpdateCall<'a, C> { self._scopes.clear(); self } } /// Re-generates the authorization code for a GTM Environment. /// /// A builder for the *containers.reauthorize_environments.update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Environment; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Environment::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.accounts().containers_reauthorize_environments_update(req, "accountId", "containerId", "environmentId") /// .doit().await; /// # } /// ``` pub struct AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Environment, _account_id: String, _container_id: String, _environment_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> {} impl<'a, C> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Environment)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.reauthorize_environments.update", http_method: hyper::Method::PUT, }); for &field in ["alt", "accountId", "containerId", "environmentId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("environmentId", self._environment_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/reauthorize_environments/{environmentId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Publish.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{environmentId}", "environmentId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["environmentId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Environment, ) -> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id( mut self, new_value: &str, ) -> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id( mut self, new_value: &str, ) -> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Environment ID. /// /// Sets the *environment 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 environment_id( mut self, new_value: &str, ) -> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> { self._environment_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> { 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, ) -> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Publish`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St, ) -> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes( mut self, scopes: I, ) -> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerReauthorizeEnvironmentUpdateCall<'a, C> { self._scopes.clear(); self } } /// Creates a GTM Tag. /// /// A builder for the *containers.tags.create* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Tag; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Tag::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.accounts().containers_tags_create(req, "accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerTagCreateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Tag, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerTagCreateCall<'a, C> {} impl<'a, C> AccountContainerTagCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Tag)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.tags.create", http_method: hyper::Method::POST, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/tags"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Tag) -> AccountContainerTagCreateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerTagCreateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerTagCreateCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerTagCreateCall<'a, C> { 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) -> AccountContainerTagCreateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerTagCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerTagCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerTagCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes a GTM Tag. /// /// A builder for the *containers.tags.delete* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_tags_delete("accountId", "containerId", "tagId") /// .doit().await; /// # } /// ``` pub struct AccountContainerTagDeleteCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _tag_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerTagDeleteCall<'a, C> {} impl<'a, C> AccountContainerTagDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.tags.delete", http_method: hyper::Method::DELETE, }); for &field in ["accountId", "containerId", "tagId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("tagId", self._tag_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/tags/{tagId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{tagId}", "tagId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["tagId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = common::Response::from_parts(parts, body); dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerTagDeleteCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerTagDeleteCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Tag ID. /// /// Sets the *tag 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 tag_id(mut self, new_value: &str) -> AccountContainerTagDeleteCall<'a, C> { self._tag_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerTagDeleteCall<'a, C> { 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) -> AccountContainerTagDeleteCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerTagDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerTagDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerTagDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets a GTM Tag. /// /// A builder for the *containers.tags.get* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_tags_get("accountId", "containerId", "tagId") /// .doit().await; /// # } /// ``` pub struct AccountContainerTagGetCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _tag_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerTagGetCall<'a, C> {} impl<'a, C> AccountContainerTagGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Tag)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.tags.get", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId", "tagId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("tagId", self._tag_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/tags/{tagId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{tagId}", "tagId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["tagId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerTagGetCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerTagGetCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Tag ID. /// /// Sets the *tag 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 tag_id(mut self, new_value: &str) -> AccountContainerTagGetCall<'a, C> { self._tag_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerTagGetCall<'a, C> { 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) -> AccountContainerTagGetCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerTagGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerTagGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerTagGetCall<'a, C> { self._scopes.clear(); self } } /// Lists all GTM Tags of a Container. /// /// A builder for the *containers.tags.list* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_tags_list("accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerTagListCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerTagListCall<'a, C> {} impl<'a, C> AccountContainerTagListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListTagsResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.tags.list", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/tags"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerTagListCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerTagListCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerTagListCall<'a, C> { 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) -> AccountContainerTagListCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerTagListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerTagListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerTagListCall<'a, C> { self._scopes.clear(); self } } /// Updates a GTM Tag. /// /// A builder for the *containers.tags.update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Tag; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Tag::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.accounts().containers_tags_update(req, "accountId", "containerId", "tagId") /// .fingerprint("Lorem") /// .doit().await; /// # } /// ``` pub struct AccountContainerTagUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Tag, _account_id: String, _container_id: String, _tag_id: String, _fingerprint: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerTagUpdateCall<'a, C> {} impl<'a, C> AccountContainerTagUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Tag)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.tags.update", http_method: hyper::Method::PUT, }); for &field in ["alt", "accountId", "containerId", "tagId", "fingerprint"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("tagId", self._tag_id); if let Some(value) = self._fingerprint.as_ref() { params.push("fingerprint", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/tags/{tagId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{tagId}", "tagId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["tagId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Tag) -> AccountContainerTagUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerTagUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerTagUpdateCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Tag ID. /// /// Sets the *tag 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 tag_id(mut self, new_value: &str) -> AccountContainerTagUpdateCall<'a, C> { self._tag_id = new_value.to_string(); self } /// When provided, this fingerprint must match the fingerprint of the tag in storage. /// /// Sets the *fingerprint* query property to the given value. pub fn fingerprint(mut self, new_value: &str) -> AccountContainerTagUpdateCall<'a, C> { self._fingerprint = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerTagUpdateCall<'a, C> { 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) -> AccountContainerTagUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerTagUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerTagUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerTagUpdateCall<'a, C> { self._scopes.clear(); self } } /// Creates a GTM Trigger. /// /// A builder for the *containers.triggers.create* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Trigger; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Trigger::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.accounts().containers_triggers_create(req, "accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerTriggerCreateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Trigger, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerTriggerCreateCall<'a, C> {} impl<'a, C> AccountContainerTriggerCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Trigger)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.triggers.create", http_method: hyper::Method::POST, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/triggers"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Trigger) -> AccountContainerTriggerCreateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerTriggerCreateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerTriggerCreateCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerTriggerCreateCall<'a, C> { 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) -> AccountContainerTriggerCreateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerTriggerCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerTriggerCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerTriggerCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes a GTM Trigger. /// /// A builder for the *containers.triggers.delete* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_triggers_delete("accountId", "containerId", "triggerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerTriggerDeleteCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _trigger_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerTriggerDeleteCall<'a, C> {} impl<'a, C> AccountContainerTriggerDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.triggers.delete", http_method: hyper::Method::DELETE, }); for &field in ["accountId", "containerId", "triggerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("triggerId", self._trigger_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/triggers/{triggerId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{triggerId}", "triggerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["triggerId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = common::Response::from_parts(parts, body); dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerTriggerDeleteCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerTriggerDeleteCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Trigger ID. /// /// Sets the *trigger 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 trigger_id(mut self, new_value: &str) -> AccountContainerTriggerDeleteCall<'a, C> { self._trigger_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerTriggerDeleteCall<'a, C> { 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) -> AccountContainerTriggerDeleteCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerTriggerDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerTriggerDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerTriggerDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets a GTM Trigger. /// /// A builder for the *containers.triggers.get* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_triggers_get("accountId", "containerId", "triggerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerTriggerGetCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _trigger_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerTriggerGetCall<'a, C> {} impl<'a, C> AccountContainerTriggerGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Trigger)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.triggers.get", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId", "triggerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("triggerId", self._trigger_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/triggers/{triggerId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{triggerId}", "triggerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["triggerId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerTriggerGetCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerTriggerGetCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Trigger ID. /// /// Sets the *trigger 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 trigger_id(mut self, new_value: &str) -> AccountContainerTriggerGetCall<'a, C> { self._trigger_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerTriggerGetCall<'a, C> { 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) -> AccountContainerTriggerGetCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerTriggerGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerTriggerGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerTriggerGetCall<'a, C> { self._scopes.clear(); self } } /// Lists all GTM Triggers of a Container. /// /// A builder for the *containers.triggers.list* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_triggers_list("accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerTriggerListCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerTriggerListCall<'a, C> {} impl<'a, C> AccountContainerTriggerListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListTriggersResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.triggers.list", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/triggers"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerTriggerListCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerTriggerListCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerTriggerListCall<'a, C> { 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) -> AccountContainerTriggerListCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerTriggerListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerTriggerListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerTriggerListCall<'a, C> { self._scopes.clear(); self } } /// Updates a GTM Trigger. /// /// A builder for the *containers.triggers.update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Trigger; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Trigger::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.accounts().containers_triggers_update(req, "accountId", "containerId", "triggerId") /// .fingerprint("dolores") /// .doit().await; /// # } /// ``` pub struct AccountContainerTriggerUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Trigger, _account_id: String, _container_id: String, _trigger_id: String, _fingerprint: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerTriggerUpdateCall<'a, C> {} impl<'a, C> AccountContainerTriggerUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Trigger)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.triggers.update", http_method: hyper::Method::PUT, }); for &field in [ "alt", "accountId", "containerId", "triggerId", "fingerprint", ] .iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("triggerId", self._trigger_id); if let Some(value) = self._fingerprint.as_ref() { params.push("fingerprint", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/triggers/{triggerId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{triggerId}", "triggerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["triggerId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Trigger) -> AccountContainerTriggerUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerTriggerUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerTriggerUpdateCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Trigger ID. /// /// Sets the *trigger 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 trigger_id(mut self, new_value: &str) -> AccountContainerTriggerUpdateCall<'a, C> { self._trigger_id = new_value.to_string(); self } /// When provided, this fingerprint must match the fingerprint of the trigger in storage. /// /// Sets the *fingerprint* query property to the given value. pub fn fingerprint(mut self, new_value: &str) -> AccountContainerTriggerUpdateCall<'a, C> { self._fingerprint = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerTriggerUpdateCall<'a, C> { 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) -> AccountContainerTriggerUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerTriggerUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerTriggerUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerTriggerUpdateCall<'a, C> { self._scopes.clear(); self } } /// Creates a GTM Variable. /// /// A builder for the *containers.variables.create* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Variable; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Variable::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.accounts().containers_variables_create(req, "accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerVariableCreateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Variable, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVariableCreateCall<'a, C> {} impl<'a, C> AccountContainerVariableCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Variable)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.variables.create", http_method: hyper::Method::POST, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/variables"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Variable) -> AccountContainerVariableCreateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVariableCreateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVariableCreateCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVariableCreateCall<'a, C> { 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) -> AccountContainerVariableCreateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVariableCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVariableCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVariableCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes a GTM Variable. /// /// A builder for the *containers.variables.delete* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_variables_delete("accountId", "containerId", "variableId") /// .doit().await; /// # } /// ``` pub struct AccountContainerVariableDeleteCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _variable_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVariableDeleteCall<'a, C> {} impl<'a, C> AccountContainerVariableDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.variables.delete", http_method: hyper::Method::DELETE, }); for &field in ["accountId", "containerId", "variableId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("variableId", self._variable_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/variables/{variableId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{variableId}", "variableId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["variableId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = common::Response::from_parts(parts, body); dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVariableDeleteCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVariableDeleteCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Variable ID. /// /// Sets the *variable 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 variable_id(mut self, new_value: &str) -> AccountContainerVariableDeleteCall<'a, C> { self._variable_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVariableDeleteCall<'a, C> { 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) -> AccountContainerVariableDeleteCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVariableDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVariableDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVariableDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets a GTM Variable. /// /// A builder for the *containers.variables.get* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_variables_get("accountId", "containerId", "variableId") /// .doit().await; /// # } /// ``` pub struct AccountContainerVariableGetCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _variable_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVariableGetCall<'a, C> {} impl<'a, C> AccountContainerVariableGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Variable)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.variables.get", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId", "variableId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("variableId", self._variable_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/variables/{variableId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{variableId}", "variableId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["variableId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVariableGetCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVariableGetCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Variable ID. /// /// Sets the *variable 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 variable_id(mut self, new_value: &str) -> AccountContainerVariableGetCall<'a, C> { self._variable_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVariableGetCall<'a, C> { 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) -> AccountContainerVariableGetCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVariableGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVariableGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVariableGetCall<'a, C> { self._scopes.clear(); self } } /// Lists all GTM Variables of a Container. /// /// A builder for the *containers.variables.list* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_variables_list("accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerVariableListCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVariableListCall<'a, C> {} impl<'a, C> AccountContainerVariableListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListVariablesResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.variables.list", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/variables"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVariableListCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVariableListCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVariableListCall<'a, C> { 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) -> AccountContainerVariableListCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVariableListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVariableListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVariableListCall<'a, C> { self._scopes.clear(); self } } /// Updates a GTM Variable. /// /// A builder for the *containers.variables.update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Variable; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Variable::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.accounts().containers_variables_update(req, "accountId", "containerId", "variableId") /// .fingerprint("no") /// .doit().await; /// # } /// ``` pub struct AccountContainerVariableUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Variable, _account_id: String, _container_id: String, _variable_id: String, _fingerprint: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVariableUpdateCall<'a, C> {} impl<'a, C> AccountContainerVariableUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Variable)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.variables.update", http_method: hyper::Method::PUT, }); for &field in [ "alt", "accountId", "containerId", "variableId", "fingerprint", ] .iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("variableId", self._variable_id); if let Some(value) = self._fingerprint.as_ref() { params.push("fingerprint", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/variables/{variableId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{variableId}", "variableId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["variableId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Variable) -> AccountContainerVariableUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVariableUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVariableUpdateCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Variable ID. /// /// Sets the *variable 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 variable_id(mut self, new_value: &str) -> AccountContainerVariableUpdateCall<'a, C> { self._variable_id = new_value.to_string(); self } /// When provided, this fingerprint must match the fingerprint of the variable in storage. /// /// Sets the *fingerprint* query property to the given value. pub fn fingerprint(mut self, new_value: &str) -> AccountContainerVariableUpdateCall<'a, C> { self._fingerprint = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVariableUpdateCall<'a, C> { 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) -> AccountContainerVariableUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVariableUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVariableUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVariableUpdateCall<'a, C> { self._scopes.clear(); self } } /// Creates a Container Version. /// /// A builder for the *containers.versions.create* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::CreateContainerVersionRequestVersionOptions; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = CreateContainerVersionRequestVersionOptions::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.accounts().containers_versions_create(req, "accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerVersionCreateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: CreateContainerVersionRequestVersionOptions, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVersionCreateCall<'a, C> {} impl<'a, C> AccountContainerVersionCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<(common::Response, CreateContainerVersionResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.versions.create", http_method: hyper::Method::POST, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/versions"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainerversion.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: CreateContainerVersionRequestVersionOptions, ) -> AccountContainerVersionCreateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVersionCreateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVersionCreateCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVersionCreateCall<'a, C> { 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) -> AccountContainerVersionCreateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainerversion`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVersionCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVersionCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVersionCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes a Container Version. /// /// A builder for the *containers.versions.delete* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_versions_delete("accountId", "containerId", "containerVersionId") /// .doit().await; /// # } /// ``` pub struct AccountContainerVersionDeleteCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _container_version_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVersionDeleteCall<'a, C> {} impl<'a, C> AccountContainerVersionDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.versions.delete", http_method: hyper::Method::DELETE, }); for &field in ["accountId", "containerId", "containerVersionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("containerVersionId", self._container_version_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/versions/{containerVersionId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainerversion.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{containerVersionId}", "containerVersionId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerVersionId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = common::Response::from_parts(parts, body); dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVersionDeleteCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVersionDeleteCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Container Version ID. /// /// Sets the *container version 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 container_version_id( mut self, new_value: &str, ) -> AccountContainerVersionDeleteCall<'a, C> { self._container_version_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVersionDeleteCall<'a, C> { 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) -> AccountContainerVersionDeleteCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainerversion`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVersionDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVersionDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVersionDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets a Container Version. /// /// A builder for the *containers.versions.get* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_versions_get("accountId", "containerId", "containerVersionId") /// .doit().await; /// # } /// ``` pub struct AccountContainerVersionGetCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _container_version_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVersionGetCall<'a, C> {} impl<'a, C> AccountContainerVersionGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ContainerVersion)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.versions.get", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId", "containerVersionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("containerVersionId", self._container_version_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/versions/{containerVersionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{containerVersionId}", "containerVersionId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerVersionId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVersionGetCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVersionGetCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Container Version ID. Specify published to retrieve the currently published version. /// /// Sets the *container version 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 container_version_id( mut self, new_value: &str, ) -> AccountContainerVersionGetCall<'a, C> { self._container_version_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVersionGetCall<'a, C> { 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) -> AccountContainerVersionGetCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVersionGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVersionGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVersionGetCall<'a, C> { self._scopes.clear(); self } } /// Lists all Container Versions of a GTM Container. /// /// A builder for the *containers.versions.list* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_versions_list("accountId", "containerId") /// .include_deleted(true) /// .headers(true) /// .doit().await; /// # } /// ``` pub struct AccountContainerVersionListCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _include_deleted: Option, _headers: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVersionListCall<'a, C> {} impl<'a, C> AccountContainerVersionListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<(common::Response, ListContainerVersionsResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.versions.list", http_method: hyper::Method::GET, }); for &field in [ "alt", "accountId", "containerId", "includeDeleted", "headers", ] .iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); if let Some(value) = self._include_deleted.as_ref() { params.push("includeDeleted", value.to_string()); } if let Some(value) = self._headers.as_ref() { params.push("headers", value.to_string()); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/versions"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVersionListCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVersionListCall<'a, C> { self._container_id = new_value.to_string(); self } /// Also retrieve deleted (archived) versions when true. /// /// Sets the *include deleted* query property to the given value. pub fn include_deleted(mut self, new_value: bool) -> AccountContainerVersionListCall<'a, C> { self._include_deleted = Some(new_value); self } /// Retrieve headers only when true. /// /// Sets the *headers* query property to the given value. pub fn headers(mut self, new_value: bool) -> AccountContainerVersionListCall<'a, C> { self._headers = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVersionListCall<'a, C> { 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) -> AccountContainerVersionListCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVersionListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVersionListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVersionListCall<'a, C> { self._scopes.clear(); self } } /// Publishes a Container Version. /// /// A builder for the *containers.versions.publish* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_versions_publish("accountId", "containerId", "containerVersionId") /// .fingerprint("et") /// .doit().await; /// # } /// ``` pub struct AccountContainerVersionPublishCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _container_version_id: String, _fingerprint: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVersionPublishCall<'a, C> {} impl<'a, C> AccountContainerVersionPublishCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<(common::Response, PublishContainerVersionResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.versions.publish", http_method: hyper::Method::POST, }); for &field in [ "alt", "accountId", "containerId", "containerVersionId", "fingerprint", ] .iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("containerVersionId", self._container_version_id); if let Some(value) = self._fingerprint.as_ref() { params.push("fingerprint", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/versions/{containerVersionId}/publish"; if self._scopes.is_empty() { self._scopes.insert(Scope::Publish.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{containerVersionId}", "containerVersionId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerVersionId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVersionPublishCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVersionPublishCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Container Version ID. /// /// Sets the *container version 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 container_version_id( mut self, new_value: &str, ) -> AccountContainerVersionPublishCall<'a, C> { self._container_version_id = new_value.to_string(); self } /// When provided, this fingerprint must match the fingerprint of the container version in storage. /// /// Sets the *fingerprint* query property to the given value. pub fn fingerprint(mut self, new_value: &str) -> AccountContainerVersionPublishCall<'a, C> { self._fingerprint = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVersionPublishCall<'a, C> { 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) -> AccountContainerVersionPublishCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Publish`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVersionPublishCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVersionPublishCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVersionPublishCall<'a, C> { self._scopes.clear(); self } } /// Restores a Container Version. This will overwrite the container's current configuration (including its variables, triggers and tags). The operation will not have any effect on the version that is being served (i.e. the published version). /// /// A builder for the *containers.versions.restore* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_versions_restore("accountId", "containerId", "containerVersionId") /// .doit().await; /// # } /// ``` pub struct AccountContainerVersionRestoreCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _container_version_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVersionRestoreCall<'a, C> {} impl<'a, C> AccountContainerVersionRestoreCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ContainerVersion)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.versions.restore", http_method: hyper::Method::POST, }); for &field in ["alt", "accountId", "containerId", "containerVersionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("containerVersionId", self._container_version_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/versions/{containerVersionId}/restore"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{containerVersionId}", "containerVersionId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerVersionId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVersionRestoreCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVersionRestoreCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Container Version ID. /// /// Sets the *container version 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 container_version_id( mut self, new_value: &str, ) -> AccountContainerVersionRestoreCall<'a, C> { self._container_version_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVersionRestoreCall<'a, C> { 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) -> AccountContainerVersionRestoreCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVersionRestoreCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVersionRestoreCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVersionRestoreCall<'a, C> { self._scopes.clear(); self } } /// Undeletes a Container Version. /// /// A builder for the *containers.versions.undelete* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_versions_undelete("accountId", "containerId", "containerVersionId") /// .doit().await; /// # } /// ``` pub struct AccountContainerVersionUndeleteCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _container_version_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVersionUndeleteCall<'a, C> {} impl<'a, C> AccountContainerVersionUndeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ContainerVersion)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.versions.undelete", http_method: hyper::Method::POST, }); for &field in ["alt", "accountId", "containerId", "containerVersionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("containerVersionId", self._container_version_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/versions/{containerVersionId}/undelete"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainerversion.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{containerVersionId}", "containerVersionId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerVersionId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVersionUndeleteCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVersionUndeleteCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Container Version ID. /// /// Sets the *container version 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 container_version_id( mut self, new_value: &str, ) -> AccountContainerVersionUndeleteCall<'a, C> { self._container_version_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVersionUndeleteCall<'a, C> { 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) -> AccountContainerVersionUndeleteCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainerversion`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVersionUndeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVersionUndeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVersionUndeleteCall<'a, C> { self._scopes.clear(); self } } /// Updates a Container Version. /// /// A builder for the *containers.versions.update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::ContainerVersion; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = ContainerVersion::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.accounts().containers_versions_update(req, "accountId", "containerId", "containerVersionId") /// .fingerprint("erat") /// .doit().await; /// # } /// ``` pub struct AccountContainerVersionUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: ContainerVersion, _account_id: String, _container_id: String, _container_version_id: String, _fingerprint: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerVersionUpdateCall<'a, C> {} impl<'a, C> AccountContainerVersionUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ContainerVersion)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.versions.update", http_method: hyper::Method::PUT, }); for &field in [ "alt", "accountId", "containerId", "containerVersionId", "fingerprint", ] .iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(7 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.push("containerVersionId", self._container_version_id); if let Some(value) = self._fingerprint.as_ref() { params.push("fingerprint", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}/versions/{containerVersionId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainerversion.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ("{containerVersionId}", "containerVersionId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerVersionId", "containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: ContainerVersion, ) -> AccountContainerVersionUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerVersionUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerVersionUpdateCall<'a, C> { self._container_id = new_value.to_string(); self } /// The GTM Container Version ID. /// /// Sets the *container version 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 container_version_id( mut self, new_value: &str, ) -> AccountContainerVersionUpdateCall<'a, C> { self._container_version_id = new_value.to_string(); self } /// When provided, this fingerprint must match the fingerprint of the container version in storage. /// /// Sets the *fingerprint* query property to the given value. pub fn fingerprint(mut self, new_value: &str) -> AccountContainerVersionUpdateCall<'a, C> { self._fingerprint = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerVersionUpdateCall<'a, C> { 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) -> AccountContainerVersionUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainerversion`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerVersionUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerVersionUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerVersionUpdateCall<'a, C> { self._scopes.clear(); self } } /// Creates a Container. /// /// A builder for the *containers.create* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Container; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Container::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.accounts().containers_create(req, "accountId") /// .doit().await; /// # } /// ``` pub struct AccountContainerCreateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Container, _account_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerCreateCall<'a, C> {} impl<'a, C> AccountContainerCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Container)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.create", http_method: hyper::Method::POST, }); for &field in ["alt", "accountId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{accountId}", "accountId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Container) -> AccountContainerCreateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerCreateCall<'a, C> { self._account_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerCreateCall<'a, C> { 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) -> AccountContainerCreateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerCreateCall<'a, C> { self._scopes.clear(); self } } /// Deletes a Container. /// /// A builder for the *containers.delete* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_delete("accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerDeleteCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerDeleteCall<'a, C> {} impl<'a, C> AccountContainerDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.delete", http_method: hyper::Method::DELETE, }); for &field in ["accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::DeleteContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = common::Response::from_parts(parts, body); dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerDeleteCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerDeleteCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerDeleteCall<'a, C> { 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) -> AccountContainerDeleteCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::DeleteContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets a Container. /// /// A builder for the *containers.get* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_get("accountId", "containerId") /// .doit().await; /// # } /// ``` pub struct AccountContainerGetCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _container_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerGetCall<'a, C> {} impl<'a, C> AccountContainerGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Container)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.get", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "containerId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerGetCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerGetCall<'a, C> { self._container_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerGetCall<'a, C> { 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) -> AccountContainerGetCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerGetCall<'a, C> { self._scopes.clear(); self } } /// Lists all Containers that belongs to a GTM Account. /// /// A builder for the *containers.list* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().containers_list("accountId") /// .doit().await; /// # } /// ``` pub struct AccountContainerListCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerListCall<'a, C> {} impl<'a, C> AccountContainerListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListContainersResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.list", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("accountId", self._account_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{accountId}", "accountId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerListCall<'a, C> { self._account_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerListCall<'a, C> { 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) -> AccountContainerListCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerListCall<'a, C> { self._scopes.clear(); self } } /// Updates a Container. /// /// A builder for the *containers.update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Container; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Container::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.accounts().containers_update(req, "accountId", "containerId") /// .fingerprint("est") /// .doit().await; /// # } /// ``` pub struct AccountContainerUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Container, _account_id: String, _container_id: String, _fingerprint: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountContainerUpdateCall<'a, C> {} impl<'a, C> AccountContainerUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Container)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.containers.update", http_method: hyper::Method::PUT, }); for &field in ["alt", "accountId", "containerId", "fingerprint"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("containerId", self._container_id); if let Some(value) = self._fingerprint.as_ref() { params.push("fingerprint", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/containers/{containerId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::EditContainer.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{containerId}", "containerId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["containerId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Container) -> AccountContainerUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountContainerUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM Container ID. /// /// Sets the *container 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 container_id(mut self, new_value: &str) -> AccountContainerUpdateCall<'a, C> { self._container_id = new_value.to_string(); self } /// When provided, this fingerprint must match the fingerprint of the container in storage. /// /// Sets the *fingerprint* query property to the given value. pub fn fingerprint(mut self, new_value: &str) -> AccountContainerUpdateCall<'a, C> { self._fingerprint = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountContainerUpdateCall<'a, C> { 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) -> AccountContainerUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::EditContainer`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountContainerUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountContainerUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountContainerUpdateCall<'a, C> { self._scopes.clear(); self } } /// Creates a user's Account & Container Permissions. /// /// A builder for the *permissions.create* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::UserAccess; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = UserAccess::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.accounts().permissions_create(req, "accountId") /// .doit().await; /// # } /// ``` pub struct AccountPermissionCreateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: UserAccess, _account_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountPermissionCreateCall<'a, C> {} impl<'a, C> AccountPermissionCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, UserAccess)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.permissions.create", http_method: hyper::Method::POST, }); for &field in ["alt", "accountId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/permissions"; if self._scopes.is_empty() { self._scopes.insert(Scope::ManageUser.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{accountId}", "accountId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: UserAccess) -> AccountPermissionCreateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountPermissionCreateCall<'a, C> { self._account_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountPermissionCreateCall<'a, C> { 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) -> AccountPermissionCreateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::ManageUser`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountPermissionCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountPermissionCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountPermissionCreateCall<'a, C> { self._scopes.clear(); self } } /// Removes a user from the account, revoking access to it and all of its containers. /// /// A builder for the *permissions.delete* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().permissions_delete("accountId", "permissionId") /// .doit().await; /// # } /// ``` pub struct AccountPermissionDeleteCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _permission_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountPermissionDeleteCall<'a, C> {} impl<'a, C> AccountPermissionDeleteCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.permissions.delete", http_method: hyper::Method::DELETE, }); for &field in ["accountId", "permissionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("permissionId", self._permission_id); params.extend(self._additional_params.iter()); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/permissions/{permissionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::ManageUser.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{permissionId}", "permissionId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["permissionId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = common::Response::from_parts(parts, body); dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountPermissionDeleteCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM User ID. /// /// Sets the *permission 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 permission_id(mut self, new_value: &str) -> AccountPermissionDeleteCall<'a, C> { self._permission_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountPermissionDeleteCall<'a, C> { 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) -> AccountPermissionDeleteCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::ManageUser`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountPermissionDeleteCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountPermissionDeleteCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountPermissionDeleteCall<'a, C> { self._scopes.clear(); self } } /// Gets a user's Account & Container Permissions. /// /// A builder for the *permissions.get* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().permissions_get("accountId", "permissionId") /// .doit().await; /// # } /// ``` pub struct AccountPermissionGetCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _permission_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountPermissionGetCall<'a, C> {} impl<'a, C> AccountPermissionGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, UserAccess)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.permissions.get", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId", "permissionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("permissionId", self._permission_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/permissions/{permissionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::ManageUser.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{permissionId}", "permissionId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["permissionId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountPermissionGetCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM User ID. /// /// Sets the *permission 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 permission_id(mut self, new_value: &str) -> AccountPermissionGetCall<'a, C> { self._permission_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountPermissionGetCall<'a, C> { 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) -> AccountPermissionGetCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::ManageUser`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountPermissionGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountPermissionGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountPermissionGetCall<'a, C> { self._scopes.clear(); self } } /// List all users that have access to the account along with Account and Container Permissions granted to each of them. /// /// A builder for the *permissions.list* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().permissions_list("accountId") /// .doit().await; /// # } /// ``` pub struct AccountPermissionListCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountPermissionListCall<'a, C> {} impl<'a, C> AccountPermissionListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListAccountUsersResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.permissions.list", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("accountId", self._account_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/permissions"; if self._scopes.is_empty() { self._scopes.insert(Scope::ManageUser.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{accountId}", "accountId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountPermissionListCall<'a, C> { self._account_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountPermissionListCall<'a, C> { 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) -> AccountPermissionListCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::ManageUser`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountPermissionListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountPermissionListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountPermissionListCall<'a, C> { self._scopes.clear(); self } } /// Updates a user's Account & Container Permissions. /// /// A builder for the *permissions.update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::UserAccess; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = UserAccess::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.accounts().permissions_update(req, "accountId", "permissionId") /// .doit().await; /// # } /// ``` pub struct AccountPermissionUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: UserAccess, _account_id: String, _permission_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountPermissionUpdateCall<'a, C> {} impl<'a, C> AccountPermissionUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, UserAccess)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.permissions.update", http_method: hyper::Method::PUT, }); for &field in ["alt", "accountId", "permissionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); params.push("permissionId", self._permission_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}/permissions/{permissionId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::ManageUser.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [ ("{accountId}", "accountId"), ("{permissionId}", "permissionId"), ] .iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["permissionId", "accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: UserAccess) -> AccountPermissionUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountPermissionUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// The GTM User ID. /// /// Sets the *permission 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 permission_id(mut self, new_value: &str) -> AccountPermissionUpdateCall<'a, C> { self._permission_id = 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. /// /// ````text /// 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 common::Delegate, ) -> AccountPermissionUpdateCall<'a, C> { 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) -> AccountPermissionUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::ManageUser`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountPermissionUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountPermissionUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountPermissionUpdateCall<'a, C> { self._scopes.clear(); self } } /// Gets a GTM Account. /// /// A builder for the *get* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().get("accountId") /// .doit().await; /// # } /// ``` pub struct AccountGetCall<'a, C> where C: 'a, { hub: &'a TagManager, _account_id: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountGetCall<'a, C> {} impl<'a, C> AccountGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Account)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.get", http_method: hyper::Method::GET, }); for &field in ["alt", "accountId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("accountId", self._account_id); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{accountId}", "accountId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountGetCall<'a, C> { self._account_id = 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. /// /// ````text /// 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 common::Delegate) -> AccountGetCall<'a, C> { 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) -> AccountGetCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountGetCall<'a, C> { self._scopes.clear(); self } } /// Lists all GTM Accounts that a user has access to. /// /// A builder for the *list* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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.accounts().list() /// .doit().await; /// # } /// ``` pub struct AccountListCall<'a, C> where C: 'a, { hub: &'a TagManager, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountListCall<'a, C> {} impl<'a, C> AccountListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, ListAccountsResponse)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.list", http_method: hyper::Method::GET, }); for &field in ["alt"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(2 + self._additional_params.len()); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts"; if self._scopes.is_empty() { self._scopes.insert(Scope::Readonly.as_ref().to_string()); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; 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.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// 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 common::Delegate) -> AccountListCall<'a, C> { 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) -> AccountListCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::Readonly`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountListCall<'a, C> { self._scopes.clear(); self } } /// Updates a GTM Account. /// /// A builder for the *update* method supported by a *account* resource. /// It is not used directly, but through a [`AccountMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_tagmanager1 as tagmanager1; /// use tagmanager1::api::Account; /// # async fn dox() { /// # use tagmanager1::{TagManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = TagManager::new(client, 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 = Account::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.accounts().update(req, "accountId") /// .fingerprint("Stet") /// .doit().await; /// # } /// ``` pub struct AccountUpdateCall<'a, C> where C: 'a, { hub: &'a TagManager, _request: Account, _account_id: String, _fingerprint: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for AccountUpdateCall<'a, C> {} impl<'a, C> AccountUpdateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> common::Result<(common::Response, Account)> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "tagmanager.accounts.update", http_method: hyper::Method::PUT, }); for &field in ["alt", "accountId", "fingerprint"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("accountId", self._account_id); if let Some(value) = self._fingerprint.as_ref() { params.push("fingerprint", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "tagmanager/v1/accounts/{accountId}"; if self._scopes.is_empty() { self._scopes .insert(Scope::ManageAccount.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{accountId}", "accountId")].iter() { url = params.uri_replacement(url, param_name, find_this, false); } { let to_remove = ["accountId"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::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::PUT) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// 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: Account) -> AccountUpdateCall<'a, C> { self._request = new_value; self } /// The GTM Account ID. /// /// Sets the *account 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 account_id(mut self, new_value: &str) -> AccountUpdateCall<'a, C> { self._account_id = new_value.to_string(); self } /// When provided, this fingerprint must match the fingerprint of the account in storage. /// /// Sets the *fingerprint* query property to the given value. pub fn fingerprint(mut self, new_value: &str) -> AccountUpdateCall<'a, C> { self._fingerprint = 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. /// /// ````text /// 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 common::Delegate) -> AccountUpdateCall<'a, C> { 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) -> AccountUpdateCall<'a, C> 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 of the default [`Scope`] variant /// [`Scope::ManageAccount`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// 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: St) -> AccountUpdateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> AccountUpdateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> AccountUpdateCall<'a, C> { self._scopes.clear(); self } }