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

3.1.0+20220303 2022年4月26日
3.0.0+20220303 2022年3月8日
2.0.4+20210325 2021年4月14日
1.0.14+20200617 2020年7月10日
0.3.6+20160905 2016年9月11日

#2924 in 网络编程

Download history 160/week @ 2024-03-31 1/week @ 2024-04-07

每月94次下载

MIT 协议

2MB
29K SLoC

content2命令行界面(CLI)允许您在终端中方便地使用Google购物内容服务的几乎所有功能。

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

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

关于购物内容API的其他一切信息都可以在官方文档站点找到。

安装和源代码

使用cargo安装命令行界面:

cargo install google-content2-cli

GitHub上找到源代码。

用法

此文档是根据购物内容 API的20220303修订版生成的。CLI版本为3.1.0

content2 [options]
        accounts
                authinfo [-p <v>]... [-o <out>]
                claimwebsite <merchant-id> <account-id> [-p <v>]... [-o <out>]
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                delete <merchant-id> <account-id> [-p <v>]...
                get <merchant-id> <account-id> [-p <v>]... [-o <out>]
                insert <merchant-id> (-r <kv>)... [-p <v>]... [-o <out>]
                link <merchant-id> <account-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
                update <merchant-id> <account-id> (-r <kv>)... [-p <v>]... [-o <out>]
        accountstatuses
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                get <merchant-id> <account-id> [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
        accounttax
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                get <merchant-id> <account-id> [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
                update <merchant-id> <account-id> (-r <kv>)... [-p <v>]... [-o <out>]
        datafeeds
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                delete <merchant-id> <datafeed-id> [-p <v>]...
                fetchnow <merchant-id> <datafeed-id> [-p <v>]... [-o <out>]
                get <merchant-id> <datafeed-id> [-p <v>]... [-o <out>]
                insert <merchant-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
                update <merchant-id> <datafeed-id> (-r <kv>)... [-p <v>]... [-o <out>]
        datafeedstatuses
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                get <merchant-id> <datafeed-id> [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
        inventory
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                set <merchant-id> <store-code> <product-id> (-r <kv>)... [-p <v>]... [-o <out>]
        liasettings
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                get <merchant-id> <account-id> [-p <v>]... [-o <out>]
                getaccessiblegmbaccounts <merchant-id> <account-id> [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
                listposdataproviders [-p <v>]... [-o <out>]
                requestgmbaccess <merchant-id> <account-id> <gmb-email> [-p <v>]... [-o <out>]
                requestinventoryverification <merchant-id> <account-id> <country> [-p <v>]... [-o <out>]
                setinventoryverificationcontact <merchant-id> <account-id> <country> <language> <contact-name> <contact-email> [-p <v>]... [-o <out>]
                setposdataprovider <merchant-id> <account-id> <country> [-p <v>]... [-o <out>]
                update <merchant-id> <account-id> (-r <kv>)... [-p <v>]... [-o <out>]
        orderinvoices
                createchargeinvoice <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                createrefundinvoice <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
        orderreports
                listdisbursements <merchant-id> [-p <v>]... [-o <out>]
                listtransactions <merchant-id> <disbursement-id> [-p <v>]... [-o <out>]
        orderreturns
                get <merchant-id> <return-id> [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
        orders
                acknowledge <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                advancetestorder <merchant-id> <order-id> [-p <v>]... [-o <out>]
                cancel <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                cancellineitem <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                canceltestorderbycustomer <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                createtestorder <merchant-id> (-r <kv>)... [-p <v>]... [-o <out>]
                createtestreturn <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                get <merchant-id> <order-id> [-p <v>]... [-o <out>]
                getbymerchantorderid <merchant-id> <merchant-order-id> [-p <v>]... [-o <out>]
                gettestordertemplate <merchant-id> <template-name> [-p <v>]... [-o <out>]
                instorerefundlineitem <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
                refund <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                rejectreturnlineitem <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                returnlineitem <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                returnrefundlineitem <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                setlineitemmetadata <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                shiplineitems <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                updatelineitemshippingdetails <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                updatemerchantorderid <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
                updateshipment <merchant-id> <order-id> (-r <kv>)... [-p <v>]... [-o <out>]
        pos
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                delete <merchant-id> <target-merchant-id> <store-code> [-p <v>]...
                get <merchant-id> <target-merchant-id> <store-code> [-p <v>]... [-o <out>]
                insert <merchant-id> <target-merchant-id> (-r <kv>)... [-p <v>]... [-o <out>]
                inventory <merchant-id> <target-merchant-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <merchant-id> <target-merchant-id> [-p <v>]... [-o <out>]
                sale <merchant-id> <target-merchant-id> (-r <kv>)... [-p <v>]... [-o <out>]
        products
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                delete <merchant-id> <product-id> [-p <v>]...
                get <merchant-id> <product-id> [-p <v>]... [-o <out>]
                insert <merchant-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
        productstatuses
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                get <merchant-id> <product-id> [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
        shippingsettings
                custombatch (-r <kv>)... [-p <v>]... [-o <out>]
                get <merchant-id> <account-id> [-p <v>]... [-o <out>]
                getsupportedcarriers <merchant-id> [-p <v>]... [-o <out>]
                getsupportedholidays <merchant-id> [-p <v>]... [-o <out>]
                getsupportedpickupservices <merchant-id> [-p <v>]... [-o <out>]
                list <merchant-id> [-p <v>]... [-o <out>]
                update <merchant-id> <account-id> (-r <kv>)... [-p <v>]... [-o <out>]
  content2 --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文件中,文件名以content2-开头。您可以使用--config-dir标志在每个调用的基础上更改用于存储配置的目录。

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

身份验证

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

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

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

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

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

应用程序密钥

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

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

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

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

调试

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

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

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

依赖项

~18–33MB
~577K SLoC