Skip to content

get_api_key async

get_api_key(
    credential_provider_arn: CredentialProviderArn,
    *,
    config_overrides: Optional[AsyncCredentialBrokerClientConfig] = None,
) -> GetApiKeyResponse

Retrieves the API key held by an API key credential provider. The broker reads the key from the AWS Secrets Manager secret the provider was configured with and returns it, so your workload does not need its own access to that secret.

Parameters:

  • credential_provider_arn (CredentialProviderArn) –

    Amazon Resource Name of the credential provider to obtain the key from. The provider must be an API key provider and must be READY.

Raises:

  • AccessDeniedException –

    The caller is not authorized to perform the request, or a resource the request depends on refused access. reason distinguishes a denial by this service from a denial reported by a dependency the caller configured, such as a customer-owned secret, KMS key, or external identity provider, which usually points at a permission or configuration fix outside this API.

  • InternalServerException –

    The request failed because of an unexpected error in the service. Whether the request took effect is undefined, so for a create or update, read the resource back before retrying. Retryable: the same request may succeed later.

  • ResourceNotFoundException –

    The requested resource does not exist, or the caller is not permitted to know that it exists. A resource that was deleted, or that is still being created, can also be reported this way.

  • ThrottlingException –

    The request was denied because the caller exceeded a request rate limit. Nothing was changed. Retry with exponential backoff, honoring retryAfterSeconds when it is present.

  • ValidationException –

    The request is not valid. The request was rejected before any change was made, so it is safe to correct the input and retry. Use reason to branch in code and message for the human-readable detail of which field or combination of fields was at fault.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_credentialbroker/_services/async_credential_broker.py
async def get_api_key(
    self,
    credential_provider_arn: "capo_credentialbroker.types.credential_provider_arn.CredentialProviderArn",
    *,
    config_overrides: Optional[AsyncCredentialBrokerClientConfig] = None,
) -> "capo_credentialbroker.types.get_api_key_response.GetApiKeyResponse":
    """<p>Retrieves the API key held by an API key credential provider. The broker reads the key from the AWS Secrets Manager secret the provider was configured with and returns it, so your workload does not need its own access to that secret.</p>

    Args:
        credential_provider_arn: <p>Amazon Resource Name of the credential provider to obtain the key from. The provider must be an API key provider and must be READY.</p>

    Raises:
        capo_credentialbroker.errors.access_denied_exception.AccessDeniedException: <p>The caller is not authorized to perform the request, or a resource the request depends on refused access. <code>reason</code> distinguishes a denial by this service from a denial reported by a dependency the caller configured, such as a customer-owned secret, KMS key, or external identity provider, which usually points at a permission or configuration fix outside this API.</p>
        capo_credentialbroker.errors.internal_server_exception.InternalServerException: <p>The request failed because of an unexpected error in the service. Whether the request took effect is undefined, so for a create or update, read the resource back before retrying. Retryable: the same request may succeed later.</p>
        capo_credentialbroker.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource does not exist, or the caller is not permitted to know that it exists. A resource that was deleted, or that is still being created, can also be reported this way.</p>
        capo_credentialbroker.errors.throttling_exception.ThrottlingException: <p>The request was denied because the caller exceeded a request rate limit. Nothing was changed. Retry with exponential backoff, honoring <code>retryAfterSeconds</code> when it is present.</p>
        capo_credentialbroker.errors.validation_exception.ValidationException: <p>The request is not valid. The request was rejected before any change was made, so it is safe to correct the input and retry. Use <code>reason</code> to branch in code and <code>message</code> for the human-readable detail of which field or combination of fields was at fault.</p>
        capo_credentialbroker.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_credentialbroker.types.get_api_key_request.GetApiKeyRequest]",
    ) -> AsyncOperationResponse[
        "capo_credentialbroker.types.get_api_key_response.GetApiKeyResponse"
    ]:
        import capo_credentialbroker._operations.aws_tessera_data_plane.get_api_key

        (
            output,
            http_response,
        ) = await capo_credentialbroker._operations.aws_tessera_data_plane.get_api_key.async_get_api_key(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_credentialbroker.types.get_api_key_response.GetApiKeyResponse",
    ) -> dict[str, Any]:
        import capo_credentialbroker.types.get_api_key_response

        return capo_credentialbroker.types.get_api_key_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetApiKey", redact_output=_redact_output),
    )
    input_: capo_credentialbroker.types.get_api_key_request.GetApiKeyRequest = {
        "credential_provider_arn": credential_provider_arn
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output