use of com.google.privacy.dlp.v2.DeidentifyTemplate in project java-dlp by googleapis.
the class DlpServiceClientTest method updateDeidentifyTemplateTest2.
@Test
public void updateDeidentifyTemplateTest2() throws Exception {
DeidentifyTemplate expectedResponse = DeidentifyTemplate.newBuilder().setName(DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName("[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setDeidentifyConfig(DeidentifyConfig.newBuilder().build()).build();
mockDlpService.addResponse(expectedResponse);
String name = "name3373707";
DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
DeidentifyTemplate actualResponse = client.updateDeidentifyTemplate(name, deidentifyTemplate, updateMask);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateDeidentifyTemplateRequest actualRequest = ((UpdateDeidentifyTemplateRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertEquals(deidentifyTemplate, actualRequest.getDeidentifyTemplate());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.DeidentifyTemplate in project java-dlp by googleapis.
the class DlpServiceClient method deleteDeidentifyTemplate.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a DeidentifyTemplate. See https://cloud.google.com/dlp/docs/creating-templates-deid to
* learn more.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
* DeidentifyTemplateName name =
* DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName(
* "[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]");
* dlpServiceClient.deleteDeidentifyTemplate(name);
* }
* }</pre>
*
* @param name Required. Resource name of the organization and deidentify template to be deleted,
* for example `organizations/433245324/deidentifyTemplates/432452342` or
* projects/project-id/deidentifyTemplates/432452342.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteDeidentifyTemplate(DeidentifyTemplateName name) {
DeleteDeidentifyTemplateRequest request = DeleteDeidentifyTemplateRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteDeidentifyTemplate(request);
}
use of com.google.privacy.dlp.v2.DeidentifyTemplate in project java-dlp by googleapis.
the class DlpServiceClientTest method createDeidentifyTemplateTest4.
@Test
public void createDeidentifyTemplateTest4() throws Exception {
DeidentifyTemplate expectedResponse = DeidentifyTemplate.newBuilder().setName(DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName("[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setDeidentifyConfig(DeidentifyConfig.newBuilder().build()).build();
mockDlpService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build();
DeidentifyTemplate actualResponse = client.createDeidentifyTemplate(parent, deidentifyTemplate);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateDeidentifyTemplateRequest actualRequest = ((CreateDeidentifyTemplateRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(deidentifyTemplate, actualRequest.getDeidentifyTemplate());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.DeidentifyTemplate in project java-dlp by googleapis.
the class DlpServiceClientTest method createDeidentifyTemplateExceptionTest2.
@Test
public void createDeidentifyTemplateExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
OrganizationLocationName parent = OrganizationLocationName.of("[ORGANIZATION]", "[LOCATION]");
DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build();
client.createDeidentifyTemplate(parent, deidentifyTemplate);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.privacy.dlp.v2.DeidentifyTemplate in project java-dlp by googleapis.
the class DlpServiceClientTest method createDeidentifyTemplateExceptionTest5.
@Test
public void createDeidentifyTemplateExceptionTest5() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
String parent = "parent-995424086";
DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build();
client.createDeidentifyTemplate(parent, deidentifyTemplate);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations