2个稳定版本
5.0.4+20240221 | 2024年3月5日 |
---|---|
3.1.0+20220223 | 2022年4月26日 |
#2643 in 网络编程
29 每月下载量
2MB
25K SLoC
networksecurity1命令行界面(CLI)允许您从终端舒适地使用Google NetworkSecurity服务的几乎所有功能。
默认情况下,所有输出都打印到标准输出,但可以通过设置标志将其直接发送到文件,而不考虑shell的能力。错误将打印到标准错误,并导致程序退出代码非零。
如果请求数据结构,则这些数据结构将作为美观打印的JSON返回,以便作为其他工具的输入。
有关NetworkSecurity API的所有其他信息,请参阅官方文档网站。
安装和源代码
使用cargo安装命令行界面
cargo install google-networksecurity1-cli
用法
本文档是根据修订版20240221的NetworkSecurity API生成的。CLI版本为5.0.4。
networksecurity1 [options]
organizations
locations-address-groups-add-items <address-group> (-r <kv>)... [-p <v>]... [-o <out>]
locations-address-groups-clone-items <address-group> (-r <kv>)... [-p <v>]... [-o <out>]
locations-address-groups-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-address-groups-delete <name> [-p <v>]... [-o <out>]
locations-address-groups-get <name> [-p <v>]... [-o <out>]
locations-address-groups-list <parent> [-p <v>]... [-o <out>]
locations-address-groups-list-references <address-group> [-p <v>]... [-o <out>]
locations-address-groups-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-address-groups-remove-items <address-group> (-r <kv>)... [-p <v>]... [-o <out>]
locations-operations-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-operations-delete <name> [-p <v>]... [-o <out>]
locations-operations-get <name> [-p <v>]... [-o <out>]
locations-operations-list <name> [-p <v>]... [-o <out>]
projects
locations-address-groups-add-items <address-group> (-r <kv>)... [-p <v>]... [-o <out>]
locations-address-groups-clone-items <address-group> (-r <kv>)... [-p <v>]... [-o <out>]
locations-address-groups-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-address-groups-delete <name> [-p <v>]... [-o <out>]
locations-address-groups-get <name> [-p <v>]... [-o <out>]
locations-address-groups-get-iam-policy <resource> [-p <v>]... [-o <out>]
locations-address-groups-list <parent> [-p <v>]... [-o <out>]
locations-address-groups-list-references <address-group> [-p <v>]... [-o <out>]
locations-address-groups-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-address-groups-remove-items <address-group> (-r <kv>)... [-p <v>]... [-o <out>]
locations-address-groups-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
locations-address-groups-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
locations-authorization-policies-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-authorization-policies-delete <name> [-p <v>]... [-o <out>]
locations-authorization-policies-get <name> [-p <v>]... [-o <out>]
locations-authorization-policies-get-iam-policy <resource> [-p <v>]... [-o <out>]
locations-authorization-policies-list <parent> [-p <v>]... [-o <out>]
locations-authorization-policies-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-authorization-policies-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
locations-authorization-policies-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
locations-client-tls-policies-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-client-tls-policies-delete <name> [-p <v>]... [-o <out>]
locations-client-tls-policies-get <name> [-p <v>]... [-o <out>]
locations-client-tls-policies-get-iam-policy <resource> [-p <v>]... [-o <out>]
locations-client-tls-policies-list <parent> [-p <v>]... [-o <out>]
locations-client-tls-policies-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-client-tls-policies-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
locations-client-tls-policies-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
locations-gateway-security-policies-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-gateway-security-policies-delete <name> [-p <v>]... [-o <out>]
locations-gateway-security-policies-get <name> [-p <v>]... [-o <out>]
locations-gateway-security-policies-list <parent> [-p <v>]... [-o <out>]
locations-gateway-security-policies-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-gateway-security-policies-rules-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-gateway-security-policies-rules-delete <name> [-p <v>]... [-o <out>]
locations-gateway-security-policies-rules-get <name> [-p <v>]... [-o <out>]
locations-gateway-security-policies-rules-list <parent> [-p <v>]... [-o <out>]
locations-gateway-security-policies-rules-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-get <name> [-p <v>]... [-o <out>]
locations-list <name> [-p <v>]... [-o <out>]
locations-operations-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-operations-delete <name> [-p <v>]... [-o <out>]
locations-operations-get <name> [-p <v>]... [-o <out>]
locations-operations-list <name> [-p <v>]... [-o <out>]
locations-server-tls-policies-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-server-tls-policies-delete <name> [-p <v>]... [-o <out>]
locations-server-tls-policies-get <name> [-p <v>]... [-o <out>]
locations-server-tls-policies-get-iam-policy <resource> [-p <v>]... [-o <out>]
locations-server-tls-policies-list <parent> [-p <v>]... [-o <out>]
locations-server-tls-policies-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-server-tls-policies-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
locations-server-tls-policies-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
locations-tls-inspection-policies-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-tls-inspection-policies-delete <name> [-p <v>]... [-o <out>]
locations-tls-inspection-policies-get <name> [-p <v>]... [-o <out>]
locations-tls-inspection-policies-list <parent> [-p <v>]... [-o <out>]
locations-tls-inspection-policies-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-url-lists-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-url-lists-delete <name> [-p <v>]... [-o <out>]
locations-url-lists-get <name> [-p <v>]... [-o <out>]
locations-url-lists-list <parent> [-p <v>]... [-o <out>]
locations-url-lists-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
networksecurity1 --help
Configuration:
[--scope <url>]...
Specify the authentication a method should be executed in. Each scope
requires the user to grant this application permission to use it.
If unset, it defaults to the shortest scope url for a particular method.
--config-dir <folder>
A directory into which we will store our persistent data. Defaults to
a user-writable directory that we will create during the first invocation.
[default: ~/.google-service-cli]
配置
程序将在~/.google-service-cli
目录中存储所有持久数据,目录中带有以networksecurity1-
为前缀的JSON文件。您可以使用--config-dir
标志在每个调用上更改用于存储配置的目录。
有关各种类型持久数据的更多信息将在以下段落中给出。
身份验证
大多数API需要用户对任何请求进行身份验证。如果是这种情况,则作用域确定授予的权限集。这些权限的粒度通常不超过只读或完全访问。
如果没有设置,系统将自动选择最小的可行作用域,例如,当调用只读方法时,它将只请求只读作用域。您可以使用--scope
标志直接指定作用域。所有适用的作用域均在各自方法的CLI文档中记录。
首次使用作用域时,会提示用户授权。按照CLI的指示进行授权或拒绝。
如果作用域已被用户认证,相关信息将以JSON格式存储在配置目录中,例如:~/.google-service-cli/networksecurity1-token-<scope-hash>.json
。无需手动管理这些令牌。
要撤销授予的认证,请参阅官方文档。
应用程序密钥
为了允许任何应用程序使用Google服务,需要使用Google开发者控制台进行注册。应用程序可能使用的API将逐一启用。大多数API可以免费使用,并设有每日配额。
为了在不强制用户注册自己应用程序的情况下更方便地使用CLI,CLI自带了一个默认的应用程序密钥,并据此进行配置。这也意味着全球范围内的频繁使用可能会耗尽每日配额。
您可以通过将您自己的密钥文件放在此位置来解决这个问题:~/.google-service-cli/networksecurity1-secret.json
,假设已为它启用了所需的networksecurity API。这样的密钥文件可以在Google开发者控制台的APIs & auth -> Credentials -> Download JSON处下载,并直接使用。
有关如何设置Google项目和使用API启用API的更多信息,请参阅官方文档。
调试
尽管CLI尽力提供可用的错误消息,但有时可能希望知道导致特定问题的确切原因。这是通过允许所有客户端-服务器通信直接输出到标准错误原样来完成的。
--debug
标志将以Debug
表示形式将错误打印到标准错误。
您可以考虑将标准错误重定向到文件,以便于使用,例如:networksecurity1 --debug <resource> <method> [options] 2>debug.txt
。
依赖项
~19–34MB
~595K SLoC