
                             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 ddlmZ ej.                   G d dej0                               Zy)z)Command to update a Data Fusion instance.    )absolute_import)division)unicode_literals)encoding)
datafusion)waiter)arg_parsers)base)maintenance_utils)operation_poller)resource_args)labels_util)logc                   D    e Zd ZdZdddZdZdZdZdZd	Z	e
d
        Zd Zy)Updatez%Updates a Cloud Data Fusion instance.z       If run asynchronously with `--async`, exits after printing an operation
       that can be used to poll the status of the creation operation via:

         {command} operations list
          a          To update instance 'my-instance' in project 'my-project' and location
        'my-location' to version `6.9.2`, run:

          $ {command} --project=my-project --location=my-location --version=6.9.2 my-instance

        To update instance 'my-instance' in project 'my-project' and location
        'my-location' to patch revision '6.9.2.1', run:

          $ {command} --project=my-project --location=my-location --version=6.9.2 --patch_revision=6.9.2.1 my-instance
          )DESCRIPTIONEXAMPLESoptions
enableRbacenableStackdriverLoggingenableStackdriverMonitoringmaintenancePolicyc                    t        j                  | d       t        j                  j	                  |        t        j                  |        | j                  ddd       | j                  ddd       | j                  ddd	       | j                  d
t        j                         dd       | j                  dd       | j                  dd       t        j                  |        y )NzInstance to update.z--enable_stackdriver_logging
store_truez9Enable Stackdriver logging for this Data Fusion instance.)actionhelpz--enable_stackdriver_monitoringz<Enable Stackdriver monitoring for this Data Fusion instance.z--enable_rbaczHEnable granular role-based access control for this Data Fusion instance.z	--optionsz	KEY=VALUEzIOptions to use for instance update, specified as KEY1=VALUE1,KEY2=VALUE2.)typemetavarr   z	--versionz#Version of Datafusion to update to.)r   z--patch_revisionz9Patch revision version of Cloud Data Fusion to update to.)r   AddInstanceResourceArgr
   
ASYNC_FLAGAddToParserr   AddCreateLabelsFlagsadd_argumentr	   ArgDictr   UpdateArgumentsGroup)parsers    +lib/surface/data_fusion/instances/update.pyArgszUpdate.ArgsC   s    ((1FGOO'$$V,
&H  J )K  M W  
   "0	  1 *OP
*1lm**62    c                    t        j                         }|j                  j                  j	                         }|j
                  xs i }d }d }d }i }g }	|j                  d      r'|j                  }|	j                  | j                         |j                  d      r'|	j                  | j                         |j                  }|j                  d      r'|	j                  | j                         |j                  }|j                  d      r'|	j                  | j                         |j                  }|j                   }
|j"                  j%                  |j'                         |
|j(                  |||t+        j,                  ||j"                  j$                  j.                  d      t+        j,                  ||j"                  j$                  j0                  d            }|j                  d      s3|j                  d      s"|j                  d	      s|j                  d
      r1t3        j4                  ||       |	j                  | j6                         |j"                  j9                  |dj;                  |	      |j'                               }|j<                  j>                  jA                  |      }|jB                  r(tE        jF                  |j'                         dd       |S tI        jJ                  tM        jN                         |jP                  djS                  |jP                        t         jT                         tE        jV                  |j'                         dd       y )Nr   enable_rbacenable_stackdriver_loggingenable_stackdriver_monitoringT)nameversionpatchRevisionr   r   r   r   labelsclear_maintenance_windowmaintenance_window_startmaintenance_window_endmaintenance_window_recurrence,)instance
updateMaskr.   r7   )kindis_asyncz<Waiting for [{}] to complete. This may take several minutes.)wait_ceiling_msF),df
DatafusionCONCEPTSr7   Parser1   IsSpecifiedr   appendFIELD_PATH_OPTIONSFIELD_PATH_ENABLE_RBACr+   %FIELD_PATH_ENABLE_STACKDRIVER_LOGGINGr,   (FIELD_PATH_ENABLE_STACKDRIVER_MONITORINGr-   r/   messagesInstanceRelativeNamepatch_revisionr   DictToAdditionalPropertyMessageOptionsValueLabelsValuer   UpdateMaintenanceWindowFIELD_PATH_MAINTENANCE_POLICY0DatafusionProjectsLocationsInstancesPatchRequestjoinclientprojects_locations_instancesPatchasync_r   CreatedResourcer   WaitForr   OperationPollerr.   formatOPERATION_TIMEOUTUpdatedResource)selfargsr   instance_refr1   r,   r-   r+   r   fields_to_updater/   r7   request	operations                 r'   Runz
Update.Run_   s   J==))//1L[[BF!%$(!KG	"gd556&d99:$$k45dHHI#'#B#B 78dKKL&*&H&H#llG""++&&())!;$A88Z((11>>F77J''00<<dD , 
EH 	346745;<//h?d@@A!!RR88,-&&( S *G
 !!>>DDWMI{{	

#
#
%JGnn

*
*
,
..
H
O
Onn..0 


#
#
%JHr)   N)__name__
__module____qualname____doc__detailed_helprB   rC   rD   rE   rN   staticmethodr(   ra    r)   r'   r   r   "   sP     /
-. !'*D'-J*"53 36?Hr)   r   N)re   
__future__r   r   r   apitools.base.pyr   "googlecloudsdk.api_lib.data_fusionr   r<   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   r
   &googlecloudsdk.command_lib.data_fusionr   r   r   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   DefaultUniverseOnlyUpdateCommandr   rh   r)   r'   <module>rs      s^    0 &  ' % ? . / ( D C @ < # {HT {H {Hr)   