
    K                         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  S
r\S-   rSrS rS rS rS rS rS rS rS rg)z?Common utility functions for Cloud Filestore snapshot commands.    )absolute_import)division)unicode_literals)encoding)filestore_client)update_util)util)
propertiesz%projects/{}/locations/{}/instances/{}z/snapshots/{}v1c                     A UR                   Ul        [        R                  R                  R
                  R                  SS9nUR                  c  UR                  OUR                  n[        R                  X4UR                  5      Ul        U$ )zWPython hook for yaml commands to supply the snapshot create request with proper values.Trequired)snapshot
snapshotIdr
   VALUEScoreprojectGetinstance_regioninstance_locationPARENT_TEMPLATEformatinstanceparentrefargsreqr   location_ids        Dlib/googlecloudsdk/command_lib/filestore/instances/snapshots/util.pyFormatSnapshotCreateRequestr!       s{    	==#.""**...='*.*>*>*F&&
  %%DMM+#* 
*    c                    A [         R                  R                  R                  R	                  SS9nUR
                  c  UR                  OUR
                  n[        R                  X4UR                  UR                  5      Ul        U$ )zVPython hook for yaml commands to supply snapshot access requests with the proper name.Tr   )r
   r   r   r   r   r   r   SNAPSHOT_NAME_TEMPLATEr   r   r   namer   s        r    FormatSnapshotAccessRequestr&   .   sv    	""**...='*.*>*>*F&&
  $**DMM4==:#( 
*r"   c                     A [         R                  R                  R                  R	                  SS9nUR
                  c  UR                  OUR
                  n[        R                  X4UR                  5      Ul
        U$ )zVPython hook for yaml commands to supply the list snapshots request with proper values.Tr   )r
   r   r   r   r   r   r   r   r   r   r   r   s        r    FormatSnapshotsListRequestr(   ;   sp    	""**...='*.*>*>*F&&
  %%DMM+#* 
*r"   c                     A [         R                  " X[         R                  5      nU(       a  X2R                  l        U$ )zUpdate snapshot labels.)r   GetUpdatedLabelssnapshot_feature_namer   labels)r   r   r   
new_labelss       r    UpdateLabelsr.   H   s3    	++D,7,M,MO*$LL	*r"   c                 X   [         R                  R                  R                  R	                  SS9n[
        R                  " U 5      n[        R                  " U5      nU R                  c  U R                  OU R                  nUR                  SUUU R                  U R                  S9nU$ )z-Creates a Snapshot and returns its reference.Tr   z+file.projects.locations.instances.snapshots)
projectsIdlocationsIdinstancesIdsnapshotsId)r
   r   r   r   r   r	   GetApiVersionFromArgsr   GetFilestoreRegistryr   r   Creater   r   )r   r   api_versionregistryr   r   s         r    GetResourceRefr9   R   s    ""**...='**40+22;?(*.*>*>*F&&
  	3---- 	 	!# 
*r"   c                     A [        U5      n[        R                  " U5      n[        R                  " U5      nUR                  U5      nXbl        U$ )zHFetch existing Filestore instance to update and add it to Patch request.)r9   r	   r4   r   FilestoreClientGetInstanceSnapshotr   )r   r   patch_requestresource_refr7   clientorig_snapshots          r    GetExistingSnapshotrA   d   sK    	%,**40+++K8&,,\:-(	r"   c                     A [        U5      n[        R                  " U5      n[        R                  " U5      n[
        R                  " UR                  U5      5      $ )z3Python hook to generate the backup update response.)r9   r	   r4   r   r;   r   MessageToDictr<   )responser   r>   r7   r?   s        r    FormatSnapshotUpdateResponserE   o   sK    %,**40+++K8&			 : :< H	IIr"   c                 N    [         R                  " XU[         R                  5      $ )z&Adds description to the patch request.)r   AddDescriptionr+   )unused_instance_refr   r=   s      r    rG   rG   y   s%    		#	#$7}$/$E$E
G Gr"   N)__doc__
__future__r   r   r   apitools.base.pyr    googlecloudsdk.api_lib.filestorer   $googlecloudsdk.command_lib.filestorer   r	   googlecloudsdk.corer
   r   r$   V1_API_VERSIONr!   r&   r(   r.   r9   rA   rE   rG    r"   r    <module>rQ      sb    F &  ' % = < 5 *9(?: 

$JGr"   