
                             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  G d
 dej"                        Zd Z e       e_        y)z"Command for describing operations.    )absolute_import)division)unicode_literals)base_classes)base)flags)scope)	resourcesc                   Z     e Zd ZdZ fdZed        Zed        Zd Z	d Z
d Zd Z xZS )	Describez$Describe a Compute Engine operation.c                 ,    t        t        | 
  |i | y N)superr   __init__)selfargskwargs	__class__s      *lib/surface/compute/operations/describe.pyr   zDescribe.__init__    s    	(D"D3F3    c                 F    t         j                  j                  | d       y )Ndescribe)operation_type)r   COMPUTE_OPERATION_ARGAddArgument)parsers    r   ArgszDescribe.Args#   s    	++F:+Nr   c                     | j                   S r   )_service)r   s    r   servicezDescribe.service'   s    ==r   c                 X    g d}t        j                  dj                  |      ||      )N)zcompute.instancescompute.globalOperationscompute.regionOperationscompute.zoneOperations,)expectedgotpath)r
    WrongResourceCollectionExceptionjoin)r   r'   r(   expected_collectionss       r   &_RaiseWrongResourceCollectionExceptionz/Describe._RaiseWrongResourceCollectionException+   s2     
4
4./ r   c                    	 t         j                  j                  ||j                  t        j
                  j                  t        j                  |j                              }j                         dk(  r'|j                  j                  j                   | _        |S |j                         dk(  r'|j                  j                  j$                  | _        |S |j                  j                  j&                  | _        |S # t        j                  $ r0}| j                  |j                  |j                         Y d }~d }~ww xY w)N)default_scopescope_listerr"   r#   )r   r   ResolveAsResourcer
   compute_scope	ScopeEnumGLOBALcompute_flagsGetDefaultScopeListerclientr)   r,   r'   r(   
Collectionapitools_clientglobalOperationsr   regionOperationszoneOperations)r   r   compute_holderrefexs        r   CreateReferencezDescribe.CreateReference7   s   C''99


"
"%//66$::##%	 : &c ~~55$++;;LLdm
 J	 
	7	7$++;;LLdm J %++;;JJdmJ 55 C
11"&&"''BBCs   A"C? ?E&D==Ec                     |j                         dk(  r|j                  |_        y |j                         dk(  r|j                  |_        y y )Nr#   r$   )r7   regionzone)r   r=   requests      r   ScopeRequestzDescribe.ScopeRequestJ   s=    
~~55zzgn		5	5XXgl 
6r   c                 &   t        j                  | j                               }| j                  ||      }| j                  j                  d      } |di |j                         }|j                  j                  | j                  d|fg      d   S )NGetr    )	r   ComputeApiHolderReleaseTrackr?   r    GetRequestTypeAsDictr6   MakeRequests)r   r   r<   operation_refrequest_typerC   s         r   RunzDescribe.RunP   s    !2243D3D3FGN((~>M<<..u5L4]1134G  --e0709 /: ;;<> >r   )__name__
__module____qualname____doc__r   staticmethodr   propertyr    r,   r?   rD   rO   __classcell__)r   s   @r   r   r      sI    ,4 O O  
&	>r   r   c                      dddd} | S )z7Construct help text based on the command release track.z#Describe a Compute Engine operationzp
        *{command}* displays all data associated with a Compute Engine
        operation in a project.
        a  
        To get details about a global operation (e.g. operation-111-222-333-444), run:

          $ {command} operation-111-222-333-444 --global

        To get details about a regional operation, run:

          $ {command} operation-111-222-333-444 --region=us-central1

        To get details about a zonal operation, run:

          $ {command} operation-111-222-333-444 --zone=us-central1-a
        )briefDESCRIPTIONEXAMPLESrG   )detailed_helps    r   DetailedHelpr\   \   s      5-( 
r   N)rS   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   r4   r	   r1   -googlecloudsdk.command_lib.compute.operationsgooglecloudsdk.corer
   DescribeCommandr   r\   r[   rG   r   r   <module>rd      sI    ) &  ' 7 ( E E ? )<>t## <>~0 & r   