Skip to content

Commit 52d5121

Browse files
shinfanmziccard
authored andcommitted
Update logging with latest generator and GAX. (googleapis#1046)
* Update logging with latest generator. * Update comments * Update grpc dependencies. * Update local logging implementation. * Remove gax related files and .classpath
1 parent 2e5d57c commit 52d5121

18 files changed

Lines changed: 2892 additions & 484 deletions

gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Api.java

Lines changed: 308 additions & 41 deletions
Large diffs are not rendered by default.

gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java

Lines changed: 148 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.google.api.gax.grpc.PageStreamingDescriptor;
4141
import com.google.api.gax.grpc.ServiceApiSettings;
4242
import com.google.api.gax.grpc.SimpleCallSettings;
43+
import com.google.auth.Credentials;
4344
import com.google.common.collect.ImmutableList;
4445
import com.google.common.collect.ImmutableMap;
4546
import com.google.common.collect.ImmutableSet;
@@ -57,12 +58,39 @@
5758
import io.grpc.ManagedChannel;
5859
import io.grpc.Status;
5960
import java.io.IOException;
61+
import java.util.List;
6062
import java.util.concurrent.ScheduledExecutorService;
6163
import org.joda.time.Duration;
6264

6365
// Manually-added imports: add custom (non-generated) imports after this point.
6466

6567
// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing.
68+
/**
69+
* Settings class to configure an instance of {@link ConfigServiceV2Api}.
70+
*
71+
* <p>The default instance has everything set to sensible defaults:
72+
*
73+
* <ul>
74+
* <li>The default service address (logging.googleapis.com) and default port (443)
75+
* are used.
76+
* <li>Credentials are acquired automatically through Application Default Credentials.
77+
* <li>Retries are configured for idempotent methods but not for non-idempotent methods.
78+
* </ul>
79+
*
80+
* <p>The builder of this class is recursive, so contained classes are themselves builders.
81+
* When build() is called, the tree of builders is called to create the complete settings
82+
* object. For example, to set the total timeout of ListSinks to 30 seconds:
83+
*
84+
* <pre>
85+
* <code>
86+
* ConfigServiceV2Settings.Builder configServiceV2SettingsBuilder =
87+
* ConfigServiceV2Settings.defaultBuilder();
88+
* configServiceV2SettingsBuilder.ListSinksSettings().getRetrySettingsBuilder()
89+
* .setTotalTimeout(Duration.standardSeconds(30));
90+
* ConfigServiceV2Settings configServiceV2Settings = configServiceV2SettingsBuilder.build();
91+
* </code>
92+
* </pre>
93+
*/
6694
@javax.annotation.Generated("by GAPIC")
6795
public class ConfigServiceV2Settings extends ServiceApiSettings {
6896

@@ -94,6 +122,16 @@ public class ConfigServiceV2Settings extends ServiceApiSettings {
94122
.add("https://www.googleapis.com/auth/cloud-platform")
95123
.build();
96124

125+
/**
126+
* The default connection settings of the service.
127+
*/
128+
public static final ConnectionSettings DEFAULT_CONNECTION_SETTINGS =
129+
ConnectionSettings.newBuilder()
130+
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
131+
.setPort(DEFAULT_SERVICE_PORT)
132+
.provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
133+
.build();
134+
97135
private final PageStreamingCallSettings<ListSinksRequest, ListSinksResponse, LogSink>
98136
listSinksSettings;
99137

@@ -102,45 +140,67 @@ public class ConfigServiceV2Settings extends ServiceApiSettings {
102140
private final SimpleCallSettings<UpdateSinkRequest, LogSink> updateSinkSettings;
103141
private final SimpleCallSettings<DeleteSinkRequest, Empty> deleteSinkSettings;
104142

143+
/**
144+
* Returns the object with the settings used for calls to listSinks.
145+
*/
105146
public PageStreamingCallSettings<ListSinksRequest, ListSinksResponse, LogSink>
106147
listSinksSettings() {
107148
return listSinksSettings;
108149
}
109150

151+
/**
152+
* Returns the object with the settings used for calls to getSink.
153+
*/
110154
public SimpleCallSettings<GetSinkRequest, LogSink> getSinkSettings() {
111155
return getSinkSettings;
112156
}
113157

158+
/**
159+
* Returns the object with the settings used for calls to createSink.
160+
*/
114161
public SimpleCallSettings<CreateSinkRequest, LogSink> createSinkSettings() {
115162
return createSinkSettings;
116163
}
117164

165+
/**
166+
* Returns the object with the settings used for calls to updateSink.
167+
*/
118168
public SimpleCallSettings<UpdateSinkRequest, LogSink> updateSinkSettings() {
119169
return updateSinkSettings;
120170
}
121171

172+
/**
173+
* Returns the object with the settings used for calls to deleteSink.
174+
*/
122175
public SimpleCallSettings<DeleteSinkRequest, Empty> deleteSinkSettings() {
123176
return deleteSinkSettings;
124177
}
125178

126-
public static ConfigServiceV2Settings defaultInstance() throws IOException {
127-
return newBuilder().build();
179+
/**
180+
* Returns a builder for this class with recommended defaults.
181+
*/
182+
public static Builder defaultBuilder() {
183+
return Builder.createDefault();
128184
}
129185

186+
/**
187+
* Returns a new builder for this class.
188+
*/
130189
public static Builder newBuilder() {
131190
return new Builder();
132191
}
133192

193+
/**
194+
* Returns a builder containing all the values of this settings class.
195+
*/
134196
public Builder toBuilder() {
135197
return new Builder(this);
136198
}
137199

138200
private ConfigServiceV2Settings(Builder settingsBuilder) throws IOException {
139201
super(
140-
settingsBuilder.getOrBuildChannel(),
141-
settingsBuilder.shouldAutoCloseChannel(),
142-
settingsBuilder.getOrBuildExecutor(),
143-
settingsBuilder.getConnectionSettings(),
202+
settingsBuilder.getChannelProvider(),
203+
settingsBuilder.getExecutorProvider(),
144204
settingsBuilder.getGeneratorName(),
145205
settingsBuilder.getGeneratorVersion(),
146206
settingsBuilder.getClientLibName(),
@@ -177,6 +237,9 @@ public Iterable<LogSink> extractResources(ListSinksResponse payload) {
177237
}
178238
};
179239

240+
/**
241+
* Builder for ConfigServiceV2Settings.
242+
*/
180243
public static class Builder extends ServiceApiSettings.Builder {
181244
private final ImmutableList<ApiCallSettings.Builder> methodSettingsBuilders;
182245

@@ -219,38 +282,19 @@ public static class Builder extends ServiceApiSettings.Builder {
219282
}
220283

221284
private Builder() {
222-
super(
223-
ConnectionSettings.builder()
224-
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
225-
.setPort(DEFAULT_SERVICE_PORT)
226-
.provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
227-
.build());
285+
super(DEFAULT_CONNECTION_SETTINGS);
228286

229287
listSinksSettings =
230288
PageStreamingCallSettings.newBuilder(
231-
ConfigServiceV2Grpc.METHOD_LIST_SINKS, LIST_SINKS_PAGE_STR_DESC)
232-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
233-
.setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
234-
235-
getSinkSettings =
236-
SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_GET_SINK)
237-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
238-
.setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
239-
240-
createSinkSettings =
241-
SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_CREATE_SINK)
242-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
243-
.setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
244-
245-
updateSinkSettings =
246-
SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_UPDATE_SINK)
247-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
248-
.setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
249-
250-
deleteSinkSettings =
251-
SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_DELETE_SINK)
252-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
253-
.setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
289+
ConfigServiceV2Grpc.METHOD_LIST_SINKS, LIST_SINKS_PAGE_STR_DESC);
290+
291+
getSinkSettings = SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_GET_SINK);
292+
293+
createSinkSettings = SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_CREATE_SINK);
294+
295+
updateSinkSettings = SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_UPDATE_SINK);
296+
297+
deleteSinkSettings = SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_DELETE_SINK);
254298

255299
methodSettingsBuilders =
256300
ImmutableList.<ApiCallSettings.Builder>of(
@@ -261,6 +305,36 @@ private Builder() {
261305
deleteSinkSettings);
262306
}
263307

308+
private static Builder createDefault() {
309+
Builder builder = new Builder();
310+
builder
311+
.listSinksSettings()
312+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
313+
.setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
314+
315+
builder
316+
.getSinkSettings()
317+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
318+
.setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
319+
320+
builder
321+
.createSinkSettings()
322+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
323+
.setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
324+
325+
builder
326+
.updateSinkSettings()
327+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
328+
.setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
329+
330+
builder
331+
.deleteSinkSettings()
332+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
333+
.setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
334+
335+
return builder;
336+
}
337+
264338
private Builder(ConfigServiceV2Settings settings) {
265339
super(settings);
266340

@@ -279,6 +353,17 @@ private Builder(ConfigServiceV2Settings settings) {
279353
deleteSinkSettings);
280354
}
281355

356+
@Override
357+
protected ConnectionSettings getDefaultConnectionSettings() {
358+
return DEFAULT_CONNECTION_SETTINGS;
359+
}
360+
361+
@Override
362+
public Builder provideExecutorWith(ScheduledExecutorService executor, boolean shouldAutoClose) {
363+
super.provideExecutorWith(executor, shouldAutoClose);
364+
return this;
365+
}
366+
282367
@Override
283368
public Builder provideChannelWith(ManagedChannel channel, boolean shouldAutoClose) {
284369
super.provideChannelWith(channel, shouldAutoClose);
@@ -292,8 +377,14 @@ public Builder provideChannelWith(ConnectionSettings settings) {
292377
}
293378

294379
@Override
295-
public Builder setExecutor(ScheduledExecutorService executor) {
296-
super.setExecutor(executor);
380+
public Builder provideChannelWith(Credentials credentials) {
381+
super.provideChannelWith(credentials);
382+
return this;
383+
}
384+
385+
@Override
386+
public Builder provideChannelWith(List<String> scopes) {
387+
super.provideChannelWith(scopes);
297388
return this;
298389
}
299390

@@ -309,28 +400,48 @@ public Builder setClientLibHeader(String name, String version) {
309400
return this;
310401
}
311402

403+
/**
404+
* Applies the given settings to all of the API methods in this service. Only
405+
* values that are non-null will be applied, so this method is not capable
406+
* of un-setting any values.
407+
*/
312408
public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception {
313409
super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings);
314410
return this;
315411
}
316412

413+
/**
414+
* Returns the builder for the settings used for calls to listSinks.
415+
*/
317416
public PageStreamingCallSettings.Builder<ListSinksRequest, ListSinksResponse, LogSink>
318417
listSinksSettings() {
319418
return listSinksSettings;
320419
}
321420

421+
/**
422+
* Returns the builder for the settings used for calls to getSink.
423+
*/
322424
public SimpleCallSettings.Builder<GetSinkRequest, LogSink> getSinkSettings() {
323425
return getSinkSettings;
324426
}
325427

428+
/**
429+
* Returns the builder for the settings used for calls to createSink.
430+
*/
326431
public SimpleCallSettings.Builder<CreateSinkRequest, LogSink> createSinkSettings() {
327432
return createSinkSettings;
328433
}
329434

435+
/**
436+
* Returns the builder for the settings used for calls to updateSink.
437+
*/
330438
public SimpleCallSettings.Builder<UpdateSinkRequest, LogSink> updateSinkSettings() {
331439
return updateSinkSettings;
332440
}
333441

442+
/**
443+
* Returns the builder for the settings used for calls to deleteSink.
444+
*/
334445
public SimpleCallSettings.Builder<DeleteSinkRequest, Empty> deleteSinkSettings() {
335446
return deleteSinkSettings;
336447
}

0 commit comments

Comments
 (0)