Skip to content

Commit 6383cc1

Browse files
authored
Regenerating spi layer - GAX 0.0.22 (#1379)
* Regenerating spi layer - GAX 0.0.22 * Update options and spi classes to catch GAX changes
1 parent 81278dc commit 6383cc1

93 files changed

Lines changed: 1873 additions & 1765 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

google-cloud-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
<dependency>
112112
<groupId>com.google.api</groupId>
113113
<artifactId>gax</artifactId>
114-
<version>0.0.21</version>
114+
<version>0.0.22</version>
115115
<exclusions>
116116
<exclusion>
117117
<groupId>io.grpc</groupId>

google-cloud-core/src/main/java/com/google/cloud/GrpcServiceOptions.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
import static com.google.common.base.MoreObjects.firstNonNull;
2020

21-
import com.google.api.gax.core.ConnectionSettings;
21+
import com.google.api.gax.core.FixedCredentialsProvider;
2222
import com.google.api.gax.core.RetrySettings;
23+
import com.google.api.gax.grpc.ChannelProvider;
24+
import com.google.api.gax.grpc.InstantiatingChannelProvider;
2325
import com.google.api.gax.grpc.UnaryCallSettings;
2426
import com.google.auth.Credentials;
2527
import com.google.cloud.spi.ServiceRpcFactory;
@@ -304,26 +306,19 @@ protected UnaryCallSettings.Builder getApiCallSettings() {
304306
}
305307

306308
/**
307-
* Returns a builder for connection-related settings.
309+
* Returns a channel provider.
308310
*/
309-
@Deprecated
310-
protected ConnectionSettings.Builder connectionSettings() {
311-
return getConnectionSettings();
312-
}
313-
314-
/**
315-
* Returns a builder for connection-related settings.
316-
*/
317-
protected ConnectionSettings.Builder getConnectionSettings() {
311+
protected ChannelProvider getChannelProvider() {
318312
HostAndPort hostAndPort = HostAndPort.fromString(getHost());
319-
ConnectionSettings.Builder builder = ConnectionSettings.newBuilder()
313+
InstantiatingChannelProvider.Builder builder = InstantiatingChannelProvider.newBuilder()
320314
.setServiceAddress(hostAndPort.getHostText())
321-
.setPort(hostAndPort.getPort());
315+
.setPort(hostAndPort.getPort())
316+
.setClientLibHeader(getLibraryName(), firstNonNull(getLibraryVersion(), ""));
322317
Credentials scopedCredentials = getScopedCredentials();
323318
if (scopedCredentials != null && scopedCredentials != NoCredentials.getInstance()) {
324-
builder.provideCredentialsWith(scopedCredentials);
319+
builder.setCredentialsProvider(FixedCredentialsProvider.create(scopedCredentials));
325320
}
326-
return builder;
321+
return builder.build();
327322
}
328323

329324
/**

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceApi.java

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
2+
* Copyright 2016, Google Inc. All rights reserved.
33
*
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
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
67
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
89
*
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.
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1315
*/
1416
package com.google.cloud.errorreporting.spi.v1beta1;
1517

18+
import com.google.api.gax.grpc.ChannelAndExecutor;
1619
import com.google.api.gax.grpc.UnaryCallable;
1720
import com.google.api.gax.protobuf.PathTemplate;
1821
import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup;
@@ -69,18 +72,22 @@
6972
*
7073
* <pre>
7174
* <code>
72-
* ErrorGroupServiceSettings errorGroupServiceSettings = ErrorGroupServiceSettings.defaultBuilder()
73-
* .provideChannelWith(myCredentials)
74-
* .build();
75-
* ErrorGroupServiceApi errorGroupServiceApi = ErrorGroupServiceApi.create(errorGroupServiceSettings);
75+
* InstantiatingChannelProvider channelProvider =
76+
* ErrorGroupServiceSettings.defaultChannelProviderBuilder()
77+
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
78+
* .build();
79+
* ErrorGroupServiceSettings errorGroupServiceSettings =
80+
* ErrorGroupServiceSettings.defaultBuilder().setChannelProvider(channelProvider).build();
81+
* ErrorGroupServiceApi errorGroupServiceApi =
82+
* ErrorGroupServiceApi.create(errorGroupServiceSettings);
7683
* </code>
7784
* </pre>
7885
*/
7986
@javax.annotation.Generated("by GAPIC")
8087
public class ErrorGroupServiceApi implements AutoCloseable {
8188
private final ErrorGroupServiceSettings settings;
82-
private final ManagedChannel channel;
8389
private final ScheduledExecutorService executor;
90+
private final ManagedChannel channel;
8491
private final List<AutoCloseable> closeables = new ArrayList<>();
8592

8693
private final UnaryCallable<GetGroupRequest, ErrorGroup> getGroupCallable;
@@ -89,13 +96,21 @@ public class ErrorGroupServiceApi implements AutoCloseable {
8996
private static final PathTemplate GROUP_PATH_TEMPLATE =
9097
PathTemplate.createWithoutUrlEncoding("projects/{project}/groups/{group}");
9198

99+
private static final PathTemplate PROJECT_PATH_TEMPLATE =
100+
PathTemplate.createWithoutUrlEncoding("projects/{project}");
101+
92102
/** Formats a string containing the fully-qualified path to represent a group resource. */
93103
public static final String formatGroupName(String project, String group) {
94104
return GROUP_PATH_TEMPLATE.instantiate(
95105
"project", project,
96106
"group", group);
97107
}
98108

109+
/** Formats a string containing the fully-qualified path to represent a project resource. */
110+
public static final String formatProjectName(String project) {
111+
return PROJECT_PATH_TEMPLATE.instantiate("project", project);
112+
}
113+
99114
/** Parses the project from the given fully-qualified path which represents a group resource. */
100115
public static final String parseProjectFromGroupName(String groupName) {
101116
return GROUP_PATH_TEMPLATE.parse(groupName).get("project");
@@ -106,6 +121,11 @@ public static final String parseGroupFromGroupName(String groupName) {
106121
return GROUP_PATH_TEMPLATE.parse(groupName).get("group");
107122
}
108123

124+
/** Parses the project from the given fully-qualified path which represents a project resource. */
125+
public static final String parseProjectFromProjectName(String projectName) {
126+
return PROJECT_PATH_TEMPLATE.parse(projectName).get("project");
127+
}
128+
109129
/** Constructs an instance of ErrorGroupServiceApi with default settings. */
110130
public static final ErrorGroupServiceApi create() throws IOException {
111131
return create(ErrorGroupServiceSettings.defaultBuilder().build());
@@ -126,8 +146,9 @@ public static final ErrorGroupServiceApi create(ErrorGroupServiceSettings settin
126146
*/
127147
protected ErrorGroupServiceApi(ErrorGroupServiceSettings settings) throws IOException {
128148
this.settings = settings;
129-
this.executor = settings.getExecutorProvider().getOrBuildExecutor();
130-
this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
149+
ChannelAndExecutor channelAndExecutor = settings.getChannelAndExecutor();
150+
this.executor = channelAndExecutor.getExecutor();
151+
this.channel = channelAndExecutor.getChannel();
131152

132153
this.getGroupCallable =
133154
UnaryCallable.create(settings.getGroupSettings(), this.channel, this.executor);

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceSettings.java

Lines changed: 39 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
/*
2-
* Copyright 2016 Google Inc. All Rights Reserved.
2+
* Copyright 2016, Google Inc. All rights reserved.
33
*
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
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
67
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
89
*
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.
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1315
*/
1416
package com.google.cloud.errorreporting.spi.v1beta1;
1517

16-
import com.google.api.gax.core.ConnectionSettings;
18+
import com.google.api.gax.core.GoogleCredentialsProvider;
1719
import com.google.api.gax.core.RetrySettings;
20+
import com.google.api.gax.grpc.ChannelProvider;
21+
import com.google.api.gax.grpc.ExecutorProvider;
22+
import com.google.api.gax.grpc.InstantiatingChannelProvider;
23+
import com.google.api.gax.grpc.InstantiatingExecutorProvider;
1824
import com.google.api.gax.grpc.ServiceApiSettings;
1925
import com.google.api.gax.grpc.SimpleCallSettings;
2026
import com.google.api.gax.grpc.UnaryCallSettings;
21-
import com.google.auth.Credentials;
2227
import com.google.common.collect.ImmutableList;
2328
import com.google.common.collect.ImmutableMap;
2429
import com.google.common.collect.ImmutableSet;
@@ -28,11 +33,8 @@
2833
import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroupServiceGrpc;
2934
import com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest;
3035
import com.google.devtools.clouderrorreporting.v1beta1.UpdateGroupRequest;
31-
import io.grpc.ManagedChannel;
3236
import io.grpc.Status;
3337
import java.io.IOException;
34-
import java.util.List;
35-
import java.util.concurrent.ScheduledExecutorService;
3638
import org.joda.time.Duration;
3739

3840
// AUTO-GENERATED DOCUMENTATION AND CLASS
@@ -87,6 +89,11 @@ public SimpleCallSettings<UpdateGroupRequest, ErrorGroup> updateGroupSettings()
8789
return updateGroupSettings;
8890
}
8991

92+
/** Returns a builder for the default ExecutorProvider for this service. */
93+
public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
94+
return InstantiatingExecutorProvider.newBuilder();
95+
}
96+
9097
/** Returns the default service address. */
9198
public static String getDefaultServiceAddress() {
9299
return DEFAULT_SERVICE_ADDRESS;
@@ -102,6 +109,19 @@ public static ImmutableList<String> getDefaultServiceScopes() {
102109
return DEFAULT_SERVICE_SCOPES;
103110
}
104111

112+
/** Returns a builder for the default credentials for this service. */
113+
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
114+
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
115+
}
116+
117+
/** Returns a builder for the default ChannelProvider for this service. */
118+
public static InstantiatingChannelProvider.Builder defaultChannelProviderBuilder() {
119+
return InstantiatingChannelProvider.newBuilder()
120+
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
121+
.setPort(DEFAULT_SERVICE_PORT)
122+
.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
123+
}
124+
105125
/** Returns a builder for this class with recommended defaults. */
106126
public static Builder defaultBuilder() {
107127
return Builder.createDefault();
@@ -118,13 +138,7 @@ public Builder toBuilder() {
118138
}
119139

120140
private ErrorGroupServiceSettings(Builder settingsBuilder) throws IOException {
121-
super(
122-
settingsBuilder.getChannelProvider(),
123-
settingsBuilder.getExecutorProvider(),
124-
settingsBuilder.getGeneratorName(),
125-
settingsBuilder.getGeneratorVersion(),
126-
settingsBuilder.getClientLibName(),
127-
settingsBuilder.getClientLibVersion());
141+
super(settingsBuilder.getExecutorProvider(), settingsBuilder.getChannelProvider());
128142

129143
getGroupSettings = settingsBuilder.getGroupSettings().build();
130144
updateGroupSettings = settingsBuilder.updateGroupSettings().build();
@@ -169,7 +183,7 @@ public static class Builder extends ServiceApiSettings.Builder {
169183
}
170184

171185
private Builder() {
172-
super(s_getDefaultConnectionSettingsBuilder().build());
186+
super(defaultChannelProviderBuilder().build());
173187

174188
getGroupSettings = SimpleCallSettings.newBuilder(ErrorGroupServiceGrpc.METHOD_GET_GROUP);
175189

@@ -206,57 +220,15 @@ private Builder(ErrorGroupServiceSettings settings) {
206220
ImmutableList.<UnaryCallSettings.Builder>of(getGroupSettings, updateGroupSettings);
207221
}
208222

209-
private static ConnectionSettings.Builder s_getDefaultConnectionSettingsBuilder() {
210-
return ConnectionSettings.newBuilder()
211-
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
212-
.setPort(DEFAULT_SERVICE_PORT)
213-
.provideCredentialsWith(DEFAULT_SERVICE_SCOPES);
214-
}
215-
216-
@Override
217-
protected ConnectionSettings.Builder getDefaultConnectionSettingsBuilder() {
218-
return s_getDefaultConnectionSettingsBuilder();
219-
}
220-
221-
@Override
222-
public Builder provideExecutorWith(ScheduledExecutorService executor, boolean shouldAutoClose) {
223-
super.provideExecutorWith(executor, shouldAutoClose);
224-
return this;
225-
}
226-
227-
@Override
228-
public Builder provideChannelWith(ManagedChannel channel, boolean shouldAutoClose) {
229-
super.provideChannelWith(channel, shouldAutoClose);
230-
return this;
231-
}
232-
233-
@Override
234-
public Builder provideChannelWith(ConnectionSettings settings) {
235-
super.provideChannelWith(settings);
236-
return this;
237-
}
238-
239-
@Override
240-
public Builder provideChannelWith(Credentials credentials) {
241-
super.provideChannelWith(credentials);
242-
return this;
243-
}
244-
245-
@Override
246-
public Builder provideChannelWith(List<String> scopes) {
247-
super.provideChannelWith(scopes);
248-
return this;
249-
}
250-
251223
@Override
252-
public Builder setGeneratorHeader(String name, String version) {
253-
super.setGeneratorHeader(name, version);
224+
public Builder setExecutorProvider(ExecutorProvider executorProvider) {
225+
super.setExecutorProvider(executorProvider);
254226
return this;
255227
}
256228

257229
@Override
258-
public Builder setClientLibHeader(String name, String version) {
259-
super.setClientLibHeader(name, version);
230+
public Builder setChannelProvider(ChannelProvider channelProvider) {
231+
super.setChannelProvider(channelProvider);
260232
return this;
261233
}
262234

0 commit comments

Comments
 (0)