Skip to content

create_api_key_credential_provider

create_api_key_credential_provider(
    name: CredentialProviderName,
    *,
    config_overrides: Optional[BedrockAgentCoreControlClientConfig] = None,
    api_key: Optional[DefaultApiKeyType] = None,
    api_key_secret_config: Optional[SecretReference] = None,
    api_key_secret_source: Optional[SecretSourceType] = None,
    tags: Optional[TagsMap] = None,
) -> CreateApiKeyCredentialProviderResponse

Creates a new API key credential provider.

Parameters:

  • name (CredentialProviderName) –

    The name of the API key credential provider. The name must be unique within your account.

  • api_key (Optional[DefaultApiKeyType], default: None ) –

    The API key to use for authentication. This value is encrypted and stored securely.

  • api_key_secret_config (Optional[SecretReference], default: None ) –

    A reference to the Amazon Web Services Secrets Manager secret that stores the API key. This includes the secret ID and the JSON key used to extract the API key value from the secret. Required when apiKeySecretSource is set to EXTERNAL.

  • api_key_secret_source (Optional[SecretSourceType], default: None ) –

    The source type of the API key secret. Use MANAGED if the secret is managed by the service, or EXTERNAL if you manage the secret yourself in Amazon Web Services Secrets Manager.

  • tags (Optional[TagsMap], default: None ) –

    A map of tag keys and values to assign to the API key credential provider. Tags enable you to categorize your resources in different ways, for example, by purpose, owner, or environment.

Raises:

Source code in docs_src/capo_bedrock_agentcore_control/_services/bedrock_agent_core_control.py
def create_api_key_credential_provider(
    self,
    name: "capo_bedrock_agentcore_control.types.credential_provider_name.CredentialProviderName",
    *,
    config_overrides: Optional[BedrockAgentCoreControlClientConfig] = None,
    api_key: Optional[
        "capo_bedrock_agentcore_control.types.default_api_key_type.DefaultApiKeyType"
    ] = None,
    api_key_secret_config: Optional[
        "capo_bedrock_agentcore_control.types.secret_reference.SecretReference"
    ] = None,
    api_key_secret_source: Optional[
        "capo_bedrock_agentcore_control.types.secret_source_type.SecretSourceType"
    ] = None,
    tags: Optional["capo_bedrock_agentcore_control.types.tags_map.TagsMap"] = None,
) -> "capo_bedrock_agentcore_control.types.create_api_key_credential_provider_response.CreateApiKeyCredentialProviderResponse":
    """<p>Creates a new API key credential provider.</p>

    Args:
        name: <p>The name of the API key credential provider. The name must be unique within your account.</p>
        api_key: <p>The API key to use for authentication. This value is encrypted and stored securely.</p>
        api_key_secret_config: <p>A reference to the Amazon Web Services Secrets Manager secret that stores the API key. This includes the secret ID and the JSON key used to extract the API key value from the secret. Required when <code>apiKeySecretSource</code> is set to <code>EXTERNAL</code>.</p>
        api_key_secret_source: <p>The source type of the API key secret. Use <code>MANAGED</code> if the secret is managed by the service, or <code>EXTERNAL</code> if you manage the secret yourself in Amazon Web Services Secrets Manager.</p>
        tags: <p>A map of tag keys and values to assign to the API key credential provider. Tags enable you to categorize your resources in different ways, for example, by purpose, owner, or environment.</p>

    Raises:
        capo_bedrock_agentcore_control.errors.access_denied_exception.AccessDeniedException: <p>This exception is thrown when a request is denied per access permissions</p>
        capo_bedrock_agentcore_control.errors.conflict_exception.ConflictException: <p>This exception is thrown when there is a conflict performing an operation</p>
        capo_bedrock_agentcore_control.errors.decryption_failure.DecryptionFailure: <p>Exception thrown when decryption of a secret fails.</p>
        capo_bedrock_agentcore_control.errors.encryption_failure.EncryptionFailure: <p>Exception thrown when encryption of a secret fails.</p>
        capo_bedrock_agentcore_control.errors.internal_server_exception.InternalServerException: <p>This exception is thrown if there was an unexpected error during processing of request</p>
        capo_bedrock_agentcore_control.errors.resource_limit_exceeded_exception.ResourceLimitExceededException: <p>Exception thrown when a resource limit is exceeded.</p>
        capo_bedrock_agentcore_control.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when a resource referenced by the operation does not exist</p>
        capo_bedrock_agentcore_control.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>This exception is thrown when a request is made beyond the service quota</p>
        capo_bedrock_agentcore_control.errors.throttling_exception.ThrottlingException: <p>This exception is thrown when the number of requests exceeds the limit</p>
        capo_bedrock_agentcore_control.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_control.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by the service.</p>
        capo_bedrock_agentcore_control.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock_agentcore_control.types.create_api_key_credential_provider_request.CreateApiKeyCredentialProviderRequest]",
    ) -> OperationResponse[
        "capo_bedrock_agentcore_control.types.create_api_key_credential_provider_response.CreateApiKeyCredentialProviderResponse"
    ]:
        import capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.create_api_key_credential_provider

        output, http_response = (
            capo_bedrock_agentcore_control._operations.amazon_bedrock_agent_core_control.create_api_key_credential_provider.create_api_key_credential_provider(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_agentcore_control.types.create_api_key_credential_provider_request.CreateApiKeyCredentialProviderRequest",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore_control.types.create_api_key_credential_provider_request

        return capo_bedrock_agentcore_control.types.create_api_key_credential_provider_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateApiKeyCredentialProvider", redact_input=_redact_input
        ),
    )
    input_: capo_bedrock_agentcore_control.types.create_api_key_credential_provider_request.CreateApiKeyCredentialProviderRequest = {
        "name": name
    }
    if api_key is not None:
        input_["api_key"] = api_key
    if api_key_secret_config is not None:
        input_["api_key_secret_config"] = api_key_secret_config
    if api_key_secret_source is not None:
        input_["api_key_secret_source"] = api_key_secret_source
    if tags is not None:
        input_["tags"] = tags

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