# Copyright 2018 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- release_tracks: [ALPHA]
  help_text:
    brief: Schedule a risk analysis job for content in a BigQuery table.
    description: |
      Schedules a job to compute risk analysis metrics on content in a
      BigQuery table.
    examples: |
      To create a job `my-bq-analysis` to analyze records in a BigQuery table
      `myproject.myds.mytable`, run:

        $ {command}  `myproject.myds.mytable` --job-id my-ds-job --output-topics my-topic --numerical-stat-field col2

  request:
    collection: dlp.projects.dlpJobs
    display_resource_type: job
    method: create
    api_version: v2
    modify_request_hooks:
    - googlecloudsdk.command_lib.dlp.hooks:SetRequestParent

  arguments:
    params:
    - group:
        mutex: true
        required: true
        help_text: Privacy analysis metrics.
        params:
        - arg_name: categorical-stat-field
          api_field: googlePrivacyDlpV2CreateDlpJobRequest.riskJob.privacyMetric.categoricalStatsConfig.field.name
          help_text: |
            An individual column to compute numerical stats on, including number
            of distinct values and value count distribution.
        - arg_name: numerical-stat-field
          api_field: googlePrivacyDlpV2CreateDlpJobRequest.riskJob.privacyMetric.numericalStatsConfig.field.name
          help_text: |
            Individual column to compute numerical stats on. Supported types are
            integer, float, date, datetime, timestamp, time.
        - group:
            help_text: l-diversity analysis options.
            params:
            - arg_name: quasi-ids
              api_field: googlePrivacyDlpV2CreateDlpJobRequest.riskJob.privacyMetric.lDiversityConfig.quasiIds
              type: googlecloudsdk.command_lib.dlp.hooks:PrivacyField
              required: true
              help_text: |
                A set of quasi-identifiers indicating how equivalence classes are
                defined for the l-diversity computation. When multiple fields are
                specified, they are considered a single composite key.

            - arg_name: sensitive-attribute
              api_field: googlePrivacyDlpV2CreateDlpJobRequest.riskJob.privacyMetric.lDiversityConfig.sensitiveAttribute.name
              help_text: |
                Sensitive field for computing the l-diversity value.

    - group:
        mutex: true
        required: true
        params:
        - arg_name: output-topics
          api_field: googlePrivacyDlpV2CreateDlpJobRequest.riskJob.actions
          type: googlecloudsdk.command_lib.dlp.hooks:PubSubTopicAction
          help_text: |
            Publishes the results of a Cloud DLP job to one or more Cloud Pub/Sub
            topics.

            Note: The topic must have given publishing access rights to the DLP
            API service account executing the Cloud DLP job.
        - arg_name: output-table
          api_field: googlePrivacyDlpV2CreateDlpJobRequest.riskJob.actions
          type: googlecloudsdk.command_lib.dlp.hooks:BigQueryTableAction
          help_text: |
            Publishes results of a Cloud DLP job to a BigQuery table.
            BigQuery tables are uniquely identified by their project_id,
            dataset_id, and table_id in the format
            `<project_id>.<dataset_id>.<table_id>`. If no table_id is specified,
            DLP will create a new table.

    - _REF_: googlecloudsdk.command_lib.dlp.flags:big_query_table
      arg_name: input_table
      api_field: googlePrivacyDlpV2CreateDlpJobRequest.riskJob.sourceTable
      required: true
      is_positional: true
      processor: googlecloudsdk.command_lib.dlp.hooks:ExtractBqTableFromInputConfig
    - _REF_: googlecloudsdk.command_lib.dlp.flags:job_id
    resource:
      help_text: |
        The Cloud DLP project to create Job In.
      spec: !REF googlecloudsdk.command_lib.dlp.resources:project
      is_parent_resource: true
