#google-api #google #cli #command-line-interface #reseller

app google-reseller1_sandbox-cli

一个用于与分销商(协议v1sandbox)交互的完整库

19个稳定版本 (4个主要版本)

5.0.4+20160329 2024年3月5日
3.0.0+20160329 2022年3月8日
2.0.4+20160329 2021年4月15日
1.0.14+20160329 2020年7月10日
0.3.6+20160329 2016年9月11日

#1763 in 网络编程

Download history 11/week @ 2024-03-11 161/week @ 2024-04-01 1/week @ 2024-05-20

每月419次下载

MIT 协议

365KB
5K SLoC

reseller1-sandbox 命令行界面(CLI)允许您在终端中舒适地使用Google分销商服务的大部分功能。

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

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

关于分销商API的所有其他信息,请参阅官方文档网站

安装和源代码

使用cargo安装命令行界面:

cargo install google-reseller1_sandbox-cli

github上找到源代码。

用法

此文档是从修订版 20160329分销商 API 生成的。CLI版本为 5.0.4

reseller1-sandbox [options]
        customers
                get <customer-id> [-p <v>]... [-o <out>]
                insert (-r <kv>)... [-p <v>]... [-o <out>]
                patch <customer-id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <customer-id> (-r <kv>)... [-p <v>]... [-o <out>]
        subscriptions
                activate <customer-id> <subscription-id> [-p <v>]... [-o <out>]
                change-plan <customer-id> <subscription-id> (-r <kv>)... [-p <v>]... [-o <out>]
                change-renewal-settings <customer-id> <subscription-id> (-r <kv>)... [-p <v>]... [-o <out>]
                change-seats <customer-id> <subscription-id> (-r <kv>)... [-p <v>]... [-o <out>]
                delete <customer-id> <subscription-id> <deletion-type> [-p <v>]...
                get <customer-id> <subscription-id> [-p <v>]... [-o <out>]
                insert <customer-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list [-p <v>]... [-o <out>]
                start-paid-service <customer-id> <subscription-id> [-p <v>]... [-o <out>]
                suspend <customer-id> <subscription-id> [-p <v>]... [-o <out>]
  reseller1-sandbox --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 目录中存储所有持久数据,该目录以 reseller1-sandbox- 前缀的 JSON 文件开头。您可以使用 --config-dir 标志在每次调用的基础上更改用于存储配置的目录。

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

身份验证

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

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

首次使用作用域时,系统会请求用户授权。按照CLI给出的指示进行授权或拒绝。

如果用户认证了某个作用域,相关信息均以JSON格式存储在配置目录中,例如:~/.google-service-cli/reseller1-sandbox-token-<scope-hash>.json。无需手动管理这些令牌。

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

应用程序密钥

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

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

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

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

调试

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

使用--debug标志会将错误打印到标准错误,使用Debug表示形式。

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

依赖项

~20–31MB
~582K SLoC