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

com.google.cloud.translate.v3.stub.HttpJsonTranslationServiceStub 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.ListDatasetsPagedResponse;
import static com.google.cloud.translate.v3.TranslationServiceClient.ListExamplesPagedResponse;
import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossariesPagedResponse;
import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossaryEntriesPagedResponse;
import static com.google.cloud.translate.v3.TranslationServiceClient.ListModelsPagedResponse;

import com.google.api.HttpRule;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.httpjson.ApiMethodDescriptor;
import com.google.api.gax.httpjson.HttpJsonCallSettings;
import com.google.api.gax.httpjson.HttpJsonOperationSnapshot;
import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
import com.google.api.gax.httpjson.ProtoMessageRequestFormatter;
import com.google.api.gax.httpjson.ProtoMessageResponseParser;
import com.google.api.gax.httpjson.ProtoRestSerializer;
import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub;
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.CreateDatasetMetadata;
import com.google.cloud.translate.v3.CreateDatasetRequest;
import com.google.cloud.translate.v3.CreateGlossaryEntryRequest;
import com.google.cloud.translate.v3.CreateGlossaryMetadata;
import com.google.cloud.translate.v3.CreateGlossaryRequest;
import com.google.cloud.translate.v3.CreateModelMetadata;
import com.google.cloud.translate.v3.CreateModelRequest;
import com.google.cloud.translate.v3.Dataset;
import com.google.cloud.translate.v3.DeleteAdaptiveMtDatasetRequest;
import com.google.cloud.translate.v3.DeleteAdaptiveMtFileRequest;
import com.google.cloud.translate.v3.DeleteDatasetMetadata;
import com.google.cloud.translate.v3.DeleteDatasetRequest;
import com.google.cloud.translate.v3.DeleteGlossaryEntryRequest;
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.DeleteModelMetadata;
import com.google.cloud.translate.v3.DeleteModelRequest;
import com.google.cloud.translate.v3.DetectLanguageRequest;
import com.google.cloud.translate.v3.DetectLanguageResponse;
import com.google.cloud.translate.v3.ExportDataMetadata;
import com.google.cloud.translate.v3.ExportDataRequest;
import com.google.cloud.translate.v3.GetAdaptiveMtDatasetRequest;
import com.google.cloud.translate.v3.GetAdaptiveMtFileRequest;
import com.google.cloud.translate.v3.GetDatasetRequest;
import com.google.cloud.translate.v3.GetGlossaryEntryRequest;
import com.google.cloud.translate.v3.GetGlossaryRequest;
import com.google.cloud.translate.v3.GetModelRequest;
import com.google.cloud.translate.v3.GetSupportedLanguagesRequest;
import com.google.cloud.translate.v3.Glossary;
import com.google.cloud.translate.v3.GlossaryEntry;
import com.google.cloud.translate.v3.ImportAdaptiveMtFileRequest;
import com.google.cloud.translate.v3.ImportAdaptiveMtFileResponse;
import com.google.cloud.translate.v3.ImportDataMetadata;
import com.google.cloud.translate.v3.ImportDataRequest;
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.ListDatasetsRequest;
import com.google.cloud.translate.v3.ListDatasetsResponse;
import com.google.cloud.translate.v3.ListExamplesRequest;
import com.google.cloud.translate.v3.ListExamplesResponse;
import com.google.cloud.translate.v3.ListGlossariesRequest;
import com.google.cloud.translate.v3.ListGlossariesResponse;
import com.google.cloud.translate.v3.ListGlossaryEntriesRequest;
import com.google.cloud.translate.v3.ListGlossaryEntriesResponse;
import com.google.cloud.translate.v3.ListModelsRequest;
import com.google.cloud.translate.v3.ListModelsResponse;
import com.google.cloud.translate.v3.Model;
import com.google.cloud.translate.v3.RomanizeTextRequest;
import com.google.cloud.translate.v3.RomanizeTextResponse;
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.cloud.translate.v3.UpdateGlossaryEntryRequest;
import com.google.cloud.translate.v3.UpdateGlossaryMetadata;
import com.google.cloud.translate.v3.UpdateGlossaryRequest;
import com.google.common.collect.ImmutableMap;
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import com.google.protobuf.TypeRegistry;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
 * REST 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 HttpJsonTranslationServiceStub extends TranslationServiceStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder() .add(DeleteGlossaryMetadata.getDescriptor()) .add(ImportDataMetadata.getDescriptor()) .add(DeleteModelMetadata.getDescriptor()) .add(UpdateGlossaryMetadata.getDescriptor()) .add(CreateModelMetadata.getDescriptor()) .add(Dataset.getDescriptor()) .add(CreateGlossaryMetadata.getDescriptor()) .add(BatchTranslateDocumentResponse.getDescriptor()) .add(DeleteGlossaryResponse.getDescriptor()) .add(BatchTranslateDocumentMetadata.getDescriptor()) .add(ExportDataMetadata.getDescriptor()) .add(Empty.getDescriptor()) .add(BatchTranslateResponse.getDescriptor()) .add(BatchTranslateMetadata.getDescriptor()) .add(Glossary.getDescriptor()) .add(DeleteDatasetMetadata.getDescriptor()) .add(Model.getDescriptor()) .add(CreateDatasetMetadata.getDescriptor()) .build(); private static final ApiMethodDescriptor translateTextMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/TranslateText") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}:translateText", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths("/v3/{parent=projects/*}:translateText") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearParent().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(TranslateTextResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor romanizeTextMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/RomanizeText") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}:romanizeText", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths("/v3/{parent=projects/*}:romanizeText") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearParent().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(RomanizeTextResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor detectLanguageMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/DetectLanguage") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}:detectLanguage", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths("/v3/{parent=projects/*}:detectLanguage") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearParent().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(DetectLanguageResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getSupportedLanguagesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/GetSupportedLanguages") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}/supportedLanguages", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths("/v3/{parent=projects/*}/supportedLanguages") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam( fields, "displayLanguageCode", request.getDisplayLanguageCode()); serializer.putQueryParam(fields, "model", request.getModel()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(SupportedLanguages.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor translateDocumentMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/TranslateDocument") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}:translateDocument", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearParent().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(TranslateDocumentResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor batchTranslateTextMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/BatchTranslateText") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}:batchTranslateText", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearParent().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (BatchTranslateTextRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor batchTranslateDocumentMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/BatchTranslateDocument") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}:batchTranslateDocument", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearParent().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (BatchTranslateDocumentRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor createGlossaryMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/CreateGlossary") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}/glossaries", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("glossary", request.getGlossary(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (CreateGlossaryRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor updateGlossaryMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/UpdateGlossary") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{glossary.name=projects/*/locations/*/glossaries/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "glossary.name", request.getGlossary().getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("glossary", request.getGlossary(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (UpdateGlossaryRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor listGlossariesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/ListGlossaries") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}/glossaries", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "filter", request.getFilter()); serializer.putQueryParam(fields, "pageSize", request.getPageSize()); serializer.putQueryParam(fields, "pageToken", request.getPageToken()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListGlossariesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getGlossaryMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/GetGlossary") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/glossaries/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Glossary.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteGlossaryMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/DeleteGlossary") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/glossaries/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (DeleteGlossaryRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor getGlossaryEntryMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/GetGlossaryEntry") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/glossaries/*/glossaryEntries/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(GlossaryEntry.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listGlossaryEntriesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/ListGlossaryEntries") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*/glossaries/*}/glossaryEntries", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "pageSize", request.getPageSize()); serializer.putQueryParam(fields, "pageToken", request.getPageToken()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListGlossaryEntriesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor createGlossaryEntryMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/CreateGlossaryEntry") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*/glossaries/*}/glossaryEntries", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("glossaryEntry", request.getGlossaryEntry(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(GlossaryEntry.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateGlossaryEntryMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/UpdateGlossaryEntry") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{glossaryEntry.name=projects/*/locations/*/glossaries/*/glossaryEntries/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "glossaryEntry.name", request.getGlossaryEntry().getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("glossaryEntry", request.getGlossaryEntry(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(GlossaryEntry.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteGlossaryEntryMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/DeleteGlossaryEntry") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/glossaries/*/glossaryEntries/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Empty.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor createDatasetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/CreateDataset") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}/datasets", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("dataset", request.getDataset(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (CreateDatasetRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor getDatasetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/GetDataset") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/datasets/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Dataset.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listDatasetsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/ListDatasets") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}/datasets", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "pageSize", request.getPageSize()); serializer.putQueryParam(fields, "pageToken", request.getPageToken()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListDatasetsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteDatasetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/DeleteDataset") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/datasets/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (DeleteDatasetRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor createAdaptiveMtDatasetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/CreateAdaptiveMtDataset") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}/adaptiveMtDatasets", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody( "adaptiveMtDataset", request.getAdaptiveMtDataset(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(AdaptiveMtDataset.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteAdaptiveMtDatasetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtDataset") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/adaptiveMtDatasets/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Empty.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getAdaptiveMtDatasetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/GetAdaptiveMtDataset") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/adaptiveMtDatasets/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(AdaptiveMtDataset.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor< ListAdaptiveMtDatasetsRequest, ListAdaptiveMtDatasetsResponse> listAdaptiveMtDatasetsMethodDescriptor = ApiMethodDescriptor .newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/ListAdaptiveMtDatasets") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}/adaptiveMtDatasets", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "filter", request.getFilter()); serializer.putQueryParam(fields, "pageSize", request.getPageSize()); serializer.putQueryParam(fields, "pageToken", request.getPageToken()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListAdaptiveMtDatasetsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor adaptiveMtTranslateMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/AdaptiveMtTranslate") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}:adaptiveMtTranslate", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearParent().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(AdaptiveMtTranslateResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getAdaptiveMtFileMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/GetAdaptiveMtFile") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/adaptiveMtDatasets/*/adaptiveMtFiles/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(AdaptiveMtFile.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteAdaptiveMtFileMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/DeleteAdaptiveMtFile") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/adaptiveMtDatasets/*/adaptiveMtFiles/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Empty.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor< ImportAdaptiveMtFileRequest, ImportAdaptiveMtFileResponse> importAdaptiveMtFileMethodDescriptor = ApiMethodDescriptor .newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/ImportAdaptiveMtFile") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*/adaptiveMtDatasets/*}:importAdaptiveMtFile", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearParent().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ImportAdaptiveMtFileResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listAdaptiveMtFilesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/ListAdaptiveMtFiles") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*/adaptiveMtDatasets/*}/adaptiveMtFiles", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "pageSize", request.getPageSize()); serializer.putQueryParam(fields, "pageToken", request.getPageToken()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListAdaptiveMtFilesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor< ListAdaptiveMtSentencesRequest, ListAdaptiveMtSentencesResponse> listAdaptiveMtSentencesMethodDescriptor = ApiMethodDescriptor .newBuilder() .setFullMethodName( "google.cloud.translation.v3.TranslationService/ListAdaptiveMtSentences") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*/adaptiveMtDatasets/*/adaptiveMtFiles/*}/adaptiveMtSentences", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v3/{parent=projects/*/locations/*/adaptiveMtDatasets/*}/adaptiveMtSentences") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "pageSize", request.getPageSize()); serializer.putQueryParam(fields, "pageToken", request.getPageToken()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListAdaptiveMtSentencesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor importDataMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/ImportData") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{dataset=projects/*/locations/*/datasets/*}:importData", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "dataset", request.getDataset()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearDataset().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (ImportDataRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor exportDataMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/ExportData") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{dataset=projects/*/locations/*/datasets/*}:exportData", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "dataset", request.getDataset()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearDataset().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (ExportDataRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor listExamplesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/ListExamples") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*/datasets/*}/examples", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "filter", request.getFilter()); serializer.putQueryParam(fields, "pageSize", request.getPageSize()); serializer.putQueryParam(fields, "pageToken", request.getPageToken()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListExamplesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor createModelMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/CreateModel") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}/models", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("model", request.getModel(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (CreateModelRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor listModelsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/ListModels") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{parent=projects/*/locations/*}/models", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "filter", request.getFilter()); serializer.putQueryParam(fields, "pageSize", request.getPageSize()); serializer.putQueryParam(fields, "pageToken", request.getPageToken()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListModelsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getModelMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/GetModel") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/models/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Model.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteModelMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.translation.v3.TranslationService/DeleteModel") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3/{name=projects/*/locations/*/models/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (DeleteModelRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private final UnaryCallable translateTextCallable; private final UnaryCallable romanizeTextCallable; 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 updateGlossaryCallable; private final OperationCallable updateGlossaryOperationCallable; 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 getGlossaryEntryCallable; private final UnaryCallable listGlossaryEntriesCallable; private final UnaryCallable listGlossaryEntriesPagedCallable; private final UnaryCallable createGlossaryEntryCallable; private final UnaryCallable updateGlossaryEntryCallable; private final UnaryCallable deleteGlossaryEntryCallable; private final UnaryCallable createDatasetCallable; private final OperationCallable createDatasetOperationCallable; private final UnaryCallable getDatasetCallable; private final UnaryCallable listDatasetsCallable; private final UnaryCallable listDatasetsPagedCallable; private final UnaryCallable deleteDatasetCallable; private final OperationCallable deleteDatasetOperationCallable; 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 UnaryCallable importDataCallable; private final OperationCallable importDataOperationCallable; private final UnaryCallable exportDataCallable; private final OperationCallable exportDataOperationCallable; private final UnaryCallable listExamplesCallable; private final UnaryCallable listExamplesPagedCallable; private final UnaryCallable createModelCallable; private final OperationCallable createModelOperationCallable; private final UnaryCallable listModelsCallable; private final UnaryCallable listModelsPagedCallable; private final UnaryCallable getModelCallable; private final UnaryCallable deleteModelCallable; private final OperationCallable deleteModelOperationCallable; private final BackgroundResource backgroundResources; private final HttpJsonOperationsStub httpJsonOperationsStub; private final HttpJsonStubCallableFactory callableFactory; public static final HttpJsonTranslationServiceStub create(TranslationServiceStubSettings settings) throws IOException { return new HttpJsonTranslationServiceStub(settings, ClientContext.create(settings)); } public static final HttpJsonTranslationServiceStub create(ClientContext clientContext) throws IOException { return new HttpJsonTranslationServiceStub( TranslationServiceStubSettings.newHttpJsonBuilder().build(), clientContext); } public static final HttpJsonTranslationServiceStub create( ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { return new HttpJsonTranslationServiceStub( TranslationServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of HttpJsonTranslationServiceStub, 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 HttpJsonTranslationServiceStub( TranslationServiceStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new HttpJsonTranslationServiceCallableFactory()); } /** * Constructs an instance of HttpJsonTranslationServiceStub, 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 HttpJsonTranslationServiceStub( TranslationServiceStubSettings settings, ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; this.httpJsonOperationsStub = HttpJsonOperationsStub.create( clientContext, callableFactory, typeRegistry, ImmutableMap.builder() .put( "google.longrunning.Operations.CancelOperation", HttpRule.newBuilder() .setPost("/v3/{name=projects/*/locations/*/operations/*}:cancel") .build()) .put( "google.longrunning.Operations.DeleteOperation", HttpRule.newBuilder() .setDelete("/v3/{name=projects/*/locations/*/operations/*}") .build()) .put( "google.longrunning.Operations.GetOperation", HttpRule.newBuilder() .setGet("/v3/{name=projects/*/locations/*/operations/*}") .build()) .put( "google.longrunning.Operations.ListOperations", HttpRule.newBuilder() .setGet("/v3/{name=projects/*/locations/*}/operations") .build()) .put( "google.longrunning.Operations.WaitOperation", HttpRule.newBuilder() .setPost("/v3/{name=projects/*/locations/*/operations/*}:wait") .build()) .build()); HttpJsonCallSettings translateTextTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(translateTextMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings romanizeTextTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(romanizeTextMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings detectLanguageTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(detectLanguageMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getSupportedLanguagesTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getSupportedLanguagesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings translateDocumentTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(translateDocumentMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings batchTranslateTextTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(batchTranslateTextMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings batchTranslateDocumentTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(batchTranslateDocumentMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings createGlossaryTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createGlossaryMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings updateGlossaryTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateGlossaryMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("glossary.name", String.valueOf(request.getGlossary().getName())); return builder.build(); }) .build(); HttpJsonCallSettings listGlossariesTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listGlossariesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getGlossaryTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getGlossaryMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteGlossaryTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteGlossaryMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings getGlossaryEntryTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getGlossaryEntryMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings listGlossaryEntriesTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(listGlossaryEntriesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings createGlossaryEntryTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createGlossaryEntryMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings updateGlossaryEntryTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateGlossaryEntryMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "glossary_entry.name", String.valueOf(request.getGlossaryEntry().getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteGlossaryEntryTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteGlossaryEntryMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings createDatasetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createDatasetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getDatasetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getDatasetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings listDatasetsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listDatasetsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings deleteDatasetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteDatasetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings createAdaptiveMtDatasetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createAdaptiveMtDatasetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings deleteAdaptiveMtDatasetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteAdaptiveMtDatasetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings getAdaptiveMtDatasetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getAdaptiveMtDatasetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings listAdaptiveMtDatasetsTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(listAdaptiveMtDatasetsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings adaptiveMtTranslateTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(adaptiveMtTranslateMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getAdaptiveMtFileTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getAdaptiveMtFileMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteAdaptiveMtFileTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteAdaptiveMtFileMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings importAdaptiveMtFileTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(importAdaptiveMtFileMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listAdaptiveMtFilesTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(listAdaptiveMtFilesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listAdaptiveMtSentencesTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(listAdaptiveMtSentencesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings importDataTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(importDataMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("dataset", String.valueOf(request.getDataset())); return builder.build(); }) .build(); HttpJsonCallSettings exportDataTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(exportDataMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("dataset", String.valueOf(request.getDataset())); return builder.build(); }) .build(); HttpJsonCallSettings listExamplesTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listExamplesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings createModelTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createModelMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listModelsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listModelsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getModelTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getModelMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteModelTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteModelMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); this.translateTextCallable = callableFactory.createUnaryCallable( translateTextTransportSettings, settings.translateTextSettings(), clientContext); this.romanizeTextCallable = callableFactory.createUnaryCallable( romanizeTextTransportSettings, settings.romanizeTextSettings(), 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, httpJsonOperationsStub); this.batchTranslateDocumentCallable = callableFactory.createUnaryCallable( batchTranslateDocumentTransportSettings, settings.batchTranslateDocumentSettings(), clientContext); this.batchTranslateDocumentOperationCallable = callableFactory.createOperationCallable( batchTranslateDocumentTransportSettings, settings.batchTranslateDocumentOperationSettings(), clientContext, httpJsonOperationsStub); this.createGlossaryCallable = callableFactory.createUnaryCallable( createGlossaryTransportSettings, settings.createGlossarySettings(), clientContext); this.createGlossaryOperationCallable = callableFactory.createOperationCallable( createGlossaryTransportSettings, settings.createGlossaryOperationSettings(), clientContext, httpJsonOperationsStub); this.updateGlossaryCallable = callableFactory.createUnaryCallable( updateGlossaryTransportSettings, settings.updateGlossarySettings(), clientContext); this.updateGlossaryOperationCallable = callableFactory.createOperationCallable( updateGlossaryTransportSettings, settings.updateGlossaryOperationSettings(), clientContext, httpJsonOperationsStub); 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, httpJsonOperationsStub); this.getGlossaryEntryCallable = callableFactory.createUnaryCallable( getGlossaryEntryTransportSettings, settings.getGlossaryEntrySettings(), clientContext); this.listGlossaryEntriesCallable = callableFactory.createUnaryCallable( listGlossaryEntriesTransportSettings, settings.listGlossaryEntriesSettings(), clientContext); this.listGlossaryEntriesPagedCallable = callableFactory.createPagedCallable( listGlossaryEntriesTransportSettings, settings.listGlossaryEntriesSettings(), clientContext); this.createGlossaryEntryCallable = callableFactory.createUnaryCallable( createGlossaryEntryTransportSettings, settings.createGlossaryEntrySettings(), clientContext); this.updateGlossaryEntryCallable = callableFactory.createUnaryCallable( updateGlossaryEntryTransportSettings, settings.updateGlossaryEntrySettings(), clientContext); this.deleteGlossaryEntryCallable = callableFactory.createUnaryCallable( deleteGlossaryEntryTransportSettings, settings.deleteGlossaryEntrySettings(), clientContext); this.createDatasetCallable = callableFactory.createUnaryCallable( createDatasetTransportSettings, settings.createDatasetSettings(), clientContext); this.createDatasetOperationCallable = callableFactory.createOperationCallable( createDatasetTransportSettings, settings.createDatasetOperationSettings(), clientContext, httpJsonOperationsStub); this.getDatasetCallable = callableFactory.createUnaryCallable( getDatasetTransportSettings, settings.getDatasetSettings(), clientContext); this.listDatasetsCallable = callableFactory.createUnaryCallable( listDatasetsTransportSettings, settings.listDatasetsSettings(), clientContext); this.listDatasetsPagedCallable = callableFactory.createPagedCallable( listDatasetsTransportSettings, settings.listDatasetsSettings(), clientContext); this.deleteDatasetCallable = callableFactory.createUnaryCallable( deleteDatasetTransportSettings, settings.deleteDatasetSettings(), clientContext); this.deleteDatasetOperationCallable = callableFactory.createOperationCallable( deleteDatasetTransportSettings, settings.deleteDatasetOperationSettings(), clientContext, httpJsonOperationsStub); 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.importDataCallable = callableFactory.createUnaryCallable( importDataTransportSettings, settings.importDataSettings(), clientContext); this.importDataOperationCallable = callableFactory.createOperationCallable( importDataTransportSettings, settings.importDataOperationSettings(), clientContext, httpJsonOperationsStub); this.exportDataCallable = callableFactory.createUnaryCallable( exportDataTransportSettings, settings.exportDataSettings(), clientContext); this.exportDataOperationCallable = callableFactory.createOperationCallable( exportDataTransportSettings, settings.exportDataOperationSettings(), clientContext, httpJsonOperationsStub); this.listExamplesCallable = callableFactory.createUnaryCallable( listExamplesTransportSettings, settings.listExamplesSettings(), clientContext); this.listExamplesPagedCallable = callableFactory.createPagedCallable( listExamplesTransportSettings, settings.listExamplesSettings(), clientContext); this.createModelCallable = callableFactory.createUnaryCallable( createModelTransportSettings, settings.createModelSettings(), clientContext); this.createModelOperationCallable = callableFactory.createOperationCallable( createModelTransportSettings, settings.createModelOperationSettings(), clientContext, httpJsonOperationsStub); this.listModelsCallable = callableFactory.createUnaryCallable( listModelsTransportSettings, settings.listModelsSettings(), clientContext); this.listModelsPagedCallable = callableFactory.createPagedCallable( listModelsTransportSettings, settings.listModelsSettings(), clientContext); this.getModelCallable = callableFactory.createUnaryCallable( getModelTransportSettings, settings.getModelSettings(), clientContext); this.deleteModelCallable = callableFactory.createUnaryCallable( deleteModelTransportSettings, settings.deleteModelSettings(), clientContext); this.deleteModelOperationCallable = callableFactory.createOperationCallable( deleteModelTransportSettings, settings.deleteModelOperationSettings(), clientContext, httpJsonOperationsStub); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } @InternalApi public static List getMethodDescriptors() { List methodDescriptors = new ArrayList<>(); methodDescriptors.add(translateTextMethodDescriptor); methodDescriptors.add(romanizeTextMethodDescriptor); methodDescriptors.add(detectLanguageMethodDescriptor); methodDescriptors.add(getSupportedLanguagesMethodDescriptor); methodDescriptors.add(translateDocumentMethodDescriptor); methodDescriptors.add(batchTranslateTextMethodDescriptor); methodDescriptors.add(batchTranslateDocumentMethodDescriptor); methodDescriptors.add(createGlossaryMethodDescriptor); methodDescriptors.add(updateGlossaryMethodDescriptor); methodDescriptors.add(listGlossariesMethodDescriptor); methodDescriptors.add(getGlossaryMethodDescriptor); methodDescriptors.add(deleteGlossaryMethodDescriptor); methodDescriptors.add(getGlossaryEntryMethodDescriptor); methodDescriptors.add(listGlossaryEntriesMethodDescriptor); methodDescriptors.add(createGlossaryEntryMethodDescriptor); methodDescriptors.add(updateGlossaryEntryMethodDescriptor); methodDescriptors.add(deleteGlossaryEntryMethodDescriptor); methodDescriptors.add(createDatasetMethodDescriptor); methodDescriptors.add(getDatasetMethodDescriptor); methodDescriptors.add(listDatasetsMethodDescriptor); methodDescriptors.add(deleteDatasetMethodDescriptor); methodDescriptors.add(createAdaptiveMtDatasetMethodDescriptor); methodDescriptors.add(deleteAdaptiveMtDatasetMethodDescriptor); methodDescriptors.add(getAdaptiveMtDatasetMethodDescriptor); methodDescriptors.add(listAdaptiveMtDatasetsMethodDescriptor); methodDescriptors.add(adaptiveMtTranslateMethodDescriptor); methodDescriptors.add(getAdaptiveMtFileMethodDescriptor); methodDescriptors.add(deleteAdaptiveMtFileMethodDescriptor); methodDescriptors.add(importAdaptiveMtFileMethodDescriptor); methodDescriptors.add(listAdaptiveMtFilesMethodDescriptor); methodDescriptors.add(listAdaptiveMtSentencesMethodDescriptor); methodDescriptors.add(importDataMethodDescriptor); methodDescriptors.add(exportDataMethodDescriptor); methodDescriptors.add(listExamplesMethodDescriptor); methodDescriptors.add(createModelMethodDescriptor); methodDescriptors.add(listModelsMethodDescriptor); methodDescriptors.add(getModelMethodDescriptor); methodDescriptors.add(deleteModelMethodDescriptor); return methodDescriptors; } public HttpJsonOperationsStub getHttpJsonOperationsStub() { return httpJsonOperationsStub; } @Override public UnaryCallable translateTextCallable() { return translateTextCallable; } @Override public UnaryCallable romanizeTextCallable() { return romanizeTextCallable; } @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 updateGlossaryCallable() { return updateGlossaryCallable; } @Override public OperationCallable updateGlossaryOperationCallable() { return updateGlossaryOperationCallable; } @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 getGlossaryEntryCallable() { return getGlossaryEntryCallable; } @Override public UnaryCallable listGlossaryEntriesCallable() { return listGlossaryEntriesCallable; } @Override public UnaryCallable listGlossaryEntriesPagedCallable() { return listGlossaryEntriesPagedCallable; } @Override public UnaryCallable createGlossaryEntryCallable() { return createGlossaryEntryCallable; } @Override public UnaryCallable updateGlossaryEntryCallable() { return updateGlossaryEntryCallable; } @Override public UnaryCallable deleteGlossaryEntryCallable() { return deleteGlossaryEntryCallable; } @Override public UnaryCallable createDatasetCallable() { return createDatasetCallable; } @Override public OperationCallable createDatasetOperationCallable() { return createDatasetOperationCallable; } @Override public UnaryCallable getDatasetCallable() { return getDatasetCallable; } @Override public UnaryCallable listDatasetsCallable() { return listDatasetsCallable; } @Override public UnaryCallable listDatasetsPagedCallable() { return listDatasetsPagedCallable; } @Override public UnaryCallable deleteDatasetCallable() { return deleteDatasetCallable; } @Override public OperationCallable deleteDatasetOperationCallable() { return deleteDatasetOperationCallable; } @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 UnaryCallable importDataCallable() { return importDataCallable; } @Override public OperationCallable importDataOperationCallable() { return importDataOperationCallable; } @Override public UnaryCallable exportDataCallable() { return exportDataCallable; } @Override public OperationCallable exportDataOperationCallable() { return exportDataOperationCallable; } @Override public UnaryCallable listExamplesCallable() { return listExamplesCallable; } @Override public UnaryCallable listExamplesPagedCallable() { return listExamplesPagedCallable; } @Override public UnaryCallable createModelCallable() { return createModelCallable; } @Override public OperationCallable createModelOperationCallable() { return createModelOperationCallable; } @Override public UnaryCallable listModelsCallable() { return listModelsCallable; } @Override public UnaryCallable listModelsPagedCallable() { return listModelsPagedCallable; } @Override public UnaryCallable getModelCallable() { return getModelCallable; } @Override public UnaryCallable deleteModelCallable() { return deleteModelCallable; } @Override public OperationCallable deleteModelOperationCallable() { return deleteModelOperationCallable; } @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