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

com.google.cloud.dialogflow.cx.v3beta1.stub.HttpJsonFlowsStub Maven / Gradle / Ivy

Go to download

provides a new way of designing agents, taking a state machine approach to agent design. This gives you clear and explicit control over a conversation, a better end-user experience, and a better development workflow.

The 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.dialogflow.cx.v3beta1.stub;

import static com.google.cloud.dialogflow.cx.v3beta1.FlowsClient.ListFlowsPagedResponse;
import static com.google.cloud.dialogflow.cx.v3beta1.FlowsClient.ListLocationsPagedResponse;

import com.google.api.HttpRule;
import com.google.api.core.BetaApi;
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.dialogflow.cx.v3beta1.CreateFlowRequest;
import com.google.cloud.dialogflow.cx.v3beta1.DeleteFlowRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ExportFlowRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ExportFlowResponse;
import com.google.cloud.dialogflow.cx.v3beta1.Flow;
import com.google.cloud.dialogflow.cx.v3beta1.FlowValidationResult;
import com.google.cloud.dialogflow.cx.v3beta1.GetFlowRequest;
import com.google.cloud.dialogflow.cx.v3beta1.GetFlowValidationResultRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ImportFlowRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ImportFlowResponse;
import com.google.cloud.dialogflow.cx.v3beta1.ListFlowsRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ListFlowsResponse;
import com.google.cloud.dialogflow.cx.v3beta1.TrainFlowRequest;
import com.google.cloud.dialogflow.cx.v3beta1.UpdateFlowRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ValidateFlowRequest;
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.common.collect.ImmutableMap;
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import com.google.protobuf.Struct;
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 Flows service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @BetaApi @Generated("by gapic-generator-java") public class HttpJsonFlowsStub extends FlowsStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder() .add(Empty.getDescriptor()) .add(ExportFlowResponse.getDescriptor()) .add(ImportFlowResponse.getDescriptor()) .add(Struct.getDescriptor()) .build(); private static final ApiMethodDescriptor createFlowMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Flows/CreateFlow") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3beta1/{parent=projects/*/locations/*/agents/*}/flows", 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, "languageCode", request.getLanguageCode()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create().toBody("flow", request.getFlow(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Flow.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteFlowMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Flows/DeleteFlow") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3beta1/{name=projects/*/locations/*/agents/*/flows/*}", 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, "force", request.getForce()); 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 listFlowsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Flows/ListFlows") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3beta1/{parent=projects/*/locations/*/agents/*}/flows", 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, "languageCode", request.getLanguageCode()); 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(ListFlowsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getFlowMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Flows/GetFlow") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3beta1/{name=projects/*/locations/*/agents/*/flows/*}", 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, "languageCode", request.getLanguageCode()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Flow.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateFlowMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Flows/UpdateFlow") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3beta1/{flow.name=projects/*/locations/*/agents/*/flows/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "flow.name", request.getFlow().getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "languageCode", request.getLanguageCode()); serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create().toBody("flow", request.getFlow(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Flow.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor trainFlowMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Flows/TrainFlow") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3beta1/{name=projects/*/locations/*/agents/*/flows/*}:train", 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( (TrainFlowRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor validateFlowMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Flows/ValidateFlow") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3beta1/{name=projects/*/locations/*/agents/*/flows/*}:validate", 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(FlowValidationResult.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getFlowValidationResultMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Flows/GetFlowValidationResult") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3beta1/{name=projects/*/locations/*/agents/*/flows/*/validationResult}", 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, "languageCode", request.getLanguageCode()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(FlowValidationResult.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor importFlowMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Flows/ImportFlow") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3beta1/{parent=projects/*/locations/*/agents/*}/flows:import", 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( (ImportFlowRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor exportFlowMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.dialogflow.cx.v3beta1.Flows/ExportFlow") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v3beta1/{name=projects/*/locations/*/agents/*/flows/*}:export", 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( (ExportFlowRequest 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( "/v3beta1/{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( "/v3beta1/{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 createFlowCallable; private final UnaryCallable deleteFlowCallable; private final UnaryCallable listFlowsCallable; private final UnaryCallable listFlowsPagedCallable; private final UnaryCallable getFlowCallable; private final UnaryCallable updateFlowCallable; private final UnaryCallable trainFlowCallable; private final OperationCallable trainFlowOperationCallable; private final UnaryCallable validateFlowCallable; private final UnaryCallable getFlowValidationResultCallable; private final UnaryCallable importFlowCallable; private final OperationCallable importFlowOperationCallable; private final UnaryCallable exportFlowCallable; private final OperationCallable exportFlowOperationCallable; 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 HttpJsonFlowsStub create(FlowsStubSettings settings) throws IOException { return new HttpJsonFlowsStub(settings, ClientContext.create(settings)); } public static final HttpJsonFlowsStub create(ClientContext clientContext) throws IOException { return new HttpJsonFlowsStub(FlowsStubSettings.newHttpJsonBuilder().build(), clientContext); } public static final HttpJsonFlowsStub create( ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { return new HttpJsonFlowsStub( FlowsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of HttpJsonFlowsStub, 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 HttpJsonFlowsStub(FlowsStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new HttpJsonFlowsCallableFactory()); } /** * Constructs an instance of HttpJsonFlowsStub, 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 HttpJsonFlowsStub( FlowsStubSettings 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("/v3beta1/{name=projects/*/operations/*}:cancel") .addAdditionalBindings( HttpRule.newBuilder() .setPost( "/v3beta1/{name=projects/*/locations/*/operations/*}:cancel") .build()) .build()) .put( "google.longrunning.Operations.GetOperation", HttpRule.newBuilder() .setGet("/v3beta1/{name=projects/*/operations/*}") .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v3beta1/{name=projects/*/locations/*/operations/*}") .build()) .build()) .put( "google.longrunning.Operations.ListOperations", HttpRule.newBuilder() .setGet("/v3beta1/{name=projects/*}/operations") .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v3beta1/{name=projects/*/locations/*}/operations") .build()) .build()) .build()); HttpJsonCallSettings createFlowTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createFlowMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings deleteFlowTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteFlowMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings listFlowsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listFlowsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getFlowTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getFlowMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateFlowTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateFlowMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("flow.name", String.valueOf(request.getFlow().getName())); return builder.build(); }) .build(); HttpJsonCallSettings trainFlowTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(trainFlowMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings validateFlowTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(validateFlowMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings getFlowValidationResultTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getFlowValidationResultMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings importFlowTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(importFlowMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings exportFlowTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(exportFlowMethodDescriptor) .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.createFlowCallable = callableFactory.createUnaryCallable( createFlowTransportSettings, settings.createFlowSettings(), clientContext); this.deleteFlowCallable = callableFactory.createUnaryCallable( deleteFlowTransportSettings, settings.deleteFlowSettings(), clientContext); this.listFlowsCallable = callableFactory.createUnaryCallable( listFlowsTransportSettings, settings.listFlowsSettings(), clientContext); this.listFlowsPagedCallable = callableFactory.createPagedCallable( listFlowsTransportSettings, settings.listFlowsSettings(), clientContext); this.getFlowCallable = callableFactory.createUnaryCallable( getFlowTransportSettings, settings.getFlowSettings(), clientContext); this.updateFlowCallable = callableFactory.createUnaryCallable( updateFlowTransportSettings, settings.updateFlowSettings(), clientContext); this.trainFlowCallable = callableFactory.createUnaryCallable( trainFlowTransportSettings, settings.trainFlowSettings(), clientContext); this.trainFlowOperationCallable = callableFactory.createOperationCallable( trainFlowTransportSettings, settings.trainFlowOperationSettings(), clientContext, httpJsonOperationsStub); this.validateFlowCallable = callableFactory.createUnaryCallable( validateFlowTransportSettings, settings.validateFlowSettings(), clientContext); this.getFlowValidationResultCallable = callableFactory.createUnaryCallable( getFlowValidationResultTransportSettings, settings.getFlowValidationResultSettings(), clientContext); this.importFlowCallable = callableFactory.createUnaryCallable( importFlowTransportSettings, settings.importFlowSettings(), clientContext); this.importFlowOperationCallable = callableFactory.createOperationCallable( importFlowTransportSettings, settings.importFlowOperationSettings(), clientContext, httpJsonOperationsStub); this.exportFlowCallable = callableFactory.createUnaryCallable( exportFlowTransportSettings, settings.exportFlowSettings(), clientContext); this.exportFlowOperationCallable = callableFactory.createOperationCallable( exportFlowTransportSettings, settings.exportFlowOperationSettings(), 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(createFlowMethodDescriptor); methodDescriptors.add(deleteFlowMethodDescriptor); methodDescriptors.add(listFlowsMethodDescriptor); methodDescriptors.add(getFlowMethodDescriptor); methodDescriptors.add(updateFlowMethodDescriptor); methodDescriptors.add(trainFlowMethodDescriptor); methodDescriptors.add(validateFlowMethodDescriptor); methodDescriptors.add(getFlowValidationResultMethodDescriptor); methodDescriptors.add(importFlowMethodDescriptor); methodDescriptors.add(exportFlowMethodDescriptor); methodDescriptors.add(listLocationsMethodDescriptor); methodDescriptors.add(getLocationMethodDescriptor); return methodDescriptors; } public HttpJsonOperationsStub getHttpJsonOperationsStub() { return httpJsonOperationsStub; } @Override public UnaryCallable createFlowCallable() { return createFlowCallable; } @Override public UnaryCallable deleteFlowCallable() { return deleteFlowCallable; } @Override public UnaryCallable listFlowsCallable() { return listFlowsCallable; } @Override public UnaryCallable listFlowsPagedCallable() { return listFlowsPagedCallable; } @Override public UnaryCallable getFlowCallable() { return getFlowCallable; } @Override public UnaryCallable updateFlowCallable() { return updateFlowCallable; } @Override public UnaryCallable trainFlowCallable() { return trainFlowCallable; } @Override public OperationCallable trainFlowOperationCallable() { return trainFlowOperationCallable; } @Override public UnaryCallable validateFlowCallable() { return validateFlowCallable; } @Override public UnaryCallable getFlowValidationResultCallable() { return getFlowValidationResultCallable; } @Override public UnaryCallable importFlowCallable() { return importFlowCallable; } @Override public OperationCallable importFlowOperationCallable() { return importFlowOperationCallable; } @Override public UnaryCallable exportFlowCallable() { return exportFlowCallable; } @Override public OperationCallable exportFlowOperationCallable() { return exportFlowOperationCallable; } @Override public UnaryCallable listLocationsCallable() { return listLocationsCallable; } @Override public UnaryCallable listLocationsPagedCallable() { return listLocationsPagedCallable; } @Override public UnaryCallable getLocationCallable() { return getLocationCallable; } @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 - 2025 Weber Informatics LLC | Privacy Policy