Skip to content

Commit 1b40a08

Browse files
aaronlichen-hpminherz
authored andcommitted
samples: Refactor the sample test to avoid direct reference the AnalyzeIamPolicyLongrunning metadata field (#829)
* Refactor to remove the direct reference to the metadata field of AnalyzeIamPolicyLongrunning operation. * Refactor to remove the direct reference to the metadata field of AnalyzeIamPolicyLongrunning operation for Bigquery, also reformat the file.
1 parent 15bf823 commit 1b40a08

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

asset/src/main/java/com/example/asset/AnalyzeIamPolicyLongrunningBigqueryExample.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
package com.example.asset;
1818

1919
// [START asset_quickstart_analyze_iam_policy_longrunning_bigquery]
20-
import com.google.api.gax.longrunning.OperationFuture;
2120
import com.google.api.gax.rpc.ApiException;
2221
import com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest;
23-
import com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningResponse;
2422
import com.google.cloud.asset.v1.AssetServiceClient;
2523
import com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig;
2624
import com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig.BigQueryDestination;
@@ -71,9 +69,9 @@ public static void analyzeIamPolicyLongrunning(
7169
// once, and can be reused for multiple requests. After completing all of your requests, call
7270
// the "close" method on the client to safely clean up any remaining background resources.
7371
try (AssetServiceClient client = AssetServiceClient.create()) {
74-
OperationFuture<AnalyzeIamPolicyLongrunningResponse, AnalyzeIamPolicyLongrunningRequest>
75-
future = client.analyzeIamPolicyLongrunningAsync(request);
76-
System.out.println("Analyze completed successfully:\n" + future.getMetadata().get());
72+
System.out.println(
73+
"Analyze completed successfully:\n"
74+
+ client.analyzeIamPolicyLongrunningAsync(request).getMetadata().get());
7775
} catch (IOException e) {
7876
System.out.println("Failed to create client:\n" + e.toString());
7977
} catch (InterruptedException e) {

asset/src/main/java/com/example/asset/AnalyzeIamPolicyLongrunningGcsExample.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
package com.example.asset;
1818

1919
// [START asset_quickstart_analyze_iam_policy_longrunning_gcs]
20-
import com.google.api.gax.longrunning.OperationFuture;
2120
import com.google.api.gax.rpc.ApiException;
2221
import com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest;
23-
import com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningResponse;
2422
import com.google.cloud.asset.v1.AssetServiceClient;
2523
import com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig;
2624
import com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig.GcsDestination;
@@ -69,9 +67,9 @@ public static void analyzeIamPolicyLongrunning(
6967
// once, and can be reused for multiple requests. After completing all of your requests, call
7068
// the "close" method on the client to safely clean up any remaining background resources.
7169
try (AssetServiceClient client = AssetServiceClient.create()) {
72-
OperationFuture<AnalyzeIamPolicyLongrunningResponse, AnalyzeIamPolicyLongrunningRequest>
73-
future = client.analyzeIamPolicyLongrunningAsync(request);
74-
System.out.println("Analyze completed successfully:\n" + future.getMetadata().get());
70+
System.out.println(
71+
"Analyze completed successfully:\n"
72+
+ client.analyzeIamPolicyLongrunningAsync(request).getMetadata().get());
7573
} catch (IOException e) {
7674
System.out.println("Failed to create client:\n" + e.toString());
7775
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)