use of com.google.privacy.dlp.v2.StoredInfoTypeName in project java-dlp by googleapis.
the class DlpServiceClient method deleteStoredInfoType.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a stored infoType. See https://cloud.google.com/dlp/docs/creating-stored-infotypes to
* learn more.
*
* <p>Sample code:
*
* <pre>{@code
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
* StoredInfoTypeName name =
* StoredInfoTypeName.ofOrganizationStoredInfoTypeName(
* "[ORGANIZATION]", "[STORED_INFO_TYPE]");
* dlpServiceClient.deleteStoredInfoType(name);
* }
* }</pre>
*
* @param name Required. Resource name of the organization and storedInfoType to be deleted, for
* example `organizations/433245324/storedInfoTypes/432452342` or
* projects/project-id/storedInfoTypes/432452342.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteStoredInfoType(StoredInfoTypeName name) {
DeleteStoredInfoTypeRequest request = DeleteStoredInfoTypeRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteStoredInfoType(request);
}
use of com.google.privacy.dlp.v2.StoredInfoTypeName in project java-dlp by googleapis.
the class DlpServiceClientTest method getStoredInfoTypeTest.
@Test
public void getStoredInfoTypeTest() throws Exception {
StoredInfoType expectedResponse = StoredInfoType.newBuilder().setName(StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]").toString()).setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()).addAllPendingVersions(new ArrayList<StoredInfoTypeVersion>()).build();
mockDlpService.addResponse(expectedResponse);
StoredInfoTypeName name = StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]");
StoredInfoType actualResponse = client.getStoredInfoType(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetStoredInfoTypeRequest actualRequest = ((GetStoredInfoTypeRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.StoredInfoTypeName in project java-dlp by googleapis.
the class DlpServiceClientTest method updateStoredInfoTypeExceptionTest.
@Test
public void updateStoredInfoTypeExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
StoredInfoTypeName name = StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]");
StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateStoredInfoType(name, config, updateMask);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.privacy.dlp.v2.StoredInfoTypeName in project java-dlp by googleapis.
the class DlpServiceClientTest method updateStoredInfoTypeTest.
@Test
public void updateStoredInfoTypeTest() throws Exception {
StoredInfoType expectedResponse = StoredInfoType.newBuilder().setName(StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]").toString()).setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()).addAllPendingVersions(new ArrayList<StoredInfoTypeVersion>()).build();
mockDlpService.addResponse(expectedResponse);
StoredInfoTypeName name = StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]");
StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
StoredInfoType actualResponse = client.updateStoredInfoType(name, config, updateMask);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateStoredInfoTypeRequest actualRequest = ((UpdateStoredInfoTypeRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(config, actualRequest.getConfig());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.StoredInfoTypeName in project java-dlp by googleapis.
the class DlpServiceClientTest method getStoredInfoTypeExceptionTest.
@Test
public void getStoredInfoTypeExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
StoredInfoTypeName name = StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]");
client.getStoredInfoType(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations