All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.lookoutvision.DefaultLookoutVisionAsyncClient Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Lookout Vision module holds the client classes that are used for communicating with Lookout Vision.

There is a newer version: 2.30.1
Show newest version
/*
 * 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.lookoutvision;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
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.async.AsyncRequestBody;
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.AsyncClientHandler;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
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.core.runtime.transform.AsyncStreamingRequestMarshaller;
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.lookoutvision.internal.LookoutVisionServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.lookoutvision.model.AccessDeniedException;
import software.amazon.awssdk.services.lookoutvision.model.ConflictException;
import software.amazon.awssdk.services.lookoutvision.model.CreateDatasetRequest;
import software.amazon.awssdk.services.lookoutvision.model.CreateDatasetResponse;
import software.amazon.awssdk.services.lookoutvision.model.CreateModelRequest;
import software.amazon.awssdk.services.lookoutvision.model.CreateModelResponse;
import software.amazon.awssdk.services.lookoutvision.model.CreateProjectRequest;
import software.amazon.awssdk.services.lookoutvision.model.CreateProjectResponse;
import software.amazon.awssdk.services.lookoutvision.model.DeleteDatasetRequest;
import software.amazon.awssdk.services.lookoutvision.model.DeleteDatasetResponse;
import software.amazon.awssdk.services.lookoutvision.model.DeleteModelRequest;
import software.amazon.awssdk.services.lookoutvision.model.DeleteModelResponse;
import software.amazon.awssdk.services.lookoutvision.model.DeleteProjectRequest;
import software.amazon.awssdk.services.lookoutvision.model.DeleteProjectResponse;
import software.amazon.awssdk.services.lookoutvision.model.DescribeDatasetRequest;
import software.amazon.awssdk.services.lookoutvision.model.DescribeDatasetResponse;
import software.amazon.awssdk.services.lookoutvision.model.DescribeModelPackagingJobRequest;
import software.amazon.awssdk.services.lookoutvision.model.DescribeModelPackagingJobResponse;
import software.amazon.awssdk.services.lookoutvision.model.DescribeModelRequest;
import software.amazon.awssdk.services.lookoutvision.model.DescribeModelResponse;
import software.amazon.awssdk.services.lookoutvision.model.DescribeProjectRequest;
import software.amazon.awssdk.services.lookoutvision.model.DescribeProjectResponse;
import software.amazon.awssdk.services.lookoutvision.model.DetectAnomaliesRequest;
import software.amazon.awssdk.services.lookoutvision.model.DetectAnomaliesResponse;
import software.amazon.awssdk.services.lookoutvision.model.InternalServerException;
import software.amazon.awssdk.services.lookoutvision.model.ListDatasetEntriesRequest;
import software.amazon.awssdk.services.lookoutvision.model.ListDatasetEntriesResponse;
import software.amazon.awssdk.services.lookoutvision.model.ListModelPackagingJobsRequest;
import software.amazon.awssdk.services.lookoutvision.model.ListModelPackagingJobsResponse;
import software.amazon.awssdk.services.lookoutvision.model.ListModelsRequest;
import software.amazon.awssdk.services.lookoutvision.model.ListModelsResponse;
import software.amazon.awssdk.services.lookoutvision.model.ListProjectsRequest;
import software.amazon.awssdk.services.lookoutvision.model.ListProjectsResponse;
import software.amazon.awssdk.services.lookoutvision.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.lookoutvision.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.lookoutvision.model.LookoutVisionException;
import software.amazon.awssdk.services.lookoutvision.model.ResourceNotFoundException;
import software.amazon.awssdk.services.lookoutvision.model.ServiceQuotaExceededException;
import software.amazon.awssdk.services.lookoutvision.model.StartModelPackagingJobRequest;
import software.amazon.awssdk.services.lookoutvision.model.StartModelPackagingJobResponse;
import software.amazon.awssdk.services.lookoutvision.model.StartModelRequest;
import software.amazon.awssdk.services.lookoutvision.model.StartModelResponse;
import software.amazon.awssdk.services.lookoutvision.model.StopModelRequest;
import software.amazon.awssdk.services.lookoutvision.model.StopModelResponse;
import software.amazon.awssdk.services.lookoutvision.model.TagResourceRequest;
import software.amazon.awssdk.services.lookoutvision.model.TagResourceResponse;
import software.amazon.awssdk.services.lookoutvision.model.ThrottlingException;
import software.amazon.awssdk.services.lookoutvision.model.UntagResourceRequest;
import software.amazon.awssdk.services.lookoutvision.model.UntagResourceResponse;
import software.amazon.awssdk.services.lookoutvision.model.UpdateDatasetEntriesRequest;
import software.amazon.awssdk.services.lookoutvision.model.UpdateDatasetEntriesResponse;
import software.amazon.awssdk.services.lookoutvision.model.ValidationException;
import software.amazon.awssdk.services.lookoutvision.transform.CreateDatasetRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.CreateModelRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.CreateProjectRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.DeleteDatasetRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.DeleteModelRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.DeleteProjectRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.DescribeDatasetRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.DescribeModelPackagingJobRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.DescribeModelRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.DescribeProjectRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.DetectAnomaliesRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.ListDatasetEntriesRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.ListModelPackagingJobsRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.ListModelsRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.ListProjectsRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.StartModelPackagingJobRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.StartModelRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.StopModelRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.lookoutvision.transform.UpdateDatasetEntriesRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;

/**
 * Internal implementation of {@link LookoutVisionAsyncClient}.
 *
 * @see LookoutVisionAsyncClient#builder()
 */
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultLookoutVisionAsyncClient implements LookoutVisionAsyncClient {
    private static final Logger log = LoggerFactory.getLogger(DefaultLookoutVisionAsyncClient.class);

    private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
            .serviceProtocol(AwsServiceProtocol.REST_JSON).build();

    private final AsyncClientHandler clientHandler;

    private final AwsJsonProtocolFactory protocolFactory;

    private final SdkClientConfiguration clientConfiguration;

    protected DefaultLookoutVisionAsyncClient(SdkClientConfiguration clientConfiguration) {
        this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
        this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
        this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
    }

    /**
     * 

* Creates a new dataset in an Amazon Lookout for Vision project. CreateDataset can create a training * or a test dataset from a valid dataset source (DatasetSource). *

*

* If you want a single dataset project, specify train for the value of DatasetType. *

*

* To have a project with separate training and test datasets, call CreateDataset twice. On the first * call, specify train for the value of DatasetType. On the second call, specify * test for the value of DatasetType. *

*

* This operation requires permissions to perform the lookoutvision:CreateDataset operation. *

* * @param createDatasetRequest * @return A Java Future containing the result of the CreateDataset operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • ServiceQuotaExceededException A service quota was exceeded the allowed limit. For more information, * see Limits in Amazon Lookout for Vision in the Amazon Lookout for Vision Developer Guide.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.CreateDataset * @see AWS * API Documentation */ @Override public CompletableFuture createDataset(CreateDatasetRequest createDatasetRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createDatasetRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, createDatasetRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateDataset"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, CreateDatasetResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("CreateDataset").withProtocolMetadata(protocolMetadata) .withMarshaller(new CreateDatasetRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(createDatasetRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Creates a new version of a model within an an Amazon Lookout for Vision project. CreateModel is an * asynchronous operation in which Amazon Lookout for Vision trains, tests, and evaluates a new version of a model. *

*

* To get the current status, check the Status field returned in the response from * DescribeModel. *

*

* If the project has a single dataset, Amazon Lookout for Vision internally splits the dataset to create a training * and a test dataset. If the project has a training and a test dataset, Lookout for Vision uses the respective * datasets to train and test the model. *

*

* After training completes, the evaluation metrics are stored at the location specified in * OutputConfig. *

*

* This operation requires permissions to perform the lookoutvision:CreateModel operation. If you want * to tag your model, you also require permission to the lookoutvision:TagResource operation. *

* * @param createModelRequest * @return A Java Future containing the result of the CreateModel operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • ServiceQuotaExceededException A service quota was exceeded the allowed limit. For more information, * see Limits in Amazon Lookout for Vision in the Amazon Lookout for Vision Developer Guide.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.CreateModel * @see AWS API * Documentation */ @Override public CompletableFuture createModel(CreateModelRequest createModelRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createModelRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, createModelRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateModel"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, CreateModelResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("CreateModel").withProtocolMetadata(protocolMetadata) .withMarshaller(new CreateModelRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(createModelRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Creates an empty Amazon Lookout for Vision project. After you create the project, add a dataset by calling * CreateDataset. *

*

* This operation requires permissions to perform the lookoutvision:CreateProject operation. *

* * @param createProjectRequest * @return A Java Future containing the result of the CreateProject operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • ServiceQuotaExceededException A service quota was exceeded the allowed limit. For more information, * see Limits in Amazon Lookout for Vision in the Amazon Lookout for Vision Developer Guide.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.CreateProject * @see AWS * API Documentation */ @Override public CompletableFuture createProject(CreateProjectRequest createProjectRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createProjectRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, createProjectRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateProject"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, CreateProjectResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("CreateProject").withProtocolMetadata(protocolMetadata) .withMarshaller(new CreateProjectRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(createProjectRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Deletes an existing Amazon Lookout for Vision dataset. *

*

* If your the project has a single dataset, you must create a new dataset before you can create a model. *

*

* If you project has a training dataset and a test dataset consider the following. *

*
    *
  • *

    * If you delete the test dataset, your project reverts to a single dataset project. If you then train the model, * Amazon Lookout for Vision internally splits the remaining dataset into a training and test dataset. *

    *
  • *
  • *

    * If you delete the training dataset, you must create a training dataset before you can create a model. *

    *
  • *
*

* This operation requires permissions to perform the lookoutvision:DeleteDataset operation. *

* * @param deleteDatasetRequest * @return A Java Future containing the result of the DeleteDataset operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.DeleteDataset * @see AWS * API Documentation */ @Override public CompletableFuture deleteDataset(DeleteDatasetRequest deleteDatasetRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteDatasetRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteDatasetRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteDataset"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DeleteDatasetResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DeleteDataset").withProtocolMetadata(protocolMetadata) .withMarshaller(new DeleteDatasetRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(deleteDatasetRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Deletes an Amazon Lookout for Vision model. You can't delete a running model. To stop a running model, use the * StopModel operation. *

*

* It might take a few seconds to delete a model. To determine if a model has been deleted, call ListModels * and check if the version of the model (ModelVersion) is in the Models array. *

*

*

* This operation requires permissions to perform the lookoutvision:DeleteModel operation. *

* * @param deleteModelRequest * @return A Java Future containing the result of the DeleteModel operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.DeleteModel * @see AWS API * Documentation */ @Override public CompletableFuture deleteModel(DeleteModelRequest deleteModelRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteModelRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteModelRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteModel"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DeleteModelResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DeleteModel").withProtocolMetadata(protocolMetadata) .withMarshaller(new DeleteModelRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(deleteModelRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Deletes an Amazon Lookout for Vision project. *

*

* To delete a project, you must first delete each version of the model associated with the project. To delete a * model use the DeleteModel operation. *

*

* You also have to delete the dataset(s) associated with the model. For more information, see DeleteDataset. * The images referenced by the training and test datasets aren't deleted. *

*

* This operation requires permissions to perform the lookoutvision:DeleteProject operation. *

* * @param deleteProjectRequest * @return A Java Future containing the result of the DeleteProject operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.DeleteProject * @see AWS * API Documentation */ @Override public CompletableFuture deleteProject(DeleteProjectRequest deleteProjectRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteProjectRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteProjectRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteProject"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DeleteProjectResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DeleteProject").withProtocolMetadata(protocolMetadata) .withMarshaller(new DeleteProjectRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(deleteProjectRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Describe an Amazon Lookout for Vision dataset. *

*

* This operation requires permissions to perform the lookoutvision:DescribeDataset operation. *

* * @param describeDatasetRequest * @return A Java Future containing the result of the DescribeDataset operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.DescribeDataset * @see AWS * API Documentation */ @Override public CompletableFuture describeDataset(DescribeDatasetRequest describeDatasetRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeDatasetRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, describeDatasetRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeDataset"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DescribeDatasetResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DescribeDataset").withProtocolMetadata(protocolMetadata) .withMarshaller(new DescribeDatasetRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(describeDatasetRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Describes a version of an Amazon Lookout for Vision model. *

*

* This operation requires permissions to perform the lookoutvision:DescribeModel operation. *

* * @param describeModelRequest * @return A Java Future containing the result of the DescribeModel operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.DescribeModel * @see AWS * API Documentation */ @Override public CompletableFuture describeModel(DescribeModelRequest describeModelRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeModelRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, describeModelRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeModel"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DescribeModelResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DescribeModel").withProtocolMetadata(protocolMetadata) .withMarshaller(new DescribeModelRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(describeModelRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Describes an Amazon Lookout for Vision model packaging job. *

*

* This operation requires permissions to perform the lookoutvision:DescribeModelPackagingJob * operation. *

*

* For more information, see Using your Amazon Lookout for Vision model on an edge device in the Amazon * Lookout for Vision Developer Guide. *

* * @param describeModelPackagingJobRequest * @return A Java Future containing the result of the DescribeModelPackagingJob operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.DescribeModelPackagingJob * @see AWS API Documentation */ @Override public CompletableFuture describeModelPackagingJob( DescribeModelPackagingJobRequest describeModelPackagingJobRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeModelPackagingJobRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, describeModelPackagingJobRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeModelPackagingJob"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DescribeModelPackagingJobResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DescribeModelPackagingJob").withProtocolMetadata(protocolMetadata) .withMarshaller(new DescribeModelPackagingJobRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(describeModelPackagingJobRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Describes an Amazon Lookout for Vision project. *

*

* This operation requires permissions to perform the lookoutvision:DescribeProject operation. *

* * @param describeProjectRequest * @return A Java Future containing the result of the DescribeProject operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.DescribeProject * @see AWS * API Documentation */ @Override public CompletableFuture describeProject(DescribeProjectRequest describeProjectRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeProjectRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, describeProjectRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeProject"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DescribeProjectResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DescribeProject").withProtocolMetadata(protocolMetadata) .withMarshaller(new DescribeProjectRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(describeProjectRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Detects anomalies in an image that you supply. *

*

* The response from DetectAnomalies includes a boolean prediction that the image contains one or more * anomalies and a confidence value for the prediction. If the model is an image segmentation model, the response * also includes segmentation information for each type of anomaly found in the image. *

* *

* Before calling DetectAnomalies, you must first start your model with the StartModel * operation. You are charged for the amount of time, in minutes, that a model runs and for the number of anomaly * detection units that your model uses. If you are not using a model, use the StopModel operation to stop * your model. *

*
*

* For more information, see Detecting anomalies in an image in the Amazon Lookout for Vision developer * guide. *

*

* This operation requires permissions to perform the lookoutvision:DetectAnomalies operation. *

* * @param detectAnomaliesRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows ' *

* The unencrypted image bytes that you want to analyze. *

* ' * @return A Java Future containing the result of the DetectAnomalies operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.DetectAnomalies * @see AWS * API Documentation */ @Override public CompletableFuture detectAnomalies(DetectAnomaliesRequest detectAnomaliesRequest, AsyncRequestBody requestBody) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(detectAnomaliesRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, detectAnomaliesRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DetectAnomalies"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DetectAnomaliesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DetectAnomalies") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new DetectAnomaliesRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).requiresLength(true).build()) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withAsyncRequestBody(requestBody).withInput(detectAnomaliesRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Lists the JSON Lines within a dataset. An Amazon Lookout for Vision JSON Line contains the anomaly information * for a single image, including the image location and the assigned label. *

*

* This operation requires permissions to perform the lookoutvision:ListDatasetEntries operation. *

* * @param listDatasetEntriesRequest * @return A Java Future containing the result of the ListDatasetEntries operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.ListDatasetEntries * @see AWS API Documentation */ @Override public CompletableFuture listDatasetEntries(ListDatasetEntriesRequest listDatasetEntriesRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listDatasetEntriesRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listDatasetEntriesRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListDatasetEntries"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListDatasetEntriesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListDatasetEntries").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListDatasetEntriesRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listDatasetEntriesRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Lists the model packaging jobs created for an Amazon Lookout for Vision project. *

*

* This operation requires permissions to perform the lookoutvision:ListModelPackagingJobs operation. *

*

* For more information, see Using your Amazon Lookout for Vision model on an edge device in the Amazon * Lookout for Vision Developer Guide. *

* * @param listModelPackagingJobsRequest * @return A Java Future containing the result of the ListModelPackagingJobs operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.ListModelPackagingJobs * @see AWS API Documentation */ @Override public CompletableFuture listModelPackagingJobs( ListModelPackagingJobsRequest listModelPackagingJobsRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listModelPackagingJobsRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listModelPackagingJobsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListModelPackagingJobs"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListModelPackagingJobsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListModelPackagingJobs").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListModelPackagingJobsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listModelPackagingJobsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Lists the versions of a model in an Amazon Lookout for Vision project. *

*

* The ListModels operation is eventually consistent. Recent calls to CreateModel might * take a while to appear in the response from ListProjects. *

*

* This operation requires permissions to perform the lookoutvision:ListModels operation. *

* * @param listModelsRequest * @return A Java Future containing the result of the ListModels operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.ListModels * @see AWS API * Documentation */ @Override public CompletableFuture listModels(ListModelsRequest listModelsRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listModelsRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listModelsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListModels"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListModelsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams().withOperationName("ListModels") .withProtocolMetadata(protocolMetadata) .withMarshaller(new ListModelsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listModelsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Lists the Amazon Lookout for Vision projects in your AWS account that are in the AWS Region in which you call * ListProjects. *

*

* The ListProjects operation is eventually consistent. Recent calls to CreateProject and * DeleteProject might take a while to appear in the response from ListProjects. *

*

* This operation requires permissions to perform the lookoutvision:ListProjects operation. *

* * @param listProjectsRequest * @return A Java Future containing the result of the ListProjects operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.ListProjects * @see AWS * API Documentation */ @Override public CompletableFuture listProjects(ListProjectsRequest listProjectsRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listProjectsRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listProjectsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListProjects"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListProjectsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListProjects").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListProjectsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listProjectsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Returns a list of tags attached to the specified Amazon Lookout for Vision model. *

*

* This operation requires permissions to perform the lookoutvision:ListTagsForResource operation. *

* * @param listTagsForResourceRequest * @return A Java Future containing the result of the ListTagsForResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.ListTagsForResource * @see AWS API Documentation */ @Override public CompletableFuture listTagsForResource( ListTagsForResourceRequest listTagsForResourceRequest) { 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, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListTagsForResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListTagsForResource").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listTagsForResourceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Starts the running of the version of an Amazon Lookout for Vision model. Starting a model takes a while to * complete. To check the current state of the model, use DescribeModel. *

*

* A model is ready to use when its status is HOSTED. *

*

* Once the model is running, you can detect custom labels in new images by calling DetectAnomalies. *

* *

* You are charged for the amount of time that the model is running. To stop a running model, call StopModel. *

*
*

* This operation requires permissions to perform the lookoutvision:StartModel operation. *

* * @param startModelRequest * @return A Java Future containing the result of the StartModel operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • ServiceQuotaExceededException A service quota was exceeded the allowed limit. For more information, * see Limits in Amazon Lookout for Vision in the Amazon Lookout for Vision Developer Guide.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.StartModel * @see AWS API * Documentation */ @Override public CompletableFuture startModel(StartModelRequest startModelRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(startModelRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, startModelRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StartModel"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, StartModelResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams().withOperationName("StartModel") .withProtocolMetadata(protocolMetadata) .withMarshaller(new StartModelRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(startModelRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Starts an Amazon Lookout for Vision model packaging job. A model packaging job creates an AWS IoT Greengrass * component for a Lookout for Vision model. You can use the component to deploy your model to an edge device * managed by Greengrass. *

*

* Use the DescribeModelPackagingJob API to determine the current status of the job. The model packaging job * is complete if the value of Status is SUCCEEDED. *

*

* To deploy the component to the target device, use the component name and component version with the AWS IoT * Greengrass CreateDeployment API. *

*

* This operation requires the following permissions: *

*
    *
  • *

    * lookoutvision:StartModelPackagingJob *

    *
  • *
  • *

    * s3:PutObject *

    *
  • *
  • *

    * s3:GetBucketLocation *

    *
  • *
  • *

    * kms:GenerateDataKey *

    *
  • *
  • *

    * greengrass:CreateComponentVersion *

    *
  • *
  • *

    * greengrass:DescribeComponent *

    *
  • *
  • *

    * (Optional) greengrass:TagResource. Only required if you want to tag the component. *

    *
  • *
*

* For more information, see Using your Amazon Lookout for Vision model on an edge device in the Amazon * Lookout for Vision Developer Guide. *

* * @param startModelPackagingJobRequest * @return A Java Future containing the result of the StartModelPackagingJob operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • ServiceQuotaExceededException A service quota was exceeded the allowed limit. For more information, * see Limits in Amazon Lookout for Vision in the Amazon Lookout for Vision Developer Guide.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.StartModelPackagingJob * @see AWS API Documentation */ @Override public CompletableFuture startModelPackagingJob( StartModelPackagingJobRequest startModelPackagingJobRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(startModelPackagingJobRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, startModelPackagingJobRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StartModelPackagingJob"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, StartModelPackagingJobResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("StartModelPackagingJob").withProtocolMetadata(protocolMetadata) .withMarshaller(new StartModelPackagingJobRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(startModelPackagingJobRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Stops the hosting of a running model. The operation might take a while to complete. To check the current status, * call DescribeModel. *

*

* After the model hosting stops, the Status of the model is TRAINED. *

*

* This operation requires permissions to perform the lookoutvision:StopModel operation. *

* * @param stopModelRequest * @return A Java Future containing the result of the StopModel operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.StopModel * @see AWS API * Documentation */ @Override public CompletableFuture stopModel(StopModelRequest stopModelRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(stopModelRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, stopModelRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StopModel"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, StopModelResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams().withOperationName("StopModel") .withProtocolMetadata(protocolMetadata) .withMarshaller(new StopModelRequestMarshaller(protocolFactory)).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withInput(stopModelRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Adds one or more key-value tags to an Amazon Lookout for Vision model. For more information, see Tagging a * model in the Amazon Lookout for Vision Developer Guide. *

*

* This operation requires permissions to perform the lookoutvision:TagResource operation. *

* * @param tagResourceRequest * @return A Java Future containing the result of the TagResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • ServiceQuotaExceededException A service quota was exceeded the allowed limit. For more information, * see Limits in Amazon Lookout for Vision in the Amazon Lookout for Vision Developer Guide.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.TagResource * @see AWS API * Documentation */ @Override public CompletableFuture tagResource(TagResourceRequest tagResourceRequest) { 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, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, TagResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("TagResource").withProtocolMetadata(protocolMetadata) .withMarshaller(new TagResourceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(tagResourceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Removes one or more tags from an Amazon Lookout for Vision model. For more information, see Tagging a * model in the Amazon Lookout for Vision Developer Guide. *

*

* This operation requires permissions to perform the lookoutvision:UntagResource operation. *

* * @param untagResourceRequest * @return A Java Future containing the result of the UntagResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.UntagResource * @see AWS * API Documentation */ @Override public CompletableFuture untagResource(UntagResourceRequest untagResourceRequest) { 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, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UntagResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("UntagResource").withProtocolMetadata(protocolMetadata) .withMarshaller(new UntagResourceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(untagResourceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Adds or updates one or more JSON Line entries in a dataset. A JSON Line includes information about an image used * for training or testing an Amazon Lookout for Vision model. *

*

* To update an existing JSON Line, use the source-ref field to identify the JSON Line. The JSON line * that you supply replaces the existing JSON line. Any existing annotations that are not in the new JSON line are * removed from the dataset. *

*

* For more information, see Defining JSON lines for anomaly classification in the Amazon Lookout for Vision * Developer Guide. *

* *

* The images you reference in the source-ref field of a JSON line, must be in the same S3 bucket as * the existing images in the dataset. *

*
*

* Updating a dataset might take a while to complete. To check the current status, call DescribeDataset and * check the Status field in the response. *

*

* This operation requires permissions to perform the lookoutvision:UpdateDatasetEntries operation. *

* * @param updateDatasetEntriesRequest * @return A Java Future containing the result of the UpdateDatasetEntries operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • AccessDeniedException You are not authorized to perform the action.
  • *
  • InternalServerException Amazon Lookout for Vision experienced a service issue. Try your call again.
  • *
  • ValidationException An input validation error occured. For example, invalid characters in a project * name, or if a pagination token is invalid.
  • *
  • ConflictException The update or deletion of a resource caused an inconsistent state.
  • *
  • ResourceNotFoundException The resource could not be found.
  • *
  • ThrottlingException Amazon Lookout for Vision is temporarily unable to process the request. Try your * call again.
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • LookoutVisionException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.
  • *
* @sample LookoutVisionAsyncClient.UpdateDatasetEntries * @see AWS API Documentation */ @Override public CompletableFuture updateDatasetEntries( UpdateDatasetEntriesRequest updateDatasetEntriesRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateDatasetEntriesRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, updateDatasetEntriesRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "LookoutVision"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateDatasetEntries"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, UpdateDatasetEntriesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("UpdateDatasetEntries").withProtocolMetadata(protocolMetadata) .withMarshaller(new UpdateDatasetEntriesRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(updateDatasetEntriesRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final LookoutVisionServiceClientConfiguration serviceClientConfiguration() { return new LookoutVisionServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private > T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(LookoutVisionException::builder) .protocol(AwsJsonProtocol.REST_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("AccessDeniedException") .exceptionBuilderSupplier(AccessDeniedException::builder).httpStatusCode(403).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ConflictException") .exceptionBuilderSupplier(ConflictException::builder).httpStatusCode(409).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ResourceNotFoundException") .exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(404).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ThrottlingException") .exceptionBuilderSupplier(ThrottlingException::builder).httpStatusCode(429).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ValidationException") .exceptionBuilderSupplier(ValidationException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ServiceQuotaExceededException") .exceptionBuilderSupplier(ServiceQuotaExceededException::builder).httpStatusCode(402).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InternalServerException") .exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(500).build()); } 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 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(); } LookoutVisionServiceClientConfigurationBuilder serviceConfigBuilder = new LookoutVisionServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } updateRetryStrategyClientConfiguration(configuration); return configuration.build(); } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy