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

software.amazon.awssdk.services.transcribe.DefaultTranscribeClient Maven / Gradle / Ivy

Go to download

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

There is a newer version: 2.29.39
Show newest version
/*
 * Copyright 2014-2019 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.transcribe;

import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.client.handler.SyncClientHandler;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.util.VersionInfo;
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.services.transcribe.model.BadRequestException;
import software.amazon.awssdk.services.transcribe.model.ConflictException;
import software.amazon.awssdk.services.transcribe.model.CreateVocabularyRequest;
import software.amazon.awssdk.services.transcribe.model.CreateVocabularyResponse;
import software.amazon.awssdk.services.transcribe.model.DeleteTranscriptionJobRequest;
import software.amazon.awssdk.services.transcribe.model.DeleteTranscriptionJobResponse;
import software.amazon.awssdk.services.transcribe.model.DeleteVocabularyRequest;
import software.amazon.awssdk.services.transcribe.model.DeleteVocabularyResponse;
import software.amazon.awssdk.services.transcribe.model.GetTranscriptionJobRequest;
import software.amazon.awssdk.services.transcribe.model.GetTranscriptionJobResponse;
import software.amazon.awssdk.services.transcribe.model.GetVocabularyRequest;
import software.amazon.awssdk.services.transcribe.model.GetVocabularyResponse;
import software.amazon.awssdk.services.transcribe.model.InternalFailureException;
import software.amazon.awssdk.services.transcribe.model.LimitExceededException;
import software.amazon.awssdk.services.transcribe.model.ListTranscriptionJobsRequest;
import software.amazon.awssdk.services.transcribe.model.ListTranscriptionJobsResponse;
import software.amazon.awssdk.services.transcribe.model.ListVocabulariesRequest;
import software.amazon.awssdk.services.transcribe.model.ListVocabulariesResponse;
import software.amazon.awssdk.services.transcribe.model.NotFoundException;
import software.amazon.awssdk.services.transcribe.model.StartTranscriptionJobRequest;
import software.amazon.awssdk.services.transcribe.model.StartTranscriptionJobResponse;
import software.amazon.awssdk.services.transcribe.model.TranscribeException;
import software.amazon.awssdk.services.transcribe.model.TranscribeRequest;
import software.amazon.awssdk.services.transcribe.model.UpdateVocabularyRequest;
import software.amazon.awssdk.services.transcribe.model.UpdateVocabularyResponse;
import software.amazon.awssdk.services.transcribe.paginators.ListTranscriptionJobsIterable;
import software.amazon.awssdk.services.transcribe.paginators.ListVocabulariesIterable;
import software.amazon.awssdk.services.transcribe.transform.CreateVocabularyRequestMarshaller;
import software.amazon.awssdk.services.transcribe.transform.DeleteTranscriptionJobRequestMarshaller;
import software.amazon.awssdk.services.transcribe.transform.DeleteVocabularyRequestMarshaller;
import software.amazon.awssdk.services.transcribe.transform.GetTranscriptionJobRequestMarshaller;
import software.amazon.awssdk.services.transcribe.transform.GetVocabularyRequestMarshaller;
import software.amazon.awssdk.services.transcribe.transform.ListTranscriptionJobsRequestMarshaller;
import software.amazon.awssdk.services.transcribe.transform.ListVocabulariesRequestMarshaller;
import software.amazon.awssdk.services.transcribe.transform.StartTranscriptionJobRequestMarshaller;
import software.amazon.awssdk.services.transcribe.transform.UpdateVocabularyRequestMarshaller;

/**
 * Internal implementation of {@link TranscribeClient}.
 *
 * @see TranscribeClient#builder()
 */
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultTranscribeClient implements TranscribeClient {
    private final SyncClientHandler clientHandler;

    private final AwsJsonProtocolFactory protocolFactory;

    private final SdkClientConfiguration clientConfiguration;

    protected DefaultTranscribeClient(SdkClientConfiguration clientConfiguration) {
        this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
        this.clientConfiguration = clientConfiguration;
        this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
    }

    @Override
    public final String serviceName() {
        return SERVICE_NAME;
    }

    /**
     * 

* Creates a new custom vocabulary that you can use to change the way Amazon Transcribe handles transcription of an * audio file. *

* * @param createVocabularyRequest * @return Result of the CreateVocabulary operation returned by the service. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws ConflictException * When you are using the StartTranscriptionJob operation, the JobName field is a * duplicate of a previously entered job name. Resend your request with a different name.

*

* When you are using the UpdateVocabulary operation, there are two jobs running at the same * time. Resend the second request later. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.CreateVocabulary * @see AWS * API Documentation */ @Override public CreateVocabularyResponse createVocabulary(CreateVocabularyRequest createVocabularyRequest) throws BadRequestException, LimitExceededException, InternalFailureException, ConflictException, AwsServiceException, SdkClientException, TranscribeException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, CreateVocabularyResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); return clientHandler.execute(new ClientExecutionParams() .withOperationName("CreateVocabulary").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(createVocabularyRequest) .withMarshaller(new CreateVocabularyRequestMarshaller(protocolFactory))); } /** *

* Deletes a previously submitted transcription job along with any other generated results such as the * transcription, models, and so on. *

* * @param deleteTranscriptionJobRequest * @return Result of the DeleteTranscriptionJob operation returned by the service. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.DeleteTranscriptionJob * @see AWS API Documentation */ @Override public DeleteTranscriptionJobResponse deleteTranscriptionJob(DeleteTranscriptionJobRequest deleteTranscriptionJobRequest) throws LimitExceededException, BadRequestException, InternalFailureException, AwsServiceException, SdkClientException, TranscribeException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DeleteTranscriptionJobResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); return clientHandler.execute(new ClientExecutionParams() .withOperationName("DeleteTranscriptionJob").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(deleteTranscriptionJobRequest) .withMarshaller(new DeleteTranscriptionJobRequestMarshaller(protocolFactory))); } /** *

* Deletes a vocabulary from Amazon Transcribe. *

* * @param deleteVocabularyRequest * @return Result of the DeleteVocabulary operation returned by the service. * @throws NotFoundException * We can't find the requested resource. Check the name and try your request again. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.DeleteVocabulary * @see AWS * API Documentation */ @Override public DeleteVocabularyResponse deleteVocabulary(DeleteVocabularyRequest deleteVocabularyRequest) throws NotFoundException, LimitExceededException, BadRequestException, InternalFailureException, AwsServiceException, SdkClientException, TranscribeException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DeleteVocabularyResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); return clientHandler.execute(new ClientExecutionParams() .withOperationName("DeleteVocabulary").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(deleteVocabularyRequest) .withMarshaller(new DeleteVocabularyRequestMarshaller(protocolFactory))); } /** *

* Returns information about a transcription job. To see the status of the job, check the * TranscriptionJobStatus field. If the status is COMPLETED, the job is finished and you * can find the results at the location specified in the TranscriptionFileUri field. *

* * @param getTranscriptionJobRequest * @return Result of the GetTranscriptionJob operation returned by the service. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws NotFoundException * We can't find the requested resource. Check the name and try your request again. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.GetTranscriptionJob * @see AWS * API Documentation */ @Override public GetTranscriptionJobResponse getTranscriptionJob(GetTranscriptionJobRequest getTranscriptionJobRequest) throws BadRequestException, LimitExceededException, InternalFailureException, NotFoundException, AwsServiceException, SdkClientException, TranscribeException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetTranscriptionJobResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); return clientHandler.execute(new ClientExecutionParams() .withOperationName("GetTranscriptionJob").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(getTranscriptionJobRequest) .withMarshaller(new GetTranscriptionJobRequestMarshaller(protocolFactory))); } /** *

* Gets information about a vocabulary. *

* * @param getVocabularyRequest * @return Result of the GetVocabulary operation returned by the service. * @throws NotFoundException * We can't find the requested resource. Check the name and try your request again. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.GetVocabulary * @see AWS API * Documentation */ @Override public GetVocabularyResponse getVocabulary(GetVocabularyRequest getVocabularyRequest) throws NotFoundException, LimitExceededException, InternalFailureException, BadRequestException, AwsServiceException, SdkClientException, TranscribeException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, GetVocabularyResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); return clientHandler.execute(new ClientExecutionParams() .withOperationName("GetVocabulary").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(getVocabularyRequest) .withMarshaller(new GetVocabularyRequestMarshaller(protocolFactory))); } /** *

* Lists transcription jobs with the specified status. *

* * @param listTranscriptionJobsRequest * @return Result of the ListTranscriptionJobs operation returned by the service. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.ListTranscriptionJobs * @see AWS API Documentation */ @Override public ListTranscriptionJobsResponse listTranscriptionJobs(ListTranscriptionJobsRequest listTranscriptionJobsRequest) throws BadRequestException, LimitExceededException, InternalFailureException, AwsServiceException, SdkClientException, TranscribeException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListTranscriptionJobsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); return clientHandler.execute(new ClientExecutionParams() .withOperationName("ListTranscriptionJobs").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(listTranscriptionJobsRequest) .withMarshaller(new ListTranscriptionJobsRequestMarshaller(protocolFactory))); } /** *

* Lists transcription jobs with the specified status. *

*
*

* This is a variant of * {@link #listTranscriptionJobs(software.amazon.awssdk.services.transcribe.model.ListTranscriptionJobsRequest)} * operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will * internally handle making service calls for you. *

*

* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. *

* *

* The following are few ways to iterate through the response pages: *

* 1) Using a Stream * *
     * {@code
     * software.amazon.awssdk.services.transcribe.paginators.ListTranscriptionJobsIterable responses = client.listTranscriptionJobsPaginator(request);
     * responses.stream().forEach(....);
     * }
     * 
* * 2) Using For loop * *
     * {
     *     @code
     *     software.amazon.awssdk.services.transcribe.paginators.ListTranscriptionJobsIterable responses = client
     *             .listTranscriptionJobsPaginator(request);
     *     for (software.amazon.awssdk.services.transcribe.model.ListTranscriptionJobsResponse response : responses) {
     *         // do something;
     *     }
     * }
     * 
* * 3) Use iterator directly * *
     * {@code
     * software.amazon.awssdk.services.transcribe.paginators.ListTranscriptionJobsIterable responses = client.listTranscriptionJobsPaginator(request);
     * responses.iterator().forEachRemaining(....);
     * }
     * 
*

* Note: If you prefer to have control on service calls, use the * {@link #listTranscriptionJobs(software.amazon.awssdk.services.transcribe.model.ListTranscriptionJobsRequest)} * operation. *

* * @param listTranscriptionJobsRequest * @return A custom iterable that can be used to iterate through all the response pages. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.ListTranscriptionJobs * @see AWS API Documentation */ @Override public ListTranscriptionJobsIterable listTranscriptionJobsPaginator(ListTranscriptionJobsRequest listTranscriptionJobsRequest) throws BadRequestException, LimitExceededException, InternalFailureException, AwsServiceException, SdkClientException, TranscribeException { return new ListTranscriptionJobsIterable(this, applyPaginatorUserAgent(listTranscriptionJobsRequest)); } /** *

* Returns a list of vocabularies that match the specified criteria. If no criteria are specified, returns the * entire list of vocabularies. *

* * @param listVocabulariesRequest * @return Result of the ListVocabularies operation returned by the service. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.ListVocabularies * @see AWS * API Documentation */ @Override public ListVocabulariesResponse listVocabularies(ListVocabulariesRequest listVocabulariesRequest) throws BadRequestException, LimitExceededException, InternalFailureException, AwsServiceException, SdkClientException, TranscribeException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListVocabulariesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); return clientHandler.execute(new ClientExecutionParams() .withOperationName("ListVocabularies").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(listVocabulariesRequest) .withMarshaller(new ListVocabulariesRequestMarshaller(protocolFactory))); } /** *

* Returns a list of vocabularies that match the specified criteria. If no criteria are specified, returns the * entire list of vocabularies. *

*
*

* This is a variant of * {@link #listVocabularies(software.amazon.awssdk.services.transcribe.model.ListVocabulariesRequest)} operation. * The return type is a custom iterable that can be used to iterate through all the pages. SDK will internally * handle making service calls for you. *

*

* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. *

* *

* The following are few ways to iterate through the response pages: *

* 1) Using a Stream * *
     * {@code
     * software.amazon.awssdk.services.transcribe.paginators.ListVocabulariesIterable responses = client.listVocabulariesPaginator(request);
     * responses.stream().forEach(....);
     * }
     * 
* * 2) Using For loop * *
     * {
     *     @code
     *     software.amazon.awssdk.services.transcribe.paginators.ListVocabulariesIterable responses = client
     *             .listVocabulariesPaginator(request);
     *     for (software.amazon.awssdk.services.transcribe.model.ListVocabulariesResponse response : responses) {
     *         // do something;
     *     }
     * }
     * 
* * 3) Use iterator directly * *
     * {@code
     * software.amazon.awssdk.services.transcribe.paginators.ListVocabulariesIterable responses = client.listVocabulariesPaginator(request);
     * responses.iterator().forEachRemaining(....);
     * }
     * 
*

* Note: If you prefer to have control on service calls, use the * {@link #listVocabularies(software.amazon.awssdk.services.transcribe.model.ListVocabulariesRequest)} * operation. *

* * @param listVocabulariesRequest * @return A custom iterable that can be used to iterate through all the response pages. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.ListVocabularies * @see AWS * API Documentation */ @Override public ListVocabulariesIterable listVocabulariesPaginator(ListVocabulariesRequest listVocabulariesRequest) throws BadRequestException, LimitExceededException, InternalFailureException, AwsServiceException, SdkClientException, TranscribeException { return new ListVocabulariesIterable(this, applyPaginatorUserAgent(listVocabulariesRequest)); } /** *

* Starts an asynchronous job to transcribe speech to text. *

* * @param startTranscriptionJobRequest * @return Result of the StartTranscriptionJob operation returned by the service. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws ConflictException * When you are using the StartTranscriptionJob operation, the JobName field is a * duplicate of a previously entered job name. Resend your request with a different name.

*

* When you are using the UpdateVocabulary operation, there are two jobs running at the same * time. Resend the second request later. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.StartTranscriptionJob * @see AWS API Documentation */ @Override public StartTranscriptionJobResponse startTranscriptionJob(StartTranscriptionJobRequest startTranscriptionJobRequest) throws BadRequestException, LimitExceededException, InternalFailureException, ConflictException, AwsServiceException, SdkClientException, TranscribeException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, StartTranscriptionJobResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); return clientHandler.execute(new ClientExecutionParams() .withOperationName("StartTranscriptionJob").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(startTranscriptionJobRequest) .withMarshaller(new StartTranscriptionJobRequestMarshaller(protocolFactory))); } /** *

* Updates an existing vocabulary with new values. The UpdateVocabulary operation overwrites all of the * existing information with the values that you provide in the request. *

* * @param updateVocabularyRequest * @return Result of the UpdateVocabulary operation returned by the service. * @throws BadRequestException * Your request didn't pass one or more validation tests. For example, if the transcription you're trying to * delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the * exception Message field for more information. * @throws LimitExceededException * Either you have sent too many requests or your input file is too long. Wait before you resend your * request, or use a smaller file and resend the request. * @throws InternalFailureException * There was an internal error. Check the error message and try your request again. * @throws NotFoundException * We can't find the requested resource. Check the name and try your request again. * @throws ConflictException * When you are using the StartTranscriptionJob operation, the JobName field is a * duplicate of a previously entered job name. Resend your request with a different name.

*

* When you are using the UpdateVocabulary operation, there are two jobs running at the same * time. Resend the second request later. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws TranscribeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample TranscribeClient.UpdateVocabulary * @see AWS * API Documentation */ @Override public UpdateVocabularyResponse updateVocabulary(UpdateVocabularyRequest updateVocabularyRequest) throws BadRequestException, LimitExceededException, InternalFailureException, NotFoundException, ConflictException, AwsServiceException, SdkClientException, TranscribeException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UpdateVocabularyResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); return clientHandler.execute(new ClientExecutionParams() .withOperationName("UpdateVocabulary").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(updateVocabularyRequest) .withMarshaller(new UpdateVocabularyRequestMarshaller(protocolFactory))); } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } private > T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(TranscribeException::builder) .protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("ConflictException") .exceptionBuilderSupplier(ConflictException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("NotFoundException") .exceptionBuilderSupplier(NotFoundException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InternalFailureException") .exceptionBuilderSupplier(InternalFailureException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("BadRequestException") .exceptionBuilderSupplier(BadRequestException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("LimitExceededException") .exceptionBuilderSupplier(LimitExceededException::builder).build()); } @Override public void close() { clientHandler.close(); } private T applyPaginatorUserAgent(T request) { Consumer userAgentApplier = b -> b.addApiName(ApiName.builder() .version(VersionInfo.SDK_VERSION).name("PAGINATED").build()); AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration() .map(c -> c.toBuilder().applyMutation(userAgentApplier).build()) .orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build())); return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy