10个稳定版本 (3个主要版本)

5.0.4+20240223 2024年3月5日
3.1.0+20220212 2022年4月26日
3.0.0+20220212 2022年3月8日
2.0.4+20210315 2021年4月15日
1.0.10+20190618 2019年7月6日

#cloudtasks 中排名 1

Download history

每月下载量 189

MIT 许可证

590KB
7K SLoC

cloudtasks2 命令行界面(CLI)允许您从终端舒适地使用大多数 Google Cloud Tasks 服务功能。

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

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

有关 Cloud Tasks API的更多信息,请参阅官方文档站点

安装和源代码

使用cargo通过以下方式安装命令行界面:

cargo install google-cloudtasks2-cli

GitHub上查找源代码

用法

本文档是根据修订版 20240223Cloud Tasks API生成的。CLI版本为 5.0.4

cloudtasks2 [options]
        projects
                locations-get <name> [-p <v>]... [-o <out>]
                locations-get-cmek-config <name> [-p <v>]... [-o <out>]
                locations-list <name> [-p <v>]... [-o <out>]
                locations-queues-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-queues-delete <name> [-p <v>]... [-o <out>]
                locations-queues-get <name> [-p <v>]... [-o <out>]
                locations-queues-get-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-queues-list <parent> [-p <v>]... [-o <out>]
                locations-queues-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-queues-pause <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-queues-purge <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-queues-resume <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-queues-set-iam-policy <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-queues-tasks-buffer <queue> <task-id> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-queues-tasks-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-queues-tasks-delete <name> [-p <v>]... [-o <out>]
                locations-queues-tasks-get <name> [-p <v>]... [-o <out>]
                locations-queues-tasks-list <parent> [-p <v>]... [-o <out>]
                locations-queues-tasks-run <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-queues-test-iam-permissions <resource> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-update-cmek-config <name> (-r <kv>)... [-p <v>]... [-o <out>]
  cloudtasks2 --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 目录中的 JSON 文件中,文件名以 cloudtasks2- 开头。您可以使用 --config-dir 标志在每个调用上更改用于存储配置的目录。

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

身份验证

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

如果没有设置,系统将自动选择最小的可行范围,例如,在调用只读方法时,它只会请求只读范围。您可以使用 --scope 标志直接指定范围。所有适用范围均在相应方法的CLI文档中进行了说明。

首次使用作用域时,会要求用户进行授权。根据CLI的指示进行授权或拒绝。

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

要撤销授予的认证,请参阅官方文档

应用程序密钥

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

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

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

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

调试

尽管CLI尽力提供可用的错误信息,但有时可能希望了解导致特定问题的确切原因。这通过允许所有客户端-服务器通信直接输出到标准错误原样来实现。

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

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

依赖关系

~20–31MB
~577K SLoC