com.google.cloud.retail.v2beta.stub.HttpJsonCatalogServiceStub Maven / Gradle / Ivy
/*
* 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.v2beta.stub;
import static com.google.cloud.retail.v2beta.CatalogServiceClient.ListCatalogsPagedResponse;
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.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.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.retail.v2beta.AddCatalogAttributeRequest;
import com.google.cloud.retail.v2beta.AttributesConfig;
import com.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest;
import com.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse;
import com.google.cloud.retail.v2beta.Catalog;
import com.google.cloud.retail.v2beta.CompletionConfig;
import com.google.cloud.retail.v2beta.GetAttributesConfigRequest;
import com.google.cloud.retail.v2beta.GetCompletionConfigRequest;
import com.google.cloud.retail.v2beta.GetDefaultBranchRequest;
import com.google.cloud.retail.v2beta.GetDefaultBranchResponse;
import com.google.cloud.retail.v2beta.ListCatalogsRequest;
import com.google.cloud.retail.v2beta.ListCatalogsResponse;
import com.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest;
import com.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest;
import com.google.cloud.retail.v2beta.SetDefaultBranchRequest;
import com.google.cloud.retail.v2beta.UpdateAttributesConfigRequest;
import com.google.cloud.retail.v2beta.UpdateCatalogRequest;
import com.google.cloud.retail.v2beta.UpdateCompletionConfigRequest;
import com.google.protobuf.Empty;
import com.google.protobuf.TypeRegistry;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* REST stub implementation for the CatalogService service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@BetaApi
@Generated("by gapic-generator-java")
public class HttpJsonCatalogServiceStub extends CatalogServiceStub {
private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build();
private static final ApiMethodDescriptor
listCatalogsMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.retail.v2beta.CatalogService/ListCatalogs")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{parent=projects/*/locations/*}/catalogs",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ListCatalogsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
updateCatalogMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.retail.v2beta.CatalogService/UpdateCatalog")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{catalog.name=projects/*/locations/*/catalogs/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "catalog.name", request.getCatalog().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("catalog", request.getCatalog(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Catalog.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
setDefaultBranchMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.retail.v2beta.CatalogService/SetDefaultBranch")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "catalog", request.getCatalog());
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().clearCatalog().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Empty.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getDefaultBranchMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.retail.v2beta.CatalogService/GetDefaultBranch")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "catalog", request.getCatalog());
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(GetDefaultBranchResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getCompletionConfigMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.retail.v2beta.CatalogService/GetCompletionConfig")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{name=projects/*/locations/*/catalogs/*/completionConfig}",
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(CompletionConfig.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
updateCompletionConfigMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.retail.v2beta.CatalogService/UpdateCompletionConfig")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{completionConfig.name=projects/*/locations/*/catalogs/*/completionConfig}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields,
"completionConfig.name",
request.getCompletionConfig().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("completionConfig", request.getCompletionConfig(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(CompletionConfig.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getAttributesConfigMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.retail.v2beta.CatalogService/GetAttributesConfig")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{name=projects/*/locations/*/catalogs/*/attributesConfig}",
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(AttributesConfig.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
updateAttributesConfigMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.retail.v2beta.CatalogService/UpdateAttributesConfig")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{attributesConfig.name=projects/*/locations/*/catalogs/*/attributesConfig}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields,
"attributesConfig.name",
request.getAttributesConfig().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("attributesConfig", request.getAttributesConfig(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(AttributesConfig.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
addCatalogAttributeMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.retail.v2beta.CatalogService/AddCatalogAttribute")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "attributesConfig", request.getAttributesConfig());
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().clearAttributesConfig().build(),
true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(AttributesConfig.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
removeCatalogAttributeMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.retail.v2beta.CatalogService/RemoveCatalogAttribute")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "attributesConfig", request.getAttributesConfig());
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().clearAttributesConfig().build(),
true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(AttributesConfig.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor<
BatchRemoveCatalogAttributesRequest, BatchRemoveCatalogAttributesResponse>
batchRemoveCatalogAttributesMethodDescriptor =
ApiMethodDescriptor
.
newBuilder()
.setFullMethodName(
"google.cloud.retail.v2beta.CatalogService/BatchRemoveCatalogAttributes")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:batchRemoveCatalogAttributes",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "attributesConfig", request.getAttributesConfig());
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().clearAttributesConfig().build(),
true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(BatchRemoveCatalogAttributesResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
replaceCatalogAttributeMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName(
"google.cloud.retail.v2beta.CatalogService/ReplaceCatalogAttribute")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v2beta/{attributesConfig=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "attributesConfig", request.getAttributesConfig());
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().clearAttributesConfig().build(),
true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(AttributesConfig.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.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 HttpJsonStubCallableFactory callableFactory;
public static final HttpJsonCatalogServiceStub create(CatalogServiceStubSettings settings)
throws IOException {
return new HttpJsonCatalogServiceStub(settings, ClientContext.create(settings));
}
public static final HttpJsonCatalogServiceStub create(ClientContext clientContext)
throws IOException {
return new HttpJsonCatalogServiceStub(
CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext);
}
public static final HttpJsonCatalogServiceStub create(
ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
return new HttpJsonCatalogServiceStub(
CatalogServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of HttpJsonCatalogServiceStub, 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 HttpJsonCatalogServiceStub(
CatalogServiceStubSettings settings, ClientContext clientContext) throws IOException {
this(settings, clientContext, new HttpJsonCatalogServiceCallableFactory());
}
/**
* Constructs an instance of HttpJsonCatalogServiceStub, 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 HttpJsonCatalogServiceStub(
CatalogServiceStubSettings settings,
ClientContext clientContext,
HttpJsonStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
HttpJsonCallSettings listCatalogsTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listCatalogsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings updateCatalogTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateCatalogMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("catalog.name", String.valueOf(request.getCatalog().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings setDefaultBranchTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(setDefaultBranchMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("catalog", String.valueOf(request.getCatalog()));
return builder.build();
})
.build();
HttpJsonCallSettings
getDefaultBranchTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getDefaultBranchMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("catalog", String.valueOf(request.getCatalog()));
return builder.build();
})
.build();
HttpJsonCallSettings
getCompletionConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getCompletionConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
updateCompletionConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateCompletionConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(
"completion_config.name",
String.valueOf(request.getCompletionConfig().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
getAttributesConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getAttributesConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
updateAttributesConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateAttributesConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(
"attributes_config.name",
String.valueOf(request.getAttributesConfig().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
addCatalogAttributeTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(addCatalogAttributeMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(
"attributes_config", String.valueOf(request.getAttributesConfig()));
return builder.build();
})
.build();
HttpJsonCallSettings
removeCatalogAttributeTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(removeCatalogAttributeMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(
"attributes_config", String.valueOf(request.getAttributesConfig()));
return builder.build();
})
.build();
HttpJsonCallSettings
batchRemoveCatalogAttributesTransportSettings =
HttpJsonCallSettings
.
newBuilder()
.setMethodDescriptor(batchRemoveCatalogAttributesMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(
"attributes_config", String.valueOf(request.getAttributesConfig()));
return builder.build();
})
.build();
HttpJsonCallSettings
replaceCatalogAttributeTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(replaceCatalogAttributeMethodDescriptor)
.setTypeRegistry(typeRegistry)
.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());
}
@InternalApi
public static List getMethodDescriptors() {
List methodDescriptors = new ArrayList<>();
methodDescriptors.add(listCatalogsMethodDescriptor);
methodDescriptors.add(updateCatalogMethodDescriptor);
methodDescriptors.add(setDefaultBranchMethodDescriptor);
methodDescriptors.add(getDefaultBranchMethodDescriptor);
methodDescriptors.add(getCompletionConfigMethodDescriptor);
methodDescriptors.add(updateCompletionConfigMethodDescriptor);
methodDescriptors.add(getAttributesConfigMethodDescriptor);
methodDescriptors.add(updateAttributesConfigMethodDescriptor);
methodDescriptors.add(addCatalogAttributeMethodDescriptor);
methodDescriptors.add(removeCatalogAttributeMethodDescriptor);
methodDescriptors.add(batchRemoveCatalogAttributesMethodDescriptor);
methodDescriptors.add(replaceCatalogAttributeMethodDescriptor);
return methodDescriptors;
}
@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);
}
}