
                         4   S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r  SrSrSr\R                  R                   S	\R                  R"                  S	\R                  R$                  S	0rSS jr\R                  R                   4S jrS rS rS rS rS rg
)zAPI Keys API helper functions.    )
exceptions)
list_pager)apis)basezprojects/%szprojects/%s/locations/globalapikeysv2Nc           	          [        [        R                  R                  5      nUR                  nUR                  [        U 5      US9n[        R                  " UR                  UUSUSS9$ )aE  List API Keys for a given project.

Args:
  project: The project for which to list keys.
  show_deleted: Includes deleted keys in the list.
  page_size: The page size to list.
  limit: The max number of metrics to return.

Raises:
  exceptions.PermissionDeniedException: when listing keys fails.

Returns:
  The list of keys
)parentshowDeletedpageSizekeys)limitbatch_size_attribute
batch_sizefield)
GetClientInstancecalliope_baseReleaseTrackGAMESSAGES_MODULE'ApikeysProjectsLocationsKeysListRequestGetParentResourceNamer   YieldFromListprojects_locations_keys)projectshow_deleted	page_sizer   clientmessagesrequests          .lib/googlecloudsdk/api_lib/services/apikeys.pyListKeysr"   #   sp     ]77::;&##(<<"7+ = G'		!	!$$%
     c                 b    [         R                  U 5      n[        R                  " [        U5      $ )z"Returns an API client for ApiKeys.)_RELEASE_TRACK_TO_API_VERSIONget	core_apisr   	_API_NAME)release_trackapi_versions     r!   r   r   @   s%    -11-@+		$	$Y	<<r#   c                 0   [        5       nUR                  nUR                  U S9n UR                  R	                  U5      $ ! [
        R                  [
        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to get an operation.

Args:
  name: The name of the operation.

Raises:
  exceptions.OperationErrorException: when the getting operation API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the service.

Returns:
  The result of the operation
)nameN)r   r   ApikeysOperationsGetRequest
operationsGetapitools_exceptionsHttpForbiddenErrorHttpNotFoundErrorr   ReraiseErrorOperationErrorException)r,   r   r   r    es        r!   GetOperationr6   F   s     &##(00d0;'C  ))

0
0

/
/
1 CAzAABBCs   A $B&%BBc                     / n[        U S/ 5      =(       d    /  H*  nUR                  US   US   S9nUR                  U5        M,     U$ )z,Create list of allowed android applications.allowed_applicationsha1_fingerprintpackage_name)sha1FingerprintpackageName)getattrV2AndroidApplicationappend)argsr   allowed_applicationsapplicationandroid_applications        r!   GetAllowedAndroidApplicationsrD   ]   se    T#8"=CCk"77#$67/ 8 1  34	 D
 
r#   c           
          / n[        U S/ 5      =(       d    /  HA  nUR                  UR                  UR                  S5      UR                  S/ 5      S95        MC     U$ )zCreate list of target apis.
api_targetservicemethods)rG   rH   )r=   r?   V2ApiTargetr&   )r@   r   api_targetsrF   s       r!   GetApiTargetsrK   h   se    +D,39r9jNN9-NN9b1 	 	34 :
 
r#   c                     [        U S0 5      n/ nU(       d  gUR                  5        H7  u  pEUR                  UR                  R                  R                  XES95        M9     UR                  R	                  US9nU$ )zCreate list of annotations.annotationsN)keyvalue)additionalProperties)r=   itemsr?   V2KeyAnnotationsValueAdditionalProperty)r@   r   rM   additional_property_messagesrN   rO   annotation_value_messages          r!   GetAnnotationsrW   s   s    mR0+!#	%%'jc '''':: 	; 	"# (
 &^^<<7 = 9 
"!r#   c                     [         U -  $ )N)_PARENT_RESOURCE)r   s    r!   r   r      s    	W	%%r#   )NNN)__doc__apitools.base.pyr   r0   r   googlecloudsdk.api_lib.servicesgooglecloudsdk.api_lib.utilr   r'   googlecloudsdk.callioper   r   _PROJECT_RESOURCErY   r(   r   ALPHABETAr   r%   r"   r   r6   rD   rK   rW   r    r#   r!   <module>rc      s    % ? ' 6 9 9! 1 	 $$d##T!!4! : %2$>$>$D$D =C."$&r#   