
                         .   d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
 dd	lmZ ddlZd
ZdZdZdZdZej&                  j(                  fdZej&                  j(                  fdZej&                  j(                  fdZ	 	 ddZd Zd Zy)z'Utilities for calling the Composer API.    )absolute_import)division)unicode_literalsN)encoding)
list_pager)apis)basecomposerv1v1beta1v1alpha2   c                     | t         j                  j                  k(  rt        S | t         j                  j                  k(  rt
        S t        S N)r	   ReleaseTrackBETACOMPOSER_BETA_API_VERSIONALPHACOMPOSER_ALPHA_API_VERSIONCOMPOSER_GA_API_VERSIONrelease_tracks    +lib/googlecloudsdk/api_lib/composer/util.pyGetApiVersionr   %   s<    d'',,,$$))///%%	      c                 J    t        j                  t        t        |             S Nr   )r   GetClientInstanceCOMPOSER_API_NAMEr   r   s    r   r   r   -   !    			]C
E Er   c                 J    t        j                  t        t        |             S r   )r   GetMessagesModuler   r   r   s    r   r"   r"   2   r    r   c                     g }|D ]_  } |        }	t        |	||j                                t        j                  |t	        j
                  ||	||dn||t        n|d            }a t        j                  ||      S )an  Collects the results of a List API call across a list of locations.

  Args:
    request_cls: class, the apitools.base.protorpclite.messages.Message class
        corresponding to the API request message used to list resources in a
        location.
    service: apitools.base.py.BaseApiService, a service whose list
        method to call with an instance of `request_cls`
    location_refs: [core.resources.Resource], a list of resource references to
        locations in which to list resources.
    field: str, the name of the field within the list method's response from
        which to extract a list of resources
    page_size: int, the maximum number of resources to retrieve in each API
        call
    limit: int, the maximum number of results to return. None if all available
        results should be returned.
    location_attribute: str, the name of the attribute in `request_cls` that
        should be populated with the name of the location

  Returns:
    A generator over up to `limit` resources if `limit` is not None. If `limit`
    is None, the generator will yield all resources in all requested locations.
  NpageSize)requestfieldlimit
batch_sizebatch_size_attribute)setattrRelativeName	itertoolschainr   YieldFromListDEFAULT_PAGE_SIZEislice)
request_clsservicelocation_refsr&   	page_sizer'   location_attributeresultslocation_refr%   s
             r   AggregateListResultsr8   7   s    < '#lmGG')B)B)DEoo  -$U,5,=(9!+	-.G $ 
		'5	))r   c                 f    | s |       S t        j                  |t        j                  |             S r   )r   JsonToMessageMessageToJson)metadata_valuemetadata_types     r   ParseOperationJsonMetadatar>   e   s2    	?			 ( 6 6~ F
H Hr   c           
           |t        j                  |       D cg c]  \  }}|j                  ||       c}}      S c c}}w )N)keyvalue)additionalProperties)six	iteritemsAdditionalProperty)
dictionarymsg_typer@   rA   s       r   DictToMessagerH   l   sL    	j1(1*#u !!c!71( 
  (s   A
)Nparent)__doc__
__future__r   r   r   r,   apitools.base.pyr   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper	   rC   r   r   r   r   r/   r   GAr   r   r"   r8   r>   rH    r   r   <module>rQ      s    . &  '  % ' , ( 
  % '   !% 1 1 4 4 ! %)$5$5$8$8 E
 %)$5$5$8$8 E  $,4+*\Hr   