use of com.google.cloud.asset.v1.AnalyzeIamPolicyResponse in project gapic-generator-java by googleapis.
the class SyncAnalyzeIamPolicy method syncAnalyzeIamPolicy.
public static void syncAnalyzeIamPolicy() throws Exception {
// It may require modifications to work in your environment.
try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
AnalyzeIamPolicyRequest request = AnalyzeIamPolicyRequest.newBuilder().setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build()).setExecutionTimeout(Duration.newBuilder().build()).build();
AnalyzeIamPolicyResponse response = assetServiceClient.analyzeIamPolicy(request);
}
}
use of com.google.cloud.asset.v1.AnalyzeIamPolicyResponse in project java-asset by googleapis.
the class AnalyzeIamPolicyExample method analyzeIamPolicy.
// Analyzes accessible IAM policies that match a request.
public static void analyzeIamPolicy(String scope, String fullResourceName) {
ResourceSelector resourceSelector = ResourceSelector.newBuilder().setFullResourceName(fullResourceName).build();
Options options = Options.newBuilder().setExpandGroups(true).setOutputGroupEdges(true).build();
IamPolicyAnalysisQuery query = IamPolicyAnalysisQuery.newBuilder().setScope(scope).setResourceSelector(resourceSelector).setOptions(options).build();
AnalyzeIamPolicyRequest request = AnalyzeIamPolicyRequest.newBuilder().setAnalysisQuery(query).build();
// the "close" method on the client to safely clean up any remaining background resources.
try (AssetServiceClient client = AssetServiceClient.create()) {
AnalyzeIamPolicyResponse response = client.analyzeIamPolicy(request);
System.out.println("Analyze completed successfully:\n" + response);
} catch (IOException e) {
System.out.println("Failed to create client:\n" + e.toString());
} catch (ApiException e) {
System.out.println("Error during AnalyzeIamPolicy:\n" + e.toString());
}
}
use of com.google.cloud.asset.v1.AnalyzeIamPolicyResponse in project gapic-generator-java by googleapis.
the class AsyncAnalyzeIamPolicy method asyncAnalyzeIamPolicy.
public static void asyncAnalyzeIamPolicy() throws Exception {
// It may require modifications to work in your environment.
try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
AnalyzeIamPolicyRequest request = AnalyzeIamPolicyRequest.newBuilder().setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build()).setExecutionTimeout(Duration.newBuilder().build()).build();
ApiFuture<AnalyzeIamPolicyResponse> future = assetServiceClient.analyzeIamPolicyCallable().futureCall(request);
// Do something.
AnalyzeIamPolicyResponse response = future.get();
}
}
Aggregations