using Google.Cloud.Dlp.V2;
using System;
public class JobsGet
{
public static DlpJob GetDlpJob(string jobName)
{
var dlp = DlpServiceClient.Create();
var response = dlp.GetDlpJob(jobName);
Console.WriteLine($"Job: {response.Name} status: {response.State}");
return response;
}
}
import com.google.cloud.dlp.v2.DlpServiceClient;
import com.google.privacy.dlp.v2.DlpJobName;
import com.google.privacy.dlp.v2.GetDlpJobRequest;
import java.io.IOException;
public class JobsGet {
public static void main(String[] args) throws Exception {
// TODO(developer): Replace these variables before running the sample.
String projectId = "your-project-id";
String jobId = "your-job-id";
getJobs(projectId, jobId);
}
// Gets a DLP Job with the given jobId
public static void getJobs(String projectId, String jobId) throws IOException {
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
// the "close" method on the client to safely clean up any remaining background resources.
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
// Construct the complete job name from the projectId and jobId
DlpJobName jobName = DlpJobName.of(projectId, jobId);
// Construct the get job request to be sent by the client.
GetDlpJobRequest getDlpJobRequest =
GetDlpJobRequest.newBuilder().setName(jobName.toString()).build();
// Send the get job request
dlpServiceClient.getDlpJob(getDlpJobRequest);
System.out.println("Job got successfully.");
}
}
}
次のステップ
他の Google Cloud プロダクトに関連するコードサンプルの検索およびフィルタ検索を行うには、Google Cloud のサンプルをご覧ください。