
    t                     T   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	Zd
ZdZej&                  j(                  dej&                  j*                  dej&                  j,                  diZddZej&                  j(                  fdZd Zd Zd Zd Zd Zy)zAPI Keys API helper functions.    )absolute_import)division)unicode_literals)
exceptions)
list_pager)apis)basezprojects/%szprojects/%s/locations/globalapikeysv2Nc                     t        t        j                  j                        }|j                  }|j                  t        |       |      }t        j                  |j                  ||d|d      S )aY  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                 `    t         j                  |       }t        j                  t        |      S )z"Returns an API client for ApiKeys.)_RELEASE_TRACK_TO_API_VERSIONget	core_apisr   	_API_NAME)release_trackapi_versions     r$   r   r   C   s%    -11-@+		$	$Y	<<r&   c                 2   t               }|j                  }|j                  |       }	 |j                  j	                  |      S # t
        j                  t
        j                  f$ r.}t        j                  |t        j                         Y d}~yd}~ww xY w)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$   GetOperationr9   I   s     &##(00d0;'C  ))

0
0

/
/
1 CAzAABBCs   A #B($BBc                     g }t        | dg       xs g D ],  }|j                  |d   |d         }|j                  |       . |S )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$   GetAllowedAndroidApplicationsrG   `   se    T#8"=CCk"77#$67/ 8 1  34	 D
 
r&   c           
          g }t        | dg       xs g D ]C  }|j                  |j                  |j                  d      |j                  dg                    E |S )zCreate list of target apis.
api_targetservicemethods)rJ   rK   )r@   rB   V2ApiTargetr)   )rC   r"   api_targetsrI   s       r$   GetApiTargetsrN   k   se    +D,39r9jNN9-NN9b1 	 	34 :
 
r&   c                     t        | di       }g }|sy|j                         D ];  \  }}|j                  |j                  j                  j                  ||             = |j                  j	                  |      }|S )zCreate list of annotations.annotationsN)keyvalue)additionalProperties)r@   itemsrB   V2KeyAnnotationsValueAdditionalProperty)rC   r"   rP   additional_property_messagesrQ   rR   annotation_value_messages          r$   GetAnnotationsrZ   v   s    mR0+!#	%%'jc5 ''''::5 	; 	"# (
 &^^<<7 = 9 
"!r&   c                     t         | z  S )N)_PARENT_RESOURCE)r   s    r$   r   r      s    	W	%%r&   )NNN)__doc__
__future__r   r   r   apitools.base.pyr   r3   r   googlecloudsdk.api_lib.servicesgooglecloudsdk.api_lib.utilr   r*   googlecloudsdk.callioper	   r   _PROJECT_RESOURCEr\   r+   r   ALPHABETAr   r(   r%   r   r9   rG   rN   rZ   r    r&   r$   <module>rg      s    % &  ' > ' 6 9 9! 1 	 $$d##T!!4! : %2$>$>$D$D =C."$&r&   