#dfareporting #google #cli #google-api #command-line-interface #json-input #standard-error

程序 google-dfareporting2d2-cli

一个用于与dfareporting(协议版本2.2)交互的完整库

8个版本 (稳定版)

使用旧Rust 2015

1.0.6+20160803 2017年9月27日
1.0.5+20160803 2017年5月26日
1.0.4+20160803 2017年2月4日
1.0.2+20160803 2016年12月27日
0.3.6+20160803 2016年9月11日

#24 in #dfareporting

每月 23 次下载

MIT 许可证

4.5MB
62K SLoC

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

默认情况下,所有输出都打印到标准输出,但可以通过设置标志将其定向到文件,而与您的shell功能无关。错误将打印到标准错误,并导致程序退出代码不为零。

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

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

安装和源代码

使用cargo安装命令行界面:

cargo install google-dfareporting2d2-cli

GitHub上查找源代码。

用法

本文档是根据修订版20160803的dfareporting API生成的。CLI版本为1.0.6

dfareporting2d2 [options]
        account-active-ad-summaries
                get <profile-id> <summary-account-id> [-p <v>]... [-o <out>]
        account-permission-groups
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        account-permissions
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        account-user-profiles
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        accounts
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        ads
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        advertiser-groups
                delete <profile-id> <id> [-p <v>]...
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        advertisers
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        browsers
                list <profile-id> [-p <v>]... [-o <out>]
        campaign-creative-associations
                insert <profile-id> <campaign-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> <campaign-id> [-p <v>]... [-o <out>]
        campaigns
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> <default-landing-page-name> <default-landing-page-url> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        change-logs
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        cities
                list <profile-id> [-p <v>]... [-o <out>]
        connection-types
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        content-categories
                delete <profile-id> <id> [-p <v>]...
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        countries
                get <profile-id> <dart-id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        creative-assets
                insert <profile-id> <advertiser-id> (-r <kv>)... (-u (simple|resumable) -f <file> [-m <mime>]) [-p <v>]... [-o <out>]
        creative-field-values
                delete <profile-id> <creative-field-id> <id> [-p <v>]...
                get <profile-id> <creative-field-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> <creative-field-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> <creative-field-id> [-p <v>]... [-o <out>]
                patch <profile-id> <creative-field-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> <creative-field-id> (-r <kv>)... [-p <v>]... [-o <out>]
        creative-fields
                delete <profile-id> <id> [-p <v>]...
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        creative-groups
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        creatives
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        dimension-values
                query <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        directory-site-contacts
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        directory-sites
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        event-tags
                delete <profile-id> <id> [-p <v>]...
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        files
                get <report-id> <file-id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        floodlight-activities
                delete <profile-id> <id> [-p <v>]...
                generatetag <profile-id> [-p <v>]... [-o <out>]
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        floodlight-activity-groups
                delete <profile-id> <id> [-p <v>]...
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        floodlight-configurations
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        inventory-items
                get <profile-id> <project-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> <project-id> [-p <v>]... [-o <out>]
        landing-pages
                delete <profile-id> <campaign-id> <id> [-p <v>]...
                get <profile-id> <campaign-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> <campaign-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> <campaign-id> [-p <v>]... [-o <out>]
                patch <profile-id> <campaign-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> <campaign-id> (-r <kv>)... [-p <v>]... [-o <out>]
        metros
                list <profile-id> [-p <v>]... [-o <out>]
        mobile-carriers
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        operating-system-versions
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        operating-systems
                get <profile-id> <dart-id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        order-documents
                get <profile-id> <project-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> <project-id> [-p <v>]... [-o <out>]
        orders
                get <profile-id> <project-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> <project-id> [-p <v>]... [-o <out>]
        placement-groups
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        placement-strategies
                delete <profile-id> <id> [-p <v>]...
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        placements
                generatetags <profile-id> [-p <v>]... [-o <out>]
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        platform-types
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        postal-codes
                get <profile-id> <code> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        projects
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        regions
                list <profile-id> [-p <v>]... [-o <out>]
        remarketing-list-shares
                get <profile-id> <remarketing-list-id> [-p <v>]... [-o <out>]
                patch <profile-id> <remarketing-list-id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        remarketing-lists
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> <advertiser-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        reports
                compatible-fields-query <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                delete <profile-id> <report-id> [-p <v>]...
                files-get <profile-id> <report-id> <file-id> [-p <v>]... [-o <out>]
                files-list <profile-id> <report-id> [-p <v>]... [-o <out>]
                get <profile-id> <report-id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <report-id> (-r <kv>)... [-p <v>]... [-o <out>]
                run <profile-id> <report-id> [-p <v>]... [-o <out>]
                update <profile-id> <report-id> (-r <kv>)... [-p <v>]... [-o <out>]
        sites
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        sizes
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        subaccounts
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
        targetable-remarketing-lists
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> <advertiser-id> [-p <v>]... [-o <out>]
        user-profiles
                get <profile-id> [-p <v>]... [-o <out>]
                list [-p <v>]... [-o <out>]
        user-role-permission-groups
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        user-role-permissions
                get <profile-id> <id> [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
        user-roles
                delete <profile-id> <id> [-p <v>]...
                get <profile-id> <id> [-p <v>]... [-o <out>]
                insert <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <profile-id> [-p <v>]... [-o <out>]
                patch <profile-id> <id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <profile-id> (-r <kv>)... [-p <v>]... [-o <out>]
  dfareporting2d2 --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]
  --debug
            Output all server communication to standard error. `tx` and `rx` are placed
            into the same stream.
  --debug-auth
            Output all communication related to authentication to standard error. `tx`
            and `rx` are placed into the same stream.

配置

程序将所有持久数据存储在~/.google-service-cli目录中的JSON文件中,文件名以dfareporting2d2-开头。您可以使用--config-dir标志在每个调用的基础上更改用于存储配置的目录。

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

身份验证

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

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

第一次使用作用域时,会要求用户授权。按照CLI给出的指示授予权限,或者拒绝。

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

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

应用程序密钥

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

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

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

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

调试

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

--debug标志将打印所有客户端-服务器通信到标准错误,而--debug-auth标志将导致所有与认证相关的通信输出到标准错误。如果设置了--debug标志,错误结果将被调试打印,可能提供有关问题的更多信息。

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

依赖项

~16–28MB
~535K SLoC