2 个稳定版本
5.0.4+20240303 | 2024 年 3 月 5 日 |
---|---|
3.1.0+20220307 | 2022 年 4 月 26 日 |
#18 在 #cli-interface
30 每月下载量
340KB
4K SLoC
该 paymentsresellersubscription1
命令行界面 (CLI) 允许您从终端舒适地使用 Google Payments Reseller Subscription 服务的多数功能。
默认情况下,所有输出都打印到标准输出,但可以设置标志将其直接导向文件,而不管您的 shell 功能如何。错误将打印到标准错误,并导致程序的退出码非零。
如果请求数据结构,则这些数据结构将作为格式化良好的 JSON 返回,以便作为其他工具的输入使用。
有关 Payments Reseller Subscription API 的其他信息,请参阅官方文档网站。
安装和源代码
使用 cargo 安装命令行界面:
cargo install google-paymentsresellersubscription1-cli
在 github 上查找源代码。
用法
本文档是根据修订版 20240303 的 Payments Reseller Subscription API 生成的。CLI 的版本为 5.0.4。
paymentsresellersubscription1 [options]
partners
products-list <parent> [-p <v>]... [-o <out>]
promotions-find-eligible <parent> (-r <kv>)... [-p <v>]... [-o <out>]
promotions-list <parent> [-p <v>]... [-o <out>]
subscriptions-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
subscriptions-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
subscriptions-entitle <name> (-r <kv>)... [-p <v>]... [-o <out>]
subscriptions-extend <name> (-r <kv>)... [-p <v>]... [-o <out>]
subscriptions-get <name> [-p <v>]... [-o <out>]
subscriptions-provision <parent> (-r <kv>)... [-p <v>]... [-o <out>]
subscriptions-undo-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
paymentsresellersubscription1 --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 文件中,文件名以 paymentsresellersubscription1-
开头。您可以使用 --config-dir
标志在每个调用的基础上更改用于存储配置的目录。
以下段落中提供了有关各种类型持久数据的更多信息。
身份验证
大多数 API 需要用户对任何请求进行身份验证。如果是这种情况,作用域 确定了授予的权限集合。这些权限的粒度通常不超过 只读 或 完全访问。
如果没有设置,系统将自动选择最小的可行作用域,例如,在调用只读方法时,它只会请求只读作用域。您可以使用 --scope
标志直接指定作用域。所有适用的作用域均在各自方法的 CLI 文档中有记录。
第一次使用作用域时,用户会被要求授权。遵循 CLI 给出的指示授予权限,或拒绝。
如果用户验证了作用域,相应的信息将被存储在配置目录中,例如 ~/.google-service-cli/paymentsresellersubscription1-token-<scope-hash>.json
中的 JSON 格式。无需手动管理这些令牌。
要撤销授权的认证,请参阅官方文档。
应用程序密钥
为了允许任何应用程序使用Google服务,它需要通过Google开发者控制台进行注册。为该应用程序逐个启用可能使用的API。大多数API可以免费使用,并且有每日配额。
为了在不强制要求用户注册自己的应用程序的情况下更方便地使用CLI,CLI自带了一个默认的应用程序密钥,并相应地进行配置。这也意味着全球范围内的重用可能会耗尽每日配额。
您可以通过在此位置放置自己的密钥文件来解决这个问题: ~/.google-service-cli/paymentsresellersubscription1-secret.json
,假设已为它启用了所需的 paymentsresellersubscription API。此类密钥文件可以在 Google开发者控制台 的 APIs & auth -> Credentials -> Download JSON 中下载并直接使用。
有关如何设置Google项目和启用API的更多信息,请参阅官方文档。
调试
尽管CLI尽可能提供可用的错误信息,但有时可能需要知道导致特定问题的确切原因。这通过允许所有客户端-服务器通信以 原始形式 输出到标准错误来实现。
使用 --debug
标志会将错误以 Debug
表示法打印到标准错误。
您可以考虑将标准错误重定向到文件以方便使用,例如 paymentsresellersubscription1 --debug <resource> <method> [options] 2>debug.txt
。
依赖项
~20–31MB
~580K SLoC