
    T
                         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 Zd Zd Zd Zd Zy)zDCommon utility functions for Cloud Filestore update backup commands.    )absolute_import)division)unicode_literals)encoding)filestore_client)update_util)util)
properties)	resourcesc                 v    t        j                  ||t         j                        }|r||j                  _        |S )zUpdate backup labels.)r   GetUpdatedLabelsbackup_feature_namebackuplabels)
unused_refargsreq
new_labelss       ?lib/googlecloudsdk/command_lib/filestore/backups/update_util.pyUpdateLabelsr      s4    ++D#,7,K,KM*"CJJ	*    c                 N    t        j                  | ||t         j                        S )N)r   AddDescriptionr   )unused_instance_refr   patch_requests      r   r   r   &   s'    		#	#$7}$/$C$C
E Er   c                     t         j                  j                  j                  j	                  d      }| j
                  }t        j                  j                  d||| j                        }|S )NT)requiredzfile.projects.locations.backups)
projectsIdlocationsId	backupsId)
r
   VALUEScoreprojectGetregionr   REGISTRYCreater   )r   r#   locationrefs       r   GetResourceRefr*   +   sb    ""**...='[[(!!'	 	" 	#
 
*r   c                     t        |      }t        j                  |      }t        j                  |      }|j                  |      }||_        |S )zHFetch existing Filestore instance to update and add it to Patch request.)r*   r	   GetApiVersionFromArgsr   FilestoreClient	GetBackupr   )unused_resource_refr   r   resource_refapi_versionclientorig_backups          r   GetExistingBackupr4   6   sJ    %,**40+++K8&  .+$-	r   c                     ~ t        |      }t        j                  |      }t        j                  |      }t        j                  |j                  |            S )z3Python hook to generate the backup update response.)r*   r	   r,   r   r-   r   MessageToDictr.   )responser   r0   r1   r2   s        r   FormatBackupUpdateResponser8   @   sK    %,**40+++K8&			 0 0 >	??r   N)__doc__
__future__r   r   r   apitools.base.pyr    googlecloudsdk.api_lib.filestorer   $googlecloudsdk.command_lib.filestorer   r	   googlecloudsdk.corer
   r   r   r   r*   r4   r8    r   r   <module>r@      sA    K &  ' % = < 5 * )E
@r   