2626
2727# [START dlp_inspect_bigquery_with_sampling]
2828
29- use Google \Cloud \Dlp \V2 \DlpServiceClient ;
30- use Google \Cloud \Dlp \V2 \BigQueryOptions ;
31- use Google \Cloud \Dlp \V2 \InfoType ;
32- use Google \Cloud \Dlp \V2 \InspectConfig ;
33- use Google \Cloud \Dlp \V2 \StorageConfig ;
34- use Google \Cloud \Dlp \V2 \BigQueryTable ;
35- use Google \Cloud \Dlp \V2 \DlpJob \JobState ;
3629use Google \Cloud \Dlp \V2 \Action ;
3730use Google \Cloud \Dlp \V2 \Action \PublishToPubSub ;
31+ use Google \Cloud \Dlp \V2 \BigQueryOptions ;
3832use Google \Cloud \Dlp \V2 \BigQueryOptions \SampleMethod ;
33+ use Google \Cloud \Dlp \V2 \BigQueryTable ;
34+ use Google \Cloud \Dlp \V2 \Client \DlpServiceClient ;
35+ use Google \Cloud \Dlp \V2 \CreateDlpJobRequest ;
36+ use Google \Cloud \Dlp \V2 \DlpJob \JobState ;
3937use Google \Cloud \Dlp \V2 \FieldId ;
38+ use Google \Cloud \Dlp \V2 \GetDlpJobRequest ;
39+ use Google \Cloud \Dlp \V2 \InfoType ;
40+ use Google \Cloud \Dlp \V2 \InspectConfig ;
4041use Google \Cloud \Dlp \V2 \InspectJobConfig ;
42+ use Google \Cloud \Dlp \V2 \StorageConfig ;
4143use Google \Cloud \PubSub \PubSubClient ;
4244
4345/**
@@ -113,9 +115,10 @@ function inspect_bigquery_with_sampling(
113115
114116 // Submit request
115117 $ parent = "projects/ $ callingProjectId/locations/global " ;
116- $ job = $ dlp ->createDlpJob ($ parent , [
117- 'inspectJob ' => $ inspectJob
118- ]);
118+ $ createDlpJobRequest = (new CreateDlpJobRequest ())
119+ ->setParent ($ parent )
120+ ->setInspectJob ($ inspectJob );
121+ $ job = $ dlp ->createDlpJob ($ createDlpJobRequest );
119122
120123 // Poll Pub/Sub using exponential backoff until job finishes
121124 // Consider using an asynchronous execution model such as Cloud Functions
@@ -130,7 +133,9 @@ function inspect_bigquery_with_sampling(
130133 $ subscription ->acknowledge ($ message );
131134 // Get the updated job. Loop to avoid race condition with DLP API.
132135 do {
133- $ job = $ dlp ->getDlpJob ($ job ->getName ());
136+ $ getDlpJobRequest = (new GetDlpJobRequest ())
137+ ->setName ($ job ->getName ());
138+ $ job = $ dlp ->getDlpJob ($ getDlpJobRequest );
134139 } while ($ job ->getState () == JobState::RUNNING );
135140 break 2 ; // break from parent do while
136141 }
0 commit comments