Skip to content

Commit d1ece8a

Browse files
Merge pull request #716 from garrettjonesgoogle/pubsub-alpha
Regenerating code, new settings classes
2 parents d549d3f + 5245e7d commit d1ece8a

File tree

11 files changed

+3014
-707
lines changed

11 files changed

+3014
-707
lines changed

gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java

Lines changed: 544 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
/*
2+
* Copyright 2015 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
/*
16+
* EDITING INSTRUCTIONS
17+
* This file was generated from the file
18+
* https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto
19+
* and updates to that file get reflected here through a refresh process.
20+
* For the short term, the refresh process will only be runnable by Google engineers.
21+
* Manual additions are allowed because the refresh process performs
22+
* a 3-way merge in order to preserve those manual additions. In order to not
23+
* break the refresh process, only certain types of modifications are
24+
* allowed.
25+
*
26+
* Allowed modifications - currently these are the only types allowed:
27+
* 1. New methods (these should be added to the end of the class)
28+
* 2. New imports
29+
* 3. Additional documentation between "manual edit" demarcations
30+
*
31+
* Happy editing!
32+
*/
33+
34+
package com.google.gcloud.pubsub.spi;
35+
36+
import com.google.api.gax.core.BackoffParams;
37+
import com.google.api.gax.core.ConnectionSettings;
38+
import com.google.api.gax.core.RetryParams;
39+
import com.google.api.gax.grpc.ApiCallSettings;
40+
import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder;
41+
import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder;
42+
import com.google.api.gax.grpc.PageDescriptor;
43+
import com.google.api.gax.grpc.ServiceApiSettings;
44+
import com.google.common.collect.ImmutableList;
45+
import com.google.common.collect.ImmutableMap;
46+
import com.google.common.collect.ImmutableSet;
47+
import com.google.common.collect.Lists;
48+
import com.google.common.collect.Sets;
49+
import com.google.protobuf.Empty;
50+
import com.google.pubsub.v1.DeleteTopicRequest;
51+
import com.google.pubsub.v1.GetTopicRequest;
52+
import com.google.pubsub.v1.ListTopicSubscriptionsRequest;
53+
import com.google.pubsub.v1.ListTopicSubscriptionsResponse;
54+
import com.google.pubsub.v1.ListTopicsRequest;
55+
import com.google.pubsub.v1.ListTopicsResponse;
56+
import com.google.pubsub.v1.PublishRequest;
57+
import com.google.pubsub.v1.PublishResponse;
58+
import com.google.pubsub.v1.PublisherGrpc;
59+
import com.google.pubsub.v1.Topic;
60+
import io.grpc.Status;
61+
62+
// Manually-added imports: add custom (non-generated) imports after this point.
63+
64+
// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing.
65+
@javax.annotation.Generated("by GAPIC")
66+
public class PublisherSettings extends ServiceApiSettings {
67+
68+
// =========
69+
// Constants
70+
// =========
71+
72+
/**
73+
* The default address of the service.
74+
*
75+
* <!-- manual edit -->
76+
* <!-- end manual edit -->
77+
*/
78+
public static final String DEFAULT_SERVICE_ADDRESS = "pubsub-experimental.googleapis.com";
79+
80+
/**
81+
* The default port of the service.
82+
*
83+
* <!-- manual edit -->
84+
* <!-- end manual edit -->
85+
*/
86+
public static final int DEFAULT_SERVICE_PORT = 443;
87+
88+
/**
89+
* The default scopes of the service.
90+
*/
91+
public static final ImmutableList<String> DEFAULT_SERVICE_SCOPES =
92+
ImmutableList.<String>builder()
93+
.add("https://www.googleapis.com/auth/pubsub")
94+
.add("https://www.googleapis.com/auth/cloud-platform")
95+
.build();
96+
97+
private static final ImmutableMap<String, ImmutableSet<Status.Code>> RETRYABLE_CODE_DEFINITIONS;
98+
99+
static {
100+
ImmutableMap.Builder<String, ImmutableSet<Status.Code>> definitions = ImmutableMap.builder();
101+
definitions.put(
102+
"idempotent",
103+
Sets.immutableEnumSet(
104+
Lists.<Status.Code>newArrayList(
105+
Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE)));
106+
definitions.put("non_idempotent", Sets.immutableEnumSet(Lists.<Status.Code>newArrayList()));
107+
RETRYABLE_CODE_DEFINITIONS = definitions.build();
108+
}
109+
110+
private static final ImmutableMap<String, RetryParams> RETRY_PARAM_DEFINITIONS;
111+
112+
static {
113+
ImmutableMap.Builder<String, RetryParams> definitions = ImmutableMap.builder();
114+
RetryParams params = null;
115+
params =
116+
RetryParams.newBuilder()
117+
.setRetryBackoff(
118+
BackoffParams.newBuilder()
119+
.setInitialDelayMillis(100L)
120+
.setDelayMultiplier(1.2)
121+
.setMaxDelayMillis(1000L)
122+
.build())
123+
.setTimeoutBackoff(
124+
BackoffParams.newBuilder()
125+
.setInitialDelayMillis(300L)
126+
.setDelayMultiplier(1.3)
127+
.setMaxDelayMillis(3000L)
128+
.build())
129+
.setTotalTimeout(30000L)
130+
.build();
131+
definitions.put("default", params);
132+
RETRY_PARAM_DEFINITIONS = definitions.build();
133+
}
134+
135+
private static class MethodBuilders {
136+
private final ApiCallableBuilder<Topic, Topic> createTopicMethod;
137+
private final ApiCallableBuilder<PublishRequest, PublishResponse> publishMethod;
138+
private final ApiCallableBuilder<GetTopicRequest, Topic> getTopicMethod;
139+
private final PageStreamingApiCallableBuilder<ListTopicsRequest, ListTopicsResponse, Topic>
140+
listTopicsMethod;
141+
private final PageStreamingApiCallableBuilder<
142+
ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
143+
listTopicSubscriptionsMethod;
144+
private final ApiCallableBuilder<DeleteTopicRequest, Empty> deleteTopicMethod;
145+
private final ImmutableList<? extends ApiCallSettings> allMethods;
146+
147+
public MethodBuilders() {
148+
createTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_CREATE_TOPIC);
149+
createTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"));
150+
createTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
151+
152+
publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH);
153+
publishMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"));
154+
publishMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
155+
156+
getTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_GET_TOPIC);
157+
getTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"));
158+
getTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
159+
160+
listTopicsMethod =
161+
new PageStreamingApiCallableBuilder<>(
162+
PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC);
163+
listTopicsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"));
164+
listTopicsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
165+
166+
listTopicSubscriptionsMethod =
167+
new PageStreamingApiCallableBuilder<>(
168+
PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS,
169+
LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC);
170+
listTopicSubscriptionsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"));
171+
listTopicSubscriptionsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
172+
173+
deleteTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_DELETE_TOPIC);
174+
deleteTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"));
175+
deleteTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
176+
177+
allMethods =
178+
ImmutableList.<ApiCallSettings>builder()
179+
.add(
180+
createTopicMethod,
181+
publishMethod,
182+
getTopicMethod,
183+
listTopicsMethod,
184+
listTopicSubscriptionsMethod,
185+
deleteTopicMethod)
186+
.build();
187+
}
188+
}
189+
190+
private final MethodBuilders methods;
191+
192+
// ===============
193+
// Factory Methods
194+
// ===============
195+
196+
/**
197+
* Constructs an instance of PublisherSettings with default settings.
198+
*
199+
* <!-- manual edit -->
200+
* <!-- end manual edit -->
201+
*/
202+
public static PublisherSettings create() {
203+
PublisherSettings settings = new PublisherSettings(new MethodBuilders());
204+
settings.provideChannelWith(
205+
ConnectionSettings.builder()
206+
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
207+
.setPort(DEFAULT_SERVICE_PORT)
208+
.provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
209+
.build());
210+
return settings;
211+
}
212+
213+
/**
214+
* Constructs an instance of PublisherSettings with default settings. This is protected so that it
215+
* easy to make a subclass, but otherwise, the static factory methods should be preferred.
216+
*
217+
* <!-- manual edit -->
218+
* <!-- end manual edit -->
219+
*/
220+
protected PublisherSettings(MethodBuilders methods) {
221+
super(methods.allMethods);
222+
this.methods = methods;
223+
}
224+
225+
/**
226+
* Returns the ApiCallableBuilder for the API method createTopic.
227+
*
228+
* <!-- manual edit -->
229+
* <!-- end manual edit -->
230+
*/
231+
public ApiCallableBuilder<Topic, Topic> createTopicMethod() {
232+
return methods.createTopicMethod;
233+
}
234+
235+
/**
236+
* Returns the ApiCallableBuilder for the API method publish.
237+
*
238+
* <!-- manual edit -->
239+
* <!-- end manual edit -->
240+
*/
241+
public ApiCallableBuilder<PublishRequest, PublishResponse> publishMethod() {
242+
return methods.publishMethod;
243+
}
244+
245+
/**
246+
* Returns the ApiCallableBuilder for the API method getTopic.
247+
*
248+
* <!-- manual edit -->
249+
* <!-- end manual edit -->
250+
*/
251+
public ApiCallableBuilder<GetTopicRequest, Topic> getTopicMethod() {
252+
return methods.getTopicMethod;
253+
}
254+
255+
/**
256+
* Returns the PageStreamingApiCallableBuilder for the API method listTopics.
257+
*
258+
* <!-- manual edit -->
259+
* <!-- end manual edit -->
260+
*/
261+
public PageStreamingApiCallableBuilder<ListTopicsRequest, ListTopicsResponse, Topic>
262+
listTopicsMethod() {
263+
return methods.listTopicsMethod;
264+
}
265+
266+
/**
267+
* Returns the PageStreamingApiCallableBuilder for the API method listTopicSubscriptions.
268+
*
269+
* <!-- manual edit -->
270+
* <!-- end manual edit -->
271+
*/
272+
public PageStreamingApiCallableBuilder<
273+
ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
274+
listTopicSubscriptionsMethod() {
275+
return methods.listTopicSubscriptionsMethod;
276+
}
277+
278+
/**
279+
* Returns the ApiCallableBuilder for the API method deleteTopic.
280+
*
281+
* <!-- manual edit -->
282+
* <!-- end manual edit -->
283+
*/
284+
public ApiCallableBuilder<DeleteTopicRequest, Empty> deleteTopicMethod() {
285+
return methods.deleteTopicMethod;
286+
}
287+
288+
private static PageDescriptor<ListTopicsRequest, ListTopicsResponse, Topic>
289+
LIST_TOPICS_PAGE_STR_DESC =
290+
new PageDescriptor<ListTopicsRequest, ListTopicsResponse, Topic>() {
291+
@Override
292+
public Object emptyToken() {
293+
return "";
294+
}
295+
296+
@Override
297+
public ListTopicsRequest injectToken(ListTopicsRequest payload, Object token) {
298+
return ListTopicsRequest.newBuilder(payload).setPageToken((String) token).build();
299+
}
300+
301+
@Override
302+
public Object extractNextToken(ListTopicsResponse payload) {
303+
return payload.getNextPageToken();
304+
}
305+
306+
@Override
307+
public Iterable<Topic> extractResources(ListTopicsResponse payload) {
308+
return payload.getTopicsList();
309+
}
310+
};
311+
312+
private static PageDescriptor<
313+
ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
314+
LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC =
315+
new PageDescriptor<
316+
ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>() {
317+
@Override
318+
public Object emptyToken() {
319+
return "";
320+
}
321+
322+
@Override
323+
public ListTopicSubscriptionsRequest injectToken(
324+
ListTopicSubscriptionsRequest payload, Object token) {
325+
return ListTopicSubscriptionsRequest.newBuilder(payload)
326+
.setPageToken((String) token)
327+
.build();
328+
}
329+
330+
@Override
331+
public Object extractNextToken(ListTopicSubscriptionsResponse payload) {
332+
return payload.getNextPageToken();
333+
}
334+
335+
@Override
336+
public Iterable<String> extractResources(ListTopicSubscriptionsResponse payload) {
337+
return payload.getSubscriptionsList();
338+
}
339+
};
340+
}

0 commit comments

Comments
 (0)