
    &                        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 Zd Z ej"                  ej$                  j&                        ej(                   G d dej*                                      Z ej"                  ej$                  j.                  ej$                  j0                         G d de             Z ej4                  d      e_        dddde_        y)zCommand for listing operations.    )absolute_import)division)unicode_literals)base_classes)lister)request_helper)utils)arg_parsers)base)
propertiesc                  f    t         j                  j                  j                  j	                         S )N)r   VALUEScomputeallow_partial_errorGetBool     &lib/surface/compute/operations/list.py_AllowPartialErrorr      s#    				"	"	6	6	>	>	@@r   c                 b   | j                   j                  d       |rt        j                  | ddd       yt        j                  |        | j                  dddt        j                                | j                  dd	d
t        j                                | j                  dddd       y)z@Helper function for adding flags dependant on the release track.z      table(
        name,
        operationType:label=TYPE,
        targetLink.scope():label=TARGET,
        operation_http_status():label=HTTP_STATUS,
        status,
        insertTime:label=TIMESTAMP
      )T)zonalregionalglobal_z--zonesZONEzIf arguments are provided, only resources from the given zones are shown. If no arguments are provided all zonal operations are shown.)metavarhelptypez	--regionsREGIONzIf arguments are provided, only resources from the given regions are shown. If no arguments are provided all regional operations are shown.z--global
store_truez,If provided, all global resources are shown.F)actionr   defaultN)display_info	AddFormatr   AddMultiScopeListerFlagsAddBaseListerArgsadd_argumentr
   ArgList)parseris_gas     r   AddFlagsr*   "   s     !  
##dT49 V$
&   "  $ &   "  $ ;	  r   c                   ,    e Zd ZdZed        Zd Zd Zy)ListList Compute Engine operations.c                     t        | d       y )NTr*   r(   s    r   Argsz	List.ArgsL   s    VTr   c                 `    |j                   du xr |j                  du xr t        |d       }|S )z:Determine if the user provided any flags indicating scope.Nglobal)zonesregionsgetattr)selfargsno_compute_argss      r   NoArgumentszList.NoArgumentsP   s;    zzT) 3dlld.B 3"422 r   c                 <   t        j                  | j                               }|j                  }| j	                  |      }g }t        j                  ||j                        }|r|j                  |j                  j                  d |j                  j                  j                  d      |j                  |j                  dt        |j                        d   j                         f       nt#        |d      r|j                  |j                  j                  d |j                  j                  j                  d      |j                  |j                  t        |j                        d   j                         f       |j$                  |j$                  xs g D cg c]\  }|j                  j'                  |d	t(        j*                  j,                  j                   j.                  id
      j1                         ^ }}g }	|xs t        j2                  |j                  j$                  t(        j*                  j,                  j                   j/                         d|j                  j4                  |j6                  |	      D 
cg c]  }
|
j8                   c}
}|	rt;        j<                  |	d       |D ]  }|j                  |j                  j>                  d |j                  j>                  j                  d      |j                  |j                  |t        |j                        d   j                         f        |j@                  |j@                  xs g D cg c]\  }|j                  j'                  |d	t(        j*                  j,                  j                   j.                  id      j1                         ^ }}g }	|xs t        j2                  |j                  j@                  t(        j*                  j,                  j                   j/                         d|j                  j4                  |j6                  |	      D 
cg c]  }
|
j8                   c}
}|	rt;        j<                  |	d       |D ]  }|j                  |j                  jB                  d |j                  jB                  j                  d      |j                  |j                  |t        |j                        d   j                         f        g }	t        tE        jF                  ||j                  j4                  |j6                  |	            }|	r6tI               rt;        jJ                  |	       |S t;        j<                  |	       |S c c}w c c}
w c c}w c c}
w )z0Yields zonal, regional, and/or global resources.AggregatedListTr   )filter
maxResultsreturnPartialSuccessprojectr3   r,   )r=   r>   r@   Nr@   zcompute.regions)params
collection)servicer@   filter_exprhttp	batch_urlerrorszMUnable to fetch a list of regions. Specifying [--regions] may fix this issue:)r=   r>   regionr@   zcompute.zoneszIUnable to fetch a list of zones. Specifying [--zones] may fix this issue:)r=   r>   zoner@   )requestsrE   rF   rG   )&r   ComputeApiHolderReleaseTrackclientr:   r   ParseNamesAndRegexpFlags	resourcesappendapitools_clientglobalOperationsGetRequestTyper=   max_resultslist	scope_setr@   r6   r5   Parser   r   core	GetOrFailNameGetGlobalResourcesrE   rF   namer	   RaiseToolExceptionregionOperationsr4   zoneOperationsr   ListJsonr   WarnIfPartialRequestFail)r7   r8   compute_holdercompute_clientno_scope_flagsrJ   request_datarH   args_region_namesrG   resregion_namesregion_namerI   args_zone_names
zone_names	zone_nameresultss                     r   RunzList.RunV   sG   !2243D3D3FGN#**N %%d+NH2243A3K3KML
 oo))::<L!>))::II!&--*66(, 6 67:BBDEF 
x	 ++<<f^++<<KK(// , 8 8!,"8"89!<DD	FG	H 
	! ,,,",.
 -	 $$**!:#4#4#9#9#A#A#K#KL, + . /3df5 - 	 .   f6O6O&66>>"))..66@@B #3388(227 "  7s#(( 7 "  	 

"
" ! (K
//-->>~-->>MM*11".":":)#L$:$:;A>FFHIJ ( 
	 

(b(* ) $$**z0055==GG + + ,
 -1DF3 ) 	 *   F4M4M&66<<"))..66@@B #3388(225    5S 5    	 

"
" ! $I
//--<<f~--<<KK*11".":":%#L$:$:;A>FFHIJ $ F//44$..		G 		&&v. N 	  (N[." ,*  s   #A!V
V(A!VVN)__name__
__module____qualname____doc__staticmethodr1   r:   rn   r   r   r   r,   r,   G   s$     ( nr   r,   c                        e Zd ZdZed        Zy)ListBetar-   c                     t        | d       y )NFr/   r0   s    r   r1   zListBeta.Args   s    VUr   N)ro   rp   rq   rr   rs   r1   r   r   r   ru   ru      s    ' r   ru   
operationszList Compute Engine operationsa  
        *{command}* displays all Compute Engine operations in a
        project.

        By default, all global, regional, and zonal operations are listed. The
        results can be narrowed by providing combinations of the --zones,
        --regions, and --global flags.

        Note: *{command}* displays operations fewer than 14 days old, up to a
        maximum of 5000.
        a  
        To list all operations in a project in table form, run:

          $ {command}

        To list the URIs of all operations in a project, run:

          $ {command} --uri

        To list all operations in zones us-central1-b and
        europe-west1-d, run:

           $ {command} --zones=us-central1-b,europe-west1-d

        To list all global operations in a project, run:

           $ {command} --global

        To list all regional operations in a project, run:

           $ {command} --regions=""

        To list all operations with names prefixed with `operation`, run:

           $ {command} --filter="name:operation"

        To list all operations in the us-central1 and europe-west1
        regions and all operations in the us-central1-a zone, run:

           $ {command} --zones=us-central1-a --regions=us-central1,europe-west1

        To list all operations with a specified target, filter on the targetLink
        field (run `{command} --format=json` to see a full, well-structured list
        of available fields). Additionally, use `scope()` which extracts the
        last part of the URL to get the required target information, and run:

           $ {command} --filter="targetLink.scope():default-12345abc"
        )briefDESCRIPTIONEXAMPLESN)rr   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r   r	   googlecloudsdk.callioper
   r   googlecloudsdk.corer   r   r*   ReleaseTracksrL   GAUniverseCompatibleListCommandr,   ALPHABETAru   GetGlobalRegionalListerHelpdetailed_helpr   r   r   <module>r      s    & &  ' 7 1 9 0 / ( *A"J D%%((){4 {  *{| D%%++T->->-C-CDt  E >\==lK -
%3 r   