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

com.google.cloud.translate.v3.stub.GrpcTranslationServiceStub Maven / Gradle / Ivy

There is a newer version: 2.54.0
Show newest version
/*
 * Copyright 2024 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License 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.google.cloud.translate.v3.stub;

import static com.google.cloud.translate.v3.TranslationServiceClient.ListAdaptiveMtDatasetsPagedResponse;
import static com.google.cloud.translate.v3.TranslationServiceClient.ListAdaptiveMtFilesPagedResponse;
import static com.google.cloud.translate.v3.TranslationServiceClient.ListAdaptiveMtSentencesPagedResponse;
import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossariesPagedResponse;

import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.translate.v3.AdaptiveMtDataset;
import com.google.cloud.translate.v3.AdaptiveMtFile;
import com.google.cloud.translate.v3.AdaptiveMtTranslateRequest;
import com.google.cloud.translate.v3.AdaptiveMtTranslateResponse;
import com.google.cloud.translate.v3.BatchTranslateDocumentMetadata;
import com.google.cloud.translate.v3.BatchTranslateDocumentRequest;
import com.google.cloud.translate.v3.BatchTranslateDocumentResponse;
import com.google.cloud.translate.v3.BatchTranslateMetadata;
import com.google.cloud.translate.v3.BatchTranslateResponse;
import com.google.cloud.translate.v3.BatchTranslateTextRequest;
import com.google.cloud.translate.v3.CreateAdaptiveMtDatasetRequest;
import com.google.cloud.translate.v3.CreateGlossaryMetadata;
import com.google.cloud.translate.v3.CreateGlossaryRequest;
import com.google.cloud.translate.v3.DeleteAdaptiveMtDatasetRequest;
import com.google.cloud.translate.v3.DeleteAdaptiveMtFileRequest;
import com.google.cloud.translate.v3.DeleteGlossaryMetadata;
import com.google.cloud.translate.v3.DeleteGlossaryRequest;
import com.google.cloud.translate.v3.DeleteGlossaryResponse;
import com.google.cloud.translate.v3.DetectLanguageRequest;
import com.google.cloud.translate.v3.DetectLanguageResponse;
import com.google.cloud.translate.v3.GetAdaptiveMtDatasetRequest;
import com.google.cloud.translate.v3.GetAdaptiveMtFileRequest;
import com.google.cloud.translate.v3.GetGlossaryRequest;
import com.google.cloud.translate.v3.GetSupportedLanguagesRequest;
import com.google.cloud.translate.v3.Glossary;
import com.google.cloud.translate.v3.ImportAdaptiveMtFileRequest;
import com.google.cloud.translate.v3.ImportAdaptiveMtFileResponse;
import com.google.cloud.translate.v3.ListAdaptiveMtDatasetsRequest;
import com.google.cloud.translate.v3.ListAdaptiveMtDatasetsResponse;
import com.google.cloud.translate.v3.ListAdaptiveMtFilesRequest;
import com.google.cloud.translate.v3.ListAdaptiveMtFilesResponse;
import com.google.cloud.translate.v3.ListAdaptiveMtSentencesRequest;
import com.google.cloud.translate.v3.ListAdaptiveMtSentencesResponse;
import com.google.cloud.translate.v3.ListGlossariesRequest;
import com.google.cloud.translate.v3.ListGlossariesResponse;
import com.google.cloud.translate.v3.SupportedLanguages;
import com.google.cloud.translate.v3.TranslateDocumentRequest;
import com.google.cloud.translate.v3.TranslateDocumentResponse;
import com.google.cloud.translate.v3.TranslateTextRequest;
import com.google.cloud.translate.v3.TranslateTextResponse;
import com.google.longrunning.Operation;
import com.google.longrunning.stub.GrpcOperationsStub;
import com.google.protobuf.Empty;
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
 * gRPC stub implementation for the TranslationService service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator-java") public class GrpcTranslationServiceStub extends TranslationServiceStub { private static final MethodDescriptor translateTextMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.translation.v3.TranslationService/TranslateText") .setRequestMarshaller( ProtoUtils.marshaller(TranslateTextRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(TranslateTextResponse.getDefaultInstance())) .build(); private static final MethodDescriptor detectLanguageMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.translation.v3.TranslationService/DetectLanguage") .setRequestMarshaller( ProtoUtils.marshaller(DetectLanguageRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(DetectLanguageResponse.getDefaultInstance())) .build(); private static final MethodDescriptor getSupportedLanguagesMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/GetSupportedLanguages") .setRequestMarshaller( ProtoUtils.marshaller(GetSupportedLanguagesRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(SupportedLanguages.getDefaultInstance())) .build(); private static final MethodDescriptor translateDocumentMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.translation.v3.TranslationService/TranslateDocument") .setRequestMarshaller( ProtoUtils.marshaller(TranslateDocumentRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(TranslateDocumentResponse.getDefaultInstance())) .build(); private static final MethodDescriptor batchTranslateTextMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/BatchTranslateText") .setRequestMarshaller( ProtoUtils.marshaller(BatchTranslateTextRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor batchTranslateDocumentMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/BatchTranslateDocument") .setRequestMarshaller( ProtoUtils.marshaller(BatchTranslateDocumentRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor createGlossaryMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.translation.v3.TranslationService/CreateGlossary") .setRequestMarshaller( ProtoUtils.marshaller(CreateGlossaryRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor listGlossariesMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.translation.v3.TranslationService/ListGlossaries") .setRequestMarshaller( ProtoUtils.marshaller(ListGlossariesRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListGlossariesResponse.getDefaultInstance())) .build(); private static final MethodDescriptor getGlossaryMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.translation.v3.TranslationService/GetGlossary") .setRequestMarshaller(ProtoUtils.marshaller(GetGlossaryRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Glossary.getDefaultInstance())) .build(); private static final MethodDescriptor deleteGlossaryMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.translation.v3.TranslationService/DeleteGlossary") .setRequestMarshaller( ProtoUtils.marshaller(DeleteGlossaryRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor createAdaptiveMtDatasetMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/CreateAdaptiveMtDataset") .setRequestMarshaller( ProtoUtils.marshaller(CreateAdaptiveMtDatasetRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(AdaptiveMtDataset.getDefaultInstance())) .build(); private static final MethodDescriptor deleteAdaptiveMtDatasetMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtDataset") .setRequestMarshaller( ProtoUtils.marshaller(DeleteAdaptiveMtDatasetRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); private static final MethodDescriptor getAdaptiveMtDatasetMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/GetAdaptiveMtDataset") .setRequestMarshaller( ProtoUtils.marshaller(GetAdaptiveMtDatasetRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(AdaptiveMtDataset.getDefaultInstance())) .build(); private static final MethodDescriptor< ListAdaptiveMtDatasetsRequest, ListAdaptiveMtDatasetsResponse> listAdaptiveMtDatasetsMethodDescriptor = MethodDescriptor .newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/ListAdaptiveMtDatasets") .setRequestMarshaller( ProtoUtils.marshaller(ListAdaptiveMtDatasetsRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListAdaptiveMtDatasetsResponse.getDefaultInstance())) .build(); private static final MethodDescriptor adaptiveMtTranslateMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/AdaptiveMtTranslate") .setRequestMarshaller( ProtoUtils.marshaller(AdaptiveMtTranslateRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(AdaptiveMtTranslateResponse.getDefaultInstance())) .build(); private static final MethodDescriptor getAdaptiveMtFileMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.translation.v3.TranslationService/GetAdaptiveMtFile") .setRequestMarshaller( ProtoUtils.marshaller(GetAdaptiveMtFileRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(AdaptiveMtFile.getDefaultInstance())) .build(); private static final MethodDescriptor deleteAdaptiveMtFileMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtFile") .setRequestMarshaller( ProtoUtils.marshaller(DeleteAdaptiveMtFileRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); private static final MethodDescriptor importAdaptiveMtFileMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/ImportAdaptiveMtFile") .setRequestMarshaller( ProtoUtils.marshaller(ImportAdaptiveMtFileRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ImportAdaptiveMtFileResponse.getDefaultInstance())) .build(); private static final MethodDescriptor listAdaptiveMtFilesMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/ListAdaptiveMtFiles") .setRequestMarshaller( ProtoUtils.marshaller(ListAdaptiveMtFilesRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListAdaptiveMtFilesResponse.getDefaultInstance())) .build(); private static final MethodDescriptor< ListAdaptiveMtSentencesRequest, ListAdaptiveMtSentencesResponse> listAdaptiveMtSentencesMethodDescriptor = MethodDescriptor .newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.translation.v3.TranslationService/ListAdaptiveMtSentences") .setRequestMarshaller( ProtoUtils.marshaller(ListAdaptiveMtSentencesRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListAdaptiveMtSentencesResponse.getDefaultInstance())) .build(); private final UnaryCallable translateTextCallable; private final UnaryCallable detectLanguageCallable; private final UnaryCallable getSupportedLanguagesCallable; private final UnaryCallable translateDocumentCallable; private final UnaryCallable batchTranslateTextCallable; private final OperationCallable< BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> batchTranslateTextOperationCallable; private final UnaryCallable batchTranslateDocumentCallable; private final OperationCallable< BatchTranslateDocumentRequest, BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> batchTranslateDocumentOperationCallable; private final UnaryCallable createGlossaryCallable; private final OperationCallable createGlossaryOperationCallable; private final UnaryCallable listGlossariesCallable; private final UnaryCallable listGlossariesPagedCallable; private final UnaryCallable getGlossaryCallable; private final UnaryCallable deleteGlossaryCallable; private final OperationCallable< DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata> deleteGlossaryOperationCallable; private final UnaryCallable createAdaptiveMtDatasetCallable; private final UnaryCallable deleteAdaptiveMtDatasetCallable; private final UnaryCallable getAdaptiveMtDatasetCallable; private final UnaryCallable listAdaptiveMtDatasetsCallable; private final UnaryCallable listAdaptiveMtDatasetsPagedCallable; private final UnaryCallable adaptiveMtTranslateCallable; private final UnaryCallable getAdaptiveMtFileCallable; private final UnaryCallable deleteAdaptiveMtFileCallable; private final UnaryCallable importAdaptiveMtFileCallable; private final UnaryCallable listAdaptiveMtFilesCallable; private final UnaryCallable listAdaptiveMtFilesPagedCallable; private final UnaryCallable listAdaptiveMtSentencesCallable; private final UnaryCallable listAdaptiveMtSentencesPagedCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcTranslationServiceStub create(TranslationServiceStubSettings settings) throws IOException { return new GrpcTranslationServiceStub(settings, ClientContext.create(settings)); } public static final GrpcTranslationServiceStub create(ClientContext clientContext) throws IOException { return new GrpcTranslationServiceStub( TranslationServiceStubSettings.newBuilder().build(), clientContext); } public static final GrpcTranslationServiceStub create( ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { return new GrpcTranslationServiceStub( TranslationServiceStubSettings.newBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of GrpcTranslationServiceStub, using the given settings. This is * protected so that it is easy to make a subclass, but otherwise, the static factory methods * should be preferred. */ protected GrpcTranslationServiceStub( TranslationServiceStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new GrpcTranslationServiceCallableFactory()); } /** * Constructs an instance of GrpcTranslationServiceStub, using the given settings. This is * protected so that it is easy to make a subclass, but otherwise, the static factory methods * should be preferred. */ protected GrpcTranslationServiceStub( TranslationServiceStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings translateTextTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(translateTextMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings detectLanguageTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(detectLanguageMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings getSupportedLanguagesTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getSupportedLanguagesMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings translateDocumentTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(translateDocumentMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings batchTranslateTextTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(batchTranslateTextMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings batchTranslateDocumentTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(batchTranslateDocumentMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings createGlossaryTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createGlossaryMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings listGlossariesTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listGlossariesMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings getGlossaryTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getGlossaryMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings deleteGlossaryTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteGlossaryMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings createAdaptiveMtDatasetTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createAdaptiveMtDatasetMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings deleteAdaptiveMtDatasetTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteAdaptiveMtDatasetMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings getAdaptiveMtDatasetTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getAdaptiveMtDatasetMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings listAdaptiveMtDatasetsTransportSettings = GrpcCallSettings .newBuilder() .setMethodDescriptor(listAdaptiveMtDatasetsMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings adaptiveMtTranslateTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(adaptiveMtTranslateMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings getAdaptiveMtFileTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getAdaptiveMtFileMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings deleteAdaptiveMtFileTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteAdaptiveMtFileMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings importAdaptiveMtFileTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(importAdaptiveMtFileMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings listAdaptiveMtFilesTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listAdaptiveMtFilesMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings listAdaptiveMtSentencesTransportSettings = GrpcCallSettings .newBuilder() .setMethodDescriptor(listAdaptiveMtSentencesMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); this.translateTextCallable = callableFactory.createUnaryCallable( translateTextTransportSettings, settings.translateTextSettings(), clientContext); this.detectLanguageCallable = callableFactory.createUnaryCallable( detectLanguageTransportSettings, settings.detectLanguageSettings(), clientContext); this.getSupportedLanguagesCallable = callableFactory.createUnaryCallable( getSupportedLanguagesTransportSettings, settings.getSupportedLanguagesSettings(), clientContext); this.translateDocumentCallable = callableFactory.createUnaryCallable( translateDocumentTransportSettings, settings.translateDocumentSettings(), clientContext); this.batchTranslateTextCallable = callableFactory.createUnaryCallable( batchTranslateTextTransportSettings, settings.batchTranslateTextSettings(), clientContext); this.batchTranslateTextOperationCallable = callableFactory.createOperationCallable( batchTranslateTextTransportSettings, settings.batchTranslateTextOperationSettings(), clientContext, operationsStub); this.batchTranslateDocumentCallable = callableFactory.createUnaryCallable( batchTranslateDocumentTransportSettings, settings.batchTranslateDocumentSettings(), clientContext); this.batchTranslateDocumentOperationCallable = callableFactory.createOperationCallable( batchTranslateDocumentTransportSettings, settings.batchTranslateDocumentOperationSettings(), clientContext, operationsStub); this.createGlossaryCallable = callableFactory.createUnaryCallable( createGlossaryTransportSettings, settings.createGlossarySettings(), clientContext); this.createGlossaryOperationCallable = callableFactory.createOperationCallable( createGlossaryTransportSettings, settings.createGlossaryOperationSettings(), clientContext, operationsStub); this.listGlossariesCallable = callableFactory.createUnaryCallable( listGlossariesTransportSettings, settings.listGlossariesSettings(), clientContext); this.listGlossariesPagedCallable = callableFactory.createPagedCallable( listGlossariesTransportSettings, settings.listGlossariesSettings(), clientContext); this.getGlossaryCallable = callableFactory.createUnaryCallable( getGlossaryTransportSettings, settings.getGlossarySettings(), clientContext); this.deleteGlossaryCallable = callableFactory.createUnaryCallable( deleteGlossaryTransportSettings, settings.deleteGlossarySettings(), clientContext); this.deleteGlossaryOperationCallable = callableFactory.createOperationCallable( deleteGlossaryTransportSettings, settings.deleteGlossaryOperationSettings(), clientContext, operationsStub); this.createAdaptiveMtDatasetCallable = callableFactory.createUnaryCallable( createAdaptiveMtDatasetTransportSettings, settings.createAdaptiveMtDatasetSettings(), clientContext); this.deleteAdaptiveMtDatasetCallable = callableFactory.createUnaryCallable( deleteAdaptiveMtDatasetTransportSettings, settings.deleteAdaptiveMtDatasetSettings(), clientContext); this.getAdaptiveMtDatasetCallable = callableFactory.createUnaryCallable( getAdaptiveMtDatasetTransportSettings, settings.getAdaptiveMtDatasetSettings(), clientContext); this.listAdaptiveMtDatasetsCallable = callableFactory.createUnaryCallable( listAdaptiveMtDatasetsTransportSettings, settings.listAdaptiveMtDatasetsSettings(), clientContext); this.listAdaptiveMtDatasetsPagedCallable = callableFactory.createPagedCallable( listAdaptiveMtDatasetsTransportSettings, settings.listAdaptiveMtDatasetsSettings(), clientContext); this.adaptiveMtTranslateCallable = callableFactory.createUnaryCallable( adaptiveMtTranslateTransportSettings, settings.adaptiveMtTranslateSettings(), clientContext); this.getAdaptiveMtFileCallable = callableFactory.createUnaryCallable( getAdaptiveMtFileTransportSettings, settings.getAdaptiveMtFileSettings(), clientContext); this.deleteAdaptiveMtFileCallable = callableFactory.createUnaryCallable( deleteAdaptiveMtFileTransportSettings, settings.deleteAdaptiveMtFileSettings(), clientContext); this.importAdaptiveMtFileCallable = callableFactory.createUnaryCallable( importAdaptiveMtFileTransportSettings, settings.importAdaptiveMtFileSettings(), clientContext); this.listAdaptiveMtFilesCallable = callableFactory.createUnaryCallable( listAdaptiveMtFilesTransportSettings, settings.listAdaptiveMtFilesSettings(), clientContext); this.listAdaptiveMtFilesPagedCallable = callableFactory.createPagedCallable( listAdaptiveMtFilesTransportSettings, settings.listAdaptiveMtFilesSettings(), clientContext); this.listAdaptiveMtSentencesCallable = callableFactory.createUnaryCallable( listAdaptiveMtSentencesTransportSettings, settings.listAdaptiveMtSentencesSettings(), clientContext); this.listAdaptiveMtSentencesPagedCallable = callableFactory.createPagedCallable( listAdaptiveMtSentencesTransportSettings, settings.listAdaptiveMtSentencesSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } public GrpcOperationsStub getOperationsStub() { return operationsStub; } @Override public UnaryCallable translateTextCallable() { return translateTextCallable; } @Override public UnaryCallable detectLanguageCallable() { return detectLanguageCallable; } @Override public UnaryCallable getSupportedLanguagesCallable() { return getSupportedLanguagesCallable; } @Override public UnaryCallable translateDocumentCallable() { return translateDocumentCallable; } @Override public UnaryCallable batchTranslateTextCallable() { return batchTranslateTextCallable; } @Override public OperationCallable< BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> batchTranslateTextOperationCallable() { return batchTranslateTextOperationCallable; } @Override public UnaryCallable batchTranslateDocumentCallable() { return batchTranslateDocumentCallable; } @Override public OperationCallable< BatchTranslateDocumentRequest, BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> batchTranslateDocumentOperationCallable() { return batchTranslateDocumentOperationCallable; } @Override public UnaryCallable createGlossaryCallable() { return createGlossaryCallable; } @Override public OperationCallable createGlossaryOperationCallable() { return createGlossaryOperationCallable; } @Override public UnaryCallable listGlossariesCallable() { return listGlossariesCallable; } @Override public UnaryCallable listGlossariesPagedCallable() { return listGlossariesPagedCallable; } @Override public UnaryCallable getGlossaryCallable() { return getGlossaryCallable; } @Override public UnaryCallable deleteGlossaryCallable() { return deleteGlossaryCallable; } @Override public OperationCallable deleteGlossaryOperationCallable() { return deleteGlossaryOperationCallable; } @Override public UnaryCallable createAdaptiveMtDatasetCallable() { return createAdaptiveMtDatasetCallable; } @Override public UnaryCallable deleteAdaptiveMtDatasetCallable() { return deleteAdaptiveMtDatasetCallable; } @Override public UnaryCallable getAdaptiveMtDatasetCallable() { return getAdaptiveMtDatasetCallable; } @Override public UnaryCallable listAdaptiveMtDatasetsCallable() { return listAdaptiveMtDatasetsCallable; } @Override public UnaryCallable listAdaptiveMtDatasetsPagedCallable() { return listAdaptiveMtDatasetsPagedCallable; } @Override public UnaryCallable adaptiveMtTranslateCallable() { return adaptiveMtTranslateCallable; } @Override public UnaryCallable getAdaptiveMtFileCallable() { return getAdaptiveMtFileCallable; } @Override public UnaryCallable deleteAdaptiveMtFileCallable() { return deleteAdaptiveMtFileCallable; } @Override public UnaryCallable importAdaptiveMtFileCallable() { return importAdaptiveMtFileCallable; } @Override public UnaryCallable listAdaptiveMtFilesCallable() { return listAdaptiveMtFilesCallable; } @Override public UnaryCallable listAdaptiveMtFilesPagedCallable() { return listAdaptiveMtFilesPagedCallable; } @Override public UnaryCallable listAdaptiveMtSentencesCallable() { return listAdaptiveMtSentencesCallable; } @Override public UnaryCallable listAdaptiveMtSentencesPagedCallable() { return listAdaptiveMtSentencesPagedCallable; } @Override public final void close() { try { backgroundResources.close(); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new IllegalStateException("Failed to close resource", e); } } @Override public void shutdown() { backgroundResources.shutdown(); } @Override public boolean isShutdown() { return backgroundResources.isShutdown(); } @Override public boolean isTerminated() { return backgroundResources.isTerminated(); } @Override public void shutdownNow() { backgroundResources.shutdownNow(); } @Override public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { return backgroundResources.awaitTermination(duration, unit); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy