Skip to content

Commit e5405e1

Browse files
authored
Sync GAPIC clients with latest toolchain (#2429)
- Update dependencies - gax -> 1.8.0 - google-auth -> 0.8.0 - grpc -> 1.6.1 - generated proto -> 0.1.17
1 parent 099118e commit e5405e1

66 files changed

Lines changed: 646 additions & 180 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-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceClient.java

Lines changed: 220 additions & 37 deletions
Large diffs are not rendered by default.

google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceSettings.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
* <pre>
8181
* <code>
8282
* DlpServiceSettings.Builder dlpServiceSettingsBuilder =
83-
* DlpServiceSettings.defaultBuilder();
83+
* DlpServiceSettings.newBuilder();
8484
* dlpServiceSettingsBuilder.inspectContentSettings().getRetrySettingsBuilder()
8585
* .setTotalTimeout(Duration.ofSeconds(30));
8686
* DlpServiceSettings dlpServiceSettings = dlpServiceSettingsBuilder.build();
@@ -210,6 +210,7 @@ private static String getGapicVersion() {
210210
}
211211

212212
/** Returns a builder for this class with recommended defaults. */
213+
@Deprecated
213214
public static Builder defaultBuilder() {
214215
return Builder.createDefault();
215216
}
@@ -218,13 +219,14 @@ public static Builder defaultBuilder() {
218219
* Returns a builder for this class with recommended defaults for API methods, and the given
219220
* ClientContext used for executor/transport/credentials.
220221
*/
222+
@Deprecated
221223
public static Builder defaultBuilder(ClientContext clientContext) {
222224
return new Builder(clientContext);
223225
}
224226

225227
/** Returns a new builder for this class. */
226228
public static Builder newBuilder() {
227-
return new Builder();
229+
return Builder.createDefault();
228230
}
229231

230232
/** Returns a new builder for this class. */

google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/package-info.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,21 @@
3131
* <pre>
3232
* <code>
3333
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
34-
* InspectConfig inspectConfig = InspectConfig.newBuilder().build();
35-
* List&lt;ContentItem&gt; items = new ArrayList&lt;&gt;();
34+
* String name = "EMAIL_ADDRESS";
35+
* InfoType infoTypesElement = InfoType.newBuilder()
36+
* .setName(name)
37+
* .build();
38+
* List&lt;InfoType&gt; infoTypes = Arrays.asList(infoTypesElement);
39+
* InspectConfig inspectConfig = InspectConfig.newBuilder()
40+
* .addAllInfoTypes(infoTypes)
41+
* .build();
42+
* String type = "text/plain";
43+
* String value = "My email is example{@literal @}example.com.";
44+
* ContentItem itemsElement = ContentItem.newBuilder()
45+
* .setType(type)
46+
* .setValue(value)
47+
* .build();
48+
* List&lt;ContentItem&gt; items = Arrays.asList(itemsElement);
3649
* InspectContentResponse response = dlpServiceClient.inspectContent(inspectConfig, items);
3750
* }
3851
* </code>

google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/stub/GrpcDlpServiceStub.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public static final GrpcDlpServiceStub create(DlpServiceSettings settings) throw
131131
}
132132

133133
public static final GrpcDlpServiceStub create(ClientContext clientContext) throws IOException {
134-
return new GrpcDlpServiceStub(DlpServiceSettings.defaultBuilder().build(), clientContext);
134+
return new GrpcDlpServiceStub(DlpServiceSettings.newBuilder().build(), clientContext);
135135
}
136136

137137
/**

google-cloud-dlp/src/test/java/com/google/cloud/dlp/v2beta1/DlpServiceClientTest.java

Lines changed: 85 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
import com.google.api.gax.grpc.testing.MockServiceHelper;
2323
import com.google.api.gax.rpc.InvalidArgumentException;
2424
import com.google.longrunning.Operation;
25+
import com.google.privacy.dlp.v2beta1.CloudStorageOptions;
26+
import com.google.privacy.dlp.v2beta1.CloudStorageOptions.FileSet;
2527
import com.google.privacy.dlp.v2beta1.ContentItem;
2628
import com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest;
29+
import com.google.privacy.dlp.v2beta1.InfoType;
2730
import com.google.privacy.dlp.v2beta1.InspectConfig;
2831
import com.google.privacy.dlp.v2beta1.InspectContentRequest;
2932
import com.google.privacy.dlp.v2beta1.InspectContentResponse;
@@ -45,7 +48,6 @@
4548
import io.grpc.Status;
4649
import io.grpc.StatusRuntimeException;
4750
import java.io.IOException;
48-
import java.util.ArrayList;
4951
import java.util.Arrays;
5052
import java.util.List;
5153
import java.util.concurrent.ExecutionException;
@@ -79,7 +81,7 @@ public static void stopServer() {
7981
public void setUp() throws IOException {
8082
serviceHelper.reset();
8183
DlpServiceSettings settings =
82-
DlpServiceSettings.defaultBuilder()
84+
DlpServiceSettings.newBuilder()
8385
.setTransportProvider(
8486
GrpcTransportProvider.newBuilder()
8587
.setChannelProvider(serviceHelper.createChannelProvider())
@@ -100,8 +102,14 @@ public void inspectContentTest() {
100102
InspectContentResponse expectedResponse = InspectContentResponse.newBuilder().build();
101103
mockDlpService.addResponse(expectedResponse);
102104

103-
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
104-
List<ContentItem> items = new ArrayList<>();
105+
String name = "EMAIL_ADDRESS";
106+
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
107+
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
108+
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
109+
String type = "text/plain";
110+
String value = "My email is [email protected].";
111+
ContentItem itemsElement = ContentItem.newBuilder().setType(type).setValue(value).build();
112+
List<ContentItem> items = Arrays.asList(itemsElement);
105113

106114
InspectContentResponse actualResponse = client.inspectContent(inspectConfig, items);
107115
Assert.assertEquals(expectedResponse, actualResponse);
@@ -121,8 +129,14 @@ public void inspectContentExceptionTest() throws Exception {
121129
mockDlpService.addException(exception);
122130

123131
try {
124-
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
125-
List<ContentItem> items = new ArrayList<>();
132+
String name = "EMAIL_ADDRESS";
133+
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
134+
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
135+
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
136+
String type = "text/plain";
137+
String value = "My email is [email protected].";
138+
ContentItem itemsElement = ContentItem.newBuilder().setType(type).setValue(value).build();
139+
List<ContentItem> items = Arrays.asList(itemsElement);
126140

127141
client.inspectContent(inspectConfig, items);
128142
Assert.fail("No exception raised");
@@ -137,9 +151,23 @@ public void redactContentTest() {
137151
RedactContentResponse expectedResponse = RedactContentResponse.newBuilder().build();
138152
mockDlpService.addResponse(expectedResponse);
139153

140-
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
141-
List<ContentItem> items = new ArrayList<>();
142-
List<RedactContentRequest.ReplaceConfig> replaceConfigs = new ArrayList<>();
154+
String name = "EMAIL_ADDRESS";
155+
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
156+
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
157+
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
158+
String type = "text/plain";
159+
String value = "My email is [email protected].";
160+
ContentItem itemsElement = ContentItem.newBuilder().setType(type).setValue(value).build();
161+
List<ContentItem> items = Arrays.asList(itemsElement);
162+
String name2 = "EMAIL_ADDRESS";
163+
InfoType infoType = InfoType.newBuilder().setName(name2).build();
164+
String replaceWith = "REDACTED";
165+
RedactContentRequest.ReplaceConfig replaceConfigsElement =
166+
RedactContentRequest.ReplaceConfig.newBuilder()
167+
.setInfoType(infoType)
168+
.setReplaceWith(replaceWith)
169+
.build();
170+
List<RedactContentRequest.ReplaceConfig> replaceConfigs = Arrays.asList(replaceConfigsElement);
143171

144172
RedactContentResponse actualResponse =
145173
client.redactContent(inspectConfig, items, replaceConfigs);
@@ -161,9 +189,24 @@ public void redactContentExceptionTest() throws Exception {
161189
mockDlpService.addException(exception);
162190

163191
try {
164-
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
165-
List<ContentItem> items = new ArrayList<>();
166-
List<RedactContentRequest.ReplaceConfig> replaceConfigs = new ArrayList<>();
192+
String name = "EMAIL_ADDRESS";
193+
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
194+
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
195+
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
196+
String type = "text/plain";
197+
String value = "My email is [email protected].";
198+
ContentItem itemsElement = ContentItem.newBuilder().setType(type).setValue(value).build();
199+
List<ContentItem> items = Arrays.asList(itemsElement);
200+
String name2 = "EMAIL_ADDRESS";
201+
InfoType infoType = InfoType.newBuilder().setName(name2).build();
202+
String replaceWith = "REDACTED";
203+
RedactContentRequest.ReplaceConfig replaceConfigsElement =
204+
RedactContentRequest.ReplaceConfig.newBuilder()
205+
.setInfoType(infoType)
206+
.setReplaceWith(replaceWith)
207+
.build();
208+
List<RedactContentRequest.ReplaceConfig> replaceConfigs =
209+
Arrays.asList(replaceConfigsElement);
167210

168211
client.redactContent(inspectConfig, items, replaceConfigs);
169212
Assert.fail("No exception raised");
@@ -175,9 +218,9 @@ public void redactContentExceptionTest() throws Exception {
175218
@Test
176219
@SuppressWarnings("all")
177220
public void createInspectOperationTest() throws Exception {
178-
ResultName name = ResultName.create("[RESULT]");
221+
ResultName name2 = ResultName.create("[RESULT]");
179222
InspectOperationResult expectedResponse =
180-
InspectOperationResult.newBuilder().setNameWithResultName(name).build();
223+
InspectOperationResult.newBuilder().setNameWithResultName(name2).build();
181224
Operation resultOperation =
182225
Operation.newBuilder()
183226
.setName("createInspectOperationTest")
@@ -186,8 +229,17 @@ public void createInspectOperationTest() throws Exception {
186229
.build();
187230
mockDlpService.addResponse(resultOperation);
188231

189-
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
190-
StorageConfig storageConfig = StorageConfig.newBuilder().build();
232+
String name = "EMAIL_ADDRESS";
233+
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
234+
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
235+
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
236+
String url = "gs://example_bucket/example_file.png";
237+
CloudStorageOptions.FileSet fileSet =
238+
CloudStorageOptions.FileSet.newBuilder().setUrl(url).build();
239+
CloudStorageOptions cloudStorageOptions =
240+
CloudStorageOptions.newBuilder().setFileSet(fileSet).build();
241+
StorageConfig storageConfig =
242+
StorageConfig.newBuilder().setCloudStorageOptions(cloudStorageOptions).build();
191243
OutputStorageConfig outputConfig = OutputStorageConfig.newBuilder().build();
192244

193245
InspectOperationResult actualResponse =
@@ -211,8 +263,17 @@ public void createInspectOperationExceptionTest() throws Exception {
211263
mockDlpService.addException(exception);
212264

213265
try {
214-
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
215-
StorageConfig storageConfig = StorageConfig.newBuilder().build();
266+
String name = "EMAIL_ADDRESS";
267+
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
268+
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
269+
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
270+
String url = "gs://example_bucket/example_file.png";
271+
CloudStorageOptions.FileSet fileSet =
272+
CloudStorageOptions.FileSet.newBuilder().setUrl(url).build();
273+
CloudStorageOptions cloudStorageOptions =
274+
CloudStorageOptions.newBuilder().setFileSet(fileSet).build();
275+
StorageConfig storageConfig =
276+
StorageConfig.newBuilder().setCloudStorageOptions(cloudStorageOptions).build();
216277
OutputStorageConfig outputConfig = OutputStorageConfig.newBuilder().build();
217278

218279
client.createInspectOperationAsync(inspectConfig, storageConfig, outputConfig).get();
@@ -268,8 +329,8 @@ public void listInfoTypesTest() {
268329
ListInfoTypesResponse expectedResponse = ListInfoTypesResponse.newBuilder().build();
269330
mockDlpService.addResponse(expectedResponse);
270331

271-
String category = "category50511102";
272-
String languageCode = "languageCode-412800396";
332+
String category = "PII";
333+
String languageCode = "en";
273334

274335
ListInfoTypesResponse actualResponse = client.listInfoTypes(category, languageCode);
275336
Assert.assertEquals(expectedResponse, actualResponse);
@@ -289,8 +350,8 @@ public void listInfoTypesExceptionTest() throws Exception {
289350
mockDlpService.addException(exception);
290351

291352
try {
292-
String category = "category50511102";
293-
String languageCode = "languageCode-412800396";
353+
String category = "PII";
354+
String languageCode = "en";
294355

295356
client.listInfoTypes(category, languageCode);
296357
Assert.fail("No exception raised");
@@ -305,7 +366,7 @@ public void listRootCategoriesTest() {
305366
ListRootCategoriesResponse expectedResponse = ListRootCategoriesResponse.newBuilder().build();
306367
mockDlpService.addResponse(expectedResponse);
307368

308-
String languageCode = "languageCode-412800396";
369+
String languageCode = "en";
309370

310371
ListRootCategoriesResponse actualResponse = client.listRootCategories(languageCode);
311372
Assert.assertEquals(expectedResponse, actualResponse);
@@ -324,7 +385,7 @@ public void listRootCategoriesExceptionTest() throws Exception {
324385
mockDlpService.addException(exception);
325386

326387
try {
327-
String languageCode = "languageCode-412800396";
388+
String languageCode = "en";
328389

329390
client.listRootCategories(languageCode);
330391
Assert.fail("No exception raised");

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorGroupServiceClient.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
* <pre>
7676
* <code>
7777
* ErrorGroupServiceSettings errorGroupServiceSettings =
78-
* ErrorGroupServiceSettings.defaultBuilder()
78+
* ErrorGroupServiceSettings.newBuilder()
7979
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
8080
* .build();
8181
* ErrorGroupServiceClient errorGroupServiceClient =
@@ -88,7 +88,7 @@
8888
* <pre>
8989
* <code>
9090
* ErrorGroupServiceSettings errorGroupServiceSettings =
91-
* ErrorGroupServiceSettings.defaultBuilder()
91+
* ErrorGroupServiceSettings.newBuilder()
9292
* .setTransportProvider(ErrorGroupServiceSettings.defaultGrpcTransportProviderBuilder()
9393
* .setChannelProvider(ErrorGroupServiceSettings.defaultGrpcChannelProviderBuilder()
9494
* .setEndpoint(myEndpoint)
@@ -108,7 +108,7 @@ public class ErrorGroupServiceClient implements BackgroundResource {
108108

109109
/** Constructs an instance of ErrorGroupServiceClient with default settings. */
110110
public static final ErrorGroupServiceClient create() throws IOException {
111-
return create(ErrorGroupServiceSettings.defaultBuilder().build());
111+
return create(ErrorGroupServiceSettings.newBuilder().build());
112112
}
113113

114114
/**
@@ -147,6 +147,7 @@ public final ErrorGroupServiceSettings getSettings() {
147147
return settings;
148148
}
149149

150+
@BetaApi
150151
public ErrorGroupServiceStub getStub() {
151152
return stub;
152153
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
* <pre>
6969
* <code>
7070
* ErrorGroupServiceSettings.Builder errorGroupServiceSettingsBuilder =
71-
* ErrorGroupServiceSettings.defaultBuilder();
71+
* ErrorGroupServiceSettings.newBuilder();
7272
* errorGroupServiceSettingsBuilder.getGroupSettings().getRetrySettingsBuilder()
7373
* .setTotalTimeout(Duration.ofSeconds(30));
7474
* ErrorGroupServiceSettings errorGroupServiceSettings = errorGroupServiceSettingsBuilder.build();
@@ -161,6 +161,7 @@ private static String getGapicVersion() {
161161
}
162162

163163
/** Returns a builder for this class with recommended defaults. */
164+
@Deprecated
164165
public static Builder defaultBuilder() {
165166
return Builder.createDefault();
166167
}
@@ -169,13 +170,14 @@ public static Builder defaultBuilder() {
169170
* Returns a builder for this class with recommended defaults for API methods, and the given
170171
* ClientContext used for executor/transport/credentials.
171172
*/
173+
@Deprecated
172174
public static Builder defaultBuilder(ClientContext clientContext) {
173175
return new Builder(clientContext);
174176
}
175177

176178
/** Returns a new builder for this class. */
177179
public static Builder newBuilder() {
178-
return new Builder();
180+
return Builder.createDefault();
179181
}
180182

181183
/** Returns a new builder for this class. */

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/v1beta1/ErrorStatsServiceClient.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
* <pre>
8484
* <code>
8585
* ErrorStatsServiceSettings errorStatsServiceSettings =
86-
* ErrorStatsServiceSettings.defaultBuilder()
86+
* ErrorStatsServiceSettings.newBuilder()
8787
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
8888
* .build();
8989
* ErrorStatsServiceClient errorStatsServiceClient =
@@ -96,7 +96,7 @@
9696
* <pre>
9797
* <code>
9898
* ErrorStatsServiceSettings errorStatsServiceSettings =
99-
* ErrorStatsServiceSettings.defaultBuilder()
99+
* ErrorStatsServiceSettings.newBuilder()
100100
* .setTransportProvider(ErrorStatsServiceSettings.defaultGrpcTransportProviderBuilder()
101101
* .setChannelProvider(ErrorStatsServiceSettings.defaultGrpcChannelProviderBuilder()
102102
* .setEndpoint(myEndpoint)
@@ -116,7 +116,7 @@ public class ErrorStatsServiceClient implements BackgroundResource {
116116

117117
/** Constructs an instance of ErrorStatsServiceClient with default settings. */
118118
public static final ErrorStatsServiceClient create() throws IOException {
119-
return create(ErrorStatsServiceSettings.defaultBuilder().build());
119+
return create(ErrorStatsServiceSettings.newBuilder().build());
120120
}
121121

122122
/**
@@ -155,6 +155,7 @@ public final ErrorStatsServiceSettings getSettings() {
155155
return settings;
156156
}
157157

158+
@BetaApi
158159
public ErrorStatsServiceStub getStub() {
159160
return stub;
160161
}

0 commit comments

Comments
 (0)