Search in sources :

Example 1 with RunAssetDiscoveryResponse

use of com.google.cloud.securitycenter.v1.RunAssetDiscoveryResponse in project google-cloud-java by GoogleCloudPlatform.

the class AssetSnippets method runAssetDiscovery.

// [END securitycenter_group_all_assets_with_compare_duration]
// [START securitycenter_run_asset_discovery]
static void runAssetDiscovery(OrganizationName organizationName) {
    try (SecurityCenterClient client = SecurityCenterClient.create()) {
        // Call the API.  Note calls to runAssetDiscovery are throttled if too many requests
        // are made.
        OperationFuture<RunAssetDiscoveryResponse, Empty> result = client.runAssetDiscoveryAsync(organizationName);
        // Uncomment this line to wait for a certain amount of time for the asset discovery run
        // to complete.
        // result.get(130, TimeUnit.SECONDS);
        System.out.println("Asset discovery runs asynchronously.");
    } catch (IOException e) {
        throw new RuntimeException("Couldn't create client.", e);
    } catch (ResourceExhaustedException e) {
        System.out.println("Asset discovery run already in progress.");
    }
}
Also used : ResourceExhaustedException(com.google.api.gax.rpc.ResourceExhaustedException) Empty(com.google.protobuf.Empty) IOException(java.io.IOException) SecurityCenterClient(com.google.cloud.securitycenter.v1.SecurityCenterClient) RunAssetDiscoveryResponse(com.google.cloud.securitycenter.v1.RunAssetDiscoveryResponse)

Aggregations

ResourceExhaustedException (com.google.api.gax.rpc.ResourceExhaustedException)1 RunAssetDiscoveryResponse (com.google.cloud.securitycenter.v1.RunAssetDiscoveryResponse)1 SecurityCenterClient (com.google.cloud.securitycenter.v1.SecurityCenterClient)1 Empty (com.google.protobuf.Empty)1 IOException (java.io.IOException)1