software.amazon.awssdk.services.bedrock.DefaultBedrockClient Maven / Gradle / Ivy
Show all versions of bedrock Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.bedrock;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.awscore.retry.AwsRetryStrategy;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.client.handler.SyncClientHandler;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.retry.RetryMode;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.retries.api.RetryStrategy;
import software.amazon.awssdk.services.bedrock.internal.BedrockServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.bedrock.model.AccessDeniedException;
import software.amazon.awssdk.services.bedrock.model.BatchDeleteEvaluationJobRequest;
import software.amazon.awssdk.services.bedrock.model.BatchDeleteEvaluationJobResponse;
import software.amazon.awssdk.services.bedrock.model.BedrockException;
import software.amazon.awssdk.services.bedrock.model.ConflictException;
import software.amazon.awssdk.services.bedrock.model.CreateEvaluationJobRequest;
import software.amazon.awssdk.services.bedrock.model.CreateEvaluationJobResponse;
import software.amazon.awssdk.services.bedrock.model.CreateGuardrailRequest;
import software.amazon.awssdk.services.bedrock.model.CreateGuardrailResponse;
import software.amazon.awssdk.services.bedrock.model.CreateGuardrailVersionRequest;
import software.amazon.awssdk.services.bedrock.model.CreateGuardrailVersionResponse;
import software.amazon.awssdk.services.bedrock.model.CreateModelCopyJobRequest;
import software.amazon.awssdk.services.bedrock.model.CreateModelCopyJobResponse;
import software.amazon.awssdk.services.bedrock.model.CreateModelCustomizationJobRequest;
import software.amazon.awssdk.services.bedrock.model.CreateModelCustomizationJobResponse;
import software.amazon.awssdk.services.bedrock.model.CreateModelImportJobRequest;
import software.amazon.awssdk.services.bedrock.model.CreateModelImportJobResponse;
import software.amazon.awssdk.services.bedrock.model.CreateModelInvocationJobRequest;
import software.amazon.awssdk.services.bedrock.model.CreateModelInvocationJobResponse;
import software.amazon.awssdk.services.bedrock.model.CreateProvisionedModelThroughputRequest;
import software.amazon.awssdk.services.bedrock.model.CreateProvisionedModelThroughputResponse;
import software.amazon.awssdk.services.bedrock.model.DeleteCustomModelRequest;
import software.amazon.awssdk.services.bedrock.model.DeleteCustomModelResponse;
import software.amazon.awssdk.services.bedrock.model.DeleteGuardrailRequest;
import software.amazon.awssdk.services.bedrock.model.DeleteGuardrailResponse;
import software.amazon.awssdk.services.bedrock.model.DeleteImportedModelRequest;
import software.amazon.awssdk.services.bedrock.model.DeleteImportedModelResponse;
import software.amazon.awssdk.services.bedrock.model.DeleteModelInvocationLoggingConfigurationRequest;
import software.amazon.awssdk.services.bedrock.model.DeleteModelInvocationLoggingConfigurationResponse;
import software.amazon.awssdk.services.bedrock.model.DeleteProvisionedModelThroughputRequest;
import software.amazon.awssdk.services.bedrock.model.DeleteProvisionedModelThroughputResponse;
import software.amazon.awssdk.services.bedrock.model.GetCustomModelRequest;
import software.amazon.awssdk.services.bedrock.model.GetCustomModelResponse;
import software.amazon.awssdk.services.bedrock.model.GetEvaluationJobRequest;
import software.amazon.awssdk.services.bedrock.model.GetEvaluationJobResponse;
import software.amazon.awssdk.services.bedrock.model.GetFoundationModelRequest;
import software.amazon.awssdk.services.bedrock.model.GetFoundationModelResponse;
import software.amazon.awssdk.services.bedrock.model.GetGuardrailRequest;
import software.amazon.awssdk.services.bedrock.model.GetGuardrailResponse;
import software.amazon.awssdk.services.bedrock.model.GetImportedModelRequest;
import software.amazon.awssdk.services.bedrock.model.GetImportedModelResponse;
import software.amazon.awssdk.services.bedrock.model.GetInferenceProfileRequest;
import software.amazon.awssdk.services.bedrock.model.GetInferenceProfileResponse;
import software.amazon.awssdk.services.bedrock.model.GetModelCopyJobRequest;
import software.amazon.awssdk.services.bedrock.model.GetModelCopyJobResponse;
import software.amazon.awssdk.services.bedrock.model.GetModelCustomizationJobRequest;
import software.amazon.awssdk.services.bedrock.model.GetModelCustomizationJobResponse;
import software.amazon.awssdk.services.bedrock.model.GetModelImportJobRequest;
import software.amazon.awssdk.services.bedrock.model.GetModelImportJobResponse;
import software.amazon.awssdk.services.bedrock.model.GetModelInvocationJobRequest;
import software.amazon.awssdk.services.bedrock.model.GetModelInvocationJobResponse;
import software.amazon.awssdk.services.bedrock.model.GetModelInvocationLoggingConfigurationRequest;
import software.amazon.awssdk.services.bedrock.model.GetModelInvocationLoggingConfigurationResponse;
import software.amazon.awssdk.services.bedrock.model.GetProvisionedModelThroughputRequest;
import software.amazon.awssdk.services.bedrock.model.GetProvisionedModelThroughputResponse;
import software.amazon.awssdk.services.bedrock.model.InternalServerException;
import software.amazon.awssdk.services.bedrock.model.ListCustomModelsRequest;
import software.amazon.awssdk.services.bedrock.model.ListCustomModelsResponse;
import software.amazon.awssdk.services.bedrock.model.ListEvaluationJobsRequest;
import software.amazon.awssdk.services.bedrock.model.ListEvaluationJobsResponse;
import software.amazon.awssdk.services.bedrock.model.ListFoundationModelsRequest;
import software.amazon.awssdk.services.bedrock.model.ListFoundationModelsResponse;
import software.amazon.awssdk.services.bedrock.model.ListGuardrailsRequest;
import software.amazon.awssdk.services.bedrock.model.ListGuardrailsResponse;
import software.amazon.awssdk.services.bedrock.model.ListImportedModelsRequest;
import software.amazon.awssdk.services.bedrock.model.ListImportedModelsResponse;
import software.amazon.awssdk.services.bedrock.model.ListInferenceProfilesRequest;
import software.amazon.awssdk.services.bedrock.model.ListInferenceProfilesResponse;
import software.amazon.awssdk.services.bedrock.model.ListModelCopyJobsRequest;
import software.amazon.awssdk.services.bedrock.model.ListModelCopyJobsResponse;
import software.amazon.awssdk.services.bedrock.model.ListModelCustomizationJobsRequest;
import software.amazon.awssdk.services.bedrock.model.ListModelCustomizationJobsResponse;
import software.amazon.awssdk.services.bedrock.model.ListModelImportJobsRequest;
import software.amazon.awssdk.services.bedrock.model.ListModelImportJobsResponse;
import software.amazon.awssdk.services.bedrock.model.ListModelInvocationJobsRequest;
import software.amazon.awssdk.services.bedrock.model.ListModelInvocationJobsResponse;
import software.amazon.awssdk.services.bedrock.model.ListProvisionedModelThroughputsRequest;
import software.amazon.awssdk.services.bedrock.model.ListProvisionedModelThroughputsResponse;
import software.amazon.awssdk.services.bedrock.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.bedrock.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.bedrock.model.PutModelInvocationLoggingConfigurationRequest;
import software.amazon.awssdk.services.bedrock.model.PutModelInvocationLoggingConfigurationResponse;
import software.amazon.awssdk.services.bedrock.model.ResourceNotFoundException;
import software.amazon.awssdk.services.bedrock.model.ServiceQuotaExceededException;
import software.amazon.awssdk.services.bedrock.model.StopEvaluationJobRequest;
import software.amazon.awssdk.services.bedrock.model.StopEvaluationJobResponse;
import software.amazon.awssdk.services.bedrock.model.StopModelCustomizationJobRequest;
import software.amazon.awssdk.services.bedrock.model.StopModelCustomizationJobResponse;
import software.amazon.awssdk.services.bedrock.model.StopModelInvocationJobRequest;
import software.amazon.awssdk.services.bedrock.model.StopModelInvocationJobResponse;
import software.amazon.awssdk.services.bedrock.model.TagResourceRequest;
import software.amazon.awssdk.services.bedrock.model.TagResourceResponse;
import software.amazon.awssdk.services.bedrock.model.ThrottlingException;
import software.amazon.awssdk.services.bedrock.model.TooManyTagsException;
import software.amazon.awssdk.services.bedrock.model.UntagResourceRequest;
import software.amazon.awssdk.services.bedrock.model.UntagResourceResponse;
import software.amazon.awssdk.services.bedrock.model.UpdateGuardrailRequest;
import software.amazon.awssdk.services.bedrock.model.UpdateGuardrailResponse;
import software.amazon.awssdk.services.bedrock.model.UpdateProvisionedModelThroughputRequest;
import software.amazon.awssdk.services.bedrock.model.UpdateProvisionedModelThroughputResponse;
import software.amazon.awssdk.services.bedrock.model.ValidationException;
import software.amazon.awssdk.services.bedrock.transform.BatchDeleteEvaluationJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.CreateEvaluationJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.CreateGuardrailRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.CreateGuardrailVersionRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.CreateModelCopyJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.CreateModelCustomizationJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.CreateModelImportJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.CreateModelInvocationJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.CreateProvisionedModelThroughputRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.DeleteCustomModelRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.DeleteGuardrailRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.DeleteImportedModelRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.DeleteModelInvocationLoggingConfigurationRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.DeleteProvisionedModelThroughputRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetCustomModelRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetEvaluationJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetFoundationModelRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetGuardrailRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetImportedModelRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetInferenceProfileRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetModelCopyJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetModelCustomizationJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetModelImportJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetModelInvocationJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetModelInvocationLoggingConfigurationRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.GetProvisionedModelThroughputRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListCustomModelsRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListEvaluationJobsRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListFoundationModelsRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListGuardrailsRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListImportedModelsRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListInferenceProfilesRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListModelCopyJobsRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListModelCustomizationJobsRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListModelImportJobsRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListModelInvocationJobsRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListProvisionedModelThroughputsRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.PutModelInvocationLoggingConfigurationRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.StopEvaluationJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.StopModelCustomizationJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.StopModelInvocationJobRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.UpdateGuardrailRequestMarshaller;
import software.amazon.awssdk.services.bedrock.transform.UpdateProvisionedModelThroughputRequestMarshaller;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link BedrockClient}.
*
* @see BedrockClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultBedrockClient implements BedrockClient {
private static final Logger log = Logger.loggerFor(DefaultBedrockClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultBedrockClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
*
* Creates a batch deletion job. A model evaluation job can only be deleted if it has following status
* FAILED
, COMPLETED
, and STOPPED
. You can request up to 25 model evaluation
* jobs be deleted in a single request.
*
*
* @param batchDeleteEvaluationJobRequest
* @return Result of the BatchDeleteEvaluationJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.BatchDeleteEvaluationJob
* @see AWS API Documentation
*/
@Override
public BatchDeleteEvaluationJobResponse batchDeleteEvaluationJob(
BatchDeleteEvaluationJobRequest batchDeleteEvaluationJobRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, ConflictException, InternalServerException, ThrottlingException,
AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, BatchDeleteEvaluationJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(batchDeleteEvaluationJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, batchDeleteEvaluationJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BatchDeleteEvaluationJob");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("BatchDeleteEvaluationJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(batchDeleteEvaluationJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new BatchDeleteEvaluationJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* API operation for creating and managing Amazon Bedrock automatic model evaluation jobs and model evaluation jobs
* that use human workers. To learn more about the requirements for creating a model evaluation job see, Model evaluation.
*
*
* @param createEvaluationJobRequest
* @return Result of the CreateEvaluationJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ServiceQuotaExceededException
* The number of requests exceeds the service quota. Resubmit your request later.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.CreateEvaluationJob
* @see AWS
* API Documentation
*/
@Override
public CreateEvaluationJobResponse createEvaluationJob(CreateEvaluationJobRequest createEvaluationJobRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, ConflictException,
InternalServerException, ServiceQuotaExceededException, ThrottlingException, AwsServiceException, SdkClientException,
BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateEvaluationJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createEvaluationJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createEvaluationJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateEvaluationJob");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateEvaluationJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createEvaluationJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateEvaluationJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates a guardrail to block topics and to implement safeguards for your generative AI applications.
*
*
* You can configure the following policies in a guardrail to avoid undesirable and harmful content, filter out
* denied topics and words, and remove sensitive information for privacy protection.
*
*
* -
*
* Content filters - Adjust filter strengths to block input prompts or model responses containing harmful
* content.
*
*
* -
*
* Denied topics - Define a set of topics that are undesirable in the context of your application. These
* topics will be blocked if detected in user queries or model responses.
*
*
* -
*
* Word filters - Configure filters to block undesirable words, phrases, and profanity. Such words can
* include offensive terms, competitor names etc.
*
*
* -
*
* Sensitive information filters - Block or mask sensitive information such as personally identifiable
* information (PII) or custom regex in user inputs and model responses.
*
*
*
*
* In addition to the above policies, you can also configure the messages to be returned to the user if a user input
* or model response is in violation of the policies defined in the guardrail.
*
*
* For more information, see Guardrails for Amazon Bedrock in
* the Amazon Bedrock User Guide.
*
*
* @param createGuardrailRequest
* @return Result of the CreateGuardrail operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws TooManyTagsException
* The request contains more tags than can be associated with a resource (50 tags per resource). The maximum
* number of tags includes both existing tags and those included in your current request.
* @throws ServiceQuotaExceededException
* The number of requests exceeds the service quota. Resubmit your request later.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.CreateGuardrail
* @see AWS API
* Documentation
*/
@Override
public CreateGuardrailResponse createGuardrail(CreateGuardrailRequest createGuardrailRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, ConflictException,
InternalServerException, TooManyTagsException, ServiceQuotaExceededException, ThrottlingException,
AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateGuardrailResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createGuardrailRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createGuardrailRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateGuardrail");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateGuardrail").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createGuardrailRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateGuardrailRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates a version of the guardrail. Use this API to create a snapshot of the guardrail when you are satisfied
* with a configuration, or to compare the configuration with another version.
*
*
* @param createGuardrailVersionRequest
* @return Result of the CreateGuardrailVersion operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ServiceQuotaExceededException
* The number of requests exceeds the service quota. Resubmit your request later.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.CreateGuardrailVersion
* @see AWS API Documentation
*/
@Override
public CreateGuardrailVersionResponse createGuardrailVersion(CreateGuardrailVersionRequest createGuardrailVersionRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, ConflictException,
InternalServerException, ServiceQuotaExceededException, ThrottlingException, AwsServiceException, SdkClientException,
BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateGuardrailVersionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createGuardrailVersionRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createGuardrailVersionRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateGuardrailVersion");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateGuardrailVersion").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createGuardrailVersionRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateGuardrailVersionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Copies a model to another region so that it can be used there. For more information, see Copy models to be used in other
* regions in the Amazon
* Bedrock User Guide.
*
*
* @param createModelCopyJobRequest
* @return Result of the CreateModelCopyJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws TooManyTagsException
* The request contains more tags than can be associated with a resource (50 tags per resource). The maximum
* number of tags includes both existing tags and those included in your current request.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.CreateModelCopyJob
* @see AWS
* API Documentation
*/
@Override
public CreateModelCopyJobResponse createModelCopyJob(CreateModelCopyJobRequest createModelCopyJobRequest)
throws ResourceNotFoundException, AccessDeniedException, InternalServerException, TooManyTagsException,
AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateModelCopyJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createModelCopyJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createModelCopyJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateModelCopyJob");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateModelCopyJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createModelCopyJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateModelCopyJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates a fine-tuning job to customize a base model.
*
*
* You specify the base foundation model and the location of the training data. After the model-customization job
* completes successfully, your custom model resource will be ready to use. Amazon Bedrock returns validation loss
* metrics and output generations after the job completes.
*
*
* For information on the format of training and validation data, see Prepare the
* datasets.
*
*
* Model-customization jobs are asynchronous and the completion time depends on the base model and the
* training/validation data size. To monitor a job, use the GetModelCustomizationJob
operation to
* retrieve the job status.
*
*
* For more information, see Custom models in the Amazon Bedrock User Guide.
*
*
* @param createModelCustomizationJobRequest
* @return Result of the CreateModelCustomizationJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws TooManyTagsException
* The request contains more tags than can be associated with a resource (50 tags per resource). The maximum
* number of tags includes both existing tags and those included in your current request.
* @throws ServiceQuotaExceededException
* The number of requests exceeds the service quota. Resubmit your request later.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.CreateModelCustomizationJob
* @see AWS API Documentation
*/
@Override
public CreateModelCustomizationJobResponse createModelCustomizationJob(
CreateModelCustomizationJobRequest createModelCustomizationJobRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, ConflictException, InternalServerException, TooManyTagsException,
ServiceQuotaExceededException, ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateModelCustomizationJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createModelCustomizationJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createModelCustomizationJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateModelCustomizationJob");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateModelCustomizationJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createModelCustomizationJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateModelCustomizationJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates a model import job to import model that you have customized in other environments, such as Amazon
* SageMaker. For more information, see Import a
* customized model
*
*
* @param createModelImportJobRequest
* @return Result of the CreateModelImportJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws TooManyTagsException
* The request contains more tags than can be associated with a resource (50 tags per resource). The maximum
* number of tags includes both existing tags and those included in your current request.
* @throws ServiceQuotaExceededException
* The number of requests exceeds the service quota. Resubmit your request later.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.CreateModelImportJob
* @see AWS
* API Documentation
*/
@Override
public CreateModelImportJobResponse createModelImportJob(CreateModelImportJobRequest createModelImportJobRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, ConflictException,
InternalServerException, TooManyTagsException, ServiceQuotaExceededException, ThrottlingException,
AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateModelImportJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createModelImportJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createModelImportJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateModelImportJob");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateModelImportJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createModelImportJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateModelImportJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates a batch inference job to invoke a model on multiple prompts. Format your data according to Format your inference data
* and upload it to an Amazon S3 bucket. For more information, see Process multiple prompts with
* batch inference.
*
*
* The response returns a jobArn
that you can use to stop or get details about the job.
*
*
* @param createModelInvocationJobRequest
* @return Result of the CreateModelInvocationJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ServiceQuotaExceededException
* The number of requests exceeds the service quota. Resubmit your request later.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.CreateModelInvocationJob
* @see AWS API Documentation
*/
@Override
public CreateModelInvocationJobResponse createModelInvocationJob(
CreateModelInvocationJobRequest createModelInvocationJobRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, ConflictException, InternalServerException,
ServiceQuotaExceededException, ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateModelInvocationJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createModelInvocationJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createModelInvocationJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateModelInvocationJob");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateModelInvocationJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createModelInvocationJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateModelInvocationJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates dedicated throughput for a base or custom model with the model units and for the duration that you
* specify. For pricing details, see Amazon Bedrock Pricing.
* For more information, see Provisioned Throughput in
* the Amazon Bedrock User
* Guide.
*
*
* @param createProvisionedModelThroughputRequest
* @return Result of the CreateProvisionedModelThroughput operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws TooManyTagsException
* The request contains more tags than can be associated with a resource (50 tags per resource). The maximum
* number of tags includes both existing tags and those included in your current request.
* @throws ServiceQuotaExceededException
* The number of requests exceeds the service quota. Resubmit your request later.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.CreateProvisionedModelThroughput
* @see AWS API Documentation
*/
@Override
public CreateProvisionedModelThroughputResponse createProvisionedModelThroughput(
CreateProvisionedModelThroughputRequest createProvisionedModelThroughputRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, InternalServerException, TooManyTagsException,
ServiceQuotaExceededException, ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateProvisionedModelThroughputResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createProvisionedModelThroughputRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
createProvisionedModelThroughputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateProvisionedModelThroughput");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateProvisionedModelThroughput").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createProvisionedModelThroughputRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateProvisionedModelThroughputRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a custom model that you created earlier. For more information, see Custom models in the Amazon Bedrock User Guide.
*
*
* @param deleteCustomModelRequest
* @return Result of the DeleteCustomModel operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.DeleteCustomModel
* @see AWS API
* Documentation
*/
@Override
public DeleteCustomModelResponse deleteCustomModel(DeleteCustomModelRequest deleteCustomModelRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, ConflictException,
InternalServerException, ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteCustomModelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteCustomModelRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteCustomModelRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteCustomModel");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteCustomModel").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(deleteCustomModelRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteCustomModelRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a guardrail.
*
*
* -
*
* To delete a guardrail, only specify the ARN of the guardrail in the guardrailIdentifier
field. If
* you delete a guardrail, all of its versions will be deleted.
*
*
* -
*
* To delete a version of a guardrail, specify the ARN of the guardrail in the guardrailIdentifier
* field and the version in the guardrailVersion
field.
*
*
*
*
* @param deleteGuardrailRequest
* @return Result of the DeleteGuardrail operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.DeleteGuardrail
* @see AWS API
* Documentation
*/
@Override
public DeleteGuardrailResponse deleteGuardrail(DeleteGuardrailRequest deleteGuardrailRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, ConflictException,
InternalServerException, ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteGuardrailResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteGuardrailRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteGuardrailRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteGuardrail");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteGuardrail").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(deleteGuardrailRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteGuardrailRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a custom model that you imported earlier. For more information, see Import a
* customized model in the Amazon Bedrock User Guide.
*
*
* @param deleteImportedModelRequest
* @return Result of the DeleteImportedModel operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.DeleteImportedModel
* @see AWS
* API Documentation
*/
@Override
public DeleteImportedModelResponse deleteImportedModel(DeleteImportedModelRequest deleteImportedModelRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, ConflictException,
InternalServerException, ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteImportedModelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteImportedModelRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteImportedModelRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteImportedModel");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteImportedModel").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(deleteImportedModelRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteImportedModelRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Delete the invocation logging.
*
*
* @param deleteModelInvocationLoggingConfigurationRequest
* @return Result of the DeleteModelInvocationLoggingConfiguration operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.DeleteModelInvocationLoggingConfiguration
* @see AWS API Documentation
*/
@Override
public DeleteModelInvocationLoggingConfigurationResponse deleteModelInvocationLoggingConfiguration(
DeleteModelInvocationLoggingConfigurationRequest deleteModelInvocationLoggingConfigurationRequest)
throws AccessDeniedException, InternalServerException, ThrottlingException, AwsServiceException, SdkClientException,
BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, DeleteModelInvocationLoggingConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(
deleteModelInvocationLoggingConfigurationRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
deleteModelInvocationLoggingConfigurationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteModelInvocationLoggingConfiguration");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteModelInvocationLoggingConfiguration")
.withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(deleteModelInvocationLoggingConfigurationRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteModelInvocationLoggingConfigurationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a Provisioned Throughput. You can't delete a Provisioned Throughput before the commitment term is over.
* For more information, see Provisioned Throughput in
* the Amazon Bedrock User
* Guide.
*
*
* @param deleteProvisionedModelThroughputRequest
* @return Result of the DeleteProvisionedModelThroughput operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.DeleteProvisionedModelThroughput
* @see AWS API Documentation
*/
@Override
public DeleteProvisionedModelThroughputResponse deleteProvisionedModelThroughput(
DeleteProvisionedModelThroughputRequest deleteProvisionedModelThroughputRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, ConflictException, InternalServerException, ThrottlingException,
AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteProvisionedModelThroughputResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteProvisionedModelThroughputRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
deleteProvisionedModelThroughputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteProvisionedModelThroughput");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteProvisionedModelThroughput").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(deleteProvisionedModelThroughputRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteProvisionedModelThroughputRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Get the properties associated with a Amazon Bedrock custom model that you have created.For more information, see
* Custom models in the Amazon Bedrock User Guide.
*
*
* @param getCustomModelRequest
* @return Result of the GetCustomModel operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetCustomModel
* @see AWS API
* Documentation
*/
@Override
public GetCustomModelResponse getCustomModel(GetCustomModelRequest getCustomModelRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetCustomModelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getCustomModelRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getCustomModelRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetCustomModel");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetCustomModel").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getCustomModelRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetCustomModelRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves the properties associated with a model evaluation job, including the status of the job. For more
* information, see Model
* evaluation.
*
*
* @param getEvaluationJobRequest
* @return Result of the GetEvaluationJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetEvaluationJob
* @see AWS API
* Documentation
*/
@Override
public GetEvaluationJobResponse getEvaluationJob(GetEvaluationJobRequest getEvaluationJobRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetEvaluationJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getEvaluationJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getEvaluationJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetEvaluationJob");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetEvaluationJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getEvaluationJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetEvaluationJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Get details about a Amazon Bedrock foundation model.
*
*
* @param getFoundationModelRequest
* @return Result of the GetFoundationModel operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetFoundationModel
* @see AWS
* API Documentation
*/
@Override
public GetFoundationModelResponse getFoundationModel(GetFoundationModelRequest getFoundationModelRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetFoundationModelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getFoundationModelRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getFoundationModelRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetFoundationModel");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetFoundationModel").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getFoundationModelRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetFoundationModelRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Gets details about a guardrail. If you don't specify a version, the response returns details for the
* DRAFT
version.
*
*
* @param getGuardrailRequest
* @return Result of the GetGuardrail operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetGuardrail
* @see AWS API
* Documentation
*/
@Override
public GetGuardrailResponse getGuardrail(GetGuardrailRequest getGuardrailRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetGuardrailResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getGuardrailRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getGuardrailRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetGuardrail");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetGuardrail").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getGuardrailRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetGuardrailRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Gets properties associated with a customized model you imported.
*
*
* @param getImportedModelRequest
* @return Result of the GetImportedModel operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetImportedModel
* @see AWS API
* Documentation
*/
@Override
public GetImportedModelResponse getImportedModel(GetImportedModelRequest getImportedModelRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetImportedModelResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getImportedModelRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getImportedModelRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetImportedModel");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetImportedModel").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getImportedModelRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetImportedModelRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Gets information about an inference profile. For more information, see the Amazon Bedrock User Guide.
*
*
* @param getInferenceProfileRequest
* @return Result of the GetInferenceProfile operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetInferenceProfile
* @see AWS
* API Documentation
*/
@Override
public GetInferenceProfileResponse getInferenceProfile(GetInferenceProfileRequest getInferenceProfileRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetInferenceProfileResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getInferenceProfileRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getInferenceProfileRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetInferenceProfile");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetInferenceProfile").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getInferenceProfileRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetInferenceProfileRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves information about a model copy job. For more information, see Copy models to be used in other
* regions in the Amazon
* Bedrock User Guide.
*
*
* @param getModelCopyJobRequest
* @return Result of the GetModelCopyJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetModelCopyJob
* @see AWS API
* Documentation
*/
@Override
public GetModelCopyJobResponse getModelCopyJob(GetModelCopyJobRequest getModelCopyJobRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetModelCopyJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getModelCopyJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getModelCopyJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetModelCopyJob");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetModelCopyJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getModelCopyJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetModelCopyJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves the properties associated with a model-customization job, including the status of the job. For more
* information, see Custom
* models in the Amazon
* Bedrock User Guide.
*
*
* @param getModelCustomizationJobRequest
* @return Result of the GetModelCustomizationJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetModelCustomizationJob
* @see AWS API Documentation
*/
@Override
public GetModelCustomizationJobResponse getModelCustomizationJob(
GetModelCustomizationJobRequest getModelCustomizationJobRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetModelCustomizationJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getModelCustomizationJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getModelCustomizationJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetModelCustomizationJob");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetModelCustomizationJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getModelCustomizationJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetModelCustomizationJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves the properties associated with import model job, including the status of the job. For more information,
* see Import a
* customized model in the Amazon Bedrock User Guide.
*
*
* @param getModelImportJobRequest
* @return Result of the GetModelImportJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetModelImportJob
* @see AWS API
* Documentation
*/
@Override
public GetModelImportJobResponse getModelImportJob(GetModelImportJobRequest getModelImportJobRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetModelImportJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getModelImportJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getModelImportJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetModelImportJob");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetModelImportJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getModelImportJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetModelImportJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Gets details about a batch inference job. For more information, see View
* details about a batch inference job
*
*
* @param getModelInvocationJobRequest
* @return Result of the GetModelInvocationJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetModelInvocationJob
* @see AWS
* API Documentation
*/
@Override
public GetModelInvocationJobResponse getModelInvocationJob(GetModelInvocationJobRequest getModelInvocationJobRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetModelInvocationJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getModelInvocationJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getModelInvocationJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetModelInvocationJob");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetModelInvocationJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getModelInvocationJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetModelInvocationJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Get the current configuration values for model invocation logging.
*
*
* @param getModelInvocationLoggingConfigurationRequest
* @return Result of the GetModelInvocationLoggingConfiguration operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetModelInvocationLoggingConfiguration
* @see AWS API Documentation
*/
@Override
public GetModelInvocationLoggingConfigurationResponse getModelInvocationLoggingConfiguration(
GetModelInvocationLoggingConfigurationRequest getModelInvocationLoggingConfigurationRequest)
throws AccessDeniedException, InternalServerException, ThrottlingException, AwsServiceException, SdkClientException,
BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, GetModelInvocationLoggingConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getModelInvocationLoggingConfigurationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getModelInvocationLoggingConfigurationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetModelInvocationLoggingConfiguration");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetModelInvocationLoggingConfiguration").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(getModelInvocationLoggingConfigurationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetModelInvocationLoggingConfigurationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns details for a Provisioned Throughput. For more information, see Provisioned Throughput in
* the Amazon Bedrock User
* Guide.
*
*
* @param getProvisionedModelThroughputRequest
* @return Result of the GetProvisionedModelThroughput operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.GetProvisionedModelThroughput
* @see AWS API Documentation
*/
@Override
public GetProvisionedModelThroughputResponse getProvisionedModelThroughput(
GetProvisionedModelThroughputRequest getProvisionedModelThroughputRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetProvisionedModelThroughputResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getProvisionedModelThroughputRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getProvisionedModelThroughputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetProvisionedModelThroughput");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetProvisionedModelThroughput").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getProvisionedModelThroughputRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetProvisionedModelThroughputRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns a list of the custom models that you have created with the CreateModelCustomizationJob
* operation.
*
*
* For more information, see Custom models in the Amazon Bedrock User Guide.
*
*
* @param listCustomModelsRequest
* @return Result of the ListCustomModels operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListCustomModels
* @see AWS API
* Documentation
*/
@Override
public ListCustomModelsResponse listCustomModels(ListCustomModelsRequest listCustomModelsRequest)
throws AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListCustomModelsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listCustomModelsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listCustomModelsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListCustomModels");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListCustomModels").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listCustomModelsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListCustomModelsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists model evaluation jobs.
*
*
* @param listEvaluationJobsRequest
* @return Result of the ListEvaluationJobs operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListEvaluationJobs
* @see AWS
* API Documentation
*/
@Override
public ListEvaluationJobsResponse listEvaluationJobs(ListEvaluationJobsRequest listEvaluationJobsRequest)
throws AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListEvaluationJobsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listEvaluationJobsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listEvaluationJobsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListEvaluationJobs");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListEvaluationJobs").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listEvaluationJobsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListEvaluationJobsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists Amazon Bedrock foundation models that you can use. You can filter the results with the request parameters.
* For more information, see Foundation models in the
* Amazon Bedrock User
* Guide.
*
*
* @param listFoundationModelsRequest
* @return Result of the ListFoundationModels operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListFoundationModels
* @see AWS
* API Documentation
*/
@Override
public ListFoundationModelsResponse listFoundationModels(ListFoundationModelsRequest listFoundationModelsRequest)
throws AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListFoundationModelsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listFoundationModelsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listFoundationModelsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListFoundationModels");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListFoundationModels").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listFoundationModelsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListFoundationModelsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists details about all the guardrails in an account. To list the DRAFT
version of all your
* guardrails, don't specify the guardrailIdentifier
field. To list all versions of a guardrail,
* specify the ARN of the guardrail in the guardrailIdentifier
field.
*
*
* You can set the maximum number of results to return in a response in the maxResults
field. If there
* are more results than the number you set, the response returns a nextToken
that you can send in
* another ListGuardrails
request to see the next batch of results.
*
*
* @param listGuardrailsRequest
* @return Result of the ListGuardrails operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListGuardrails
* @see AWS API
* Documentation
*/
@Override
public ListGuardrailsResponse listGuardrails(ListGuardrailsRequest listGuardrailsRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListGuardrailsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listGuardrailsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listGuardrailsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListGuardrails");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListGuardrails").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listGuardrailsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListGuardrailsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns a list of models you've imported. You can filter the results to return based on one or more criteria. For
* more information, see Import a
* customized model in the Amazon Bedrock User Guide.
*
*
* @param listImportedModelsRequest
* @return Result of the ListImportedModels operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListImportedModels
* @see AWS
* API Documentation
*/
@Override
public ListImportedModelsResponse listImportedModels(ListImportedModelsRequest listImportedModelsRequest)
throws AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListImportedModelsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listImportedModelsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listImportedModelsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListImportedModels");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListImportedModels").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listImportedModelsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListImportedModelsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns a list of inference profiles that you can use.
*
*
* @param listInferenceProfilesRequest
* @return Result of the ListInferenceProfiles operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListInferenceProfiles
* @see AWS
* API Documentation
*/
@Override
public ListInferenceProfilesResponse listInferenceProfiles(ListInferenceProfilesRequest listInferenceProfilesRequest)
throws AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListInferenceProfilesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listInferenceProfilesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listInferenceProfilesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListInferenceProfiles");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListInferenceProfiles").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listInferenceProfilesRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListInferenceProfilesRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns a list of model copy jobs that you have submitted. You can filter the jobs to return based on one or more
* criteria. For more information, see Copy models to be used in other
* regions in the Amazon
* Bedrock User Guide.
*
*
* @param listModelCopyJobsRequest
* @return Result of the ListModelCopyJobs operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListModelCopyJobs
* @see AWS API
* Documentation
*/
@Override
public ListModelCopyJobsResponse listModelCopyJobs(ListModelCopyJobsRequest listModelCopyJobsRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListModelCopyJobsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listModelCopyJobsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listModelCopyJobsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListModelCopyJobs");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListModelCopyJobs").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listModelCopyJobsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListModelCopyJobsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns a list of model customization jobs that you have submitted. You can filter the jobs to return based on
* one or more criteria.
*
*
* For more information, see Custom models in the Amazon Bedrock User Guide.
*
*
* @param listModelCustomizationJobsRequest
* @return Result of the ListModelCustomizationJobs operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListModelCustomizationJobs
* @see AWS API Documentation
*/
@Override
public ListModelCustomizationJobsResponse listModelCustomizationJobs(
ListModelCustomizationJobsRequest listModelCustomizationJobsRequest) throws AccessDeniedException,
ValidationException, InternalServerException, ThrottlingException, AwsServiceException, SdkClientException,
BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListModelCustomizationJobsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listModelCustomizationJobsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listModelCustomizationJobsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListModelCustomizationJobs");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListModelCustomizationJobs").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listModelCustomizationJobsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListModelCustomizationJobsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns a list of import jobs you've submitted. You can filter the results to return based on one or more
* criteria. For more information, see Import a
* customized model in the Amazon Bedrock User Guide.
*
*
* @param listModelImportJobsRequest
* @return Result of the ListModelImportJobs operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListModelImportJobs
* @see AWS
* API Documentation
*/
@Override
public ListModelImportJobsResponse listModelImportJobs(ListModelImportJobsRequest listModelImportJobsRequest)
throws AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListModelImportJobsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listModelImportJobsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listModelImportJobsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListModelImportJobs");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListModelImportJobs").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listModelImportJobsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListModelImportJobsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists all batch inference jobs in the account. For more information, see View
* details about a batch inference job.
*
*
* @param listModelInvocationJobsRequest
* @return Result of the ListModelInvocationJobs operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListModelInvocationJobs
* @see AWS API Documentation
*/
@Override
public ListModelInvocationJobsResponse listModelInvocationJobs(ListModelInvocationJobsRequest listModelInvocationJobsRequest)
throws AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListModelInvocationJobsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listModelInvocationJobsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listModelInvocationJobsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListModelInvocationJobs");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListModelInvocationJobs").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listModelInvocationJobsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListModelInvocationJobsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists the Provisioned Throughputs in the account. For more information, see Provisioned Throughput in
* the Amazon Bedrock User
* Guide.
*
*
* @param listProvisionedModelThroughputsRequest
* @return Result of the ListProvisionedModelThroughputs operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListProvisionedModelThroughputs
* @see AWS API Documentation
*/
@Override
public ListProvisionedModelThroughputsResponse listProvisionedModelThroughputs(
ListProvisionedModelThroughputsRequest listProvisionedModelThroughputsRequest) throws AccessDeniedException,
ValidationException, InternalServerException, ThrottlingException, AwsServiceException, SdkClientException,
BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListProvisionedModelThroughputsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listProvisionedModelThroughputsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
listProvisionedModelThroughputsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListProvisionedModelThroughputs");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListProvisionedModelThroughputs").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listProvisionedModelThroughputsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListProvisionedModelThroughputsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* List the tags associated with the specified resource.
*
*
* For more information, see Tagging
* resources in the Amazon
* Bedrock User Guide.
*
*
* @param listTagsForResourceRequest
* @return Result of the ListTagsForResource operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.ListTagsForResource
* @see AWS
* API Documentation
*/
@Override
public ListTagsForResourceResponse listTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListTagsForResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listTagsForResourceRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListTagsForResource").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listTagsForResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Set the configuration values for model invocation logging.
*
*
* @param putModelInvocationLoggingConfigurationRequest
* @return Result of the PutModelInvocationLoggingConfiguration operation returned by the service.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.PutModelInvocationLoggingConfiguration
* @see AWS API Documentation
*/
@Override
public PutModelInvocationLoggingConfigurationResponse putModelInvocationLoggingConfiguration(
PutModelInvocationLoggingConfigurationRequest putModelInvocationLoggingConfigurationRequest)
throws AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, PutModelInvocationLoggingConfigurationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putModelInvocationLoggingConfigurationRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
putModelInvocationLoggingConfigurationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutModelInvocationLoggingConfiguration");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("PutModelInvocationLoggingConfiguration").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(putModelInvocationLoggingConfigurationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new PutModelInvocationLoggingConfigurationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Stops an in progress model evaluation job.
*
*
* @param stopEvaluationJobRequest
* @return Result of the StopEvaluationJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.StopEvaluationJob
* @see AWS API
* Documentation
*/
@Override
public StopEvaluationJobResponse stopEvaluationJob(StopEvaluationJobRequest stopEvaluationJobRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, ConflictException,
InternalServerException, ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
StopEvaluationJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(stopEvaluationJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, stopEvaluationJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StopEvaluationJob");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("StopEvaluationJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(stopEvaluationJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StopEvaluationJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Stops an active model customization job. For more information, see Custom models in the Amazon Bedrock User Guide.
*
*
* @param stopModelCustomizationJobRequest
* @return Result of the StopModelCustomizationJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.StopModelCustomizationJob
* @see AWS API Documentation
*/
@Override
public StopModelCustomizationJobResponse stopModelCustomizationJob(
StopModelCustomizationJobRequest stopModelCustomizationJobRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, ConflictException, InternalServerException, ThrottlingException,
AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StopModelCustomizationJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(stopModelCustomizationJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, stopModelCustomizationJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StopModelCustomizationJob");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("StopModelCustomizationJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(stopModelCustomizationJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StopModelCustomizationJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Stops a batch inference job. You're only charged for tokens that were already processed. For more information,
* see Stop
* a batch inference job.
*
*
* @param stopModelInvocationJobRequest
* @return Result of the StopModelInvocationJob operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.StopModelInvocationJob
* @see AWS API Documentation
*/
@Override
public StopModelInvocationJobResponse stopModelInvocationJob(StopModelInvocationJobRequest stopModelInvocationJobRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, ConflictException,
InternalServerException, ThrottlingException, AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StopModelInvocationJobResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(stopModelInvocationJobRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, stopModelInvocationJobRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StopModelInvocationJob");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("StopModelInvocationJob").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(stopModelInvocationJobRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StopModelInvocationJobRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Associate tags with a resource. For more information, see Tagging resources in the Amazon Bedrock User Guide.
*
*
* @param tagResourceRequest
* @return Result of the TagResource operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws TooManyTagsException
* The request contains more tags than can be associated with a resource (50 tags per resource). The maximum
* number of tags includes both existing tags and those included in your current request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.TagResource
* @see AWS API
* Documentation
*/
@Override
public TagResourceResponse tagResource(TagResourceRequest tagResourceRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, InternalServerException, TooManyTagsException, ThrottlingException,
AwsServiceException, SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
TagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(tagResourceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("TagResource").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(tagResourceRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new TagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Remove one or more tags from a resource. For more information, see Tagging resources in the Amazon Bedrock User Guide.
*
*
* @param untagResourceRequest
* @return Result of the UntagResource operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.UntagResource
* @see AWS API
* Documentation
*/
@Override
public UntagResourceResponse untagResource(UntagResourceRequest untagResourceRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UntagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(untagResourceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UntagResource").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(untagResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UntagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Updates a guardrail with the values you specify.
*
*
* -
*
* Specify a name
and optional description
.
*
*
* -
*
* Specify messages for when the guardrail successfully blocks a prompt or a model response in the
* blockedInputMessaging
and blockedOutputsMessaging
fields.
*
*
* -
*
* Specify topics for the guardrail to deny in the topicPolicyConfig
object. Each GuardrailTopicConfig object in the topicsConfig
list pertains to one topic.
*
*
* -
*
* Give a name
and description
so that the guardrail can properly identify the topic.
*
*
* -
*
* Specify DENY
in the type
field.
*
*
* -
*
* (Optional) Provide up to five prompts that you would categorize as belonging to the topic in the
* examples
list.
*
*
*
*
* -
*
* Specify filter strengths for the harmful categories defined in Amazon Bedrock in the
* contentPolicyConfig
object. Each GuardrailContentFilterConfig object in the filtersConfig
list pertains to a harmful category.
* For more information, see Content filters. For
* more information about the fields in a content filter, see GuardrailContentFilterConfig.
*
*
* -
*
* Specify the category in the type
field.
*
*
* -
*
* Specify the strength of the filter for prompts in the inputStrength
field and for model responses in
* the strength
field of the GuardrailContentFilterConfig.
*
*
*
*
* -
*
* (Optional) For security, include the ARN of a KMS key in the kmsKeyId
field.
*
*
*
*
* @param updateGuardrailRequest
* @return Result of the UpdateGuardrail operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws ConflictException
* Error occurred because of a conflict while performing an operation.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ServiceQuotaExceededException
* The number of requests exceeds the service quota. Resubmit your request later.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.UpdateGuardrail
* @see AWS API
* Documentation
*/
@Override
public UpdateGuardrailResponse updateGuardrail(UpdateGuardrailRequest updateGuardrailRequest)
throws ResourceNotFoundException, AccessDeniedException, ValidationException, ConflictException,
InternalServerException, ServiceQuotaExceededException, ThrottlingException, AwsServiceException, SdkClientException,
BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UpdateGuardrailResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateGuardrailRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateGuardrailRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateGuardrail");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UpdateGuardrail").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(updateGuardrailRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateGuardrailRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Updates the name or associated model for a Provisioned Throughput. For more information, see Provisioned Throughput in
* the Amazon Bedrock User
* Guide.
*
*
* @param updateProvisionedModelThroughputRequest
* @return Result of the UpdateProvisionedModelThroughput operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and
* try your request again.
* @throws AccessDeniedException
* The request is denied because of missing access permissions.
* @throws ValidationException
* Input validation failed. Check your request parameters and retry the request.
* @throws InternalServerException
* An internal server error occurred. Retry your request.
* @throws ThrottlingException
* The number of requests exceeds the limit. Resubmit your request later.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws BedrockException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample BedrockClient.UpdateProvisionedModelThroughput
* @see AWS API Documentation
*/
@Override
public UpdateProvisionedModelThroughputResponse updateProvisionedModelThroughput(
UpdateProvisionedModelThroughputRequest updateProvisionedModelThroughputRequest) throws ResourceNotFoundException,
AccessDeniedException, ValidationException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, BedrockException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateProvisionedModelThroughputResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateProvisionedModelThroughputRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
updateProvisionedModelThroughputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Bedrock");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateProvisionedModelThroughput");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateProvisionedModelThroughput").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(updateProvisionedModelThroughputRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateProvisionedModelThroughputRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) {
ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder();
RetryMode retryMode = builder.retryMode();
if (retryMode != null) {
configuration.option(SdkClientOption.RETRY_STRATEGY, AwsRetryStrategy.forRetryMode(retryMode));
} else {
Consumer> configurator = builder.retryStrategyConfigurator();
if (configurator != null) {
RetryStrategy.Builder, ?> defaultBuilder = AwsRetryStrategy.defaultRetryStrategy().toBuilder();
configurator.accept(defaultBuilder);
configuration.option(SdkClientOption.RETRY_STRATEGY, defaultBuilder.build());
} else {
RetryStrategy retryStrategy = builder.retryStrategy();
if (retryStrategy != null) {
configuration.option(SdkClientOption.RETRY_STRATEGY, retryStrategy);
}
}
}
configuration.option(SdkClientOption.CONFIGURED_RETRY_MODE, null);
configuration.option(SdkClientOption.CONFIGURED_RETRY_STRATEGY, null);
configuration.option(SdkClientOption.CONFIGURED_RETRY_CONFIGURATOR, null);
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
if (plugins.isEmpty()) {
return configuration.build();
}
BedrockServiceClientConfigurationBuilder serviceConfigBuilder = new BedrockServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
updateRetryStrategyClientConfiguration(configuration);
return configuration.build();
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(BedrockException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceQuotaExceededException")
.exceptionBuilderSupplier(ServiceQuotaExceededException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerException")
.exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(500).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(404).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ValidationException")
.exceptionBuilderSupplier(ValidationException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ThrottlingException")
.exceptionBuilderSupplier(ThrottlingException::builder).httpStatusCode(429).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedException")
.exceptionBuilderSupplier(AccessDeniedException::builder).httpStatusCode(403).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConflictException")
.exceptionBuilderSupplier(ConflictException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("TooManyTagsException")
.exceptionBuilderSupplier(TooManyTagsException::builder).httpStatusCode(400).build());
}
@Override
public final BedrockServiceClientConfiguration serviceClientConfiguration() {
return new BedrockServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}