Search in sources :

Example 6 with JobTriggerName

use of com.google.privacy.dlp.v2.JobTriggerName in project java-dlp by googleapis.

the class DlpServiceClientTest method hybridInspectJobTriggerTest.

@Test
public void hybridInspectJobTriggerTest() throws Exception {
    HybridInspectResponse expectedResponse = HybridInspectResponse.newBuilder().build();
    mockDlpService.addResponse(expectedResponse);
    JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]");
    HybridInspectResponse actualResponse = client.hybridInspectJobTrigger(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    HybridInspectJobTriggerRequest actualRequest = ((HybridInspectJobTriggerRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : HybridInspectJobTriggerRequest(com.google.privacy.dlp.v2.HybridInspectJobTriggerRequest) AbstractMessage(com.google.protobuf.AbstractMessage) HybridInspectResponse(com.google.privacy.dlp.v2.HybridInspectResponse) JobTriggerName(com.google.privacy.dlp.v2.JobTriggerName) Test(org.junit.Test)

Example 7 with JobTriggerName

use of com.google.privacy.dlp.v2.JobTriggerName in project java-dlp by googleapis.

the class DlpServiceClientTest method hybridInspectJobTriggerExceptionTest.

@Test
public void hybridInspectJobTriggerExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockDlpService.addException(exception);
    try {
        JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]");
        client.hybridInspectJobTrigger(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) JobTriggerName(com.google.privacy.dlp.v2.JobTriggerName) Test(org.junit.Test)

Example 8 with JobTriggerName

use of com.google.privacy.dlp.v2.JobTriggerName in project java-dlp by googleapis.

the class DlpServiceClient method deleteJobTrigger.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes a job trigger. See https://cloud.google.com/dlp/docs/creating-job-triggers 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()) {
 *   JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]");
 *   dlpServiceClient.deleteJobTrigger(name);
 * }
 * }</pre>
 *
 * @param name Required. Resource name of the project and the triggeredJob, for example
 *     `projects/dlp-test-project/jobTriggers/53234423`.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteJobTrigger(JobTriggerName name) {
    DeleteJobTriggerRequest request = DeleteJobTriggerRequest.newBuilder().setName(name == null ? null : name.toString()).build();
    deleteJobTrigger(request);
}
Also used : DeleteJobTriggerRequest(com.google.privacy.dlp.v2.DeleteJobTriggerRequest)

Example 9 with JobTriggerName

use of com.google.privacy.dlp.v2.JobTriggerName in project java-dlp by googleapis.

the class DlpServiceClientTest method deleteJobTriggerExceptionTest.

@Test
public void deleteJobTriggerExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockDlpService.addException(exception);
    try {
        JobTriggerName name = JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]");
        client.deleteJobTrigger(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) JobTriggerName(com.google.privacy.dlp.v2.JobTriggerName) Test(org.junit.Test)

Aggregations

JobTriggerName (com.google.privacy.dlp.v2.JobTriggerName)8 Test (org.junit.Test)8 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4 JobTrigger (com.google.privacy.dlp.v2.JobTrigger)3 DeleteJobTriggerRequest (com.google.privacy.dlp.v2.DeleteJobTriggerRequest)2 Error (com.google.privacy.dlp.v2.Error)2 FieldMask (com.google.protobuf.FieldMask)2 ArrayList (java.util.ArrayList)2 GetJobTriggerRequest (com.google.privacy.dlp.v2.GetJobTriggerRequest)1 HybridInspectJobTriggerRequest (com.google.privacy.dlp.v2.HybridInspectJobTriggerRequest)1 HybridInspectResponse (com.google.privacy.dlp.v2.HybridInspectResponse)1 UpdateJobTriggerRequest (com.google.privacy.dlp.v2.UpdateJobTriggerRequest)1 Empty (com.google.protobuf.Empty)1