#google #cli #google-api #命令行界面 #networkservices

应用 google-networkservices1-cli

一个完整的库,用于与 NetworkServices(协议 v1)交互

2 个稳定版本

5.0.4+20240224 2024 年 3 月 5 日
3.1.0+20220222 2022 年 4 月 26 日

150#命令行界面

每月 28 次下载

MIT 许可证

2MB
24K SLoC

networkservices1 命令行界面 (CLI) 允许您从终端舒适地使用 Google NetworkServices 服务的多数功能。

默认情况下,所有输出都打印到标准输出,但可以设置标志将其直接导向文件,而不依赖于您的 shell 功能。错误将打印到标准错误,并导致程序退出代码非零。

如果请求数据结构,则这些结构将作为格式化的 JSON 返回,以便作为其他工具的输入。

有关 NetworkServices API 的其他信息,请参阅 官方文档网站

安装和源代码

使用 cargo 安装命令行界面:

cargo install google-networkservices1-cli

GitHub 上找到源代码。

用法

本文档是根据修订版 20240224NetworkServices API 生成的。CLI 版本为 5.0.4

networkservices1 [options]
        projects
                locations-edge-cache-keysets-get-iam-policy <resource> [-p <v>]... [-o <out>]
                locations-edge-cache-keysets-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-edge-cache-keysets-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-edge-cache-origins-get-iam-policy <resource> [-p <v>]... [-o <out>]
                locations-edge-cache-origins-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-edge-cache-origins-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-edge-cache-services-get-iam-policy <resource> [-p <v>]... [-o <out>]
                locations-edge-cache-services-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-edge-cache-services-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-endpoint-policies-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-endpoint-policies-delete <name> [-p <v>]... [-o <out>]
                locations-endpoint-policies-get <name> [-p <v>]... [-o <out>]
                locations-endpoint-policies-get-iam-policy <resource> [-p <v>]... [-o <out>]
                locations-endpoint-policies-list <parent> [-p <v>]... [-o <out>]
                locations-endpoint-policies-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-endpoint-policies-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-endpoint-policies-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-gateways-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-gateways-delete <name> [-p <v>]... [-o <out>]
                locations-gateways-get <name> [-p <v>]... [-o <out>]
                locations-gateways-get-iam-policy <resource> [-p <v>]... [-o <out>]
                locations-gateways-list <parent> [-p <v>]... [-o <out>]
                locations-gateways-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-gateways-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-gateways-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-get <name> [-p <v>]... [-o <out>]
                locations-grpc-routes-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-grpc-routes-delete <name> [-p <v>]... [-o <out>]
                locations-grpc-routes-get <name> [-p <v>]... [-o <out>]
                locations-grpc-routes-list <parent> [-p <v>]... [-o <out>]
                locations-grpc-routes-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-http-routes-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-http-routes-delete <name> [-p <v>]... [-o <out>]
                locations-http-routes-get <name> [-p <v>]... [-o <out>]
                locations-http-routes-list <parent> [-p <v>]... [-o <out>]
                locations-http-routes-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-lb-route-extensions-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-lb-route-extensions-delete <name> [-p <v>]... [-o <out>]
                locations-lb-route-extensions-get <name> [-p <v>]... [-o <out>]
                locations-lb-route-extensions-list <parent> [-p <v>]... [-o <out>]
                locations-lb-route-extensions-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-lb-traffic-extensions-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-lb-traffic-extensions-delete <name> [-p <v>]... [-o <out>]
                locations-lb-traffic-extensions-get <name> [-p <v>]... [-o <out>]
                locations-lb-traffic-extensions-list <parent> [-p <v>]... [-o <out>]
                locations-lb-traffic-extensions-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-list <name> [-p <v>]... [-o <out>]
                locations-meshes-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-meshes-delete <name> [-p <v>]... [-o <out>]
                locations-meshes-get <name> [-p <v>]... [-o <out>]
                locations-meshes-get-iam-policy <resource> [-p <v>]... [-o <out>]
                locations-meshes-list <parent> [-p <v>]... [-o <out>]
                locations-meshes-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-meshes-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-meshes-test-iam-permissions <resource> (-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>]
                locations-service-bindings-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-service-bindings-delete <name> [-p <v>]... [-o <out>]
                locations-service-bindings-get <name> [-p <v>]... [-o <out>]
                locations-service-bindings-get-iam-policy <resource> [-p <v>]... [-o <out>]
                locations-service-bindings-list <parent> [-p <v>]... [-o <out>]
                locations-service-bindings-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-service-bindings-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-service-lb-policies-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-service-lb-policies-delete <name> [-p <v>]... [-o <out>]
                locations-service-lb-policies-get <name> [-p <v>]... [-o <out>]
                locations-service-lb-policies-get-iam-policy <resource> [-p <v>]... [-o <out>]
                locations-service-lb-policies-list <parent> [-p <v>]... [-o <out>]
                locations-service-lb-policies-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-service-lb-policies-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-service-lb-policies-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-tcp-routes-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-tcp-routes-delete <name> [-p <v>]... [-o <out>]
                locations-tcp-routes-get <name> [-p <v>]... [-o <out>]
                locations-tcp-routes-list <parent> [-p <v>]... [-o <out>]
                locations-tcp-routes-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-tls-routes-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-tls-routes-delete <name> [-p <v>]... [-o <out>]
                locations-tls-routes-get <name> [-p <v>]... [-o <out>]
                locations-tls-routes-list <parent> [-p <v>]... [-o <out>]
                locations-tls-routes-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
  networkservices1 --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 目录中存储所有持久数据,在 networkservices1- 前缀的 JSON 文件中。您可以使用 --config-dir 标志在每个调用的基础上更改用于存储配置的目录。

以下段落提供了有关各种持久数据的更多信息。

身份验证

大多数 API 需要用户对任何请求进行身份验证。如果是这种情况,作用域 确定了授予的权限集。这些的粒度通常不超过 只读完全访问

如果未设置,系统将自动选择最小的可行作用域,例如,当调用只读方法时,它将只请求只读作用域。您可以使用 --scope 标志直接指定作用域。所有适用的作用域都在各自方法的 CLI 文档中记录。

第一次使用作用域时,用户将被要求授权。按照 CLI 提供的说明授权权限或拒绝。

如果用户验证了作用域,相应的信息将存储在配置目录中,格式为JSON,例如:~/.google-service-cli/networkservices1-token-<scope-hash>.json。无需手动管理这些令牌。

要撤销授权的验证,请参阅官方文档

应用程序密钥

为了允许任何应用程序使用Google服务,它需要使用Google开发者控制台进行注册。应用程序可能使用的API将逐个启用。大多数API可以免费使用,并设有每日配额。

为了在不强制要求用户注册自己的应用程序的情况下更方便地使用CLI,CLI自带默认应用程序密钥,并相应配置。这也意味着全球范围内的重用可能会耗尽每日配额。

您可以通过将您自己的密钥文件放在此位置来解决这个问题:~/.google-service-cli/networkservices1-secret.json,假设已经为它启用了所需的networkservices API。这样的密钥文件可以在Google开发者控制台APIs & auth -> Credentials -> Download JSON中下载并直接使用。

有关如何设置Google项目和启用API的更多信息,请参阅官方文档

调试

尽管CLI尽力提供可用的错误消息,但有时可能需要知道导致特定问题的确切原因。这是通过允许所有客户端服务器通信以标准错误原始输出方式实现。

使用--debug标志将使用Debug表示法将错误打印到标准错误。

您可以考虑将标准错误重定向到文件,以便于使用,例如:networkservices1 --debug <resource> <method> [options] 2>debug.txt

依赖项

~20–31MB
~577K SLoC