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

com.google.cloud.speech.v2.stub.HttpJsonSpeechStub Maven / Gradle / Ivy

There is a newer version: 4.49.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.speech.v2.stub;

import static com.google.cloud.speech.v2.SpeechClient.ListCustomClassesPagedResponse;
import static com.google.cloud.speech.v2.SpeechClient.ListLocationsPagedResponse;
import static com.google.cloud.speech.v2.SpeechClient.ListPhraseSetsPagedResponse;
import static com.google.cloud.speech.v2.SpeechClient.ListRecognizersPagedResponse;

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.BidiStreamingCallable;
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.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.cloud.speech.v2.BatchRecognizeRequest;
import com.google.cloud.speech.v2.BatchRecognizeResponse;
import com.google.cloud.speech.v2.Config;
import com.google.cloud.speech.v2.CreateCustomClassRequest;
import com.google.cloud.speech.v2.CreatePhraseSetRequest;
import com.google.cloud.speech.v2.CreateRecognizerRequest;
import com.google.cloud.speech.v2.CustomClass;
import com.google.cloud.speech.v2.DeleteCustomClassRequest;
import com.google.cloud.speech.v2.DeletePhraseSetRequest;
import com.google.cloud.speech.v2.DeleteRecognizerRequest;
import com.google.cloud.speech.v2.GetConfigRequest;
import com.google.cloud.speech.v2.GetCustomClassRequest;
import com.google.cloud.speech.v2.GetPhraseSetRequest;
import com.google.cloud.speech.v2.GetRecognizerRequest;
import com.google.cloud.speech.v2.ListCustomClassesRequest;
import com.google.cloud.speech.v2.ListCustomClassesResponse;
import com.google.cloud.speech.v2.ListPhraseSetsRequest;
import com.google.cloud.speech.v2.ListPhraseSetsResponse;
import com.google.cloud.speech.v2.ListRecognizersRequest;
import com.google.cloud.speech.v2.ListRecognizersResponse;
import com.google.cloud.speech.v2.OperationMetadata;
import com.google.cloud.speech.v2.PhraseSet;
import com.google.cloud.speech.v2.RecognizeRequest;
import com.google.cloud.speech.v2.RecognizeResponse;
import com.google.cloud.speech.v2.Recognizer;
import com.google.cloud.speech.v2.StreamingRecognizeRequest;
import com.google.cloud.speech.v2.StreamingRecognizeResponse;
import com.google.cloud.speech.v2.UndeleteCustomClassRequest;
import com.google.cloud.speech.v2.UndeletePhraseSetRequest;
import com.google.cloud.speech.v2.UndeleteRecognizerRequest;
import com.google.cloud.speech.v2.UpdateConfigRequest;
import com.google.cloud.speech.v2.UpdateCustomClassRequest;
import com.google.cloud.speech.v2.UpdatePhraseSetRequest;
import com.google.cloud.speech.v2.UpdateRecognizerRequest;
import com.google.common.collect.ImmutableMap;
import com.google.longrunning.Operation;
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 Speech service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator-java") public class HttpJsonSpeechStub extends SpeechStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder() .add(OperationMetadata.getDescriptor()) .add(CustomClass.getDescriptor()) .add(Recognizer.getDescriptor()) .add(PhraseSet.getDescriptor()) .add(BatchRecognizeResponse.getDescriptor()) .build(); private static final ApiMethodDescriptor createRecognizerMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/CreateRecognizer") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{parent=projects/*/locations/*}/recognizers", 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, "recognizerId", request.getRecognizerId()); serializer.putQueryParam( fields, "validateOnly", request.getValidateOnly()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("recognizer", request.getRecognizer(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (CreateRecognizerRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor listRecognizersMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/ListRecognizers") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{parent=projects/*/locations/*}/recognizers", 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, "showDeleted", request.getShowDeleted()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListRecognizersResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getRecognizerMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/GetRecognizer") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*/recognizers/*}", 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(Recognizer.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateRecognizerMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/UpdateRecognizer") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{recognizer.name=projects/*/locations/*/recognizers/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "recognizer.name", request.getRecognizer().getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); serializer.putQueryParam( fields, "validateOnly", request.getValidateOnly()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("recognizer", request.getRecognizer(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (UpdateRecognizerRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor deleteRecognizerMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/DeleteRecognizer") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*/recognizers/*}", 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, "allowMissing", request.getAllowMissing()); serializer.putQueryParam(fields, "etag", request.getEtag()); serializer.putQueryParam( fields, "validateOnly", request.getValidateOnly()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (DeleteRecognizerRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor undeleteRecognizerMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/UndeleteRecognizer") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*/recognizers/*}:undelete", 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 -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearName().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (UndeleteRecognizerRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor recognizeMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/Recognize") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{recognizer=projects/*/locations/*/recognizers/*}:recognize", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "recognizer", request.getRecognizer()); 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().clearRecognizer().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(RecognizeResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor batchRecognizeMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/BatchRecognize") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{recognizer=projects/*/locations/*/recognizers/*}:batchRecognize", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "recognizer", request.getRecognizer()); 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().clearRecognizer().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (BatchRecognizeRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor getConfigMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/GetConfig") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*/config}", 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(Config.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateConfigMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/UpdateConfig") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{config.name=projects/*/locations/*/config}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "config.name", request.getConfig().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("config", request.getConfig(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Config.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor createCustomClassMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/CreateCustomClass") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{parent=projects/*/locations/*}/customClasses", 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, "customClassId", request.getCustomClassId()); serializer.putQueryParam( fields, "validateOnly", request.getValidateOnly()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("customClass", request.getCustomClass(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (CreateCustomClassRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor listCustomClassesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/ListCustomClasses") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{parent=projects/*/locations/*}/customClasses", 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, "showDeleted", request.getShowDeleted()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListCustomClassesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getCustomClassMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/GetCustomClass") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*/customClasses/*}", 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(CustomClass.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateCustomClassMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/UpdateCustomClass") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{customClass.name=projects/*/locations/*/customClasses/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "customClass.name", request.getCustomClass().getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); serializer.putQueryParam( fields, "validateOnly", request.getValidateOnly()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("customClass", request.getCustomClass(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (UpdateCustomClassRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor deleteCustomClassMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/DeleteCustomClass") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*/customClasses/*}", 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, "allowMissing", request.getAllowMissing()); serializer.putQueryParam(fields, "etag", request.getEtag()); serializer.putQueryParam( fields, "validateOnly", request.getValidateOnly()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (DeleteCustomClassRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor undeleteCustomClassMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/UndeleteCustomClass") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*/customClasses/*}:undelete", 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 -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearName().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (UndeleteCustomClassRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor createPhraseSetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/CreatePhraseSet") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{parent=projects/*/locations/*}/phraseSets", 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, "phraseSetId", request.getPhraseSetId()); serializer.putQueryParam( fields, "validateOnly", request.getValidateOnly()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("phraseSet", request.getPhraseSet(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (CreatePhraseSetRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor listPhraseSetsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/ListPhraseSets") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{parent=projects/*/locations/*}/phraseSets", 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, "showDeleted", request.getShowDeleted()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListPhraseSetsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getPhraseSetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/GetPhraseSet") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*/phraseSets/*}", 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(PhraseSet.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updatePhraseSetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/UpdatePhraseSet") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{phraseSet.name=projects/*/locations/*/phraseSets/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "phraseSet.name", request.getPhraseSet().getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); serializer.putQueryParam( fields, "validateOnly", request.getValidateOnly()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("phraseSet", request.getPhraseSet(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (UpdatePhraseSetRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor deletePhraseSetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/DeletePhraseSet") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*/phraseSets/*}", 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, "allowMissing", request.getAllowMissing()); serializer.putQueryParam(fields, "etag", request.getEtag()); serializer.putQueryParam( fields, "validateOnly", request.getValidateOnly()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (DeletePhraseSetRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor undeletePhraseSetMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.speech.v2.Speech/UndeletePhraseSet") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*/phraseSets/*}:undelete", 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 -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearName().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (UndeletePhraseSetRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor listLocationsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.location.Locations/ListLocations") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*}/locations", 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(ListLocationsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getLocationMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.location.Locations/GetLocation") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v2/{name=projects/*/locations/*}", 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(Location.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private final UnaryCallable createRecognizerCallable; private final OperationCallable createRecognizerOperationCallable; private final UnaryCallable listRecognizersCallable; private final UnaryCallable listRecognizersPagedCallable; private final UnaryCallable getRecognizerCallable; private final UnaryCallable updateRecognizerCallable; private final OperationCallable updateRecognizerOperationCallable; private final UnaryCallable deleteRecognizerCallable; private final OperationCallable deleteRecognizerOperationCallable; private final UnaryCallable undeleteRecognizerCallable; private final OperationCallable undeleteRecognizerOperationCallable; private final UnaryCallable recognizeCallable; private final UnaryCallable batchRecognizeCallable; private final OperationCallable batchRecognizeOperationCallable; private final UnaryCallable getConfigCallable; private final UnaryCallable updateConfigCallable; private final UnaryCallable createCustomClassCallable; private final OperationCallable createCustomClassOperationCallable; private final UnaryCallable listCustomClassesCallable; private final UnaryCallable listCustomClassesPagedCallable; private final UnaryCallable getCustomClassCallable; private final UnaryCallable updateCustomClassCallable; private final OperationCallable updateCustomClassOperationCallable; private final UnaryCallable deleteCustomClassCallable; private final OperationCallable deleteCustomClassOperationCallable; private final UnaryCallable undeleteCustomClassCallable; private final OperationCallable undeleteCustomClassOperationCallable; private final UnaryCallable createPhraseSetCallable; private final OperationCallable createPhraseSetOperationCallable; private final UnaryCallable listPhraseSetsCallable; private final UnaryCallable listPhraseSetsPagedCallable; private final UnaryCallable getPhraseSetCallable; private final UnaryCallable updatePhraseSetCallable; private final OperationCallable updatePhraseSetOperationCallable; private final UnaryCallable deletePhraseSetCallable; private final OperationCallable deletePhraseSetOperationCallable; private final UnaryCallable undeletePhraseSetCallable; private final OperationCallable undeletePhraseSetOperationCallable; private final UnaryCallable listLocationsCallable; private final UnaryCallable listLocationsPagedCallable; private final UnaryCallable getLocationCallable; private final BackgroundResource backgroundResources; private final HttpJsonOperationsStub httpJsonOperationsStub; private final HttpJsonStubCallableFactory callableFactory; public static final HttpJsonSpeechStub create(SpeechStubSettings settings) throws IOException { return new HttpJsonSpeechStub(settings, ClientContext.create(settings)); } public static final HttpJsonSpeechStub create(ClientContext clientContext) throws IOException { return new HttpJsonSpeechStub(SpeechStubSettings.newHttpJsonBuilder().build(), clientContext); } public static final HttpJsonSpeechStub create( ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { return new HttpJsonSpeechStub( SpeechStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of HttpJsonSpeechStub, 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 HttpJsonSpeechStub(SpeechStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new HttpJsonSpeechCallableFactory()); } /** * Constructs an instance of HttpJsonSpeechStub, 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 HttpJsonSpeechStub( SpeechStubSettings 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("/v2/{name=projects/*/locations/*/operations/*}:cancel") .build()) .put( "google.longrunning.Operations.DeleteOperation", HttpRule.newBuilder() .setDelete("/v2/{name=projects/*/locations/*/operations/*}") .build()) .put( "google.longrunning.Operations.GetOperation", HttpRule.newBuilder() .setGet("/v2/{name=projects/*/locations/*/operations/*}") .build()) .put( "google.longrunning.Operations.ListOperations", HttpRule.newBuilder() .setGet("/v2/{name=projects/*/locations/*}/operations") .build()) .build()); HttpJsonCallSettings createRecognizerTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createRecognizerMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listRecognizersTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listRecognizersMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getRecognizerTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getRecognizerMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateRecognizerTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateRecognizerMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("recognizer.name", String.valueOf(request.getRecognizer().getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteRecognizerTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteRecognizerMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings undeleteRecognizerTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(undeleteRecognizerMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings recognizeTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(recognizeMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("recognizer", String.valueOf(request.getRecognizer())); return builder.build(); }) .build(); HttpJsonCallSettings batchRecognizeTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(batchRecognizeMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("recognizer", String.valueOf(request.getRecognizer())); return builder.build(); }) .build(); HttpJsonCallSettings getConfigTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getConfigMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateConfigTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateConfigMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("config.name", String.valueOf(request.getConfig().getName())); return builder.build(); }) .build(); HttpJsonCallSettings createCustomClassTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createCustomClassMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listCustomClassesTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listCustomClassesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getCustomClassTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getCustomClassMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateCustomClassTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateCustomClassMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "custom_class.name", String.valueOf(request.getCustomClass().getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteCustomClassTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteCustomClassMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings undeleteCustomClassTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(undeleteCustomClassMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings createPhraseSetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createPhraseSetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listPhraseSetsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listPhraseSetsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getPhraseSetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getPhraseSetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updatePhraseSetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updatePhraseSetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("phrase_set.name", String.valueOf(request.getPhraseSet().getName())); return builder.build(); }) .build(); HttpJsonCallSettings deletePhraseSetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deletePhraseSetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings undeletePhraseSetTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(undeletePhraseSetMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings listLocationsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listLocationsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings getLocationTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getLocationMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); this.createRecognizerCallable = callableFactory.createUnaryCallable( createRecognizerTransportSettings, settings.createRecognizerSettings(), clientContext); this.createRecognizerOperationCallable = callableFactory.createOperationCallable( createRecognizerTransportSettings, settings.createRecognizerOperationSettings(), clientContext, httpJsonOperationsStub); this.listRecognizersCallable = callableFactory.createUnaryCallable( listRecognizersTransportSettings, settings.listRecognizersSettings(), clientContext); this.listRecognizersPagedCallable = callableFactory.createPagedCallable( listRecognizersTransportSettings, settings.listRecognizersSettings(), clientContext); this.getRecognizerCallable = callableFactory.createUnaryCallable( getRecognizerTransportSettings, settings.getRecognizerSettings(), clientContext); this.updateRecognizerCallable = callableFactory.createUnaryCallable( updateRecognizerTransportSettings, settings.updateRecognizerSettings(), clientContext); this.updateRecognizerOperationCallable = callableFactory.createOperationCallable( updateRecognizerTransportSettings, settings.updateRecognizerOperationSettings(), clientContext, httpJsonOperationsStub); this.deleteRecognizerCallable = callableFactory.createUnaryCallable( deleteRecognizerTransportSettings, settings.deleteRecognizerSettings(), clientContext); this.deleteRecognizerOperationCallable = callableFactory.createOperationCallable( deleteRecognizerTransportSettings, settings.deleteRecognizerOperationSettings(), clientContext, httpJsonOperationsStub); this.undeleteRecognizerCallable = callableFactory.createUnaryCallable( undeleteRecognizerTransportSettings, settings.undeleteRecognizerSettings(), clientContext); this.undeleteRecognizerOperationCallable = callableFactory.createOperationCallable( undeleteRecognizerTransportSettings, settings.undeleteRecognizerOperationSettings(), clientContext, httpJsonOperationsStub); this.recognizeCallable = callableFactory.createUnaryCallable( recognizeTransportSettings, settings.recognizeSettings(), clientContext); this.batchRecognizeCallable = callableFactory.createUnaryCallable( batchRecognizeTransportSettings, settings.batchRecognizeSettings(), clientContext); this.batchRecognizeOperationCallable = callableFactory.createOperationCallable( batchRecognizeTransportSettings, settings.batchRecognizeOperationSettings(), clientContext, httpJsonOperationsStub); this.getConfigCallable = callableFactory.createUnaryCallable( getConfigTransportSettings, settings.getConfigSettings(), clientContext); this.updateConfigCallable = callableFactory.createUnaryCallable( updateConfigTransportSettings, settings.updateConfigSettings(), clientContext); this.createCustomClassCallable = callableFactory.createUnaryCallable( createCustomClassTransportSettings, settings.createCustomClassSettings(), clientContext); this.createCustomClassOperationCallable = callableFactory.createOperationCallable( createCustomClassTransportSettings, settings.createCustomClassOperationSettings(), clientContext, httpJsonOperationsStub); this.listCustomClassesCallable = callableFactory.createUnaryCallable( listCustomClassesTransportSettings, settings.listCustomClassesSettings(), clientContext); this.listCustomClassesPagedCallable = callableFactory.createPagedCallable( listCustomClassesTransportSettings, settings.listCustomClassesSettings(), clientContext); this.getCustomClassCallable = callableFactory.createUnaryCallable( getCustomClassTransportSettings, settings.getCustomClassSettings(), clientContext); this.updateCustomClassCallable = callableFactory.createUnaryCallable( updateCustomClassTransportSettings, settings.updateCustomClassSettings(), clientContext); this.updateCustomClassOperationCallable = callableFactory.createOperationCallable( updateCustomClassTransportSettings, settings.updateCustomClassOperationSettings(), clientContext, httpJsonOperationsStub); this.deleteCustomClassCallable = callableFactory.createUnaryCallable( deleteCustomClassTransportSettings, settings.deleteCustomClassSettings(), clientContext); this.deleteCustomClassOperationCallable = callableFactory.createOperationCallable( deleteCustomClassTransportSettings, settings.deleteCustomClassOperationSettings(), clientContext, httpJsonOperationsStub); this.undeleteCustomClassCallable = callableFactory.createUnaryCallable( undeleteCustomClassTransportSettings, settings.undeleteCustomClassSettings(), clientContext); this.undeleteCustomClassOperationCallable = callableFactory.createOperationCallable( undeleteCustomClassTransportSettings, settings.undeleteCustomClassOperationSettings(), clientContext, httpJsonOperationsStub); this.createPhraseSetCallable = callableFactory.createUnaryCallable( createPhraseSetTransportSettings, settings.createPhraseSetSettings(), clientContext); this.createPhraseSetOperationCallable = callableFactory.createOperationCallable( createPhraseSetTransportSettings, settings.createPhraseSetOperationSettings(), clientContext, httpJsonOperationsStub); this.listPhraseSetsCallable = callableFactory.createUnaryCallable( listPhraseSetsTransportSettings, settings.listPhraseSetsSettings(), clientContext); this.listPhraseSetsPagedCallable = callableFactory.createPagedCallable( listPhraseSetsTransportSettings, settings.listPhraseSetsSettings(), clientContext); this.getPhraseSetCallable = callableFactory.createUnaryCallable( getPhraseSetTransportSettings, settings.getPhraseSetSettings(), clientContext); this.updatePhraseSetCallable = callableFactory.createUnaryCallable( updatePhraseSetTransportSettings, settings.updatePhraseSetSettings(), clientContext); this.updatePhraseSetOperationCallable = callableFactory.createOperationCallable( updatePhraseSetTransportSettings, settings.updatePhraseSetOperationSettings(), clientContext, httpJsonOperationsStub); this.deletePhraseSetCallable = callableFactory.createUnaryCallable( deletePhraseSetTransportSettings, settings.deletePhraseSetSettings(), clientContext); this.deletePhraseSetOperationCallable = callableFactory.createOperationCallable( deletePhraseSetTransportSettings, settings.deletePhraseSetOperationSettings(), clientContext, httpJsonOperationsStub); this.undeletePhraseSetCallable = callableFactory.createUnaryCallable( undeletePhraseSetTransportSettings, settings.undeletePhraseSetSettings(), clientContext); this.undeletePhraseSetOperationCallable = callableFactory.createOperationCallable( undeletePhraseSetTransportSettings, settings.undeletePhraseSetOperationSettings(), clientContext, httpJsonOperationsStub); this.listLocationsCallable = callableFactory.createUnaryCallable( listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); this.listLocationsPagedCallable = callableFactory.createPagedCallable( listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); this.getLocationCallable = callableFactory.createUnaryCallable( getLocationTransportSettings, settings.getLocationSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } @InternalApi public static List getMethodDescriptors() { List methodDescriptors = new ArrayList<>(); methodDescriptors.add(createRecognizerMethodDescriptor); methodDescriptors.add(listRecognizersMethodDescriptor); methodDescriptors.add(getRecognizerMethodDescriptor); methodDescriptors.add(updateRecognizerMethodDescriptor); methodDescriptors.add(deleteRecognizerMethodDescriptor); methodDescriptors.add(undeleteRecognizerMethodDescriptor); methodDescriptors.add(recognizeMethodDescriptor); methodDescriptors.add(batchRecognizeMethodDescriptor); methodDescriptors.add(getConfigMethodDescriptor); methodDescriptors.add(updateConfigMethodDescriptor); methodDescriptors.add(createCustomClassMethodDescriptor); methodDescriptors.add(listCustomClassesMethodDescriptor); methodDescriptors.add(getCustomClassMethodDescriptor); methodDescriptors.add(updateCustomClassMethodDescriptor); methodDescriptors.add(deleteCustomClassMethodDescriptor); methodDescriptors.add(undeleteCustomClassMethodDescriptor); methodDescriptors.add(createPhraseSetMethodDescriptor); methodDescriptors.add(listPhraseSetsMethodDescriptor); methodDescriptors.add(getPhraseSetMethodDescriptor); methodDescriptors.add(updatePhraseSetMethodDescriptor); methodDescriptors.add(deletePhraseSetMethodDescriptor); methodDescriptors.add(undeletePhraseSetMethodDescriptor); methodDescriptors.add(listLocationsMethodDescriptor); methodDescriptors.add(getLocationMethodDescriptor); return methodDescriptors; } public HttpJsonOperationsStub getHttpJsonOperationsStub() { return httpJsonOperationsStub; } @Override public UnaryCallable createRecognizerCallable() { return createRecognizerCallable; } @Override public OperationCallable createRecognizerOperationCallable() { return createRecognizerOperationCallable; } @Override public UnaryCallable listRecognizersCallable() { return listRecognizersCallable; } @Override public UnaryCallable listRecognizersPagedCallable() { return listRecognizersPagedCallable; } @Override public UnaryCallable getRecognizerCallable() { return getRecognizerCallable; } @Override public UnaryCallable updateRecognizerCallable() { return updateRecognizerCallable; } @Override public OperationCallable updateRecognizerOperationCallable() { return updateRecognizerOperationCallable; } @Override public UnaryCallable deleteRecognizerCallable() { return deleteRecognizerCallable; } @Override public OperationCallable deleteRecognizerOperationCallable() { return deleteRecognizerOperationCallable; } @Override public UnaryCallable undeleteRecognizerCallable() { return undeleteRecognizerCallable; } @Override public OperationCallable undeleteRecognizerOperationCallable() { return undeleteRecognizerOperationCallable; } @Override public UnaryCallable recognizeCallable() { return recognizeCallable; } @Override public UnaryCallable batchRecognizeCallable() { return batchRecognizeCallable; } @Override public OperationCallable batchRecognizeOperationCallable() { return batchRecognizeOperationCallable; } @Override public UnaryCallable getConfigCallable() { return getConfigCallable; } @Override public UnaryCallable updateConfigCallable() { return updateConfigCallable; } @Override public UnaryCallable createCustomClassCallable() { return createCustomClassCallable; } @Override public OperationCallable createCustomClassOperationCallable() { return createCustomClassOperationCallable; } @Override public UnaryCallable listCustomClassesCallable() { return listCustomClassesCallable; } @Override public UnaryCallable listCustomClassesPagedCallable() { return listCustomClassesPagedCallable; } @Override public UnaryCallable getCustomClassCallable() { return getCustomClassCallable; } @Override public UnaryCallable updateCustomClassCallable() { return updateCustomClassCallable; } @Override public OperationCallable updateCustomClassOperationCallable() { return updateCustomClassOperationCallable; } @Override public UnaryCallable deleteCustomClassCallable() { return deleteCustomClassCallable; } @Override public OperationCallable deleteCustomClassOperationCallable() { return deleteCustomClassOperationCallable; } @Override public UnaryCallable undeleteCustomClassCallable() { return undeleteCustomClassCallable; } @Override public OperationCallable undeleteCustomClassOperationCallable() { return undeleteCustomClassOperationCallable; } @Override public UnaryCallable createPhraseSetCallable() { return createPhraseSetCallable; } @Override public OperationCallable createPhraseSetOperationCallable() { return createPhraseSetOperationCallable; } @Override public UnaryCallable listPhraseSetsCallable() { return listPhraseSetsCallable; } @Override public UnaryCallable listPhraseSetsPagedCallable() { return listPhraseSetsPagedCallable; } @Override public UnaryCallable getPhraseSetCallable() { return getPhraseSetCallable; } @Override public UnaryCallable updatePhraseSetCallable() { return updatePhraseSetCallable; } @Override public OperationCallable updatePhraseSetOperationCallable() { return updatePhraseSetOperationCallable; } @Override public UnaryCallable deletePhraseSetCallable() { return deletePhraseSetCallable; } @Override public OperationCallable deletePhraseSetOperationCallable() { return deletePhraseSetOperationCallable; } @Override public UnaryCallable undeletePhraseSetCallable() { return undeletePhraseSetCallable; } @Override public OperationCallable undeletePhraseSetOperationCallable() { return undeletePhraseSetOperationCallable; } @Override public UnaryCallable listLocationsCallable() { return listLocationsCallable; } @Override public UnaryCallable listLocationsPagedCallable() { return listLocationsPagedCallable; } @Override public UnaryCallable getLocationCallable() { return getLocationCallable; } @Override public BidiStreamingCallable streamingRecognizeCallable() { throw new UnsupportedOperationException( "Not implemented: streamingRecognizeCallable(). REST transport is not implemented for this method yet."); } @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