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

com.google.cloud.discoveryengine.v1beta.stub.GrpcEngineServiceStub Maven / Gradle / Ivy

Go to download

Discovery Engine API A Cloud API that offers search and recommendation discoverability for documents from different industry verticals (e.g. media, retail, etc.).

There is a newer version: 0.51.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.discoveryengine.v1beta.stub;

import static com.google.cloud.discoveryengine.v1beta.EngineServiceClient.ListEnginesPagedResponse;

import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.discoveryengine.v1beta.CreateEngineMetadata;
import com.google.cloud.discoveryengine.v1beta.CreateEngineRequest;
import com.google.cloud.discoveryengine.v1beta.DeleteEngineMetadata;
import com.google.cloud.discoveryengine.v1beta.DeleteEngineRequest;
import com.google.cloud.discoveryengine.v1beta.Engine;
import com.google.cloud.discoveryengine.v1beta.GetEngineRequest;
import com.google.cloud.discoveryengine.v1beta.ListEnginesRequest;
import com.google.cloud.discoveryengine.v1beta.ListEnginesResponse;
import com.google.cloud.discoveryengine.v1beta.PauseEngineRequest;
import com.google.cloud.discoveryengine.v1beta.ResumeEngineRequest;
import com.google.cloud.discoveryengine.v1beta.TuneEngineMetadata;
import com.google.cloud.discoveryengine.v1beta.TuneEngineRequest;
import com.google.cloud.discoveryengine.v1beta.TuneEngineResponse;
import com.google.cloud.discoveryengine.v1beta.UpdateEngineRequest;
import com.google.longrunning.Operation;
import com.google.longrunning.stub.GrpcOperationsStub;
import com.google.protobuf.Empty;
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

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

This class is for advanced usage and reflects the underlying API directly. */ @BetaApi @Generated("by gapic-generator-java") public class GrpcEngineServiceStub extends EngineServiceStub { private static final MethodDescriptor createEngineMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.discoveryengine.v1beta.EngineService/CreateEngine") .setRequestMarshaller(ProtoUtils.marshaller(CreateEngineRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor deleteEngineMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.discoveryengine.v1beta.EngineService/DeleteEngine") .setRequestMarshaller(ProtoUtils.marshaller(DeleteEngineRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private static final MethodDescriptor updateEngineMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.discoveryengine.v1beta.EngineService/UpdateEngine") .setRequestMarshaller(ProtoUtils.marshaller(UpdateEngineRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Engine.getDefaultInstance())) .build(); private static final MethodDescriptor getEngineMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.discoveryengine.v1beta.EngineService/GetEngine") .setRequestMarshaller(ProtoUtils.marshaller(GetEngineRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Engine.getDefaultInstance())) .build(); private static final MethodDescriptor listEnginesMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.discoveryengine.v1beta.EngineService/ListEngines") .setRequestMarshaller(ProtoUtils.marshaller(ListEnginesRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListEnginesResponse.getDefaultInstance())) .build(); private static final MethodDescriptor pauseEngineMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.discoveryengine.v1beta.EngineService/PauseEngine") .setRequestMarshaller(ProtoUtils.marshaller(PauseEngineRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Engine.getDefaultInstance())) .build(); private static final MethodDescriptor resumeEngineMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.discoveryengine.v1beta.EngineService/ResumeEngine") .setRequestMarshaller(ProtoUtils.marshaller(ResumeEngineRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Engine.getDefaultInstance())) .build(); private static final MethodDescriptor tuneEngineMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.discoveryengine.v1beta.EngineService/TuneEngine") .setRequestMarshaller(ProtoUtils.marshaller(TuneEngineRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); private final UnaryCallable createEngineCallable; private final OperationCallable createEngineOperationCallable; private final UnaryCallable deleteEngineCallable; private final OperationCallable deleteEngineOperationCallable; private final UnaryCallable updateEngineCallable; private final UnaryCallable getEngineCallable; private final UnaryCallable listEnginesCallable; private final UnaryCallable listEnginesPagedCallable; private final UnaryCallable pauseEngineCallable; private final UnaryCallable resumeEngineCallable; private final UnaryCallable tuneEngineCallable; private final OperationCallable tuneEngineOperationCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcEngineServiceStub create(EngineServiceStubSettings settings) throws IOException { return new GrpcEngineServiceStub(settings, ClientContext.create(settings)); } public static final GrpcEngineServiceStub create(ClientContext clientContext) throws IOException { return new GrpcEngineServiceStub(EngineServiceStubSettings.newBuilder().build(), clientContext); } public static final GrpcEngineServiceStub create( ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { return new GrpcEngineServiceStub( EngineServiceStubSettings.newBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of GrpcEngineServiceStub, 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 GrpcEngineServiceStub(EngineServiceStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new GrpcEngineServiceCallableFactory()); } /** * Constructs an instance of GrpcEngineServiceStub, 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 GrpcEngineServiceStub( EngineServiceStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings createEngineTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(createEngineMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings deleteEngineTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(deleteEngineMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings updateEngineTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateEngineMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("engine.name", String.valueOf(request.getEngine().getName())); return builder.build(); }) .build(); GrpcCallSettings getEngineTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getEngineMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings listEnginesTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listEnginesMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings pauseEngineTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(pauseEngineMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings resumeEngineTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(resumeEngineMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings tuneEngineTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(tuneEngineMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); this.createEngineCallable = callableFactory.createUnaryCallable( createEngineTransportSettings, settings.createEngineSettings(), clientContext); this.createEngineOperationCallable = callableFactory.createOperationCallable( createEngineTransportSettings, settings.createEngineOperationSettings(), clientContext, operationsStub); this.deleteEngineCallable = callableFactory.createUnaryCallable( deleteEngineTransportSettings, settings.deleteEngineSettings(), clientContext); this.deleteEngineOperationCallable = callableFactory.createOperationCallable( deleteEngineTransportSettings, settings.deleteEngineOperationSettings(), clientContext, operationsStub); this.updateEngineCallable = callableFactory.createUnaryCallable( updateEngineTransportSettings, settings.updateEngineSettings(), clientContext); this.getEngineCallable = callableFactory.createUnaryCallable( getEngineTransportSettings, settings.getEngineSettings(), clientContext); this.listEnginesCallable = callableFactory.createUnaryCallable( listEnginesTransportSettings, settings.listEnginesSettings(), clientContext); this.listEnginesPagedCallable = callableFactory.createPagedCallable( listEnginesTransportSettings, settings.listEnginesSettings(), clientContext); this.pauseEngineCallable = callableFactory.createUnaryCallable( pauseEngineTransportSettings, settings.pauseEngineSettings(), clientContext); this.resumeEngineCallable = callableFactory.createUnaryCallable( resumeEngineTransportSettings, settings.resumeEngineSettings(), clientContext); this.tuneEngineCallable = callableFactory.createUnaryCallable( tuneEngineTransportSettings, settings.tuneEngineSettings(), clientContext); this.tuneEngineOperationCallable = callableFactory.createOperationCallable( tuneEngineTransportSettings, settings.tuneEngineOperationSettings(), clientContext, operationsStub); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } public GrpcOperationsStub getOperationsStub() { return operationsStub; } @Override public UnaryCallable createEngineCallable() { return createEngineCallable; } @Override public OperationCallable createEngineOperationCallable() { return createEngineOperationCallable; } @Override public UnaryCallable deleteEngineCallable() { return deleteEngineCallable; } @Override public OperationCallable deleteEngineOperationCallable() { return deleteEngineOperationCallable; } @Override public UnaryCallable updateEngineCallable() { return updateEngineCallable; } @Override public UnaryCallable getEngineCallable() { return getEngineCallable; } @Override public UnaryCallable listEnginesCallable() { return listEnginesCallable; } @Override public UnaryCallable listEnginesPagedCallable() { return listEnginesPagedCallable; } @Override public UnaryCallable pauseEngineCallable() { return pauseEngineCallable; } @Override public UnaryCallable resumeEngineCallable() { return resumeEngineCallable; } @Override public UnaryCallable tuneEngineCallable() { return tuneEngineCallable; } @Override public OperationCallable tuneEngineOperationCallable() { return tuneEngineOperationCallable; } @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