com.google.cloud.apigateway.v1.stub.HttpJsonApiGatewayServiceStub Maven / Gradle / Ivy
Show all versions of google-cloud-api-gateway Show documentation
/*
* 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.apigateway.v1.stub;
import static com.google.cloud.apigateway.v1.ApiGatewayServiceClient.ListApiConfigsPagedResponse;
import static com.google.cloud.apigateway.v1.ApiGatewayServiceClient.ListApisPagedResponse;
import static com.google.cloud.apigateway.v1.ApiGatewayServiceClient.ListGatewaysPagedResponse;
import com.google.api.HttpRule;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.httpjson.ApiMethodDescriptor;
import com.google.api.gax.httpjson.HttpJsonCallSettings;
import com.google.api.gax.httpjson.HttpJsonOperationSnapshot;
import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
import com.google.api.gax.httpjson.ProtoMessageRequestFormatter;
import com.google.api.gax.httpjson.ProtoMessageResponseParser;
import com.google.api.gax.httpjson.ProtoRestSerializer;
import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub;
import com.google.api.gax.rpc.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.apigateway.v1.Api;
import com.google.cloud.apigateway.v1.ApiConfig;
import com.google.cloud.apigateway.v1.CreateApiConfigRequest;
import com.google.cloud.apigateway.v1.CreateApiRequest;
import com.google.cloud.apigateway.v1.CreateGatewayRequest;
import com.google.cloud.apigateway.v1.DeleteApiConfigRequest;
import com.google.cloud.apigateway.v1.DeleteApiRequest;
import com.google.cloud.apigateway.v1.DeleteGatewayRequest;
import com.google.cloud.apigateway.v1.Gateway;
import com.google.cloud.apigateway.v1.GetApiConfigRequest;
import com.google.cloud.apigateway.v1.GetApiRequest;
import com.google.cloud.apigateway.v1.GetGatewayRequest;
import com.google.cloud.apigateway.v1.ListApiConfigsRequest;
import com.google.cloud.apigateway.v1.ListApiConfigsResponse;
import com.google.cloud.apigateway.v1.ListApisRequest;
import com.google.cloud.apigateway.v1.ListApisResponse;
import com.google.cloud.apigateway.v1.ListGatewaysRequest;
import com.google.cloud.apigateway.v1.ListGatewaysResponse;
import com.google.cloud.apigateway.v1.OperationMetadata;
import com.google.cloud.apigateway.v1.UpdateApiConfigRequest;
import com.google.cloud.apigateway.v1.UpdateApiRequest;
import com.google.cloud.apigateway.v1.UpdateGatewayRequest;
import com.google.common.collect.ImmutableMap;
import com.google.longrunning.Operation;
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 ApiGatewayService service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@Generated("by gapic-generator-java")
public class HttpJsonApiGatewayServiceStub extends ApiGatewayServiceStub {
private static final TypeRegistry typeRegistry =
TypeRegistry.newBuilder()
.add(OperationMetadata.getDescriptor())
.add(Empty.getDescriptor())
.add(Gateway.getDescriptor())
.add(ApiConfig.getDescriptor())
.add(Api.getDescriptor())
.build();
private static final ApiMethodDescriptor
listGatewaysMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/ListGateways")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*}/gateways",
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, "filter", request.getFilter());
serializer.putQueryParam(fields, "orderBy", request.getOrderBy());
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(ListGatewaysResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor getGatewayMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/GetGateway")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/gateways/*}",
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(Gateway.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
createGatewayMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/CreateGateway")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*}/gateways",
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, "gatewayId", request.getGatewayId());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("gateway", request.getGateway(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(CreateGatewayRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
updateGatewayMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/UpdateGateway")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{gateway.name=projects/*/locations/*/gateways/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "gateway.name", request.getGateway().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("gateway", request.getGateway(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(UpdateGatewayRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
deleteGatewayMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/DeleteGateway")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/gateways/*}",
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(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(DeleteGatewayRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
listApisMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/ListApis")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*}/apis",
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, "filter", request.getFilter());
serializer.putQueryParam(fields, "orderBy", request.getOrderBy());
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(ListApisResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor getApiMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/GetApi")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/apis/*}",
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(Api.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor createApiMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/CreateApi")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*}/apis",
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, "apiId", request.getApiId());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request -> ProtoRestSerializer.create().toBody("api", request.getApi(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(CreateApiRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor updateApiMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/UpdateApi")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{api.name=projects/*/locations/*/apis/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "api.name", request.getApi().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("api", request.getApi(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(UpdateApiRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor deleteApiMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/DeleteApi")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/apis/*}",
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(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(DeleteApiRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
listApiConfigsMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/ListApiConfigs")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*/apis/*}/configs",
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, "filter", request.getFilter());
serializer.putQueryParam(fields, "orderBy", request.getOrderBy());
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(ListApiConfigsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getApiConfigMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/GetApiConfig")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/apis/*/configs/*}",
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, "view", request.getViewValue());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ApiConfig.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
createApiConfigMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/CreateApiConfig")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*/apis/*}/configs",
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, "apiConfigId", request.getApiConfigId());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("apiConfig", request.getApiConfig(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(CreateApiConfigRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
updateApiConfigMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/UpdateApiConfig")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{apiConfig.name=projects/*/locations/*/apis/*/configs/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "apiConfig.name", request.getApiConfig().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("apiConfig", request.getApiConfig(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(UpdateApiConfigRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
deleteApiConfigMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/DeleteApiConfig")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/apis/*/configs/*}",
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(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(DeleteApiConfigRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private final UnaryCallable listGatewaysCallable;
private final UnaryCallable
listGatewaysPagedCallable;
private final UnaryCallable getGatewayCallable;
private final UnaryCallable createGatewayCallable;
private final OperationCallable
createGatewayOperationCallable;
private final UnaryCallable updateGatewayCallable;
private final OperationCallable
updateGatewayOperationCallable;
private final UnaryCallable deleteGatewayCallable;
private final OperationCallable
deleteGatewayOperationCallable;
private final UnaryCallable listApisCallable;
private final UnaryCallable listApisPagedCallable;
private final UnaryCallable getApiCallable;
private final UnaryCallable createApiCallable;
private final OperationCallable
createApiOperationCallable;
private final UnaryCallable updateApiCallable;
private final OperationCallable
updateApiOperationCallable;
private final UnaryCallable deleteApiCallable;
private final OperationCallable
deleteApiOperationCallable;
private final UnaryCallable listApiConfigsCallable;
private final UnaryCallable
listApiConfigsPagedCallable;
private final UnaryCallable getApiConfigCallable;
private final UnaryCallable createApiConfigCallable;
private final OperationCallable
createApiConfigOperationCallable;
private final UnaryCallable updateApiConfigCallable;
private final OperationCallable
updateApiConfigOperationCallable;
private final UnaryCallable deleteApiConfigCallable;
private final OperationCallable
deleteApiConfigOperationCallable;
private final BackgroundResource backgroundResources;
private final HttpJsonOperationsStub httpJsonOperationsStub;
private final HttpJsonStubCallableFactory callableFactory;
public static final HttpJsonApiGatewayServiceStub create(ApiGatewayServiceStubSettings settings)
throws IOException {
return new HttpJsonApiGatewayServiceStub(settings, ClientContext.create(settings));
}
public static final HttpJsonApiGatewayServiceStub create(ClientContext clientContext)
throws IOException {
return new HttpJsonApiGatewayServiceStub(
ApiGatewayServiceStubSettings.newHttpJsonBuilder().build(), clientContext);
}
public static final HttpJsonApiGatewayServiceStub create(
ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
return new HttpJsonApiGatewayServiceStub(
ApiGatewayServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of HttpJsonApiGatewayServiceStub, 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 HttpJsonApiGatewayServiceStub(
ApiGatewayServiceStubSettings settings, ClientContext clientContext) throws IOException {
this(settings, clientContext, new HttpJsonApiGatewayServiceCallableFactory());
}
/**
* Constructs an instance of HttpJsonApiGatewayServiceStub, 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 HttpJsonApiGatewayServiceStub(
ApiGatewayServiceStubSettings 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("/v1/{name=projects/*/locations/*/operations/*}:cancel")
.build())
.put(
"google.longrunning.Operations.DeleteOperation",
HttpRule.newBuilder()
.setDelete("/v1/{name=projects/*/locations/*/operations/*}")
.build())
.put(
"google.longrunning.Operations.GetOperation",
HttpRule.newBuilder()
.setGet("/v1/{name=projects/*/locations/*/operations/*}")
.build())
.put(
"google.longrunning.Operations.ListOperations",
HttpRule.newBuilder()
.setGet("/v1/{name=projects/*/locations/*}/operations")
.build())
.build());
HttpJsonCallSettings listGatewaysTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listGatewaysMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings getGatewayTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getGatewayMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings createGatewayTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createGatewayMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings updateGatewayTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateGatewayMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("gateway.name", String.valueOf(request.getGateway().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings deleteGatewayTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(deleteGatewayMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings listApisTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listApisMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings getApiTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getApiMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings createApiTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createApiMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings updateApiTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateApiMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("api.name", String.valueOf(request.getApi().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings deleteApiTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(deleteApiMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
listApiConfigsTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listApiConfigsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings getApiConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getApiConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings createApiConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createApiConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings updateApiConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateApiConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("api_config.name", String.valueOf(request.getApiConfig().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings deleteApiConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(deleteApiConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
this.listGatewaysCallable =
callableFactory.createUnaryCallable(
listGatewaysTransportSettings, settings.listGatewaysSettings(), clientContext);
this.listGatewaysPagedCallable =
callableFactory.createPagedCallable(
listGatewaysTransportSettings, settings.listGatewaysSettings(), clientContext);
this.getGatewayCallable =
callableFactory.createUnaryCallable(
getGatewayTransportSettings, settings.getGatewaySettings(), clientContext);
this.createGatewayCallable =
callableFactory.createUnaryCallable(
createGatewayTransportSettings, settings.createGatewaySettings(), clientContext);
this.createGatewayOperationCallable =
callableFactory.createOperationCallable(
createGatewayTransportSettings,
settings.createGatewayOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.updateGatewayCallable =
callableFactory.createUnaryCallable(
updateGatewayTransportSettings, settings.updateGatewaySettings(), clientContext);
this.updateGatewayOperationCallable =
callableFactory.createOperationCallable(
updateGatewayTransportSettings,
settings.updateGatewayOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.deleteGatewayCallable =
callableFactory.createUnaryCallable(
deleteGatewayTransportSettings, settings.deleteGatewaySettings(), clientContext);
this.deleteGatewayOperationCallable =
callableFactory.createOperationCallable(
deleteGatewayTransportSettings,
settings.deleteGatewayOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.listApisCallable =
callableFactory.createUnaryCallable(
listApisTransportSettings, settings.listApisSettings(), clientContext);
this.listApisPagedCallable =
callableFactory.createPagedCallable(
listApisTransportSettings, settings.listApisSettings(), clientContext);
this.getApiCallable =
callableFactory.createUnaryCallable(
getApiTransportSettings, settings.getApiSettings(), clientContext);
this.createApiCallable =
callableFactory.createUnaryCallable(
createApiTransportSettings, settings.createApiSettings(), clientContext);
this.createApiOperationCallable =
callableFactory.createOperationCallable(
createApiTransportSettings,
settings.createApiOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.updateApiCallable =
callableFactory.createUnaryCallable(
updateApiTransportSettings, settings.updateApiSettings(), clientContext);
this.updateApiOperationCallable =
callableFactory.createOperationCallable(
updateApiTransportSettings,
settings.updateApiOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.deleteApiCallable =
callableFactory.createUnaryCallable(
deleteApiTransportSettings, settings.deleteApiSettings(), clientContext);
this.deleteApiOperationCallable =
callableFactory.createOperationCallable(
deleteApiTransportSettings,
settings.deleteApiOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.listApiConfigsCallable =
callableFactory.createUnaryCallable(
listApiConfigsTransportSettings, settings.listApiConfigsSettings(), clientContext);
this.listApiConfigsPagedCallable =
callableFactory.createPagedCallable(
listApiConfigsTransportSettings, settings.listApiConfigsSettings(), clientContext);
this.getApiConfigCallable =
callableFactory.createUnaryCallable(
getApiConfigTransportSettings, settings.getApiConfigSettings(), clientContext);
this.createApiConfigCallable =
callableFactory.createUnaryCallable(
createApiConfigTransportSettings, settings.createApiConfigSettings(), clientContext);
this.createApiConfigOperationCallable =
callableFactory.createOperationCallable(
createApiConfigTransportSettings,
settings.createApiConfigOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.updateApiConfigCallable =
callableFactory.createUnaryCallable(
updateApiConfigTransportSettings, settings.updateApiConfigSettings(), clientContext);
this.updateApiConfigOperationCallable =
callableFactory.createOperationCallable(
updateApiConfigTransportSettings,
settings.updateApiConfigOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.deleteApiConfigCallable =
callableFactory.createUnaryCallable(
deleteApiConfigTransportSettings, settings.deleteApiConfigSettings(), clientContext);
this.deleteApiConfigOperationCallable =
callableFactory.createOperationCallable(
deleteApiConfigTransportSettings,
settings.deleteApiConfigOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}
@InternalApi
public static List getMethodDescriptors() {
List methodDescriptors = new ArrayList<>();
methodDescriptors.add(listGatewaysMethodDescriptor);
methodDescriptors.add(getGatewayMethodDescriptor);
methodDescriptors.add(createGatewayMethodDescriptor);
methodDescriptors.add(updateGatewayMethodDescriptor);
methodDescriptors.add(deleteGatewayMethodDescriptor);
methodDescriptors.add(listApisMethodDescriptor);
methodDescriptors.add(getApiMethodDescriptor);
methodDescriptors.add(createApiMethodDescriptor);
methodDescriptors.add(updateApiMethodDescriptor);
methodDescriptors.add(deleteApiMethodDescriptor);
methodDescriptors.add(listApiConfigsMethodDescriptor);
methodDescriptors.add(getApiConfigMethodDescriptor);
methodDescriptors.add(createApiConfigMethodDescriptor);
methodDescriptors.add(updateApiConfigMethodDescriptor);
methodDescriptors.add(deleteApiConfigMethodDescriptor);
return methodDescriptors;
}
public HttpJsonOperationsStub getHttpJsonOperationsStub() {
return httpJsonOperationsStub;
}
@Override
public UnaryCallable listGatewaysCallable() {
return listGatewaysCallable;
}
@Override
public UnaryCallable listGatewaysPagedCallable() {
return listGatewaysPagedCallable;
}
@Override
public UnaryCallable getGatewayCallable() {
return getGatewayCallable;
}
@Override
public UnaryCallable createGatewayCallable() {
return createGatewayCallable;
}
@Override
public OperationCallable
createGatewayOperationCallable() {
return createGatewayOperationCallable;
}
@Override
public UnaryCallable updateGatewayCallable() {
return updateGatewayCallable;
}
@Override
public OperationCallable
updateGatewayOperationCallable() {
return updateGatewayOperationCallable;
}
@Override
public UnaryCallable deleteGatewayCallable() {
return deleteGatewayCallable;
}
@Override
public OperationCallable
deleteGatewayOperationCallable() {
return deleteGatewayOperationCallable;
}
@Override
public UnaryCallable listApisCallable() {
return listApisCallable;
}
@Override
public UnaryCallable listApisPagedCallable() {
return listApisPagedCallable;
}
@Override
public UnaryCallable getApiCallable() {
return getApiCallable;
}
@Override
public UnaryCallable createApiCallable() {
return createApiCallable;
}
@Override
public OperationCallable createApiOperationCallable() {
return createApiOperationCallable;
}
@Override
public UnaryCallable updateApiCallable() {
return updateApiCallable;
}
@Override
public OperationCallable updateApiOperationCallable() {
return updateApiOperationCallable;
}
@Override
public UnaryCallable deleteApiCallable() {
return deleteApiCallable;
}
@Override
public OperationCallable
deleteApiOperationCallable() {
return deleteApiOperationCallable;
}
@Override
public UnaryCallable listApiConfigsCallable() {
return listApiConfigsCallable;
}
@Override
public UnaryCallable
listApiConfigsPagedCallable() {
return listApiConfigsPagedCallable;
}
@Override
public UnaryCallable getApiConfigCallable() {
return getApiConfigCallable;
}
@Override
public UnaryCallable createApiConfigCallable() {
return createApiConfigCallable;
}
@Override
public OperationCallable
createApiConfigOperationCallable() {
return createApiConfigOperationCallable;
}
@Override
public UnaryCallable updateApiConfigCallable() {
return updateApiConfigCallable;
}
@Override
public OperationCallable
updateApiConfigOperationCallable() {
return updateApiConfigOperationCallable;
}
@Override
public UnaryCallable deleteApiConfigCallable() {
return deleteApiConfigCallable;
}
@Override
public OperationCallable
deleteApiConfigOperationCallable() {
return deleteApiConfigOperationCallable;
}
@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);
}
}