38个版本 (稳定)
5.0.5+20240608 | 2024年6月27日 |
---|---|
5.0.4+20240214 | 2024年3月5日 |
5.0.3+20230104 | 2023年8月23日 |
5.0.2+20230104 | 2023年3月16日 |
0.1.9+20150603 | 2015年10月19日 |
#14 in #container
在 google-container1-cli 中使用
1.5MB
15K SLoC
该 google-container1
库允许访问Google Container服务的所有功能。
此文档是从Containercrate版本5.0.5+20240608生成的,其中20240608是mako代码生成器v5.0.5构建的container:v1架构的确切修订。
关于Container v1 API的所有其他信息都可以在官方文档网站找到。
功能
从中央中心轻松处理以下资源...
- 项目
- aggregated usable subnetworks list, locations clusters check autopilot compatibility, locations clusters complete ip rotation, locations clusters create, locations clusters delete, locations clusters get, locations clusters get jwks, locations clusters list, locations clusters node pools complete upgrade, locations clusters node pools create, locations clusters node pools delete, locations clusters node pools get, locations clusters node pools list, locations clusters node pools rollback, locations clusters node pools set autoscaling, locations clusters node pools set management, locations clusters node pools set size, locations clusters node pools update, locations clusters set addons, locations clusters set legacy abac, locations clusters set locations, locations clusters set logging, locations clusters set maintenance policy, locations clusters set master auth, locations clusters set monitoring, locations clusters set network policy, locations clusters set resource labels, locations clusters start ip rotation, locations clusters update, locations clusters update master, locations clusters well-known get openid-configuration, locations get server config, locations operations cancel, locations operations get, locations operations list, zones clusters addons, zones clusters complete ip rotation, zones clusters create, zones clusters delete, zones clusters get, zones clusters legacy abac, zones clusters list, zones clusters locations, zones clusters logging, zones clusters master, zones clusters monitoring, zones clusters node pools autoscaling, zones clusters node pools create, zones clusters node pools delete, zones clusters node pools get, zones clusters node pools list, zones clusters node pools rollback, zones clusters node pools set management, zones clusters node pools set size, zones clusters node pools update, zones clusters resource labels, zones clusters set maintenance policy, zones clusters set master auth, zones clusters set network policy, zones clusters start ip rotation, zones clusters update, zones get serverconfig, zones operations cancel, zones operations get and zones operations list
本库的结构
API结构为以下主要项目
所有结构都标记有适用特性,以进一步分类它们并简化浏览。
一般来说,您可以像这样调用活动
let r = hub.resource().activity(...).doit().await
或具体地...
let r = hub.projects().locations_clusters_node_pools_create(...).doit().await
let r = hub.projects().locations_clusters_node_pools_delete(...).doit().await
let r = hub.projects().locations_clusters_node_pools_rollback(...).doit().await
let r = hub.projects().locations_clusters_node_pools_set_autoscaling(...).doit().await
let r = hub.projects().locations_clusters_node_pools_set_management(...).doit().await
let r = hub.projects().locations_clusters_node_pools_set_size(...).doit().await
let r = hub.projects().locations_clusters_node_pools_update(...).doit().await
let r = hub.projects().locations_clusters_complete_ip_rotation(...).doit().await
let r = hub.projects().locations_clusters_create(...).doit().await
let r = hub.projects().locations_clusters_delete(...).doit().await
let r = hub.projects().locations_clusters_set_addons(...).doit().await
let r = hub.projects().locations_clusters_set_legacy_abac(...).doit().await
let r = hub.projects().locations_clusters_set_locations(...).doit().await
let r = hub.projects().locations_clusters_set_logging(...).doit().await
let r = hub.projects().locations_clusters_set_maintenance_policy(...).doit().await
let r = hub.projects().locations_clusters_set_master_auth(...).doit().await
let r = hub.projects().locations_clusters_set_monitoring(...).doit().await
let r = hub.projects().locations_clusters_set_network_policy(...).doit().await
let r = hub.projects().locations_clusters_set_resource_labels(...).doit().await
let r = hub.projects().locations_clusters_start_ip_rotation(...).doit().await
let r = hub.projects().locations_clusters_update(...).doit().await
let r = hub.projects().locations_clusters_update_master(...).doit().await
let r = hub.projects().locations_operations_get(...).doit().await
let r = hub.projects().zones_clusters_node_pools_autoscaling(...).doit().await
let r = hub.projects().zones_clusters_node_pools_create(...).doit().await
let r = hub.projects().zones_clusters_node_pools_delete(...).doit().await
let r = hub.projects().zones_clusters_node_pools_rollback(...).doit().await
let r = hub.projects().zones_clusters_node_pools_set_management(...).doit().await
let r = hub.projects().zones_clusters_node_pools_set_size(...).doit().await
let r = hub.projects().zones_clusters_node_pools_update(...).doit().await
let r = hub.projects().zones_clusters_addons(...).doit().await
let r = hub.projects().zones_clusters_complete_ip_rotation(...).doit().await
let r = hub.projects().zones_clusters_create(...).doit().await
let r = hub.projects().zones_clusters_delete(...).doit().await
let r = hub.projects().zones_clusters_legacy_abac(...).doit().await
let r = hub.projects().zones_clusters_locations(...).doit().await
let r = hub.projects().zones_clusters_logging(...).doit().await
let r = hub.projects().zones_clusters_master(...).doit().await
let r = hub.projects().zones_clusters_monitoring(...).doit().await
let r = hub.projects().zones_clusters_resource_labels(...).doit().await
let r = hub.projects().zones_clusters_set_maintenance_policy(...).doit().await
let r = hub.projects().zones_clusters_set_master_auth(...).doit().await
let r = hub.projects().zones_clusters_set_network_policy(...).doit().await
let r = hub.projects().zones_clusters_start_ip_rotation(...).doit().await
let r = hub.projects().zones_clusters_update(...).doit().await
let r = hub.projects().zones_operations_get(...).doit().await
资源(resource)和活动(activity)的调用创建了构建器。第二个处理活动(Activities)的构建器支持各种方法来配置即将进行的操作(此处未展示)。它被设计成必须立即指定所有必需参数(即(...)
),而所有可选参数可以按照所需的方式逐步构建。doit()
方法执行与服务器实际的通信并返回相应的结果。
用法
设置你的项目
要使用此库,您需要在您的Cargo.toml
文件中添加以下行
[dependencies]
google-container1 = "*"
serde = "^1.0"
serde_json = "^1.0"
一个完整的示例
extern crate hyper;
extern crate hyper_rustls;
extern crate google_container1 as container1;
use container1::{Result, Error};
use std::default::Default;
use container1::{Container, 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 = Container::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.projects().locations_clusters_node_pools_delete("name")
.zone("magna")
.project_id("no")
.node_pool_id("ipsum")
.cluster_id("voluptua.")
.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")
。
支持上传的方法可以使用最多2种不同的协议:简单和可恢复。每种协议的独特性由定制的doit(...)
方法表示,分别命名为upload(...)
和upload_resumable(...)
。
定制和回调
您可以通过在调用最终doit()
之前向Method Builder提供一个代理来更改doit()
方法的调用方式。相应的方法将被调用以提供进度信息,以及确定系统在失败时是否应该重试。
delegate trait具有默认实现,允许您以最小的努力进行自定义。
服务器请求中的可选部分
本库提供的所有结构都设计为可以通过json进行编码和解码。使用可选参数来表示部分请求或响应是有效的。大多数可选参数被视为部分,可以通过名称识别,这些部分将被发送到服务器,以指示请求或响应中所需的特定部分。
构建器参数
通过使用方法构建器,您可以通过重复调用其方法来准备一个操作调用。这些方法始终接受一个参数,以下陈述对其适用。
参数将被复制或克隆到构建器中,以确保它们与其原始的生命周期独立。
Cargo功能
utoipa
- 添加对utoipa的支持,并从所有类型中推导出utoipa::ToSchema
。您必须在#[openapi(schemas(...))]
中导入和注册所需的类型,否则生成的openapi
规范将无效。
许可证
container1库由Sebastian Thiel生成,并置于MIT许可证之下。您可以在存储库的许可证文件中阅读全文。
依赖项
~12–22MB
~341K SLoC