use of com.google.api.gax.rpc.ResourceExhaustedException 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.");
}
}
Aggregations