Sync GAPIC clients with latest toolchain by shinfan · Pull Request #2429 · googleapis/google-cloud-java · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,21 @@
* <pre>
* <code>
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
* InspectConfig inspectConfig = InspectConfig.newBuilder().build();
* List&lt;ContentItem&gt; items = new ArrayList&lt;&gt;();
* String name = "EMAIL_ADDRESS";
* InfoType infoTypesElement = InfoType.newBuilder()
* .setName(name)
* .build();
* List&lt;InfoType&gt; infoTypes = Arrays.asList(infoTypesElement);
* InspectConfig inspectConfig = InspectConfig.newBuilder()
* .addAllInfoTypes(infoTypes)
* .build();
* String type = "text/plain";
* String value = "My email is example{@literal @}example.com.";
* ContentItem itemsElement = ContentItem.newBuilder()
* .setType(type)
* .setValue(value)
* .build();
* List&lt;ContentItem&gt; items = Arrays.asList(itemsElement);
* InspectContentResponse response = dlpServiceClient.inspectContent(inspectConfig, items);
* }
* </code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static final GrpcDlpServiceStub create(DlpServiceSettings settings) throw
}

public static final GrpcDlpServiceStub create(ClientContext clientContext) throws IOException {
return new GrpcDlpServiceStub(DlpServiceSettings.defaultBuilder().build(), clientContext);
return new GrpcDlpServiceStub(DlpServiceSettings.newBuilder().build(), clientContext);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
import com.google.api.gax.grpc.testing.MockServiceHelper;
import com.google.api.gax.rpc.InvalidArgumentException;
import com.google.longrunning.Operation;
import com.google.privacy.dlp.v2beta1.CloudStorageOptions;
import com.google.privacy.dlp.v2beta1.CloudStorageOptions.FileSet;
import com.google.privacy.dlp.v2beta1.ContentItem;
import com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest;
import com.google.privacy.dlp.v2beta1.InfoType;
import com.google.privacy.dlp.v2beta1.InspectConfig;
import com.google.privacy.dlp.v2beta1.InspectContentRequest;
import com.google.privacy.dlp.v2beta1.InspectContentResponse;
Expand All @@ -45,7 +48,6 @@
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -79,7 +81,7 @@ public static void stopServer() {
public void setUp() throws IOException {
serviceHelper.reset();
DlpServiceSettings settings =
DlpServiceSettings.defaultBuilder()
DlpServiceSettings.newBuilder()
.setTransportProvider(
GrpcTransportProvider.newBuilder()
.setChannelProvider(serviceHelper.createChannelProvider())
Expand All @@ -100,8 +102,14 @@ public void inspectContentTest() {
InspectContentResponse expectedResponse = InspectContentResponse.newBuilder().build();
mockDlpService.addResponse(expectedResponse);

InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
String name = "EMAIL_ADDRESS";
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
String type = "text/plain";
String value = "My email is example@example.com.";
ContentItem itemsElement = ContentItem.newBuilder().setType(type).setValue(value).build();
List<ContentItem> items = Arrays.asList(itemsElement);

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

try {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
String name = "EMAIL_ADDRESS";
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
String type = "text/plain";
String value = "My email is example@example.com.";
ContentItem itemsElement = ContentItem.newBuilder().setType(type).setValue(value).build();
List<ContentItem> items = Arrays.asList(itemsElement);

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

InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
List<RedactContentRequest.ReplaceConfig> replaceConfigs = new ArrayList<>();
String name = "EMAIL_ADDRESS";
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
String type = "text/plain";
String value = "My email is example@example.com.";
ContentItem itemsElement = ContentItem.newBuilder().setType(type).setValue(value).build();
List<ContentItem> items = Arrays.asList(itemsElement);
String name2 = "EMAIL_ADDRESS";
InfoType infoType = InfoType.newBuilder().setName(name2).build();
String replaceWith = "REDACTED";
RedactContentRequest.ReplaceConfig replaceConfigsElement =
RedactContentRequest.ReplaceConfig.newBuilder()
.setInfoType(infoType)
.setReplaceWith(replaceWith)
.build();
List<RedactContentRequest.ReplaceConfig> replaceConfigs = Arrays.asList(replaceConfigsElement);

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

try {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
List<RedactContentRequest.ReplaceConfig> replaceConfigs = new ArrayList<>();
String name = "EMAIL_ADDRESS";
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
String type = "text/plain";
String value = "My email is example@example.com.";
ContentItem itemsElement = ContentItem.newBuilder().setType(type).setValue(value).build();
List<ContentItem> items = Arrays.asList(itemsElement);
String name2 = "EMAIL_ADDRESS";
InfoType infoType = InfoType.newBuilder().setName(name2).build();
String replaceWith = "REDACTED";
RedactContentRequest.ReplaceConfig replaceConfigsElement =
RedactContentRequest.ReplaceConfig.newBuilder()
.setInfoType(infoType)
.setReplaceWith(replaceWith)
.build();
List<RedactContentRequest.ReplaceConfig> replaceConfigs =
Arrays.asList(replaceConfigsElement);

client.redactContent(inspectConfig, items, replaceConfigs);
Assert.fail("No exception raised");
Expand All @@ -175,9 +218,9 @@ public void redactContentExceptionTest() throws Exception {
@Test
@SuppressWarnings("all")
public void createInspectOperationTest() throws Exception {
ResultName name = ResultName.create("[RESULT]");
ResultName name2 = ResultName.create("[RESULT]");
InspectOperationResult expectedResponse =
InspectOperationResult.newBuilder().setNameWithResultName(name).build();
InspectOperationResult.newBuilder().setNameWithResultName(name2).build();
Operation resultOperation =
Operation.newBuilder()
.setName("createInspectOperationTest")
Expand All @@ -186,8 +229,17 @@ public void createInspectOperationTest() throws Exception {
.build();
mockDlpService.addResponse(resultOperation);

InspectConfig inspectConfig = InspectConfig.newBuilder().build();
StorageConfig storageConfig = StorageConfig.newBuilder().build();
String name = "EMAIL_ADDRESS";
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
String url = "gs://example_bucket/example_file.png";
CloudStorageOptions.FileSet fileSet =
CloudStorageOptions.FileSet.newBuilder().setUrl(url).build();
CloudStorageOptions cloudStorageOptions =
CloudStorageOptions.newBuilder().setFileSet(fileSet).build();
StorageConfig storageConfig =
StorageConfig.newBuilder().setCloudStorageOptions(cloudStorageOptions).build();
OutputStorageConfig outputConfig = OutputStorageConfig.newBuilder().build();

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

try {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
StorageConfig storageConfig = StorageConfig.newBuilder().build();
String name = "EMAIL_ADDRESS";
InfoType infoTypesElement = InfoType.newBuilder().setName(name).build();
List<InfoType> infoTypes = Arrays.asList(infoTypesElement);
InspectConfig inspectConfig = InspectConfig.newBuilder().addAllInfoTypes(infoTypes).build();
String url = "gs://example_bucket/example_file.png";
CloudStorageOptions.FileSet fileSet =
CloudStorageOptions.FileSet.newBuilder().setUrl(url).build();
CloudStorageOptions cloudStorageOptions =
CloudStorageOptions.newBuilder().setFileSet(fileSet).build();
StorageConfig storageConfig =
StorageConfig.newBuilder().setCloudStorageOptions(cloudStorageOptions).build();
OutputStorageConfig outputConfig = OutputStorageConfig.newBuilder().build();

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

String category = "category50511102";
String languageCode = "languageCode-412800396";
String category = "PII";
String languageCode = "en";

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

try {
String category = "category50511102";
String languageCode = "languageCode-412800396";
String category = "PII";
String languageCode = "en";

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

String languageCode = "languageCode-412800396";
String languageCode = "en";

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

try {
String languageCode = "languageCode-412800396";
String languageCode = "en";

client.listRootCategories(languageCode);
Assert.fail("No exception raised");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
* <pre>
* <code>
* ErrorGroupServiceSettings errorGroupServiceSettings =
* ErrorGroupServiceSettings.defaultBuilder()
* ErrorGroupServiceSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* ErrorGroupServiceClient errorGroupServiceClient =
Expand All @@ -88,7 +88,7 @@
* <pre>
* <code>
* ErrorGroupServiceSettings errorGroupServiceSettings =
* ErrorGroupServiceSettings.defaultBuilder()
* ErrorGroupServiceSettings.newBuilder()
* .setTransportProvider(ErrorGroupServiceSettings.defaultGrpcTransportProviderBuilder()
* .setChannelProvider(ErrorGroupServiceSettings.defaultGrpcChannelProviderBuilder()
* .setEndpoint(myEndpoint)
Expand All @@ -108,7 +108,7 @@ public class ErrorGroupServiceClient implements BackgroundResource {

/** Constructs an instance of ErrorGroupServiceClient with default settings. */
public static final ErrorGroupServiceClient create() throws IOException {
return create(ErrorGroupServiceSettings.defaultBuilder().build());
return create(ErrorGroupServiceSettings.newBuilder().build());
}

/**
Expand Down Expand Up @@ -147,6 +147,7 @@ public final ErrorGroupServiceSettings getSettings() {
return settings;
}

@BetaApi
public ErrorGroupServiceStub getStub() {
return stub;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
* <pre>
* <code>
* ErrorGroupServiceSettings.Builder errorGroupServiceSettingsBuilder =
* ErrorGroupServiceSettings.defaultBuilder();
* ErrorGroupServiceSettings.newBuilder();
* errorGroupServiceSettingsBuilder.getGroupSettings().getRetrySettingsBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* ErrorGroupServiceSettings errorGroupServiceSettings = errorGroupServiceSettingsBuilder.build();
Expand Down Expand Up @@ -161,6 +161,7 @@ private static String getGapicVersion() {
}

/** Returns a builder for this class with recommended defaults. */
@Deprecated
public static Builder defaultBuilder() {
return Builder.createDefault();
}
Expand All @@ -169,13 +170,14 @@ public static Builder defaultBuilder() {
* Returns a builder for this class with recommended defaults for API methods, and the given
* ClientContext used for executor/transport/credentials.
*/
@Deprecated
public static Builder defaultBuilder(ClientContext clientContext) {
return new Builder(clientContext);
}

/** Returns a new builder for this class. */
public static Builder newBuilder() {
return new Builder();
return Builder.createDefault();
}

/** Returns a new builder for this class. */
Expand Down
Loading