#google #google-api #admin #cli #command-line-interface #json-input

app google-admin1_directory-cli

一个完整的库,用于与目录(协议 directory_v1)交互

14 个稳定版本

使用旧Rust 2015

1.0.13+20200204 2020年4月12日
1.0.12+20190214 2019年12月9日
1.0.10+20190214 2019年7月6日
1.0.8+20180917 2018年10月14日
0.3.6+20160824 2016年9月11日

#24 in #admin

Download history 70/week @ 2024-03-28 51/week @ 2024-04-04

53 个月下载量

MIT 许可证

2MB
32K SLoC

admin1-directory 命令行界面(CLI)允许您在终端中舒适地使用 Google 目录服务的几乎所有功能。

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

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

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

安装和源代码

使用 cargo 安装命令行界面

cargo install google-admin1_directory-cli

GitHub 上找到源代码。

用法

此文档是从版本 20200204目录 API 生成的。CLI 版本为 1.0.13

admin1-directory [options]
        asps
                delete <user-key> <code-id> [-p <v>]...
                get <user-key> <code-id> [-p <v>]... [-o <out>]
                list <user-key> [-p <v>]... [-o <out>]
        channels
                stop (-r <kv>)... [-p <v>]...
        chromeosdevices
                action <customer-id> <resource-id> (-r <kv>)... [-p <v>]...
                get <customer-id> <device-id> [-p <v>]... [-o <out>]
                list <customer-id> [-p <v>]... [-o <out>]
                move-devices-to-ou <customer-id> <org-unit-path> (-r <kv>)... [-p <v>]...
                patch <customer-id> <device-id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <customer-id> <device-id> (-r <kv>)... [-p <v>]... [-o <out>]
        customers
                get <customer-key> [-p <v>]... [-o <out>]
                patch <customer-key> (-r <kv>)... [-p <v>]... [-o <out>]
                update <customer-key> (-r <kv>)... [-p <v>]... [-o <out>]
        domain-aliases
                delete <customer> <domain-alias-name> [-p <v>]...
                get <customer> <domain-alias-name> [-p <v>]... [-o <out>]
                insert <customer> (-r <kv>)... [-p <v>]... [-o <out>]
                list <customer> [-p <v>]... [-o <out>]
        domains
                delete <customer> <domain-name> [-p <v>]...
                get <customer> <domain-name> [-p <v>]... [-o <out>]
                insert <customer> (-r <kv>)... [-p <v>]... [-o <out>]
                list <customer> [-p <v>]... [-o <out>]
        groups
                aliases-delete <group-key> <alias> [-p <v>]...
                aliases-insert <group-key> (-r <kv>)... [-p <v>]... [-o <out>]
                aliases-list <group-key> [-p <v>]... [-o <out>]
                delete <group-key> [-p <v>]...
                get <group-key> [-p <v>]... [-o <out>]
                insert (-r <kv>)... [-p <v>]... [-o <out>]
                list [-p <v>]... [-o <out>]
                patch <group-key> (-r <kv>)... [-p <v>]... [-o <out>]
                update <group-key> (-r <kv>)... [-p <v>]... [-o <out>]
        members
                delete <group-key> <member-key> [-p <v>]...
                get <group-key> <member-key> [-p <v>]... [-o <out>]
                has-member <group-key> <member-key> [-p <v>]... [-o <out>]
                insert <group-key> (-r <kv>)... [-p <v>]... [-o <out>]
                list <group-key> [-p <v>]... [-o <out>]
                patch <group-key> <member-key> (-r <kv>)... [-p <v>]... [-o <out>]
                update <group-key> <member-key> (-r <kv>)... [-p <v>]... [-o <out>]
        mobiledevices
                action <customer-id> <resource-id> (-r <kv>)... [-p <v>]...
                delete <customer-id> <resource-id> [-p <v>]...
                get <customer-id> <resource-id> [-p <v>]... [-o <out>]
                list <customer-id> [-p <v>]... [-o <out>]
        notifications
                delete <customer> <notification-id> [-p <v>]...
                get <customer> <notification-id> [-p <v>]... [-o <out>]
                list <customer> [-p <v>]... [-o <out>]
                patch <customer> <notification-id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <customer> <notification-id> (-r <kv>)... [-p <v>]... [-o <out>]
        orgunits
                delete <customer-id> <org-unit-path>... [-p <v>]...
                get <customer-id> <org-unit-path>... [-p <v>]... [-o <out>]
                insert <customer-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <customer-id> [-p <v>]... [-o <out>]
                patch <customer-id> <org-unit-path>... (-r <kv>)... [-p <v>]... [-o <out>]
                update <customer-id> <org-unit-path>... (-r <kv>)... [-p <v>]... [-o <out>]
        privileges
                list <customer> [-p <v>]... [-o <out>]
        resources
                buildings-delete <customer> <building-id> [-p <v>]...
                buildings-get <customer> <building-id> [-p <v>]... [-o <out>]
                buildings-insert <customer> (-r <kv>)... [-p <v>]... [-o <out>]
                buildings-list <customer> [-p <v>]... [-o <out>]
                buildings-patch <customer> <building-id> (-r <kv>)... [-p <v>]... [-o <out>]
                buildings-update <customer> <building-id> (-r <kv>)... [-p <v>]... [-o <out>]
                calendars-delete <customer> <calendar-resource-id> [-p <v>]...
                calendars-get <customer> <calendar-resource-id> [-p <v>]... [-o <out>]
                calendars-insert <customer> (-r <kv>)... [-p <v>]... [-o <out>]
                calendars-list <customer> [-p <v>]... [-o <out>]
                calendars-patch <customer> <calendar-resource-id> (-r <kv>)... [-p <v>]... [-o <out>]
                calendars-update <customer> <calendar-resource-id> (-r <kv>)... [-p <v>]... [-o <out>]
                features-delete <customer> <feature-key> [-p <v>]...
                features-get <customer> <feature-key> [-p <v>]... [-o <out>]
                features-insert <customer> (-r <kv>)... [-p <v>]... [-o <out>]
                features-list <customer> [-p <v>]... [-o <out>]
                features-patch <customer> <feature-key> (-r <kv>)... [-p <v>]... [-o <out>]
                features-rename <customer> <old-name> (-r <kv>)... [-p <v>]...
                features-update <customer> <feature-key> (-r <kv>)... [-p <v>]... [-o <out>]
        role-assignments
                delete <customer> <role-assignment-id> [-p <v>]...
                get <customer> <role-assignment-id> [-p <v>]... [-o <out>]
                insert <customer> (-r <kv>)... [-p <v>]... [-o <out>]
                list <customer> [-p <v>]... [-o <out>]
        roles
                delete <customer> <role-id> [-p <v>]...
                get <customer> <role-id> [-p <v>]... [-o <out>]
                insert <customer> (-r <kv>)... [-p <v>]... [-o <out>]
                list <customer> [-p <v>]... [-o <out>]
                patch <customer> <role-id> (-r <kv>)... [-p <v>]... [-o <out>]
                update <customer> <role-id> (-r <kv>)... [-p <v>]... [-o <out>]
        schemas
                delete <customer-id> <schema-key> [-p <v>]...
                get <customer-id> <schema-key> [-p <v>]... [-o <out>]
                insert <customer-id> (-r <kv>)... [-p <v>]... [-o <out>]
                list <customer-id> [-p <v>]... [-o <out>]
                patch <customer-id> <schema-key> (-r <kv>)... [-p <v>]... [-o <out>]
                update <customer-id> <schema-key> (-r <kv>)... [-p <v>]... [-o <out>]
        tokens
                delete <user-key> <client-id> [-p <v>]...
                get <user-key> <client-id> [-p <v>]... [-o <out>]
                list <user-key> [-p <v>]... [-o <out>]
        users
                aliases-delete <user-key> <alias> [-p <v>]...
                aliases-insert <user-key> (-r <kv>)... [-p <v>]... [-o <out>]
                aliases-list <user-key> [-p <v>]... [-o <out>]
                aliases-watch <user-key> (-r <kv>)... [-p <v>]... [-o <out>]
                delete <user-key> [-p <v>]...
                get <user-key> [-p <v>]... [-o <out>]
                insert (-r <kv>)... [-p <v>]... [-o <out>]
                list [-p <v>]... [-o <out>]
                make-admin <user-key> (-r <kv>)... [-p <v>]...
                patch <user-key> (-r <kv>)... [-p <v>]... [-o <out>]
                photos-delete <user-key> [-p <v>]...
                photos-get <user-key> [-p <v>]... [-o <out>]
                photos-patch <user-key> (-r <kv>)... [-p <v>]... [-o <out>]
                photos-update <user-key> (-r <kv>)... [-p <v>]... [-o <out>]
                undelete <user-key> (-r <kv>)... [-p <v>]...
                update <user-key> (-r <kv>)... [-p <v>]... [-o <out>]
                watch (-r <kv>)... [-p <v>]... [-o <out>]
        verification-codes
                generate <user-key> [-p <v>]...
                invalidate <user-key> [-p <v>]...
                list <user-key> [-p <v>]... [-o <out>]
  admin1-directory --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 目录中存储所有持久数据,以 admin1-directory- 为前缀的 JSON 文件。您可以使用 --config-dir 标志在每次调用中更改用于存储配置的目录。

有关各种类型持久数据的更多信息,请参阅以下段落。

身份验证

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

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

首次使用作用域时,会询问用户权限。按照CLI提供的说明来授权或拒绝。

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

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

应用程序密钥

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

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

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

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

调试

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

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

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

依赖项

~14–25MB
~490K SLoC