Search in sources :

Example 1 with AnalyzeIamPolicyLongrunningRequest

use of com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest in project gapic-generator-java by googleapis.

the class SyncAnalyzeIamPolicyLongrunning method syncAnalyzeIamPolicyLongrunning.

public static void syncAnalyzeIamPolicyLongrunning() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        AnalyzeIamPolicyLongrunningRequest request = AnalyzeIamPolicyLongrunningRequest.newBuilder().setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build()).setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build()).build();
        AnalyzeIamPolicyLongrunningResponse response = assetServiceClient.analyzeIamPolicyLongrunningAsync(request).get();
    }
}
Also used : AnalyzeIamPolicyLongrunningRequest(com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) AnalyzeIamPolicyLongrunningResponse(com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningResponse)

Example 2 with AnalyzeIamPolicyLongrunningRequest

use of com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest in project java-asset by googleapis.

the class AnalyzeIamPolicyLongrunningBigqueryExample method analyzeIamPolicyLongrunning.

// Analyzes accessible IAM policies that match a request.
public static void analyzeIamPolicyLongrunning(String scope, String fullResourceName, String dataset, String tablePrefix) {
    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();
    BigQueryDestination bigQueryDestination = BigQueryDestination.newBuilder().setDataset(dataset).setTablePrefix(tablePrefix).build();
    IamPolicyAnalysisOutputConfig outputConfig = IamPolicyAnalysisOutputConfig.newBuilder().setBigqueryDestination(bigQueryDestination).build();
    AnalyzeIamPolicyLongrunningRequest request = AnalyzeIamPolicyLongrunningRequest.newBuilder().setAnalysisQuery(query).setOutputConfig(outputConfig).build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (AssetServiceClient client = AssetServiceClient.create()) {
        System.out.println("Analyze completed successfully:\n" + client.analyzeIamPolicyLongrunningAsync(request).getMetadata().get());
    } catch (IOException e) {
        System.out.println("Failed to create client:\n" + e.toString());
    } catch (InterruptedException e) {
        System.out.println("Operation was interrupted:\n" + e.toString());
    } catch (ExecutionException e) {
        System.out.println("Operation was aborted:\n" + e.toString());
    } catch (ApiException e) {
        System.out.println("Error during AnalyzeIamPolicyLongrunning:\n" + e.toString());
    }
}
Also used : Options(com.google.cloud.asset.v1.IamPolicyAnalysisQuery.Options) AnalyzeIamPolicyLongrunningRequest(com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest) IamPolicyAnalysisOutputConfig(com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) ResourceSelector(com.google.cloud.asset.v1.IamPolicyAnalysisQuery.ResourceSelector) IamPolicyAnalysisQuery(com.google.cloud.asset.v1.IamPolicyAnalysisQuery) IOException(java.io.IOException) BigQueryDestination(com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig.BigQueryDestination) ExecutionException(java.util.concurrent.ExecutionException) ApiException(com.google.api.gax.rpc.ApiException)

Example 3 with AnalyzeIamPolicyLongrunningRequest

use of com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest in project gapic-generator-java by googleapis.

the class AsyncAnalyzeIamPolicyLongrunning method asyncAnalyzeIamPolicyLongrunning.

public static void asyncAnalyzeIamPolicyLongrunning() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        AnalyzeIamPolicyLongrunningRequest request = AnalyzeIamPolicyLongrunningRequest.newBuilder().setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build()).setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build()).build();
        ApiFuture<Operation> future = assetServiceClient.analyzeIamPolicyLongrunningCallable().futureCall(request);
        // Do something.
        Operation response = future.get();
    }
}
Also used : AnalyzeIamPolicyLongrunningRequest(com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) Operation(com.google.longrunning.Operation)

Example 4 with AnalyzeIamPolicyLongrunningRequest

use of com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest in project gapic-generator-java by googleapis.

the class AsyncAnalyzeIamPolicyLongrunningLRO method asyncAnalyzeIamPolicyLongrunningLRO.

public static void asyncAnalyzeIamPolicyLongrunningLRO() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        AnalyzeIamPolicyLongrunningRequest request = AnalyzeIamPolicyLongrunningRequest.newBuilder().setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build()).setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build()).build();
        OperationFuture<AnalyzeIamPolicyLongrunningResponse, AnalyzeIamPolicyLongrunningMetadata> future = assetServiceClient.analyzeIamPolicyLongrunningOperationCallable().futureCall(request);
        // Do something.
        AnalyzeIamPolicyLongrunningResponse response = future.get();
    }
}
Also used : AnalyzeIamPolicyLongrunningRequest(com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) AnalyzeIamPolicyLongrunningMetadata(com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningMetadata) AnalyzeIamPolicyLongrunningResponse(com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningResponse)

Example 5 with AnalyzeIamPolicyLongrunningRequest

use of com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest in project java-asset by googleapis.

the class AnalyzeIamPolicyLongrunningGcsExample method analyzeIamPolicyLongrunning.

// Analyzes accessible IAM policies that match a request.
public static void analyzeIamPolicyLongrunning(String scope, String fullResourceName, String uri) {
    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();
    GcsDestination gcsDestination = GcsDestination.newBuilder().setUri(uri).build();
    IamPolicyAnalysisOutputConfig outputConfig = IamPolicyAnalysisOutputConfig.newBuilder().setGcsDestination(GcsDestination.newBuilder().setUri(uri).build()).build();
    AnalyzeIamPolicyLongrunningRequest request = AnalyzeIamPolicyLongrunningRequest.newBuilder().setAnalysisQuery(query).setOutputConfig(outputConfig).build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (AssetServiceClient client = AssetServiceClient.create()) {
        System.out.println("Analyze completed successfully:\n" + client.analyzeIamPolicyLongrunningAsync(request).getMetadata().get());
    } catch (IOException e) {
        System.out.println("Failed to create client:\n" + e.toString());
    } catch (InterruptedException e) {
        System.out.println("Operation was interrupted:\n" + e.toString());
    } catch (ExecutionException e) {
        System.out.println("Operation was aborted:\n" + e.toString());
    } catch (ApiException e) {
        System.out.println("Error during AnalyzeIamPolicyLongrunning:\n" + e.toString());
    }
}
Also used : Options(com.google.cloud.asset.v1.IamPolicyAnalysisQuery.Options) AnalyzeIamPolicyLongrunningRequest(com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest) IamPolicyAnalysisOutputConfig(com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) ResourceSelector(com.google.cloud.asset.v1.IamPolicyAnalysisQuery.ResourceSelector) IamPolicyAnalysisQuery(com.google.cloud.asset.v1.IamPolicyAnalysisQuery) IOException(java.io.IOException) GcsDestination(com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig.GcsDestination) ExecutionException(java.util.concurrent.ExecutionException) ApiException(com.google.api.gax.rpc.ApiException)

Aggregations

AnalyzeIamPolicyLongrunningRequest (com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest)5 AssetServiceClient (com.google.cloud.asset.v1.AssetServiceClient)5 ApiException (com.google.api.gax.rpc.ApiException)2 AnalyzeIamPolicyLongrunningResponse (com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningResponse)2 IamPolicyAnalysisOutputConfig (com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig)2 IamPolicyAnalysisQuery (com.google.cloud.asset.v1.IamPolicyAnalysisQuery)2 Options (com.google.cloud.asset.v1.IamPolicyAnalysisQuery.Options)2 ResourceSelector (com.google.cloud.asset.v1.IamPolicyAnalysisQuery.ResourceSelector)2 IOException (java.io.IOException)2 ExecutionException (java.util.concurrent.ExecutionException)2 AnalyzeIamPolicyLongrunningMetadata (com.google.cloud.asset.v1.AnalyzeIamPolicyLongrunningMetadata)1 BigQueryDestination (com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig.BigQueryDestination)1 GcsDestination (com.google.cloud.asset.v1.IamPolicyAnalysisOutputConfig.GcsDestination)1 Operation (com.google.longrunning.Operation)1