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

com.google.cloud.retail.v2alpha.stub.GrpcCatalogServiceStub Maven / Gradle / Ivy

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.retail.v2alpha.stub;

import static com.google.cloud.retail.v2alpha.CatalogServiceClient.ListCatalogsPagedResponse;

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.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.retail.v2alpha.AddCatalogAttributeRequest;
import com.google.cloud.retail.v2alpha.AttributesConfig;
import com.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesRequest;
import com.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse;
import com.google.cloud.retail.v2alpha.Catalog;
import com.google.cloud.retail.v2alpha.CompletionConfig;
import com.google.cloud.retail.v2alpha.GetAttributesConfigRequest;
import com.google.cloud.retail.v2alpha.GetCompletionConfigRequest;
import com.google.cloud.retail.v2alpha.GetDefaultBranchRequest;
import com.google.cloud.retail.v2alpha.GetDefaultBranchResponse;
import com.google.cloud.retail.v2alpha.ListCatalogsRequest;
import com.google.cloud.retail.v2alpha.ListCatalogsResponse;
import com.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest;
import com.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest;
import com.google.cloud.retail.v2alpha.SetDefaultBranchRequest;
import com.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest;
import com.google.cloud.retail.v2alpha.UpdateCatalogRequest;
import com.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest;
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 CatalogService service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @BetaApi @Generated("by gapic-generator-java") public class GrpcCatalogServiceStub extends CatalogServiceStub { private static final MethodDescriptor listCatalogsMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/ListCatalogs") .setRequestMarshaller(ProtoUtils.marshaller(ListCatalogsRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(ListCatalogsResponse.getDefaultInstance())) .build(); private static final MethodDescriptor updateCatalogMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/UpdateCatalog") .setRequestMarshaller( ProtoUtils.marshaller(UpdateCatalogRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Catalog.getDefaultInstance())) .build(); private static final MethodDescriptor setDefaultBranchMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/SetDefaultBranch") .setRequestMarshaller( ProtoUtils.marshaller(SetDefaultBranchRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); private static final MethodDescriptor getDefaultBranchMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/GetDefaultBranch") .setRequestMarshaller( ProtoUtils.marshaller(GetDefaultBranchRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(GetDefaultBranchResponse.getDefaultInstance())) .build(); private static final MethodDescriptor getCompletionConfigMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/GetCompletionConfig") .setRequestMarshaller( ProtoUtils.marshaller(GetCompletionConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(CompletionConfig.getDefaultInstance())) .build(); private static final MethodDescriptor updateCompletionConfigMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.retail.v2alpha.CatalogService/UpdateCompletionConfig") .setRequestMarshaller( ProtoUtils.marshaller(UpdateCompletionConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(CompletionConfig.getDefaultInstance())) .build(); private static final MethodDescriptor getAttributesConfigMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/GetAttributesConfig") .setRequestMarshaller( ProtoUtils.marshaller(GetAttributesConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(AttributesConfig.getDefaultInstance())) .build(); private static final MethodDescriptor updateAttributesConfigMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.retail.v2alpha.CatalogService/UpdateAttributesConfig") .setRequestMarshaller( ProtoUtils.marshaller(UpdateAttributesConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(AttributesConfig.getDefaultInstance())) .build(); private static final MethodDescriptor addCatalogAttributeMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName("google.cloud.retail.v2alpha.CatalogService/AddCatalogAttribute") .setRequestMarshaller( ProtoUtils.marshaller(AddCatalogAttributeRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(AttributesConfig.getDefaultInstance())) .build(); private static final MethodDescriptor removeCatalogAttributeMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.retail.v2alpha.CatalogService/RemoveCatalogAttribute") .setRequestMarshaller( ProtoUtils.marshaller(RemoveCatalogAttributeRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(AttributesConfig.getDefaultInstance())) .build(); private static final MethodDescriptor< BatchRemoveCatalogAttributesRequest, BatchRemoveCatalogAttributesResponse> batchRemoveCatalogAttributesMethodDescriptor = MethodDescriptor . newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.retail.v2alpha.CatalogService/BatchRemoveCatalogAttributes") .setRequestMarshaller( ProtoUtils.marshaller(BatchRemoveCatalogAttributesRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(BatchRemoveCatalogAttributesResponse.getDefaultInstance())) .build(); private static final MethodDescriptor replaceCatalogAttributeMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName( "google.cloud.retail.v2alpha.CatalogService/ReplaceCatalogAttribute") .setRequestMarshaller( ProtoUtils.marshaller(ReplaceCatalogAttributeRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(AttributesConfig.getDefaultInstance())) .build(); private final UnaryCallable listCatalogsCallable; private final UnaryCallable listCatalogsPagedCallable; private final UnaryCallable updateCatalogCallable; private final UnaryCallable setDefaultBranchCallable; private final UnaryCallable getDefaultBranchCallable; private final UnaryCallable getCompletionConfigCallable; private final UnaryCallable updateCompletionConfigCallable; private final UnaryCallable getAttributesConfigCallable; private final UnaryCallable updateAttributesConfigCallable; private final UnaryCallable addCatalogAttributeCallable; private final UnaryCallable removeCatalogAttributeCallable; private final UnaryCallable< BatchRemoveCatalogAttributesRequest, BatchRemoveCatalogAttributesResponse> batchRemoveCatalogAttributesCallable; private final UnaryCallable replaceCatalogAttributeCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcCatalogServiceStub create(CatalogServiceStubSettings settings) throws IOException { return new GrpcCatalogServiceStub(settings, ClientContext.create(settings)); } public static final GrpcCatalogServiceStub create(ClientContext clientContext) throws IOException { return new GrpcCatalogServiceStub( CatalogServiceStubSettings.newBuilder().build(), clientContext); } public static final GrpcCatalogServiceStub create( ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { return new GrpcCatalogServiceStub( CatalogServiceStubSettings.newBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of GrpcCatalogServiceStub, 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 GrpcCatalogServiceStub(CatalogServiceStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new GrpcCatalogServiceCallableFactory()); } /** * Constructs an instance of GrpcCatalogServiceStub, 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 GrpcCatalogServiceStub( CatalogServiceStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings listCatalogsTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(listCatalogsMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); GrpcCallSettings updateCatalogTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateCatalogMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("catalog.name", String.valueOf(request.getCatalog().getName())); return builder.build(); }) .build(); GrpcCallSettings setDefaultBranchTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(setDefaultBranchMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("catalog", String.valueOf(request.getCatalog())); return builder.build(); }) .build(); GrpcCallSettings getDefaultBranchTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getDefaultBranchMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("catalog", String.valueOf(request.getCatalog())); return builder.build(); }) .build(); GrpcCallSettings getCompletionConfigTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getCompletionConfigMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings updateCompletionConfigTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateCompletionConfigMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "completion_config.name", String.valueOf(request.getCompletionConfig().getName())); return builder.build(); }) .build(); GrpcCallSettings getAttributesConfigTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(getAttributesConfigMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); GrpcCallSettings updateAttributesConfigTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(updateAttributesConfigMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "attributes_config.name", String.valueOf(request.getAttributesConfig().getName())); return builder.build(); }) .build(); GrpcCallSettings addCatalogAttributeTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(addCatalogAttributeMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "attributes_config", String.valueOf(request.getAttributesConfig())); return builder.build(); }) .build(); GrpcCallSettings removeCatalogAttributeTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(removeCatalogAttributeMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "attributes_config", String.valueOf(request.getAttributesConfig())); return builder.build(); }) .build(); GrpcCallSettings batchRemoveCatalogAttributesTransportSettings = GrpcCallSettings . newBuilder() .setMethodDescriptor(batchRemoveCatalogAttributesMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "attributes_config", String.valueOf(request.getAttributesConfig())); return builder.build(); }) .build(); GrpcCallSettings replaceCatalogAttributeTransportSettings = GrpcCallSettings.newBuilder() .setMethodDescriptor(replaceCatalogAttributeMethodDescriptor) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "attributes_config", String.valueOf(request.getAttributesConfig())); return builder.build(); }) .build(); this.listCatalogsCallable = callableFactory.createUnaryCallable( listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); this.listCatalogsPagedCallable = callableFactory.createPagedCallable( listCatalogsTransportSettings, settings.listCatalogsSettings(), clientContext); this.updateCatalogCallable = callableFactory.createUnaryCallable( updateCatalogTransportSettings, settings.updateCatalogSettings(), clientContext); this.setDefaultBranchCallable = callableFactory.createUnaryCallable( setDefaultBranchTransportSettings, settings.setDefaultBranchSettings(), clientContext); this.getDefaultBranchCallable = callableFactory.createUnaryCallable( getDefaultBranchTransportSettings, settings.getDefaultBranchSettings(), clientContext); this.getCompletionConfigCallable = callableFactory.createUnaryCallable( getCompletionConfigTransportSettings, settings.getCompletionConfigSettings(), clientContext); this.updateCompletionConfigCallable = callableFactory.createUnaryCallable( updateCompletionConfigTransportSettings, settings.updateCompletionConfigSettings(), clientContext); this.getAttributesConfigCallable = callableFactory.createUnaryCallable( getAttributesConfigTransportSettings, settings.getAttributesConfigSettings(), clientContext); this.updateAttributesConfigCallable = callableFactory.createUnaryCallable( updateAttributesConfigTransportSettings, settings.updateAttributesConfigSettings(), clientContext); this.addCatalogAttributeCallable = callableFactory.createUnaryCallable( addCatalogAttributeTransportSettings, settings.addCatalogAttributeSettings(), clientContext); this.removeCatalogAttributeCallable = callableFactory.createUnaryCallable( removeCatalogAttributeTransportSettings, settings.removeCatalogAttributeSettings(), clientContext); this.batchRemoveCatalogAttributesCallable = callableFactory.createUnaryCallable( batchRemoveCatalogAttributesTransportSettings, settings.batchRemoveCatalogAttributesSettings(), clientContext); this.replaceCatalogAttributeCallable = callableFactory.createUnaryCallable( replaceCatalogAttributeTransportSettings, settings.replaceCatalogAttributeSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } public GrpcOperationsStub getOperationsStub() { return operationsStub; } @Override public UnaryCallable listCatalogsCallable() { return listCatalogsCallable; } @Override public UnaryCallable listCatalogsPagedCallable() { return listCatalogsPagedCallable; } @Override public UnaryCallable updateCatalogCallable() { return updateCatalogCallable; } @Override public UnaryCallable setDefaultBranchCallable() { return setDefaultBranchCallable; } @Override public UnaryCallable getDefaultBranchCallable() { return getDefaultBranchCallable; } @Override public UnaryCallable getCompletionConfigCallable() { return getCompletionConfigCallable; } @Override public UnaryCallable updateCompletionConfigCallable() { return updateCompletionConfigCallable; } @Override public UnaryCallable getAttributesConfigCallable() { return getAttributesConfigCallable; } @Override public UnaryCallable updateAttributesConfigCallable() { return updateAttributesConfigCallable; } @Override public UnaryCallable addCatalogAttributeCallable() { return addCatalogAttributeCallable; } @Override public UnaryCallable removeCatalogAttributeCallable() { return removeCatalogAttributeCallable; } @Override public UnaryCallable batchRemoveCatalogAttributesCallable() { return batchRemoveCatalogAttributesCallable; } @Override public UnaryCallable replaceCatalogAttributeCallable() { return replaceCatalogAttributeCallable; } @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