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

com.amazonaws.services.lookoutforvision.AmazonLookoutforVisionAsyncClient Maven / Gradle / Ivy

/*
 * Copyright 2016-2021 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 com.amazonaws.services.lookoutforvision;

import javax.annotation.Generated;

import com.amazonaws.services.lookoutforvision.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;

import java.util.concurrent.ExecutorService;

/**
 * Client for accessing Amazon Lookout for Vision asynchronously. Each asynchronous method will return a Java Future
 * object representing the asynchronous operation; overloads which accept an {@code AsyncHandler} can be used to receive
 * notification when an asynchronous operation completes.
 * 

*

* This is the Amazon Lookout for Vision API Reference. It provides descriptions of actions, data types, common * parameters, and common errors. *

*

* Amazon Lookout for Vision enables you to find visual defects in industrial products, accurately and at scale. It uses * computer vision to identify missing components in an industrial product, damage to vehicles or structures, * irregularities in production lines, and even minuscule defects in silicon wafers — or any other physical item where * quality is important such as a missing capacitor on printed circuit boards. *

*/ @ThreadSafe @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AmazonLookoutforVisionAsyncClient extends AmazonLookoutforVisionClient implements AmazonLookoutforVisionAsync { private static final int DEFAULT_THREAD_POOL_SIZE = 50; private final java.util.concurrent.ExecutorService executorService; public static AmazonLookoutforVisionAsyncClientBuilder asyncBuilder() { return AmazonLookoutforVisionAsyncClientBuilder.standard(); } /** * Constructs a new asynchronous client to invoke service methods on Amazon Lookout for Vision using the specified * parameters. * * @param asyncClientParams * Object providing client parameters. */ AmazonLookoutforVisionAsyncClient(AwsAsyncClientParams asyncClientParams) { this(asyncClientParams, false); } /** * Constructs a new asynchronous client to invoke service methods on Amazon Lookout for Vision using the specified * parameters. * * @param asyncClientParams * Object providing client parameters. * @param endpointDiscoveryEnabled * true will enable endpoint discovery if the service supports it. */ AmazonLookoutforVisionAsyncClient(AwsAsyncClientParams asyncClientParams, boolean endpointDiscoveryEnabled) { super(asyncClientParams, endpointDiscoveryEnabled); this.executorService = asyncClientParams.getExecutor(); } /** * Returns the executor service used by this client to execute async requests. * * @return The executor service used by this client to execute async requests. */ public ExecutorService getExecutorService() { return executorService; } @Override public java.util.concurrent.Future createDatasetAsync(CreateDatasetRequest request) { return createDatasetAsync(request, null); } @Override public java.util.concurrent.Future createDatasetAsync(final CreateDatasetRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final CreateDatasetRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public CreateDatasetResult call() throws Exception { CreateDatasetResult result = null; try { result = executeCreateDataset(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future createModelAsync(CreateModelRequest request) { return createModelAsync(request, null); } @Override public java.util.concurrent.Future createModelAsync(final CreateModelRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final CreateModelRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public CreateModelResult call() throws Exception { CreateModelResult result = null; try { result = executeCreateModel(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future createProjectAsync(CreateProjectRequest request) { return createProjectAsync(request, null); } @Override public java.util.concurrent.Future createProjectAsync(final CreateProjectRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final CreateProjectRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public CreateProjectResult call() throws Exception { CreateProjectResult result = null; try { result = executeCreateProject(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future deleteDatasetAsync(DeleteDatasetRequest request) { return deleteDatasetAsync(request, null); } @Override public java.util.concurrent.Future deleteDatasetAsync(final DeleteDatasetRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final DeleteDatasetRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public DeleteDatasetResult call() throws Exception { DeleteDatasetResult result = null; try { result = executeDeleteDataset(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future deleteModelAsync(DeleteModelRequest request) { return deleteModelAsync(request, null); } @Override public java.util.concurrent.Future deleteModelAsync(final DeleteModelRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final DeleteModelRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public DeleteModelResult call() throws Exception { DeleteModelResult result = null; try { result = executeDeleteModel(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future deleteProjectAsync(DeleteProjectRequest request) { return deleteProjectAsync(request, null); } @Override public java.util.concurrent.Future deleteProjectAsync(final DeleteProjectRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final DeleteProjectRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public DeleteProjectResult call() throws Exception { DeleteProjectResult result = null; try { result = executeDeleteProject(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future describeDatasetAsync(DescribeDatasetRequest request) { return describeDatasetAsync(request, null); } @Override public java.util.concurrent.Future describeDatasetAsync(final DescribeDatasetRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final DescribeDatasetRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public DescribeDatasetResult call() throws Exception { DescribeDatasetResult result = null; try { result = executeDescribeDataset(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future describeModelAsync(DescribeModelRequest request) { return describeModelAsync(request, null); } @Override public java.util.concurrent.Future describeModelAsync(final DescribeModelRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final DescribeModelRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public DescribeModelResult call() throws Exception { DescribeModelResult result = null; try { result = executeDescribeModel(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future describeProjectAsync(DescribeProjectRequest request) { return describeProjectAsync(request, null); } @Override public java.util.concurrent.Future describeProjectAsync(final DescribeProjectRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final DescribeProjectRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public DescribeProjectResult call() throws Exception { DescribeProjectResult result = null; try { result = executeDescribeProject(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future detectAnomaliesAsync(DetectAnomaliesRequest request) { return detectAnomaliesAsync(request, null); } @Override public java.util.concurrent.Future detectAnomaliesAsync(final DetectAnomaliesRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final DetectAnomaliesRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public DetectAnomaliesResult call() throws Exception { DetectAnomaliesResult result = null; try { result = executeDetectAnomalies(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future listDatasetEntriesAsync(ListDatasetEntriesRequest request) { return listDatasetEntriesAsync(request, null); } @Override public java.util.concurrent.Future listDatasetEntriesAsync(final ListDatasetEntriesRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final ListDatasetEntriesRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public ListDatasetEntriesResult call() throws Exception { ListDatasetEntriesResult result = null; try { result = executeListDatasetEntries(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future listModelsAsync(ListModelsRequest request) { return listModelsAsync(request, null); } @Override public java.util.concurrent.Future listModelsAsync(final ListModelsRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final ListModelsRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public ListModelsResult call() throws Exception { ListModelsResult result = null; try { result = executeListModels(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future listProjectsAsync(ListProjectsRequest request) { return listProjectsAsync(request, null); } @Override public java.util.concurrent.Future listProjectsAsync(final ListProjectsRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final ListProjectsRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public ListProjectsResult call() throws Exception { ListProjectsResult result = null; try { result = executeListProjects(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future listTagsForResourceAsync(ListTagsForResourceRequest request) { return listTagsForResourceAsync(request, null); } @Override public java.util.concurrent.Future listTagsForResourceAsync(final ListTagsForResourceRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final ListTagsForResourceRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public ListTagsForResourceResult call() throws Exception { ListTagsForResourceResult result = null; try { result = executeListTagsForResource(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future startModelAsync(StartModelRequest request) { return startModelAsync(request, null); } @Override public java.util.concurrent.Future startModelAsync(final StartModelRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final StartModelRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public StartModelResult call() throws Exception { StartModelResult result = null; try { result = executeStartModel(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future stopModelAsync(StopModelRequest request) { return stopModelAsync(request, null); } @Override public java.util.concurrent.Future stopModelAsync(final StopModelRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final StopModelRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public StopModelResult call() throws Exception { StopModelResult result = null; try { result = executeStopModel(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future tagResourceAsync(TagResourceRequest request) { return tagResourceAsync(request, null); } @Override public java.util.concurrent.Future tagResourceAsync(final TagResourceRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final TagResourceRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public TagResourceResult call() throws Exception { TagResourceResult result = null; try { result = executeTagResource(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future untagResourceAsync(UntagResourceRequest request) { return untagResourceAsync(request, null); } @Override public java.util.concurrent.Future untagResourceAsync(final UntagResourceRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final UntagResourceRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public UntagResourceResult call() throws Exception { UntagResourceResult result = null; try { result = executeUntagResource(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future updateDatasetEntriesAsync(UpdateDatasetEntriesRequest request) { return updateDatasetEntriesAsync(request, null); } @Override public java.util.concurrent.Future updateDatasetEntriesAsync(final UpdateDatasetEntriesRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final UpdateDatasetEntriesRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public UpdateDatasetEntriesResult call() throws Exception { UpdateDatasetEntriesResult result = null; try { result = executeUpdateDatasetEntries(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } /** * Shuts down the client, releasing all managed resources. This includes forcibly terminating all pending * asynchronous service calls. Clients who wish to give pending asynchronous service calls time to complete should * call {@code getExecutorService().shutdown()} followed by {@code getExecutorService().awaitTermination()} prior to * calling this method. */ @Override public void shutdown() { super.shutdown(); executorService.shutdownNow(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy