
    C                        S r SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSK
Jr  SSKJr  SS	KJr  \R                   \R"                  " \R$                  R&                  5       " S
 S\R(                  5      5       5       r\R                   \R"                  " \R$                  R,                  5       " S S\5      5       5       rg)z=Implementation of create command for Insights dataset config.    )
exceptions)insights_api)base)flags)create_update_util)log_util)log)
propertiesc                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
Create   )Create a new dataset config for Insights.z8
       Create a new dataset config for Insights.
      aY  
      To create a dataset config with config name as "my_config" in location
      "us-central1" and project numbers "123456" and "456789" belonging to
      organization number "54321":

         $ {command} my_config --location=us-central1
         --source-projects=123456,456789 --organization=54321 --retention-period-days=1

      To create a dataset config that automatically adds new buckets into
      config:

         $ {command} my_config --location=us-central1
         --source-projects=123456,456789 --organization=54321
         --auto-add-new-buckets --retention-period-days=1
      )DESCRIPTIONEXAMPLESc           	      "   UR                  S[        SS9  UR                  S[        SSSS9  UR                  S	[        S
SS/SSS9  UR                  SSSS9  [        R                  " U5        [        R
                  " XR                  5       S9  g )NDATASET_CONFIG_NAMEz#Provide human readable config name.)typehelpz--organizationTSOURCE_ORG_NUMBERz'Provide the source organization number.)r   requiredmetavarr   z
--identityIDENTITY_TYPEIDENTITY_TYPE_PER_CONFIGIDENTITY_TYPE_PER_PROJECTz7The type of service account used in the dataset config.)r   r   choicesdefaultr   z--auto-add-new-buckets
store_truezbAutomatically include any new buckets created if they satisfy criteria defined in config settings.)actionr   )release_track)add_argumentstrintr    add_dataset_config_location_flag&add_dataset_config_create_update_flagsReleaseTrack)clsparsers     6lib/surface/storage/insights/dataset_configs/create.pyArgsCreate.Args6   s    
2  
 #6   +-HI*F    4	   
**62	00..0    c                 N   S nUR                   b  UR                   nOFUR                  b9  [        R                  " UR                  [        R                  R
                  5      nS nUR                  b  UR                  nOFUR                  b9  [        R                  " UR                  [        R                  R                  5      n[        R                  " 5       n UR                  UR                  UR                  [        R                  R                   R"                  R%                  5       UR&                  UUUR(                  UR*                  UR,                  UR.                  UR0                  UR2                  UR4                  UR6                  UR8                  [;        USS 5      UR<                  UR>                  S9n[@        RB                  " SUR                  URD                  5        g ! [F        RH                   a!    [J        RL                  RO                  S5        e f = f)N#activity_data_retention_period_days)dataset_config_namelocationdestination_projectorganization_scopesource_projects_listsource_folders_listorganization_numberinclude_buckets_name_list!include_buckets_prefix_regex_listexclude_buckets_name_list!exclude_buckets_prefix_regex_listinclude_source_locationsexclude_source_locationsauto_add_new_bucketsretention_periodactivity_data_retention_periodidentity_typedescriptionr   zWe caught an exception while trying to create the dataset-configuration.
Please check that the flags are set with valid values. For example, config name must start with an alphanumeric value and only contain '_' as a special character)(source_projectssource_projects_filer   get_source_configs_list
ConfigTypePROJECTSsource_folderssource_folders_fileFOLDERSr   InsightsApicreate_dataset_configr   r/   r
   VALUEScoreprojectGetenable_organization_scopeorganizationinclude_bucket_namesinclude_bucket_prefix_regexesexclude_bucket_namesexclude_bucket_prefix_regexesr9   r:   r;   retention_period_daysgetattridentityr?   r   /dataset_config_operation_started_and_status_lognameapitools_exceptionsHttpBadRequestErrorr	   statusPrint)selfargsr2   r3   
api_clientdataset_config_operations         r(   Run
Create.Run[   s   '!11		"	"	./GG

#
#%7%B%B%K%K & //		!	!	-.FF

"
"$6$A$A$I$I ))+J!!+!A!A"66==(//44<<@@B!;;31"//$($=$=,0,N,N$($=$=,0,N,N#'#@#@#'#@#@#8855)094* &&) "B ", >>
D,,.F.K.K 22 	jjL s   DG/ /5H$ N)
__name__
__module____qualname____firstlineno____doc__detailed_helpclassmethodr)   ra   __static_attributes__rc   r+   r(   r   r      s2     2

	-* " "H5r+   r   c                       \ rS rSrSrSrg)CreateAlpha   r   rc   N)rd   re   rf   rg   rh   rk   rc   r+   r(   rm   rm      s     2r+   rm   N)rh   apitools.base.pyr   rY   googlecloudsdk.api_lib.storager   googlecloudsdk.callioper   "googlecloudsdk.command_lib.storager   ;googlecloudsdk.command_lib.storage.insights.dataset_configsr   r   googlecloudsdk.corer	   r
   DefaultUniverseOnlyReleaseTracksr%   GACommandr   ALPHArm   rc   r+   r(   <module>rz      s     D > 7 ( 4 Z P # * D%%(()rT\\ r * rj D%%++,2& 2 - 2r+   