
    d                         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  G d	 d
ej                        Zdddde_        y)z3Command for getting the latest image from a family.    )absolute_import)division)unicode_literals)base_classes)base)
completers)flagsc                   &    e Zd ZdZed        Zd Zy)DescribeFromFamilyzDescribe the latest image from an image family.

  *{command}* looks up the latest image from an image family and runs a describe
  on it.
  c                     t        j                         t        _        t        j                  j	                  | d       | j                  dt        j                  d       y )Ndescribe)operation_typez--zonezZone to query. Returns the latest image available in the image family for the specified zone. If not specified, returns the latest globally available image.)	completerhelp)r	   MakeDiskImageArgr   DiskImageArgAddArgumentadd_argumentr   ZonesCompleter)parsers    2lib/surface/compute/images/describe_from_family.pyArgszDescribeFromFamily.Args$   sX    &+&<&<&>###//z 0 + ++1  3    c                    t        j                  | j                               }|j                  }t        j
                  j                  ||j                  t        j                  |            }|j                  }|j                  d      r|t        d      d  }t        |d      rj|j                  r^|j                  j!                  ||j"                  |j                        }|j%                  |j&                  j(                  d|fg      d   S |j                  j+                  ||j"                        }|j%                  |j&                  j,                  d|fg      d   S )	N)scope_listerzfamily/zone)familyprojectr   Getr   )r   r   GetFromFamily)r   ComputeApiHolderReleaseTrackclientr   r   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListerimage
startswithlenhasattrr   messages!ComputeImageFamilyViewsGetRequestr   MakeRequestsapitools_clientimageFamilyViews!ComputeImagesGetFromFamilyRequestimages)selfargsholderr#   	image_refr   requests          r   RunzDescribeFromFamily.Run2   s]   **4+<+<+>?F]]F"//AA"88@ B BI
 __F#c)no&ftVAA!2!2 B Dg   6#9#9#J#J#('#3 "4 5568 8 AA!2!2 B 4g   6#9#9#@#@#2G#= "> ??@B Br   N)__name__
__module____qualname____doc__staticmethodr   r8    r   r   r   r      s!     3 3Br   r   z/Describe the latest image from an image family.z        *{command}* looks up the latest image from an image family and runs a
        describe on it. If the image is not in the default project, you need to
        specify a value for `--project`.
        z        To view the description for the latest ``debian-9'' image from the
        ``debian-cloud'' project, run:

          $ {command} debian-9 --project=debian-cloud
        )briefDESCRIPTIONEXAMPLESN)r<   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   r	   r&   )googlecloudsdk.command_lib.compute.imagesDescribeCommandr   detailed_helpr>   r   r   <module>rI      sQ     : &  ' 7 ( 9 E ;.B-- .Bf 	:		$   r   