use of org.orcid.jaxb.model.common_v2.SourceName in project google-cloud-java by GoogleCloudPlatform.
the class FindingSnippets method groupFindings.
// [END securitycenter_test_iam]
/**
* Group all findings under an organization across all sources by their specified properties (e.g.
* category).
*
* @param organizationName The organizatoin to group all findings for.
*/
// [START securitycenter_group_all_findings]
static ImmutableList<GroupResult> groupFindings(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// OrganizationName organizationName = OrganizationName.of("123234324");
SourceName sourceName = SourceName.of(organizationName.getOrganization(), "-");
GroupFindingsRequest.Builder request = GroupFindingsRequest.newBuilder().setParent(sourceName.toString()).setGroupBy("category");
// Call the API.
GroupFindingsPagedResponse response = client.groupFindings(request.build());
// This creates one list for all findings. If your organization has a large number of
// findings
// this can cause out of memory issues. You can process them batches by returning
// the Iterable returned response.iterateAll() directly.
ImmutableList<GroupResult> results = ImmutableList.copyOf(response.iterateAll());
System.out.println("Findings:");
System.out.println(results);
return results;
} catch (IOException e) {
throw new RuntimeException("Couldn't create client.", e);
}
}
Aggregations