com.google.cloud.pubsub.v1.stub.HttpJsonSubscriberStub Maven / Gradle / Ivy
Show all versions of google-cloud-pubsub 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.pubsub.v1.stub;
import static com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse;
import static com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSubscriptionsPagedResponse;
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.BidiStreamingCallable;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
import com.google.protobuf.Empty;
import com.google.protobuf.TypeRegistry;
import com.google.pubsub.v1.AcknowledgeRequest;
import com.google.pubsub.v1.CreateSnapshotRequest;
import com.google.pubsub.v1.DeleteSnapshotRequest;
import com.google.pubsub.v1.DeleteSubscriptionRequest;
import com.google.pubsub.v1.GetSnapshotRequest;
import com.google.pubsub.v1.GetSubscriptionRequest;
import com.google.pubsub.v1.ListSnapshotsRequest;
import com.google.pubsub.v1.ListSnapshotsResponse;
import com.google.pubsub.v1.ListSubscriptionsRequest;
import com.google.pubsub.v1.ListSubscriptionsResponse;
import com.google.pubsub.v1.ModifyAckDeadlineRequest;
import com.google.pubsub.v1.ModifyPushConfigRequest;
import com.google.pubsub.v1.PullRequest;
import com.google.pubsub.v1.PullResponse;
import com.google.pubsub.v1.SeekRequest;
import com.google.pubsub.v1.SeekResponse;
import com.google.pubsub.v1.Snapshot;
import com.google.pubsub.v1.StreamingPullRequest;
import com.google.pubsub.v1.StreamingPullResponse;
import com.google.pubsub.v1.Subscription;
import com.google.pubsub.v1.UpdateSnapshotRequest;
import com.google.pubsub.v1.UpdateSubscriptionRequest;
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 Subscriber service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@Generated("by gapic-generator-java")
public class HttpJsonSubscriberStub extends SubscriberStub {
private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build();
private static final ApiMethodDescriptor
createSubscriptionMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/CreateSubscription")
.setHttpMethod("PUT")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/subscriptions/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Subscription.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getSubscriptionMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/GetSubscription")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{subscription=projects/*/subscriptions/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "subscription", request.getSubscription());
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(Subscription.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
updateSubscriptionMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/UpdateSubscription")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{subscription.name=projects/*/subscriptions/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "subscription.name", request.getSubscription().getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Subscription.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
listSubscriptionsMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/ListSubscriptions")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{project=projects/*}/subscriptions",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "project", request.getProject());
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(ListSubscriptionsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
deleteSubscriptionMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/DeleteSubscription")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{subscription=projects/*/subscriptions/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "subscription", request.getSubscription());
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(Empty.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
modifyAckDeadlineMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/ModifyAckDeadline")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{subscription=projects/*/subscriptions/*}:modifyAckDeadline",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "subscription", request.getSubscription());
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().clearSubscription().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Empty.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor acknowledgeMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/Acknowledge")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{subscription=projects/*/subscriptions/*}:acknowledge",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "subscription", request.getSubscription());
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().clearSubscription().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Empty.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor pullMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/Pull")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{subscription=projects/*/subscriptions/*}:pull",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer = ProtoRestSerializer.create();
serializer.putPathParam(fields, "subscription", request.getSubscription());
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().clearSubscription().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(PullResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
modifyPushConfigMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/ModifyPushConfig")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{subscription=projects/*/subscriptions/*}:modifyPushConfig",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "subscription", request.getSubscription());
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().clearSubscription().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Empty.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getSnapshotMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/GetSnapshot")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{snapshot=projects/*/snapshots/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "snapshot", request.getSnapshot());
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(Snapshot.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
listSnapshotsMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/ListSnapshots")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{project=projects/*}/snapshots",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "project", request.getProject());
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(ListSnapshotsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
createSnapshotMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/CreateSnapshot")
.setHttpMethod("PUT")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/snapshots/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Snapshot.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
updateSnapshotMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/UpdateSnapshot")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{snapshot.name=projects/*/snapshots/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "snapshot.name", request.getSnapshot().getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Snapshot.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
deleteSnapshotMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/DeleteSnapshot")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{snapshot=projects/*/snapshots/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "snapshot", request.getSnapshot());
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(Empty.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor seekMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.pubsub.v1.Subscriber/Seek")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{subscription=projects/*/subscriptions/*}:seek",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer = ProtoRestSerializer.create();
serializer.putPathParam(fields, "subscription", request.getSubscription());
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().clearSubscription().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(SeekResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
setIamPolicyMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.iam.v1.IAMPolicy/SetIamPolicy")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{resource=projects/*/topics/*}:setIamPolicy",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "resource", request.getResource());
return fields;
})
.setAdditionalPaths(
"/v1/{resource=projects/*/subscriptions/*}:setIamPolicy",
"/v1/{resource=projects/*/snapshots/*}:setIamPolicy",
"/v1/{resource=projects/*/schemas/*}:setIamPolicy")
.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().clearResource().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Policy.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getIamPolicyMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.iam.v1.IAMPolicy/GetIamPolicy")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{resource=projects/*/topics/*}:getIamPolicy",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "resource", request.getResource());
return fields;
})
.setAdditionalPaths(
"/v1/{resource=projects/*/subscriptions/*}:getIamPolicy",
"/v1/{resource=projects/*/snapshots/*}:getIamPolicy",
"/v1/{resource=projects/*/schemas/*}:getIamPolicy")
.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(Policy.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
testIamPermissionsMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.iam.v1.IAMPolicy/TestIamPermissions")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{resource=projects/*/subscriptions/*}:testIamPermissions",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "resource", request.getResource());
return fields;
})
.setAdditionalPaths(
"/v1/{resource=projects/*/topics/*}:testIamPermissions",
"/v1/{resource=projects/*/snapshots/*}:testIamPermissions",
"/v1/{resource=projects/*/schemas/*}:testIamPermissions")
.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().clearResource().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private final UnaryCallable createSubscriptionCallable;
private final UnaryCallable getSubscriptionCallable;
private final UnaryCallable updateSubscriptionCallable;
private final UnaryCallable
listSubscriptionsCallable;
private final UnaryCallable
listSubscriptionsPagedCallable;
private final UnaryCallable deleteSubscriptionCallable;
private final UnaryCallable modifyAckDeadlineCallable;
private final UnaryCallable acknowledgeCallable;
private final UnaryCallable pullCallable;
private final UnaryCallable modifyPushConfigCallable;
private final UnaryCallable getSnapshotCallable;
private final UnaryCallable listSnapshotsCallable;
private final UnaryCallable
listSnapshotsPagedCallable;
private final UnaryCallable createSnapshotCallable;
private final UnaryCallable updateSnapshotCallable;
private final UnaryCallable deleteSnapshotCallable;
private final UnaryCallable seekCallable;
private final UnaryCallable setIamPolicyCallable;
private final UnaryCallable getIamPolicyCallable;
private final UnaryCallable
testIamPermissionsCallable;
private final BackgroundResource backgroundResources;
private final HttpJsonStubCallableFactory callableFactory;
public static final HttpJsonSubscriberStub create(SubscriberStubSettings settings)
throws IOException {
return new HttpJsonSubscriberStub(settings, ClientContext.create(settings));
}
public static final HttpJsonSubscriberStub create(ClientContext clientContext)
throws IOException {
return new HttpJsonSubscriberStub(
SubscriberStubSettings.newHttpJsonBuilder().build(), clientContext);
}
public static final HttpJsonSubscriberStub create(
ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
return new HttpJsonSubscriberStub(
SubscriberStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of HttpJsonSubscriberStub, 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 HttpJsonSubscriberStub(SubscriberStubSettings settings, ClientContext clientContext)
throws IOException {
this(settings, clientContext, new HttpJsonSubscriberCallableFactory());
}
/**
* Constructs an instance of HttpJsonSubscriberStub, 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 HttpJsonSubscriberStub(
SubscriberStubSettings settings,
ClientContext clientContext,
HttpJsonStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
HttpJsonCallSettings createSubscriptionTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createSubscriptionMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings getSubscriptionTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getSubscriptionMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("subscription", String.valueOf(request.getSubscription()));
return builder.build();
})
.build();
HttpJsonCallSettings
updateSubscriptionTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateSubscriptionMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(
"subscription.name", String.valueOf(request.getSubscription().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
listSubscriptionsTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listSubscriptionsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("project", String.valueOf(request.getProject()));
return builder.build();
})
.build();
HttpJsonCallSettings deleteSubscriptionTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(deleteSubscriptionMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("subscription", String.valueOf(request.getSubscription()));
return builder.build();
})
.build();
HttpJsonCallSettings modifyAckDeadlineTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(modifyAckDeadlineMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("subscription", String.valueOf(request.getSubscription()));
return builder.build();
})
.build();
HttpJsonCallSettings acknowledgeTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(acknowledgeMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("subscription", String.valueOf(request.getSubscription()));
return builder.build();
})
.build();
HttpJsonCallSettings pullTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(pullMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("subscription", String.valueOf(request.getSubscription()));
return builder.build();
})
.build();
HttpJsonCallSettings modifyPushConfigTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(modifyPushConfigMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("subscription", String.valueOf(request.getSubscription()));
return builder.build();
})
.build();
HttpJsonCallSettings getSnapshotTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getSnapshotMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("snapshot", String.valueOf(request.getSnapshot()));
return builder.build();
})
.build();
HttpJsonCallSettings
listSnapshotsTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listSnapshotsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("project", String.valueOf(request.getProject()));
return builder.build();
})
.build();
HttpJsonCallSettings createSnapshotTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createSnapshotMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings updateSnapshotTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateSnapshotMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("snapshot.name", String.valueOf(request.getSnapshot().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings deleteSnapshotTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(deleteSnapshotMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("snapshot", String.valueOf(request.getSnapshot()));
return builder.build();
})
.build();
HttpJsonCallSettings seekTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(seekMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("subscription", String.valueOf(request.getSubscription()));
return builder.build();
})
.build();
HttpJsonCallSettings setIamPolicyTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(setIamPolicyMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("resource", String.valueOf(request.getResource()));
return builder.build();
})
.build();
HttpJsonCallSettings getIamPolicyTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getIamPolicyMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("resource", String.valueOf(request.getResource()));
return builder.build();
})
.build();
HttpJsonCallSettings
testIamPermissionsTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(testIamPermissionsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("resource", String.valueOf(request.getResource()));
return builder.build();
})
.build();
this.createSubscriptionCallable =
callableFactory.createUnaryCallable(
createSubscriptionTransportSettings,
settings.createSubscriptionSettings(),
clientContext);
this.getSubscriptionCallable =
callableFactory.createUnaryCallable(
getSubscriptionTransportSettings, settings.getSubscriptionSettings(), clientContext);
this.updateSubscriptionCallable =
callableFactory.createUnaryCallable(
updateSubscriptionTransportSettings,
settings.updateSubscriptionSettings(),
clientContext);
this.listSubscriptionsCallable =
callableFactory.createUnaryCallable(
listSubscriptionsTransportSettings,
settings.listSubscriptionsSettings(),
clientContext);
this.listSubscriptionsPagedCallable =
callableFactory.createPagedCallable(
listSubscriptionsTransportSettings,
settings.listSubscriptionsSettings(),
clientContext);
this.deleteSubscriptionCallable =
callableFactory.createUnaryCallable(
deleteSubscriptionTransportSettings,
settings.deleteSubscriptionSettings(),
clientContext);
this.modifyAckDeadlineCallable =
callableFactory.createUnaryCallable(
modifyAckDeadlineTransportSettings,
settings.modifyAckDeadlineSettings(),
clientContext);
this.acknowledgeCallable =
callableFactory.createUnaryCallable(
acknowledgeTransportSettings, settings.acknowledgeSettings(), clientContext);
this.pullCallable =
callableFactory.createUnaryCallable(
pullTransportSettings, settings.pullSettings(), clientContext);
this.modifyPushConfigCallable =
callableFactory.createUnaryCallable(
modifyPushConfigTransportSettings, settings.modifyPushConfigSettings(), clientContext);
this.getSnapshotCallable =
callableFactory.createUnaryCallable(
getSnapshotTransportSettings, settings.getSnapshotSettings(), clientContext);
this.listSnapshotsCallable =
callableFactory.createUnaryCallable(
listSnapshotsTransportSettings, settings.listSnapshotsSettings(), clientContext);
this.listSnapshotsPagedCallable =
callableFactory.createPagedCallable(
listSnapshotsTransportSettings, settings.listSnapshotsSettings(), clientContext);
this.createSnapshotCallable =
callableFactory.createUnaryCallable(
createSnapshotTransportSettings, settings.createSnapshotSettings(), clientContext);
this.updateSnapshotCallable =
callableFactory.createUnaryCallable(
updateSnapshotTransportSettings, settings.updateSnapshotSettings(), clientContext);
this.deleteSnapshotCallable =
callableFactory.createUnaryCallable(
deleteSnapshotTransportSettings, settings.deleteSnapshotSettings(), clientContext);
this.seekCallable =
callableFactory.createUnaryCallable(
seekTransportSettings, settings.seekSettings(), clientContext);
this.setIamPolicyCallable =
callableFactory.createUnaryCallable(
setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext);
this.getIamPolicyCallable =
callableFactory.createUnaryCallable(
getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext);
this.testIamPermissionsCallable =
callableFactory.createUnaryCallable(
testIamPermissionsTransportSettings,
settings.testIamPermissionsSettings(),
clientContext);
this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}
@InternalApi
public static List getMethodDescriptors() {
List methodDescriptors = new ArrayList<>();
methodDescriptors.add(createSubscriptionMethodDescriptor);
methodDescriptors.add(getSubscriptionMethodDescriptor);
methodDescriptors.add(updateSubscriptionMethodDescriptor);
methodDescriptors.add(listSubscriptionsMethodDescriptor);
methodDescriptors.add(deleteSubscriptionMethodDescriptor);
methodDescriptors.add(modifyAckDeadlineMethodDescriptor);
methodDescriptors.add(acknowledgeMethodDescriptor);
methodDescriptors.add(pullMethodDescriptor);
methodDescriptors.add(modifyPushConfigMethodDescriptor);
methodDescriptors.add(getSnapshotMethodDescriptor);
methodDescriptors.add(listSnapshotsMethodDescriptor);
methodDescriptors.add(createSnapshotMethodDescriptor);
methodDescriptors.add(updateSnapshotMethodDescriptor);
methodDescriptors.add(deleteSnapshotMethodDescriptor);
methodDescriptors.add(seekMethodDescriptor);
methodDescriptors.add(setIamPolicyMethodDescriptor);
methodDescriptors.add(getIamPolicyMethodDescriptor);
methodDescriptors.add(testIamPermissionsMethodDescriptor);
return methodDescriptors;
}
@Override
public UnaryCallable createSubscriptionCallable() {
return createSubscriptionCallable;
}
@Override
public UnaryCallable getSubscriptionCallable() {
return getSubscriptionCallable;
}
@Override
public UnaryCallable updateSubscriptionCallable() {
return updateSubscriptionCallable;
}
@Override
public UnaryCallable
listSubscriptionsCallable() {
return listSubscriptionsCallable;
}
@Override
public UnaryCallable
listSubscriptionsPagedCallable() {
return listSubscriptionsPagedCallable;
}
@Override
public UnaryCallable deleteSubscriptionCallable() {
return deleteSubscriptionCallable;
}
@Override
public UnaryCallable modifyAckDeadlineCallable() {
return modifyAckDeadlineCallable;
}
@Override
public UnaryCallable acknowledgeCallable() {
return acknowledgeCallable;
}
@Override
public UnaryCallable pullCallable() {
return pullCallable;
}
@Override
public UnaryCallable modifyPushConfigCallable() {
return modifyPushConfigCallable;
}
@Override
public UnaryCallable getSnapshotCallable() {
return getSnapshotCallable;
}
@Override
public UnaryCallable listSnapshotsCallable() {
return listSnapshotsCallable;
}
@Override
public UnaryCallable
listSnapshotsPagedCallable() {
return listSnapshotsPagedCallable;
}
@Override
public UnaryCallable createSnapshotCallable() {
return createSnapshotCallable;
}
@Override
public UnaryCallable updateSnapshotCallable() {
return updateSnapshotCallable;
}
@Override
public UnaryCallable deleteSnapshotCallable() {
return deleteSnapshotCallable;
}
@Override
public UnaryCallable seekCallable() {
return seekCallable;
}
@Override
public UnaryCallable setIamPolicyCallable() {
return setIamPolicyCallable;
}
@Override
public UnaryCallable getIamPolicyCallable() {
return getIamPolicyCallable;
}
@Override
public UnaryCallable
testIamPermissionsCallable() {
return testIamPermissionsCallable;
}
@Override
public BidiStreamingCallable
streamingPullCallable() {
throw new UnsupportedOperationException(
"Not implemented: streamingPullCallable(). REST transport is not implemented for this method yet.");
}
@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);
}
}