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

5.0.4+20240225 2024年3月5日
3.1.0+20220227 2022年4月26日
3.0.0+20220227 2022年3月8日
2.0.4+20210326 2021年4月15日
1.0.8+20181009 2018年10月14日

Web编程中排名第1157

Download history 14/week @ 2024-03-10 101/week @ 2024-03-31 2/week @ 2024-04-07 1/week @ 2024-05-19

每月下载量234

MIT许可

3MB
39K SLoC

dlp2命令行界面(CLI)允许您从终端舒适地使用Google DLP服务的多数功能。

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

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

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

安装和源代码

使用cargo安装命令行界面:

cargo install google-dlp2-cli

GitHub上找到源代码

用法

本文档是根据DLP API修订版20240225生成的。CLI版本为5.0.4

dlp2 [options]
        info-types
                list [-p <v>]... [-o <out>]
        locations
                info-types-list <parent> [-p <v>]... [-o <out>]
        organizations
                deidentify-templates-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                deidentify-templates-delete <name> [-p <v>]... [-o <out>]
                deidentify-templates-get <name> [-p <v>]... [-o <out>]
                deidentify-templates-list <parent> [-p <v>]... [-o <out>]
                deidentify-templates-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                inspect-templates-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                inspect-templates-delete <name> [-p <v>]... [-o <out>]
                inspect-templates-get <name> [-p <v>]... [-o <out>]
                inspect-templates-list <parent> [-p <v>]... [-o <out>]
                inspect-templates-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-column-data-profiles-get <name> [-p <v>]... [-o <out>]
                locations-column-data-profiles-list <parent> [-p <v>]... [-o <out>]
                locations-deidentify-templates-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-deidentify-templates-delete <name> [-p <v>]... [-o <out>]
                locations-deidentify-templates-get <name> [-p <v>]... [-o <out>]
                locations-deidentify-templates-list <parent> [-p <v>]... [-o <out>]
                locations-deidentify-templates-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-discovery-configs-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-discovery-configs-delete <name> [-p <v>]... [-o <out>]
                locations-discovery-configs-get <name> [-p <v>]... [-o <out>]
                locations-discovery-configs-list <parent> [-p <v>]... [-o <out>]
                locations-discovery-configs-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-dlp-jobs-list <parent> [-p <v>]... [-o <out>]
                locations-inspect-templates-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-inspect-templates-delete <name> [-p <v>]... [-o <out>]
                locations-inspect-templates-get <name> [-p <v>]... [-o <out>]
                locations-inspect-templates-list <parent> [-p <v>]... [-o <out>]
                locations-inspect-templates-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-job-triggers-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-job-triggers-delete <name> [-p <v>]... [-o <out>]
                locations-job-triggers-get <name> [-p <v>]... [-o <out>]
                locations-job-triggers-list <parent> [-p <v>]... [-o <out>]
                locations-job-triggers-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-project-data-profiles-get <name> [-p <v>]... [-o <out>]
                locations-project-data-profiles-list <parent> [-p <v>]... [-o <out>]
                locations-stored-info-types-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-stored-info-types-delete <name> [-p <v>]... [-o <out>]
                locations-stored-info-types-get <name> [-p <v>]... [-o <out>]
                locations-stored-info-types-list <parent> [-p <v>]... [-o <out>]
                locations-stored-info-types-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-table-data-profiles-get <name> [-p <v>]... [-o <out>]
                locations-table-data-profiles-list <parent> [-p <v>]... [-o <out>]
                stored-info-types-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                stored-info-types-delete <name> [-p <v>]... [-o <out>]
                stored-info-types-get <name> [-p <v>]... [-o <out>]
                stored-info-types-list <parent> [-p <v>]... [-o <out>]
                stored-info-types-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
        projects
                content-deidentify <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                content-inspect <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                content-reidentify <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                deidentify-templates-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                deidentify-templates-delete <name> [-p <v>]... [-o <out>]
                deidentify-templates-get <name> [-p <v>]... [-o <out>]
                deidentify-templates-list <parent> [-p <v>]... [-o <out>]
                deidentify-templates-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                dlp-jobs-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
                dlp-jobs-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                dlp-jobs-delete <name> [-p <v>]... [-o <out>]
                dlp-jobs-get <name> [-p <v>]... [-o <out>]
                dlp-jobs-list <parent> [-p <v>]... [-o <out>]
                image-redact <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                inspect-templates-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                inspect-templates-delete <name> [-p <v>]... [-o <out>]
                inspect-templates-get <name> [-p <v>]... [-o <out>]
                inspect-templates-list <parent> [-p <v>]... [-o <out>]
                inspect-templates-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                job-triggers-activate <name> (-r <kv>)... [-p <v>]... [-o <out>]
                job-triggers-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                job-triggers-delete <name> [-p <v>]... [-o <out>]
                job-triggers-get <name> [-p <v>]... [-o <out>]
                job-triggers-list <parent> [-p <v>]... [-o <out>]
                job-triggers-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-column-data-profiles-get <name> [-p <v>]... [-o <out>]
                locations-column-data-profiles-list <parent> [-p <v>]... [-o <out>]
                locations-content-deidentify <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-content-inspect <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-content-reidentify <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-deidentify-templates-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-deidentify-templates-delete <name> [-p <v>]... [-o <out>]
                locations-deidentify-templates-get <name> [-p <v>]... [-o <out>]
                locations-deidentify-templates-list <parent> [-p <v>]... [-o <out>]
                locations-deidentify-templates-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-discovery-configs-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-discovery-configs-delete <name> [-p <v>]... [-o <out>]
                locations-discovery-configs-get <name> [-p <v>]... [-o <out>]
                locations-discovery-configs-list <parent> [-p <v>]... [-o <out>]
                locations-discovery-configs-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-dlp-jobs-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-dlp-jobs-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-dlp-jobs-delete <name> [-p <v>]... [-o <out>]
                locations-dlp-jobs-finish <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-dlp-jobs-get <name> [-p <v>]... [-o <out>]
                locations-dlp-jobs-hybrid-inspect <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-dlp-jobs-list <parent> [-p <v>]... [-o <out>]
                locations-image-redact <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-inspect-templates-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-inspect-templates-delete <name> [-p <v>]... [-o <out>]
                locations-inspect-templates-get <name> [-p <v>]... [-o <out>]
                locations-inspect-templates-list <parent> [-p <v>]... [-o <out>]
                locations-inspect-templates-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-job-triggers-activate <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-job-triggers-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-job-triggers-delete <name> [-p <v>]... [-o <out>]
                locations-job-triggers-get <name> [-p <v>]... [-o <out>]
                locations-job-triggers-hybrid-inspect <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-job-triggers-list <parent> [-p <v>]... [-o <out>]
                locations-job-triggers-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-project-data-profiles-get <name> [-p <v>]... [-o <out>]
                locations-project-data-profiles-list <parent> [-p <v>]... [-o <out>]
                locations-stored-info-types-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-stored-info-types-delete <name> [-p <v>]... [-o <out>]
                locations-stored-info-types-get <name> [-p <v>]... [-o <out>]
                locations-stored-info-types-list <parent> [-p <v>]... [-o <out>]
                locations-stored-info-types-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
                locations-table-data-profiles-get <name> [-p <v>]... [-o <out>]
                locations-table-data-profiles-list <parent> [-p <v>]... [-o <out>]
                stored-info-types-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
                stored-info-types-delete <name> [-p <v>]... [-o <out>]
                stored-info-types-get <name> [-p <v>]... [-o <out>]
                stored-info-types-list <parent> [-p <v>]... [-o <out>]
                stored-info-types-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
  dlp2 --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文件中,文件名以dlp2-开头。您可以使用--config-dir标志在每次调用中更改用于存储配置的目录。

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

身份验证

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

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

第一次使用范围时,用户会被要求授权。按照CLI给出的说明授权或拒绝。

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

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

应用程序密钥

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

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

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

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

调试

尽管CLI已尽力提供可用的错误消息,但有时可能需要了解导致特定问题的确切原因。这是通过允许所有客户端-服务器通信以原始形式输出到标准错误来完成的。

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

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

依赖关系

~19–31MB
~578K SLoC