
    L                     |   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  \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 update command for Insights dataset config.    )insights_api)base)flags)create_update_util)log_util)resource_args)
console_ioc                   J    \ rS rSrSrSSS.r\S 5       rS rS r	S	 r
S
 rSrg)Update   &Updates a dataset config for Insights.z3
      Update a dataset config for Insights.
      a1  

      To update the description for a dataset config "my_config" in
      location "us-central1":

          $ {command} my_config --location=us-central1 --description="a user provided description"

      To update the same dataset config with fully specified name:

          $ {command} projects/foo/locations/us-central1/datasetConfigs/my_config

      To update the retention period days for the dataset config "my_config" in
      location "us-central1":

          $ {command} my_config --location=us-central1
          --retention-period-days=20
      )DESCRIPTIONEXAMPLESc                     UR                  SSS/SS9  [        R                  " US5        [        R                  " USU R                  5       S9  g )	Nz--auto-add-new-bucketstruefalsezbAutomatically include any new buckets created if they satisfy criteria defined in config settings.)choiceshelpz	to updateT)	is_updaterelease_track)add_argumentr   add_dataset_config_resource_argr   &add_dataset_config_create_update_flagsReleaseTrack)clsparsers     6lib/surface/storage/insights/dataset_configs/update.pyArgsUpdate.Args7   sU    
 !4	   11&+F	00$c.>.>.@    c                     UR                   b  UR                   $ UR                  b9  [        R                  " UR                  [        R                  R
                  5      $ g N)source_projectssource_projects_filer   get_source_configs_list
ConfigTypePROJECTSselfargss     r   _get_source_projects_list Update._get_source_projects_listG   sV    '!!!		"	"	.77

#
#%7%B%B%K%K  r    c                     UR                   b  UR                   $ UR                  b9  [        R                  " UR                  [        R                  R
                  5      $ g r"   )source_folderssource_folders_filer   r%   r&   FOLDERSr(   s     r   _get_source_folders_listUpdate._get_source_folders_listP   sV    &   		!	!	-77

"
"$6$A$A$I$I  r    c                 b    UR                   b"  UR                   S:X  a  gUR                   S:X  a  gg )Nr   Tr   F)auto_add_new_bucketsr(   s     r   _get_auto_add_new_buckets Update._get_auto_add_new_bucketsY   s3      ,		"	"f	,$$/r    c                    [         R                  " 5       nUR                  R                  R	                  5       R                  5       nUR                  bC  UR                  S:  a(  SR                  U5      n[        R                  " USSS9  O[        S5      eU R                  U5      nU R                  U5      n[        R                  " UR                  UU5      nUb8  [        R                   " X25      nSU SU SU S	3n[        R                  " USSS9  U R#                  U5      n	UR%                  UUR                  UUUR&                  UR(                  UR*                  UR,                  UR.                  UR0                  U	UR                  [3        US
S 5      UR4                  S9n
[6        R8                  " SUU
R:                  5        U
$ )Nr   z?You are about to change retention period for dataset config: {}T)messagethrow_if_unattendedcancel_on_noz2retention-period-days value must be greater than 0z1You are about to change scope of dataset config: z from z to z`. Refer https://cloud.google.com/storage/docs/insights/datasets#dataset-config for more details.#activity_data_retention_period_days)organization_scopesource_projects_listsource_folders_listinclude_buckets_name_list!include_buckets_prefix_regex_listexclude_buckets_name_list!exclude_buckets_prefix_regex_listinclude_source_locationsexclude_source_locationsr4   retention_periodactivity_data_retention_perioddescriptionr   )r   InsightsApiCONCEPTSdataset_configParseRelativeNameretention_period_daysformatr	   PromptContinue
ValueErrorr+   r1   r   get_new_source_configenable_organization_scopeget_existing_source_configr5   update_dataset_configinclude_bucket_namesinclude_bucket_prefix_regexesexclude_bucket_namesexclude_bucket_prefix_regexesrC   rD   getattrrG   r   /dataset_config_operation_started_and_status_logname)r)   r*   clientdataset_config_relative_namer8   r=   r>   	new_scopeexisting_scoper4   update_dataset_config_operations              r   Run
Update.Runa   s   %%'F$$**,99; ! !!-		#	#a	'MV01 	 	!!D	
 MNN99$?77="88&&I )DD
&n*+6.1A B[   t$  99$?&,&B&B$991/"&";";*.*L*L"&";";*.*L*L!%!>!>!%!>!>133'.7(
 $$! 'C '#& <<$',, +*r     N)__name__
__module____qualname____firstlineno____doc__detailed_helpclassmethodr   r+   r1   r5   ra   __static_attributes__rc   r    r   r   r      sA     /

	-.  D+r    r   c                       \ rS rSrSrSrg)UpdateAlpha   r   rc   N)rd   re   rf   rg   rh   rk   rc   r    r   rm   rm      s     /r    rm   N)rh   googlecloudsdk.api_lib.storager   googlecloudsdk.callioper   "googlecloudsdk.command_lib.storager   ;googlecloudsdk.command_lib.storage.insights.dataset_configsr   r   r   googlecloudsdk.core.consoler	   DefaultUniverseOnlyReleaseTracksr   GACommandr   ALPHArm   rc   r    r   <module>ry      s     D 7 ( 4 Z P U 2 D%%(()H+T\\ H+ * H+V D%%++,/& / - /r    