2222use Google \Cloud \Dlp \V2 \DatastoreOptions ;
2323use Google \Cloud \Dlp \V2 \InfoType ;
2424use Google \Cloud \Dlp \V2 \Action ;
25- use Google \Cloud \Dlp \V2 \Action_PublishToPubSub ;
25+ use Google \Cloud \Dlp \V2 \Action \ PublishToPubSub ;
2626use Google \Cloud \Dlp \V2 \InspectConfig ;
2727use Google \Cloud \Dlp \V2 \InspectJobConfig ;
2828use Google \Cloud \Dlp \V2 \KindExpression ;
2929use Google \Cloud \Dlp \V2 \PartitionId ;
3030use Google \Cloud \Dlp \V2 \StorageConfig ;
3131use Google \Cloud \Dlp \V2 \Likelihood ;
32- use Google \Cloud \Dlp \V2 \DlpJob_JobState ;
33- use Google \Cloud \Dlp \V2 \InspectConfig_FindingLimits ;
32+ use Google \Cloud \Dlp \V2 \DlpJob \ JobState ;
33+ use Google \Cloud \Dlp \V2 \InspectConfig \ FindingLimits ;
3434use Google \Cloud \PubSub \PubSubClient ;
3535
3636/**
@@ -70,7 +70,7 @@ function inspect_datastore(
7070 $ minLikelihood = likelihood::LIKELIHOOD_UNSPECIFIED ;
7171
7272 // Specify finding limits
73- $ limits = (new InspectConfig_FindingLimits ())
73+ $ limits = (new FindingLimits ())
7474 ->setMaxFindingsPerRequest ($ maxFindings );
7575
7676 // Construct items to be inspected
@@ -96,7 +96,7 @@ function inspect_datastore(
9696 ->setDatastoreOptions ($ datastoreOptions );
9797
9898 // Construct the action to run when job completes
99- $ pubSubAction = (new Action_PublishToPubSub ())
99+ $ pubSubAction = (new PublishToPubSub ())
100100 ->setTopic ($ topic ->name ());
101101
102102 $ action = (new Action ())
@@ -118,13 +118,12 @@ function inspect_datastore(
118118 ]);
119119
120120 // Poll via Pub/Sub until job finishes
121- $ polling = true ;
122- while ($ polling ) {
121+ while (true ) {
123122 foreach ($ subscription ->pull () as $ message ) {
124123 if (isset ($ message ->attributes ()['DlpJobName ' ]) &&
125124 $ message ->attributes ()['DlpJobName ' ] === $ job ->getName ()) {
126125 $ subscription ->acknowledge ($ message );
127- $ polling = false ;
126+ break 2 ;
128127 }
129128 }
130129 }
@@ -138,7 +137,7 @@ function inspect_datastore(
138137 // Print finding counts
139138 printf ('Job %s status: %s ' . PHP_EOL , $ job ->getName (), $ job ->getState ());
140139 switch ($ job ->getState ()) {
141- case DlpJob_JobState ::DONE :
140+ case JobState ::DONE :
142141 $ infoTypeStats = $ job ->getInspectDetails ()->getResult ()->getInfoTypeStats ();
143142 if (count ($ infoTypeStats ) === 0 ) {
144143 print ('No findings. ' . PHP_EOL );
@@ -148,7 +147,7 @@ function inspect_datastore(
148147 }
149148 }
150149 break ;
151- case DlpJob_JobState ::FAILED :
150+ case JobState ::FAILED :
152151 printf ('Job %s had errors: ' . PHP_EOL , $ job ->getName ());
153152 $ errors = $ job ->getErrors ();
154153 foreach ($ errors as $ error ) {
0 commit comments