Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ private AssetSnippets() {}
* @param organizationName The organization to list assets for.
*/
// [START securitycenter_list_all_assets]
// [START list_all_assets]
static ImmutableList<ListAssetsResult> listAssets(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// Start setting up a request for to search for all assets in an organization.
Expand All @@ -66,7 +65,6 @@ static ImmutableList<ListAssetsResult> listAssets(OrganizationName organizationN
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END list_all_assets]
// [END securitycenter_list_all_assets]

/**
Expand All @@ -75,7 +73,6 @@ static ImmutableList<ListAssetsResult> listAssets(OrganizationName organizationN
* @param organizationName The organization to list assets for.
*/
// [START securitycenter_list_assets_with_filter]
// [START list_assets_with_filter]
static ImmutableList<ListAssetsResult> listAssetsWithFilter(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// Start setting up a request for to search for all assets in an organization.
Expand All @@ -100,7 +97,6 @@ static ImmutableList<ListAssetsResult> listAssetsWithFilter(OrganizationName org
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END list_assets_with_filter]
// [END securitycenter_list_assets_with_filter]

/**
Expand All @@ -110,7 +106,6 @@ static ImmutableList<ListAssetsResult> listAssetsWithFilter(OrganizationName org
* @param asOf The snapshot time to query for assets. If null defaults to one day ago.
*/
// [START securitycenter_list_assets_at_time]
// [START list_assets_as_of_time]
static ImmutableList<ListAssetsResult> listAssetsAsOfYesterday(
OrganizationName organizationName, Instant asOf) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
Expand Down Expand Up @@ -142,7 +137,6 @@ static ImmutableList<ListAssetsResult> listAssetsAsOfYesterday(
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END list_assets_as_of_time]
// [END securitycenter_list_assets_at_time]

/**
Expand All @@ -153,7 +147,6 @@ static ImmutableList<ListAssetsResult> listAssetsAsOfYesterday(
* @param asOf The instant in time to query for. If null, current time is assumed.
*/
// [START securitycenter_list_assets_and_changes]
// [START list_asset_changes_status_changes]
static ImmutableList<ListAssetsResult> listAssetAndStatusChanges(
OrganizationName organizationName, Duration timeSpan, Instant asOf) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
Expand Down Expand Up @@ -188,7 +181,6 @@ static ImmutableList<ListAssetsResult> listAssetAndStatusChanges(
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END list_asset_changes_status_changes]
// [END securitycenter_list_assets_and_changes]

/**
Expand All @@ -197,7 +189,6 @@ static ImmutableList<ListAssetsResult> listAssetAndStatusChanges(
* @param organizationName The organization to group assets for.
*/
// [START securitycenter_group_all_assets]
// [START group_all_assets]
static ImmutableList<GroupResult> groupAssets(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// Start setting up a request for to group all assets by type in an organization.
Expand All @@ -221,7 +212,6 @@ static ImmutableList<GroupResult> groupAssets(OrganizationName organizationName)
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END group_all_assets]
// [END securitycenter_group_all_assets]

/**
Expand All @@ -231,7 +221,6 @@ static ImmutableList<GroupResult> groupAssets(OrganizationName organizationName)
* @param organizationName The organization to group assets for.
*/
// [START securitycenter_group_all_assets_with_filter]
// [START group_all_assets_with_filter]
static ImmutableList<GroupResult> groupAssetsWithFilter(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// Start setting up a request for to filter all assets by type and group them by project in an
Expand All @@ -258,7 +247,6 @@ static ImmutableList<GroupResult> groupAssetsWithFilter(OrganizationName organiz
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END group_all_assets_with_filter]
// [END securitycenter_group_all_assets_with_filter]

/**
Expand All @@ -268,7 +256,6 @@ static ImmutableList<GroupResult> groupAssetsWithFilter(OrganizationName organiz
* @param organizationName The organization to group assets for.
*/
// [START securitycenter_group_all_assets_with_compare_duration]
// [START group_all_assets_with_compare_duration]
static ImmutableList<GroupResult> groupAssetsWithCompareDuration(
OrganizationName organizationName, Duration duration) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
Expand Down Expand Up @@ -298,11 +285,9 @@ static ImmutableList<GroupResult> groupAssetsWithCompareDuration(
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END group_all_assets_with_compare_duration]
// [END securitycenter_group_all_assets_with_compare_duration]

// [START securitycenter_run_asset_discovery]
// [START 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
Expand All @@ -320,7 +305,6 @@ static void runAssetDiscovery(OrganizationName organizationName) {
System.out.println("Asset discovery run already in progress.");
}
}
// [END run_asset_discovery]
// [END securitycenter_run_asset_discovery]

public static void main(String... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ private FindingSnippets() {}
* @param sourceName The source for the finding.
*/
// [START securitycenter_create_finding]
// [START create_finding]
static Finding createFinding(SourceName sourceName, String findingId) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// SourceName sourceName = SourceName.of(/*organization=*/"123234324",/*source=*/
Expand Down Expand Up @@ -87,7 +86,6 @@ static Finding createFinding(SourceName sourceName, String findingId) {
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END create_finding]
// [END securitycenter_create_finding]

/**
Expand All @@ -96,7 +94,6 @@ static Finding createFinding(SourceName sourceName, String findingId) {
* @param sourceName The source for the finding.
*/
// [START securitycenter_create_finding_with_source_properties]
// [START create_finding_with_source_properties]
static Finding createFindingWithSourceProperties(SourceName sourceName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// SourceName sourceName = SourceName.of(/*organization=*/"123234324",/*source=*/
Expand Down Expand Up @@ -141,7 +138,6 @@ static Finding createFindingWithSourceProperties(SourceName sourceName) {
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END create_finding_with_source_properties]
// [END securitycenter_create_finding_with_source_properties]

/**
Expand All @@ -150,7 +146,6 @@ static Finding createFindingWithSourceProperties(SourceName sourceName) {
* @param findingName The finding to update.
*/
// [START securitycenter_update_finding_source_properties]
// [START update_finding]
static Finding updateFinding(FindingName findingName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// FindingName findingName = FindingName.of(/*organization=*/"123234324",
Expand Down Expand Up @@ -190,7 +185,6 @@ static Finding updateFinding(FindingName findingName) {
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END update_finding]
// [END securitycenter_update_finding_source_properties]

/**
Expand All @@ -199,7 +193,6 @@ static Finding updateFinding(FindingName findingName) {
* @param findingName The finding to update.
*/
// [START securitycenter_update_finding_state]
// [START update_finding_state]
static Finding setFindingState(FindingName findingName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// FindingName findingName = FindingName.of(/*organization=*/"123234324",
Expand All @@ -223,7 +216,6 @@ static Finding setFindingState(FindingName findingName) {
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END update_finding_state]
// [END securitycenter_update_finding_state]

/**
Expand All @@ -232,7 +224,6 @@ static Finding setFindingState(FindingName findingName) {
* @param organizationName The source to list all findings for.
*/
// [START securitycenter_list_all_findings]
// [START list_all_findings]
static ImmutableList<ListFindingsResult> listAllFindings(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// OrganizationName organizationName = OrganizationName.of(/*organizationId=*/"123234324");
Expand All @@ -256,7 +247,6 @@ static ImmutableList<ListFindingsResult> listAllFindings(OrganizationName organi
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END list_all_findings]
// [END securitycenter_list_all_findings]

/**
Expand All @@ -265,7 +255,6 @@ static ImmutableList<ListFindingsResult> listAllFindings(OrganizationName organi
* @param sourceName The source to list filtered findings for.
*/
// [START securitycenter_list_filtered_findings]
// [START list_filtered_findings]
static ImmutableList<ListFindingsResult> listFilteredFindings(SourceName sourceName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// SourceName sourceName = SourceName.of(/*organizationId=*/"123234324",
Expand All @@ -291,7 +280,6 @@ static ImmutableList<ListFindingsResult> listFilteredFindings(SourceName sourceN
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END list_filtered_findings]
// [END securitycenter_list_filtered_findings]

/**
Expand All @@ -300,7 +288,6 @@ static ImmutableList<ListFindingsResult> listFilteredFindings(SourceName sourceN
* @param sourceName The source to list findings at a specific time for.
*/
// [START securitycenter_list_findings_at_time]
// [START list_findings_at_time]
static ImmutableList<ListFindingsResult> listFindingsAtTime(SourceName sourceName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// SourceName sourceName = SourceName.of(/*organizationId=*/"123234324",
Expand Down Expand Up @@ -331,7 +318,6 @@ static ImmutableList<ListFindingsResult> listFindingsAtTime(SourceName sourceNam
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END list_findings_at_time]
// [END securitycenter_list_findings_at_time]

/**
Expand All @@ -341,7 +327,6 @@ static ImmutableList<ListFindingsResult> listFindingsAtTime(SourceName sourceNam
* @param sourceName The source to create a finding for.
*/
// [START securitycenter_test_iam]
// [START test_iam_permissions]
static TestIamPermissionsResponse testIamPermissions(SourceName sourceName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// SourceName sourceName = SourceName.of(/*organizationId=*/"123234324",
Expand All @@ -362,7 +347,6 @@ static TestIamPermissionsResponse testIamPermissions(SourceName sourceName) {
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END test_iam_permissions]
// [END securitycenter_test_iam]

/**
Expand All @@ -372,7 +356,6 @@ static TestIamPermissionsResponse testIamPermissions(SourceName sourceName) {
* @param organizationName The organizatoin to group all findings for.
*/
// [START securitycenter_group_all_findings]
// [START group_all_findings]
static ImmutableList<GroupResult> groupFindings(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// OrganizationName organizationName = OrganizationName.of("123234324");
Expand All @@ -396,7 +379,6 @@ static ImmutableList<GroupResult> groupFindings(OrganizationName organizationNam
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END group_all_findings]
// [END securitycenter_group_all_findings]

/**
Expand All @@ -406,7 +388,6 @@ static ImmutableList<GroupResult> groupFindings(OrganizationName organizationNam
* @param sourceName The source to limit the findings to.
*/
// [START securitycenter_group_findings_with_source]
// [START group_findings_with_source]
static ImmutableList<GroupResult> groupFindingsWithSource(SourceName sourceName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// SourceName sourceName = SourceName.of(/*organization=*/"123234324",/*source=*/
Expand All @@ -430,7 +411,6 @@ static ImmutableList<GroupResult> groupFindingsWithSource(SourceName sourceName)
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END group_findings_with_source]
// [END securitycenter_group_findings_with_source]

/**
Expand All @@ -440,7 +420,6 @@ static ImmutableList<GroupResult> groupFindingsWithSource(SourceName sourceName)
* @param sourceName The source to limit the findings to.
*/
// [START securitycenter_group_active_findings_with_source]
// [START group_active_findings_with_source]
static ImmutableList<GroupResult> groupActiveFindingsWithSource(SourceName sourceName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// SourceName sourceName = SourceName.of(/*organization=*/"123234324",/*source=*/
Expand All @@ -467,7 +446,6 @@ static ImmutableList<GroupResult> groupActiveFindingsWithSource(SourceName sourc
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END group_active_findings_with_source]
// [END securitycenter_group_active_findings_with_source]

/**
Expand All @@ -477,7 +455,6 @@ static ImmutableList<GroupResult> groupActiveFindingsWithSource(SourceName sourc
* @param sourceName The source to limit the findings to.
*/
// [START securitycenter_group_active_findings_with_source_at_time]
// [START group_active_findings_with_source_at_time]
static ImmutableList<GroupResult> groupActiveFindingsWithSourceAtTime(SourceName sourceName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// SourceName sourceName = SourceName.of(/*organization=*/"123234324",/*source=*/
Expand Down Expand Up @@ -511,7 +488,6 @@ static ImmutableList<GroupResult> groupActiveFindingsWithSourceAtTime(SourceName
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END group_active_findings_with_source_at_time]
// [END securitycenter_group_active_findings_with_source_at_time]

/**
Expand All @@ -521,7 +497,6 @@ static ImmutableList<GroupResult> groupActiveFindingsWithSourceAtTime(SourceName
* @param sourceName The source to limit the findings to.
*/
// [START securitycenter_group_active_findings_with_source_and_compare_duration]
// [START group_active_findings_with_source_and_compare_duration]
static ImmutableList<GroupResult> groupActiveFindingsWithSourceAndCompareDuration(
SourceName sourceName, Duration duration) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
Expand Down Expand Up @@ -553,6 +528,5 @@ static ImmutableList<GroupResult> groupActiveFindingsWithSourceAndCompareDuratio
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END group_active_findings_with_source_and_compare_duration]
// [END securitycenter_group_active_findings_with_source_and_compare_duration]
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ private OrganizationSnippets() {}
* @param organizationName The organization to get settings for.
*/
// [START securitycenter_get_org_settings]
// [START get_organization_settings]
static OrganizationSettings getOrganizationSettings(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// Start setting up a request to get OrganizationSettings for.
Expand All @@ -53,7 +52,6 @@ static OrganizationSettings getOrganizationSettings(OrganizationName organizatio
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END get_organization_settings]
// [END securitycenter_get_org_settings]

/**
Expand All @@ -62,7 +60,6 @@ static OrganizationSettings getOrganizationSettings(OrganizationName organizatio
* @param organizationName The organization to update settings for.
*/
// [START securitycenter_enable_asset_discovery]
// [START update_organization_settings]
static OrganizationSettings updateOrganizationSettings(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// Start setting up a request to update OrganizationSettings for.
Expand All @@ -89,7 +86,6 @@ static OrganizationSettings updateOrganizationSettings(OrganizationName organiza
throw new RuntimeException("Couldn't create client.", e);
}
}
// [END update_organization_settings]
// [END securitycenter_enable_asset_discovery]

}
Loading