use of com.google.privacy.dlp.v2.DeidentifyTemplateName in project java-dlp by googleapis.
the class DlpServiceClientTest method deleteDeidentifyTemplateExceptionTest.
@Test
public void deleteDeidentifyTemplateExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
DeidentifyTemplateName name = DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName("[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]");
client.deleteDeidentifyTemplate(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.privacy.dlp.v2.DeidentifyTemplateName 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.DeidentifyTemplateName in project java-dlp by googleapis.
the class DlpServiceClientTest method deleteDeidentifyTemplateTest.
@Test
public void deleteDeidentifyTemplateTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockDlpService.addResponse(expectedResponse);
DeidentifyTemplateName name = DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName("[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]");
client.deleteDeidentifyTemplate(name);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteDeidentifyTemplateRequest actualRequest = ((DeleteDeidentifyTemplateRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.DeidentifyTemplateName in project java-dlp by googleapis.
the class DlpServiceClientTest method updateDeidentifyTemplateExceptionTest.
@Test
public void updateDeidentifyTemplateExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
DeidentifyTemplateName name = DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName("[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]");
DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateDeidentifyTemplate(name, deidentifyTemplate, updateMask);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations