
                         
   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dj                  dd      dZ e	j                   e	j"                  j$                         G d de	j&                               Z e	j                   e	j"                  j*                         G d de             Z e	j                   e	j"                  j.                         G d de             Zee_        ee_        ee_        y)z!Command for describing instances.    )absolute_import)division)unicode_literals)base_classes)arg_parsers)base)flags)	arg_utils$Describe a virtual machine instance.ak          *{command}* displays all data associated with a Compute
        Engine virtual machine instance.

        It's possible to limit the the scope of the description by using the
        '--format' flag. For details, see
        [Filtering and formatting fun with gcloud](https://cloud.google.com/blog/products/gcp/filtering-and-formatting-fun-with).
        a           To describe an instance named ``{0}'', run:

          $ {1} {0}

        To output only a set of fields from the available information, specify
        it  using the '--format' flag:

          $ {1} {0} --format="yaml(name,status,disks)"
        ztest-instancez	{command})briefDESCRIPTIONEXAMPLESc                   2    e Zd ZdZed        Zd Zd Zd Zy)Describer   c                 F    t         j                  j                  | d       y )Ndescribeoperation_type)r	   INSTANCE_ARGAddArgumentparsers    )lib/surface/compute/instances/describe.pyArgszDescribe.Args8   s    	""6*"E    c                     t         j                  j                  ||j                  t        j                  |j
                              S )N)scope_lister)r	   r   ResolveAsResource	resourcesGetInstanceZoneScopeListerclient)selfholderargss      r   _GetInstanceRefzDescribe._GetInstanceRef<   s@    //55fmmD 0 F Fr   c                      |j                   j                  j                  di |j                         }|j                   j	                  |j                   j
                  j                  d|fg      d   S )NGetr    r!   messagesComputeInstancesGetRequestAsDictMakeRequestsapitools_client	instances)r"   r#   instance_refrequests       r   _GetInstancezDescribe._GetInstanceB   sq    ?fmm$$?? !



!G==%%		&	&	0	0%A'C DDEG Gr   c                     t        j                  | j                               }| j                  ||      }| j	                  ||      S N)r   ComputeApiHolderReleaseTrackr%   r2   r"   r$   r#   r0   s       r   RunzDescribe.RunH   s@    **4+<+<+>?F''5LV\22r   N)	__name__
__module____qualname____doc__staticmethodr   r%   r2   r8   r(   r   r   r   r   4   s*    ,F FFG3r   r   c                   4    e Zd ZdZed        Zd ZddZd Zy)DescribeBetar   c                     t         j                  j                  | d       | j                  ddddt        j
                  d       y )	Nr   r   --viewVOutput contains all configuration details of the instance, including partner metadata.hDefault output view. Output contains all configuration details of the instance, except partner metadata.FULLBASIC9Specifies the information that the output should contain.choicestypehelp)r	   r   r   add_argumentr
   ChoiceToEnumNamer   s    r   r   zDescribeBeta.ArgsR   sN    	""6*"E
0=	
 ''H  r   c                 p    |dk(  r|j                   j                  S |dk(  r|j                   j                  S y )NrE   rF   )ViewValueValuesEnumrE   rF   )r"   viewrequest_messages      r   _GetInstanceViewzDescribeBeta._GetInstanceViewe   s7    v~00555	00666r   Nc                      |j                   j                  j                  di |j                         d|i}|j                   j	                  |j                   j
                  j                  d|fg      d   S )NrP   r'   r   r(   r)   )r"   r#   r0   rP   r1   s        r   r2   zDescribeBeta._GetInstancel   sy    ?fmm$$?? ,



,&*,G==%%		&	&	0	0%A'C DDEG Gr   c                 <   t        j                  | j                               }| j                  ||      }|j                  r?| j                  |j                  |j                  j                  j                        |_        | j                  |||j                        S r4   )
r   r5   r6   r%   rP   rR   r!   r*   r+   r2   r7   s       r   r8   zDescribeBeta.Runr   sz    **4+<+<+>?F''5Lyy''
))V]]++FFdi V\499==r   r4   )	r9   r:   r;   r<   r=   r   rR   r2   r8   r(   r   r   r?   r?   N   s'    , $G>r   r?   c                   ,    e Zd ZdZed        Zd Zd Zy)DescribeAlphar   c                     t         j                  j                  | d       | j                  ddt	        j
                         g d       | j                  ddd	d
t        j                  d       y )Nr   r   z--guest-attributesGUEST_ATTRIBUTE_KEYzaInstead of instance resource display guest attributes of the instance stored with the given keys.)metavarrJ   defaultrK   rA   rB   rC   rD   rG   rH   )r	   r   r   rL   r   ArgListr
   rM   r   s    r   r   zDescribeAlpha.Args   s}    	""6*"E
%  "5  7 0=	
 ''H  r   c                 v    d }|D cg c]  } ||||       }}|j                   j                  |      S c c}w )Nc                     | j                   j                  j                  |j                         |j                  ||j
                        }| j                   j                  j                  d|fS )N)instanceprojectvariableKeyzoneGetGuestAttributes)r!   r*   )ComputeInstancesGetGuestAttributesRequestNamer_   ra   r.   r/   )r#   r0   variable_keyreqs       r   _GetGuestAttributeRequestzDDescribeAlpha._GetGuestAttributes.<locals>._GetGuestAttributeRequest   si    MM""LL$$&&&"  	 M "c --
'
'
1
13GN Nr   )r!   r-   )r"   r#   r0   variable_keysrg   re   requestss          r   _GetGuestAttributesz!DescribeAlpha._GetGuestAttributes   sO    N *+)L 	"&,E)  + ==%%h//+s   6c                    t        j                  | j                               }| j                  ||      }|j                  r| j                  |||j                        S |j                  r?| j                  |j                  |j                  j                  j                        |_        | j                  |||j                        S r4   )r   r5   r6   r%   guest_attributesrj   rP   rR   r!   r*   r+   r2   r7   s       r   r8   zDescribeAlpha.Run   s    **4+<+<+>?F''5L%%
, 5 5  yy''
))V]]++FFdi V\499==r   N)r9   r:   r;   r<   r=   r   rj   r8   r(   r   r   rV   rV   |   s!    , 20>r   rV   N)r<   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   ,googlecloudsdk.command_lib.compute.instancesr	   $googlecloudsdk.command_lib.util.apisr
   formatDETAILED_HELPReleaseTracksr6   GADescribeCommandr   BETAr?   ALPHArV   detailed_helpr(   r   r   <module>rz      s   ( &  ' 7 / ( > : 4			 F?K0+2 D%%(()3t## 3 *32 D%%**+*>8 *> ,*>Z D%%++,7>L 7> -7>t ' * + r   