20个稳定版本 (4个主要版本)
5.0.5+20240619 | 2024年6月27日 |
---|---|
5.0.4+20240228 | 2024年3月5日 |
5.0.3+20230123 | 2023年8月24日 |
5.0.2+20230123 | 2023年3月16日 |
1.0.6+20170915 | 2017年9月27日 |
#2055 in 网络编程
1.5MB
20K SLoC
google-tagmanager2
库允许访问 Google Tag Manager 服务中的所有功能。
本文档由 Tag Manager crate 版本 5.0.5+20240619 生成,其中 20240619 是由 mako 代码生成器 v5.0.5 构建的 tagmanager:v2 架构的确切修订。
有关 Tag Manager v2 API 的其他所有信息,请参阅 官方文档站点。
特性
从中央 中心 轻松处理以下 资源 ...
- 账户
- containers combine, containers create, containers delete, containers destinations get, containers destinations link, containers destinations list, containers environments create, containers environments delete, containers environments get, containers environments list, containers environments reauthorize, containers environments update, containers get, containers list, containers lookup, containers move_tag_id, containers snippet, containers update, containers version_headers latest, containers version_headers list, containers versions delete, containers versions get, containers versions live, containers versions publish, containers versions set_latest, containers versions undelete, containers versions update, containers workspaces built_in_variables create, containers workspaces built_in_variables delete, containers workspaces built_in_variables list, containers workspaces built_in_variables revert, containers workspaces clients create, containers workspaces clients delete, containers workspaces clients get, containers workspaces clients list, containers workspaces clients revert, containers workspaces clients update, containers workspaces create, containers workspaces create_version, containers workspaces delete, containers workspaces folders create, containers workspaces folders delete, containers workspaces folders entities, containers workspaces folders get, containers workspaces folders list, containers workspaces folders move_entities_to_folder, containers workspaces folders revert, containers workspaces folders update, containers workspaces get, containers workspaces get status, containers workspaces gtag_config create, containers workspaces gtag_config delete, containers workspaces gtag_config get, containers workspaces gtag_config list, containers workspaces gtag_config update, containers workspaces list, containers workspaces quick_preview, containers workspaces resolve_conflict, containers workspaces sync, containers workspaces tags create, containers workspaces tags delete, containers workspaces tags get, containers workspaces tags list, containers workspaces tags revert, containers workspaces tags update, containers workspaces templates create, containers workspaces templates delete, containers workspaces templates get, containers workspaces templates list, containers workspaces templates revert, containers workspaces templates update, containers workspaces transformations create, containers workspaces transformations delete, containers workspaces transformations get, containers workspaces transformations list, containers workspaces transformations revert, containers workspaces transformations update, containers workspaces triggers create, containers workspaces triggers delete, containers workspaces triggers get, containers workspaces triggers list, containers workspaces triggers revert, containers workspaces triggers update, containers workspaces update, containers workspaces variables create, containers workspaces variables delete, containers workspaces variables get, containers workspaces variables list, containers workspaces variables revert, containers workspaces variables update, containers workspaces zones create, containers workspaces zones delete, containers workspaces zones get, containers workspaces zones list, containers workspaces zones revert, containers workspaces zones update, get, list, update, user_permissions create, user_permissions delete, user_permissions get, user_permissions list and user_permissions update
本库的结构
API结构如下
所有 结构 都带有适用的特性,以进一步分类它们并简化浏览。
一般来说,您可以像这样调用 活动
let r = hub.resource().activity(...).doit().await
或具体地 ...
let r = hub.accounts().containers_destinations_get(...).doit().await
let r = hub.accounts().containers_destinations_link(...).doit().await
let r = hub.accounts().containers_destinations_list(...).doit().await
let r = hub.accounts().containers_environments_create(...).doit().await
let r = hub.accounts().containers_environments_delete(...).doit().await
let r = hub.accounts().containers_environments_get(...).doit().await
let r = hub.accounts().containers_environments_list(...).doit().await
let r = hub.accounts().containers_environments_reauthorize(...).doit().await
let r = hub.accounts().containers_environments_update(...).doit().await
let r = hub.accounts().containers_version_headers_latest(...).doit().await
let r = hub.accounts().containers_version_headers_list(...).doit().await
let r = hub.accounts().containers_versions_delete(...).doit().await
let r = hub.accounts().containers_versions_get(...).doit().await
let r = hub.accounts().containers_versions_live(...).doit().await
let r = hub.accounts().containers_versions_publish(...).doit().await
let r = hub.accounts().containers_versions_set_latest(...).doit().await
let r = hub.accounts().containers_versions_undelete(...).doit().await
let r = hub.accounts().containers_versions_update(...).doit().await
let r = hub.accounts().containers_workspaces_built_in_variables_create(...).doit().await
let r = hub.accounts().containers_workspaces_built_in_variables_delete(...).doit().await
let r = hub.accounts().containers_workspaces_built_in_variables_list(...).doit().await
let r = hub.accounts().containers_workspaces_built_in_variables_revert(...).doit().await
let r = hub.accounts().containers_workspaces_clients_create(...).doit().await
let r = hub.accounts().containers_workspaces_clients_delete(...).doit().await
let r = hub.accounts().containers_workspaces_clients_get(...).doit().await
let r = hub.accounts().containers_workspaces_clients_list(...).doit().await
let r = hub.accounts().containers_workspaces_clients_revert(...).doit().await
let r = hub.accounts().containers_workspaces_clients_update(...).doit().await
let r = hub.accounts().containers_workspaces_folders_create(...).doit().await
let r = hub.accounts().containers_workspaces_folders_delete(...).doit().await
let r = hub.accounts().containers_workspaces_folders_entities(...).doit().await
let r = hub.accounts().containers_workspaces_folders_get(...).doit().await
let r = hub.accounts().containers_workspaces_folders_list(...).doit().await
let r = hub.accounts().containers_workspaces_folders_move_entities_to_folder(...).doit().await
let r = hub.accounts().containers_workspaces_folders_revert(...).doit().await
let r = hub.accounts().containers_workspaces_folders_update(...).doit().await
let r = hub.accounts().containers_workspaces_gtag_config_create(...).doit().await
let r = hub.accounts().containers_workspaces_gtag_config_delete(...).doit().await
let r = hub.accounts().containers_workspaces_gtag_config_get(...).doit().await
let r = hub.accounts().containers_workspaces_gtag_config_list(...).doit().await
let r = hub.accounts().containers_workspaces_gtag_config_update(...).doit().await
let r = hub.accounts().containers_workspaces_tags_create(...).doit().await
let r = hub.accounts().containers_workspaces_tags_delete(...).doit().await
let r = hub.accounts().containers_workspaces_tags_get(...).doit().await
let r = hub.accounts().containers_workspaces_tags_list(...).doit().await
let r = hub.accounts().containers_workspaces_tags_revert(...).doit().await
let r = hub.accounts().containers_workspaces_tags_update(...).doit().await
let r = hub.accounts().containers_workspaces_templates_create(...).doit().await
let r = hub.accounts().containers_workspaces_templates_delete(...).doit().await
let r = hub.accounts().containers_workspaces_templates_get(...).doit().await
let r = hub.accounts().containers_workspaces_templates_list(...).doit().await
let r = hub.accounts().containers_workspaces_templates_revert(...).doit().await
let r = hub.accounts().containers_workspaces_templates_update(...).doit().await
let r = hub.accounts().containers_workspaces_transformations_create(...).doit().await
let r = hub.accounts().containers_workspaces_transformations_delete(...).doit().await
let r = hub.accounts().containers_workspaces_transformations_get(...).doit().await
let r = hub.accounts().containers_workspaces_transformations_list(...).doit().await
let r = hub.accounts().containers_workspaces_transformations_revert(...).doit().await
let r = hub.accounts().containers_workspaces_transformations_update(...).doit().await
let r = hub.accounts().containers_workspaces_triggers_create(...).doit().await
let r = hub.accounts().containers_workspaces_triggers_delete(...).doit().await
let r = hub.accounts().containers_workspaces_triggers_get(...).doit().await
let r = hub.accounts().containers_workspaces_triggers_list(...).doit().await
let r = hub.accounts().containers_workspaces_triggers_revert(...).doit().await
let r = hub.accounts().containers_workspaces_triggers_update(...).doit().await
let r = hub.accounts().containers_workspaces_variables_create(...).doit().await
let r = hub.accounts().containers_workspaces_variables_delete(...).doit().await
let r = hub.accounts().containers_workspaces_variables_get(...).doit().await
let r = hub.accounts().containers_workspaces_variables_list(...).doit().await
let r = hub.accounts().containers_workspaces_variables_revert(...).doit().await
let r = hub.accounts().containers_workspaces_variables_update(...).doit().await
let r = hub.accounts().containers_workspaces_zones_create(...).doit().await
let r = hub.accounts().containers_workspaces_zones_delete(...).doit().await
let r = hub.accounts().containers_workspaces_zones_get(...).doit().await
let r = hub.accounts().containers_workspaces_zones_list(...).doit().await
let r = hub.accounts().containers_workspaces_zones_revert(...).doit().await
let r = hub.accounts().containers_workspaces_zones_update(...).doit().await
let r = hub.accounts().containers_workspaces_create(...).doit().await
let r = hub.accounts().containers_workspaces_create_version(...).doit().await
let r = hub.accounts().containers_workspaces_delete(...).doit().await
let r = hub.accounts().containers_workspaces_get(...).doit().await
let r = hub.accounts().containers_workspaces_get_status(...).doit().await
let r = hub.accounts().containers_workspaces_list(...).doit().await
let r = hub.accounts().containers_workspaces_quick_preview(...).doit().await
let r = hub.accounts().containers_workspaces_resolve_conflict(...).doit().await
let r = hub.accounts().containers_workspaces_sync(...).doit().await
let r = hub.accounts().containers_workspaces_update(...).doit().await
let r = hub.accounts().containers_combine(...).doit().await
let r = hub.accounts().containers_create(...).doit().await
let r = hub.accounts().containers_delete(...).doit().await
let r = hub.accounts().containers_get(...).doit().await
let r = hub.accounts().containers_list(...).doit().await
let r = hub.accounts().containers_lookup(...).doit().await
let r = hub.accounts().containers_move_tag_id(...).doit().await
let r = hub.accounts().containers_snippet(...).doit().await
let r = hub.accounts().containers_update(...).doit().await
let r = hub.accounts().user_permissions_create(...).doit().await
let r = hub.accounts().user_permissions_delete(...).doit().await
let r = hub.accounts().user_permissions_get(...).doit().await
let r = hub.accounts().user_permissions_list(...).doit().await
let r = hub.accounts().user_permissions_update(...).doit().await
let r = hub.accounts().get(...).doit().await
let r = hub.accounts().list(...).doit().await
let r = hub.accounts().update(...).doit().await
资源调用 resource()
和活动调用 activity(...)
创建构建器。后者处理 Activities
并支持各种配置即将进行的操作(此处未显示)的方法。它被设计成必须立即指定所有必需的参数(即 (...)
),而所有可选的都可以按需构建。doit()
方法执行与服务器的实际通信,并返回相应的结果。
使用方法
设置您的项目
要使用此库,您需要将以下行放入您的 Cargo.toml
文件中
[dependencies]
google-tagmanager2 = "*"
serde = "^1.0"
serde_json = "^1.0"
一个完整的例子
extern crate hyper;
extern crate hyper_rustls;
extern crate google_tagmanager2 as tagmanager2;
use tagmanager2::{Result, Error};
use std::default::Default;
use tagmanager2::{TagManager, oauth2, hyper, hyper_rustls, chrono, FieldMask};
// Get an ApplicationSecret instance by some means. It contains the `client_id` and
// `client_secret`, among other things.
let secret: oauth2::ApplicationSecret = Default::default();
// Instantiate the authenticator. It will choose a suitable authentication flow for you,
// unless you replace `None` with the desired Flow.
// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
// retrieve them from storage.
let auth = oauth2::InstalledFlowAuthenticator::builder(
secret,
oauth2::InstalledFlowReturnMethod::HTTPRedirect,
).build().await.unwrap();
let mut hub = TagManager::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth);
// You can configure optional parameters by calling the respective setters at will, and
// execute the final call using `doit()`.
// Values shown here are possibly random and not representative !
let result = hub.accounts().containers_move_tag_id("path")
.tag_name("magna")
.tag_id("no")
.copy_users(true)
.copy_terms_of_service(false)
.copy_settings(true)
.allow_user_permission_feature_update(true)
.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),
}
错误处理
系统产生的所有错误都作为 Result 枚举提供,作为 doit() 方法的返回值,或者作为可能的中继结果传递给 Hub Delegate 或 Authenticator Delegate。
当代理处理错误或中间值时,它们有机会指示系统重试。这使得系统可能对所有类型的错误都有弹性。
上传和下载
如果某个方法支持下载,则响应体(作为 Result 的一部分)应由您读取以获取媒体。如果此类方法还支持 Response Result,则默认返回该值。您可以将它视为实际媒体的元数据。要触发媒体下载,您必须通过此调用设置构建器:.param("alt", "media")
。
支持上传的方法可以使用最多两种不同的协议:简单 和 可恢复。每种协议的独特之处在于定制的 doit(...)
方法,分别命名为 upload(...)
和 upload_resumable(...)
。
定制和回调
您可以通过在最终 doit()
调用之前向 Method Builder 提供一个 代理 来更改 doit()
方法的调用方式。相应的方程序会被调用以提供进度信息,以及确定系统在失败时是否应该重试。
代理特质 有默认实现,允许您以最小的努力进行自定义。
服务器请求中的可选部分
本库提供的所有结构都设计成可以通过 编码 和 解码 来使用 json 格式。使用可选参数来表示部分请求或响应是有效的。大多数可选参数被视为 部分,可以通过名称识别,这些部分将被发送到服务器以指示请求的设置部分或响应中期望的部分。
构建器参数
通过使用 方法构建器,你可以通过重复调用其方法来准备一个操作调用。这些方法始终接受单个参数,以下陈述适用于这些参数。
参数将始终被复制或克隆到构建器中,以使其与其原始生命周期独立。
Cargo 特性
utoipa
- 添加对 utoipa 的支持,并从所有类型中派生utoipa::ToSchema
。你必须在#[openapi(schemas(...))]
中导入和注册所需类型,否则生成的openapi
规范将是无效的。
许可证
tagmanager2 库由 Sebastian Thiel 生成,并置于 MIT 许可证之下。你可以在存储库的 许可证文件 中阅读全文。
依赖关系
~12–22MB
~342K SLoC