Skip to content

get_resource_api_key

get_resource_api_key(
    workload_identity_token: WorkloadIdentityTokenType,
    resource_credential_provider_name: CredentialProviderName,
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
) -> GetResourceApiKeyResponse

Retrieves the API key associated with an API key credential provider.

Parameters:

  • workload_identity_token (WorkloadIdentityTokenType) –

    The identity token of the workload from which you want to retrieve the API key.

  • resource_credential_provider_name (CredentialProviderName) –

    The credential provider name for the resource from which you are retrieving the API key.

Raises:

  • AccessDeniedException –

    The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.

  • InternalServerException –

    The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.

  • ResourceNotFoundException –

    The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.

  • ThrottlingException –

    The exception that occurs when the request was denied due to request throttling. This happens when you exceed the allowed request rate for an operation. Reduce the frequency of requests or implement exponential backoff retry logic in your application.

  • UnauthorizedException –

    This exception is thrown when the JWT bearer token is invalid or not found for OAuth bearer token based access

  • ValidationException –

    The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.

  • UnknownServiceError –

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

Source code in docs_src/capo_bedrock_agentcore/_services/bedrock_agent_core.py
def get_resource_api_key(
    self,
    workload_identity_token: "capo_bedrock_agentcore.types.workload_identity_token_type.WorkloadIdentityTokenType",
    resource_credential_provider_name: "capo_bedrock_agentcore.types.credential_provider_name.CredentialProviderName",
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
) -> "capo_bedrock_agentcore.types.get_resource_api_key_response.GetResourceApiKeyResponse":
    """<p>Retrieves the API key associated with an API key credential provider.</p>

    Args:
        workload_identity_token: <p>The identity token of the workload from which you want to retrieve the API key.</p>
        resource_credential_provider_name: <p>The credential provider name for the resource from which you are retrieving the API key.</p>

    Raises:
        capo_bedrock_agentcore.errors.access_denied_exception.AccessDeniedException: <p>The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.</p>
        capo_bedrock_agentcore.errors.internal_server_exception.InternalServerException: <p>The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.</p>
        capo_bedrock_agentcore.errors.resource_not_found_exception.ResourceNotFoundException: <p>The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.</p>
        capo_bedrock_agentcore.errors.throttling_exception.ThrottlingException: <p>The exception that occurs when the request was denied due to request throttling. This happens when you exceed the allowed request rate for an operation. Reduce the frequency of requests or implement exponential backoff retry logic in your application.</p>
        capo_bedrock_agentcore.errors.unauthorized_exception.UnauthorizedException: <p>This exception is thrown when the JWT bearer token is invalid or not found for OAuth bearer token based access</p>
        capo_bedrock_agentcore.errors.validation_exception.ValidationException: <p>The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.</p>
        capo_bedrock_agentcore.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock_agentcore.types.get_resource_api_key_request.GetResourceApiKeyRequest]",
    ) -> OperationResponse[
        "capo_bedrock_agentcore.types.get_resource_api_key_response.GetResourceApiKeyResponse"
    ]:
        import capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.get_resource_api_key

        output, http_response = (
            capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.get_resource_api_key.get_resource_api_key(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_agentcore.types.get_resource_api_key_request.GetResourceApiKeyRequest",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore.types.get_resource_api_key_request

        return capo_bedrock_agentcore.types.get_resource_api_key_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_bedrock_agentcore.types.get_resource_api_key_response.GetResourceApiKeyResponse",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore.types.get_resource_api_key_response

        return capo_bedrock_agentcore.types.get_resource_api_key_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "GetResourceApiKey",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_bedrock_agentcore.types.get_resource_api_key_request.GetResourceApiKeyRequest = {
        "workload_identity_token": workload_identity_token,
        "resource_credential_provider_name": resource_credential_provider_name,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output