
    "              
       2   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ZdZdZej,                  ZdZ G d dej2                        Z G d dej6                        Zd1dZd Zd Z ej@                  ddeddde      Z! ej@                  ddejD                  ddeed       Z# ej@                  d!d"edd#d$      Z$ ej@                  d%d&ejJ                  dd'd(e)      Z&d2d*Z'd+ Z(d, Z)d- Z*d. Z+d/ Z,y0)3z;Flags and helpers for the compute backend-buckets commands.    )absolute_import)division)unicode_literals)actions)arg_parsers)base)
exceptions)
completers)flagsz        A source disk to create the image from. The value for this option can be
        the name of a disk with the zone specified via ``--source-disk-zone''
        flag.
z        A source snapshot to create the image from. The value for this option
        can be the name of a snapshot within the same project as the destination
        image.
a         Specifies a Compute Engine image as a replacement for the image
       being phased out. Users of the deprecated image will be
       advised to switch to this replacement. For example, *--replacement
       example-image* or *--replacement
       projects/google/global/images/example-image*.

       This flag value is purely informational and is not validated in any way.
       z    table(
      name,
      selfLink.map().scope(projects).segment(0):label=PROJECT,
      family,
      deprecated.state:label=DEPRECATED,
      status
    )c                        e Zd Z fdZ xZS )ImagesCompleterc                 2    t        t        | 
  dddd| y )Ncompute.imageszcompute images list --uri)
collectionlist_command )superr   __init__selfkwargs	__class__s     6lib/googlecloudsdk/command_lib/compute/images/flags.pyr   zImagesCompleter.__init__A   s'    	/4) #0     __name__
__module____qualname__r   __classcell__r   s   @r   r   r   ?   s     r   r   c                        e Zd Z fdZ xZS )SearchImagesCompleterc                 0    t        t        | 
  dddi| y )Nr   r   r   )r   r"   r   r   s     r   r   zSearchImagesCompleter.__init__J   s#    	
/ #
r   r   r    s   @r   r"   r"   H   s     r   r"   Fc                 @    t        j                  d|t        | |d      S )N
disk imager   )resource_namename	completerpluralrequiredglobal_collection)compute_flagsResourceArgumentr   )r)   r*   r'   s      r   MakeDiskImageArgr.   P   s'    		'	' (
* *r   c            	      b    t        j                  dt        j                  dddd      dd	      S )
Nz--force-createzforce-createz5Flag force-create is deprecated. Use --force instead.z2Flag force-create is removed. Use --force instead.
store_true)	flag_namewarnerroractionFa            DEPRECATED, use --force instead.
          By default, image creation fails when it is created from a disk that
          is attached to a running instance. When this flag is used, image
          creation from disk will proceed even if the disk is in use.
          r4   defaulthelp)r   Argumentcalliope_actionsDeprecationActionr   r   r   MakeForceCreateArgr;   Z   s:    	//"FD	
 
 r   c                  4    t        j                  dddd      S )Nz--forcer0   Fz          By default, image creation fails when it is created from a disk that
          is attached to a running instance. When this flag is used, image
          creation from disk will proceed even if the disk is in use.
          r5   )r   r8   r   r   r   MakeForceArgr=   k   s!    		
 r   r%   z--replacementr   z2Specifies a Compute Engine image as a replacement.)r&   r'   r(   r+   r*   
short_helpdetailed_helpzsource diskz--source-diskzcompute.disksz*The deprecation state to set on the image.)r&   r'   r(   zonal_collectionr>   r?   zone_explanationr*   zsource image--source-imagez6An existing Compute Engine image from which to import.)r&   r'   r(   r+   r>   r*   snapshotz--source-snapshotzcompute.snapshotsz*A source snapshot used to create an image.)r&   r'   r(   r*   r+   r>   r?   c                     | j                  dd       | j                  dd       |r'| j                  dt        j                         dd	       | j                  d
t        j                         d       y)zAdd common image creation args.z--descriptionz=An optional, textual description for the image being created.r7   z--familyzThe family of the image. When creating an instance or disk, specifying a family will cause the latest non-deprecated image in the family to be used.z--user-licensesLICENSEzdURI for the license resource. For multiple licenses, you can provide a comma-separated list of URIs.)typemetavarr7   z
--licensesz2Comma-separated list of URIs to license resources.)rG   r7   N)add_argumentr   ArgList)parsersupport_user_licensess     r   AddCommonArgsrM      s    K  N 	(   
  "r   	 ?  Ar   c                 X    |j                  dd       t        j                  | |       y)z=Add common args for specifying the source for image creation.z--source-uria         The full Cloud Storage URI where the disk image is stored.
      This file must be a gzip-compressed tarball whose name ends in
      ``.tar.gz''.
      For more information about Cloud Storage URIs,
      see https://cloud.google.com/storage/docs/request-endpoints#json-api.
      rE   mutex_groupN)rI   SOURCE_DISK_ARGAddArgumentrK   sources_groups     r   AddCommonSourcesArgsrU      s2    
   f-@r   c                 v    |j                  dd       |j                  dd       | j                  dd       y)	z"Add args to support image cloning.rB   z      The name of an image to clone. May be used with
      ``--source-image-project'' to clone an image in a different
      project.
      rE   z--source-image-familyz      The family of the source image. This will cause the latest non-
      deprecated image in the family to be used as the source image.
      May be used with ``--source-image-project'' to refer to an image
      family in a different project.
      z--source-image-projectz      The project name of the source image. Must also specify either
      ``--source-image'' or ``--source-image-family'' when using
      this flag.
      NrI   rS   s     r   AddCloningImagesArgsrX      sW    
   
   	
  r   c                 2    t         j                  | |       y)z1Add args to support creating image from snapshot.rO   N)SOURCE_SNAPSHOT_ARGrR   rS   s     r    AddCreatingImageFromSnapshotArgsr[      s    !!&m!Dr   c           
         d}|D cg c]  }t        | |j                  dd              }}t        d |D              }|D cg c]  }d|z   	 }}|dkD  rt        j                  | |dk  rt        j
                  ||      yc c}w c c}w )zGValidate that there is one, and only one, source for creating an image.z+Please specify a source for image creation.-_c              3   2   K   | ]  }t        |        y w)N)bool).0as     r   	<genexpr>z%ValidateSourceArgs.<locals>.<genexpr>   s     :/Qa/s   z--   N)getattrreplacesumr	   ConflictingArgumentsExceptionMinimumArgumentException)argssourcessources_error_messagessource_arg_listsource_arg_countsource_arg_namess          r   ValidateSourceArgsrq      s    G BIIAWT199S##67/I:/::(/01dQh0

2
24D
EE

-
-.>.CE E  J 1s   #BBc                 *    | j                  dd       y )Nz--source-disk-projectzm        Project name of the source disk. Must also specify
        --source-disk when using this flag.
      rE   rW   )rK   s    r   AddSourceDiskProjectFlagrs      s    
  r   N)FT
image_name)F)-__doc__
__future__r   r   r   googlecloudsdk.callioper   r9   r   r   r	   "googlecloudsdk.command_lib.computer
   compute_completersr   r,   (googlecloudsdk.command_lib.compute.disksdisks_flagsgooglecloudsdk.command_lib.util_SOURCE_DISK_DETAILED_HELP_SOURCE_SNAPSHOT_DETAILED_HELP_REPLACEMENT_DISK_DETAILED_HELPZONE_PROPERTY_EXPLANATION_SOURCE_DISK_ZONE_EXPLANATIONLIST_FORMATListCommandCompleterr   ResourceSearchCompleterr"   r.   r;   r=   r-   REPLACEMENT_DISK_IMAGE_ARGDisksCompleterrQ   SOURCE_IMAGE_ARGSnapshotsCompleterrZ   rM   rU   rX   r[   rq   rs   r   r   r   <module>r      sb    B &  ' ? / ( . O E I 6 
" 
#  !. G G 	(== J>> *"	 <];;	&C13  1-00	 //$;,2 2=11 	&G  5m44	,,);0 A8A8E
E&r   