Example #1
0
    private static DlpJob EnsureJobFinishes(string projectId, string jobName)
    {
        var client  = DlpServiceClient.Create();
        var request = new GetDlpJobRequest
        {
            DlpJobName = new DlpJobName(projectId, jobName),
        };

        // Simple logic that gives the job 5*30 sec at most to complete - for testing purposes only
        var numOfAttempts = 5;

        do
        {
            var dlpJob = client.GetDlpJob(request);
            numOfAttempts--;
            if (dlpJob.State != DlpJob.Types.JobState.Running)
            {
                return(dlpJob);
            }

            Thread.Sleep(TimeSpan.FromSeconds(30));
        } while (numOfAttempts > 0);

        throw new InvalidOperationException("Job did not complete in time");
    }
Example #2
0
        // [END dlp_inspect_gcs]

        static bool EnsureJobFinishes(string projectId, string jobName)
        {
            DlpServiceClient client = DlpServiceClient.Create();
            var request             = new GetDlpJobRequest
            {
                DlpJobName = new DlpJobName(projectId, jobName),
            };

            // Simple logic that gives the job 5*30 sec at most to complete - for testing purposes only
            int numOfAttempts = 5;

            do
            {
                var dlpJob = client.GetDlpJob(request);
                numOfAttempts--;
                if (dlpJob.State != DlpJob.Types.JobState.Running)
                {
                    return(true);
                }

                Thread.Sleep(TimeSpan.FromSeconds(30));
            } while (numOfAttempts > 0);

            return(false);
        }
Example #3
0
 /// <summary>Snippet for GetDlpJob</summary>
 public void GetDlpJob_RequestObject()
 {
     // Snippet: GetDlpJob(GetDlpJobRequest,CallSettings)
     // Create client
     DlpServiceClient dlpServiceClient = DlpServiceClient.Create();
     // Initialize request argument(s)
     GetDlpJobRequest request = new GetDlpJobRequest
     {
         DlpJobName = new DlpJobName("[PROJECT]", "[DLP_JOB]"),
     };
     // Make the request
     DlpJob response = dlpServiceClient.GetDlpJob(request);
     // End snippet
 }
Example #4
0
        /// <summary>Snippet for GetDlpJobAsync</summary>
        public async Task GetDlpJobAsync_RequestObject()
        {
            // Snippet: GetDlpJobAsync(GetDlpJobRequest,CallSettings)
            // Additional: GetDlpJobAsync(GetDlpJobRequest,CancellationToken)
            // Create client
            DlpServiceClient dlpServiceClient = await DlpServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetDlpJobRequest request = new GetDlpJobRequest
            {
                DlpJobName = new DlpJobName("[PROJECT]", "[DLP_JOB]"),
            };
            // Make the request
            DlpJob response = await dlpServiceClient.GetDlpJobAsync(request);

            // End snippet
        }
        public async Task GetDlpJobAsync()
        {
            Mock <DlpService.DlpServiceClient> mockGrpcClient = new Mock <DlpService.DlpServiceClient>(MockBehavior.Strict);
            GetDlpJobRequest request = new GetDlpJobRequest
            {
                DlpJobName = new DlpJobName("[PROJECT]", "[DLP_JOB]"),
            };
            DlpJob expectedResponse = new DlpJob
            {
                Name           = "name2-1052831874",
                JobTriggerName = "jobTriggerName1819490804",
            };

            mockGrpcClient.Setup(x => x.GetDlpJobAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <DlpJob>(Task.FromResult(expectedResponse), null, null, null, null));
            DlpServiceClient client   = new DlpServiceClientImpl(mockGrpcClient.Object, null);
            DlpJob           response = await client.GetDlpJobAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetDlpJob()
        {
            Mock <DlpService.DlpServiceClient> mockGrpcClient = new Mock <DlpService.DlpServiceClient>(MockBehavior.Strict);
            GetDlpJobRequest request = new GetDlpJobRequest
            {
                DlpJobName = new DlpJobName("[PROJECT]", "[DLP_JOB]"),
            };
            DlpJob expectedResponse = new DlpJob
            {
                Name           = "name2-1052831874",
                JobTriggerName = "jobTriggerName1819490804",
            };

            mockGrpcClient.Setup(x => x.GetDlpJob(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            DlpServiceClient client   = new DlpServiceClientImpl(mockGrpcClient.Object, null);
            DlpJob           response = client.GetDlpJob(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }