
                             d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	l
mZ dd
lmZ ddlmZ ddlmZ ddlmZ  e	j*                  e	j,                  j.                         G d de	j0                               Zd Zd Zy)zECommand for creating a Cloud Security Command Center BigQuery export.    )absolute_import)division)print_function)unicode_literals)securitycenter_client)base)flags)util)bqexport_util)log)
propertiesc                   2    e Zd ZdZddddZed        Zd Zy)	Createz1Create a Security Command Center BigQuery export.a        Create a Security Command Center BigQuery export.

      BigQuery exports that are created with Security Command Center API V2 and
      later include a `location` attribute. If a location is not specified, the
      default `global` location is used. For example, the following BigQuery
      export name has `location=global` attribute:
      `organizations/123/locations/global/bigQueryExports/test-bq-export`.
      a        To create a BigQuery export `test-bq-export` given organization `123` with a
      dataset `abc` in project `234` and filter on category that equals to
      `XSS_SCRIPTING`, run:

        $ gcloud scc bqexports create test-bq-export           --organization=123           --dataset=projects/234/datasets/abc           --description="This is a test BigQuery export"           --filter="category=\"XSS_SCRIPTING\""

      To create a BigQuery export `test-bq-export` given folder `456` with a
      dataset `abc` in project `234` and filter on category that equals to
      `XSS_SCRIPTING`, run:

        $ gcloud scc bqexports create test-bq-export --folder=456           --dataset=projects/234/datasets/abc           --description="This is a test BigQuery export"           --filter="category=\"XSS_SCRIPTING\""

      To create a BigQuery export test-bq-export given project `789` with a
      dataset `abc` in project `234` and filter on category that equals to
      `XSS_SCRIPTING`, run:

        $ gcloud scc bqexports create test-bq-export --project=789           --dataset=projects/234/datasets/abc           --description="This is a test BigQuery export"           --filter="category=\"XSS_SCRIPTING\""

      To create a BigQuery export `test-bq-export` given organization `123` and
      `location=global` to send findings with `category=XSS_SCRIPTING` to the
      BigQuery dataset `abc` in project `234`, run:

        $ gcloud scc bqexports create test-bq-export           --organization=123           --dataset=projects/234/datasets/abc           --description="This is a test BigQuery export"           --filter="category=\"XSS_SCRIPTING\""
          --location=global
      z      This command uses the Security Command Center API. For more information,
      see [Security Command Center API.](https://cloud.google.com/security-command-center/docs/reference/rest)
      )DESCRIPTIONEXAMPLESzAPI REFERENCEc                 $   t         j                  j                  |        t         j                  j                  |        t         j                  j                  |        t        j
                  |        t        j                  |        | j                  j                  t        j                  j                  j                  j                                t        j                  j                  |        t        j                   j                  |        y )N)bqexports_flagsDATASET_FLAG_REQUIREDAddToParserDESCRIPTION_FLAGFILTER_FLAGAddBigQueryPositionalArgumentAddParentGroupdisplay_info	AddFormatr   VALUEScoredefault_formatGet	scc_flagsAPI_VERSION_FLAGLOCATION_FLAG)parsers    #lib/surface/scc/bqexports/create.pyArgszCreate.Args]   s    ))55f=$$008++F311&9""6*
!!*"3"3"8"8"G"G"K"K"MN**62''/    c                    t        j                  ||j                  d      }t        j                  |      }t        j
                  |      }|dk(  rI|j                         }t        j                  |      }|j                         }||_
        |j                  }nH|j                         }t        j                  |      }|j                         }||_        |j                   }t#        |      |_        t'        |      |_        |j*                  |_        |j,                  |_        |j.                  |_        d |_        |j1                  |      }	t2        j4                  j7                  d       |	S )NT)"version_specific_existing_resourcev1zCreated.)scc_utilGetVersionFromArgumentsBIG_QUERY_EXPORTr   GetMessages	GetClient7SecuritycenterOrganizationsBigQueryExportsCreateRequestr   "ValidateAndGetBigQueryExportV1Name)GoogleCloudSecuritycenterV1BigQueryExport)googleCloudSecuritycenterV1BigQueryExportorganizations_bigQueryExports@SecuritycenterOrganizationsLocationsBigQueryExportsCreateRequest"ValidateAndGetBigQueryExportV2Name)GoogleCloudSecuritycenterV2BigQueryExport)googleCloudSecuritycenterV2BigQueryExport'organizations_locations_bigQueryExports(_GetBigQueryExportIdFromFullResourceNamebigQueryExportId_GetParentFromFullResourceNameparentdatasetdescriptionfilterr   r   statusPrint)
selfargsversionmessagesclientreqconfig_nameexportendpointbq_export_responses
             r$   Runz
Create.Runk   s>    ..d##G %009H",,W5F $LLNc!DDTJkAACf6<c355h 
S
S
U 
 "DDTJkAACf6<c3??hCKPC/<CJ\\FN))FKKFM DK!-JJZ r&   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr%   rL    r&   r$   r   r   !   s7    9
'
P
e6-p 0 0%r&   r   c                 F    | j                  d      }|t        |      dz
     S )z4Gets BigQuery export id from the full resource name./   )splitlen)rH   bq_export_componentss     r$   r9   r9      s)    $**3/	c"67!;	<<r&   c                 H    dj                  | j                  d      dd       S )zHReturns the parts of the BigQuery export name before "/bigQueryExports".rU   N)joinrW   )rH   s    r$   r;   r;      s#    	+##C("-	..r&   N)rP   
__future__r   r   r   r   googlecloudsdk.api_lib.sccr   googlecloudsdk.callioper   googlecloudsdk.command_lib.sccr	   r    r
   r*   (googlecloudsdk.command_lib.scc.bqexportsr   r   googlecloudsdk.corer   r   ReleaseTracksReleaseTrackGACreateCommandr   r9   r;   rS   r&   r$   <module>rg      sw     L &  % ' < ( = ; B M # * D%%(()nT n *nb=/r&   