diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/AssetSnippets.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/AssetSnippets.java index 956bcdb92653..d101ae186c0b 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/AssetSnippets.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/AssetSnippets.java @@ -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 listAssets(OrganizationName organizationName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // Start setting up a request for to search for all assets in an organization. @@ -66,7 +65,6 @@ static ImmutableList listAssets(OrganizationName organizationN throw new RuntimeException("Couldn't create client.", e); } } - // [END list_all_assets] // [END securitycenter_list_all_assets] /** @@ -75,7 +73,6 @@ static ImmutableList listAssets(OrganizationName organizationN * @param organizationName The organization to list assets for. */ // [START securitycenter_list_assets_with_filter] - // [START list_assets_with_filter] static ImmutableList listAssetsWithFilter(OrganizationName organizationName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // Start setting up a request for to search for all assets in an organization. @@ -100,7 +97,6 @@ static ImmutableList listAssetsWithFilter(OrganizationName org throw new RuntimeException("Couldn't create client.", e); } } - // [END list_assets_with_filter] // [END securitycenter_list_assets_with_filter] /** @@ -110,7 +106,6 @@ static ImmutableList 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 listAssetsAsOfYesterday( OrganizationName organizationName, Instant asOf) { try (SecurityCenterClient client = SecurityCenterClient.create()) { @@ -142,7 +137,6 @@ static ImmutableList listAssetsAsOfYesterday( throw new RuntimeException("Couldn't create client.", e); } } - // [END list_assets_as_of_time] // [END securitycenter_list_assets_at_time] /** @@ -153,7 +147,6 @@ static ImmutableList 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 listAssetAndStatusChanges( OrganizationName organizationName, Duration timeSpan, Instant asOf) { try (SecurityCenterClient client = SecurityCenterClient.create()) { @@ -188,7 +181,6 @@ static ImmutableList listAssetAndStatusChanges( throw new RuntimeException("Couldn't create client.", e); } } - // [END list_asset_changes_status_changes] // [END securitycenter_list_assets_and_changes] /** @@ -197,7 +189,6 @@ static ImmutableList listAssetAndStatusChanges( * @param organizationName The organization to group assets for. */ // [START securitycenter_group_all_assets] - // [START group_all_assets] static ImmutableList groupAssets(OrganizationName organizationName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // Start setting up a request for to group all assets by type in an organization. @@ -221,7 +212,6 @@ static ImmutableList groupAssets(OrganizationName organizationName) throw new RuntimeException("Couldn't create client.", e); } } - // [END group_all_assets] // [END securitycenter_group_all_assets] /** @@ -231,7 +221,6 @@ static ImmutableList 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 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 @@ -258,7 +247,6 @@ static ImmutableList groupAssetsWithFilter(OrganizationName organiz throw new RuntimeException("Couldn't create client.", e); } } - // [END group_all_assets_with_filter] // [END securitycenter_group_all_assets_with_filter] /** @@ -268,7 +256,6 @@ static ImmutableList 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 groupAssetsWithCompareDuration( OrganizationName organizationName, Duration duration) { try (SecurityCenterClient client = SecurityCenterClient.create()) { @@ -298,11 +285,9 @@ static ImmutableList 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 @@ -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) { diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/FindingSnippets.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/FindingSnippets.java index 9034faf2cf02..9cf8cd4c9e99 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/FindingSnippets.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/FindingSnippets.java @@ -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=*/ @@ -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] /** @@ -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=*/ @@ -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] /** @@ -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", @@ -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] /** @@ -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", @@ -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] /** @@ -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 listAllFindings(OrganizationName organizationName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // OrganizationName organizationName = OrganizationName.of(/*organizationId=*/"123234324"); @@ -256,7 +247,6 @@ static ImmutableList listAllFindings(OrganizationName organi throw new RuntimeException("Couldn't create client.", e); } } - // [END list_all_findings] // [END securitycenter_list_all_findings] /** @@ -265,7 +255,6 @@ static ImmutableList listAllFindings(OrganizationName organi * @param sourceName The source to list filtered findings for. */ // [START securitycenter_list_filtered_findings] - // [START list_filtered_findings] static ImmutableList listFilteredFindings(SourceName sourceName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // SourceName sourceName = SourceName.of(/*organizationId=*/"123234324", @@ -291,7 +280,6 @@ static ImmutableList listFilteredFindings(SourceName sourceN throw new RuntimeException("Couldn't create client.", e); } } - // [END list_filtered_findings] // [END securitycenter_list_filtered_findings] /** @@ -300,7 +288,6 @@ static ImmutableList 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 listFindingsAtTime(SourceName sourceName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // SourceName sourceName = SourceName.of(/*organizationId=*/"123234324", @@ -331,7 +318,6 @@ static ImmutableList listFindingsAtTime(SourceName sourceNam throw new RuntimeException("Couldn't create client.", e); } } - // [END list_findings_at_time] // [END securitycenter_list_findings_at_time] /** @@ -341,7 +327,6 @@ static ImmutableList 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", @@ -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] /** @@ -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 groupFindings(OrganizationName organizationName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // OrganizationName organizationName = OrganizationName.of("123234324"); @@ -396,7 +379,6 @@ static ImmutableList groupFindings(OrganizationName organizationNam throw new RuntimeException("Couldn't create client.", e); } } - // [END group_all_findings] // [END securitycenter_group_all_findings] /** @@ -406,7 +388,6 @@ static ImmutableList 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 groupFindingsWithSource(SourceName sourceName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // SourceName sourceName = SourceName.of(/*organization=*/"123234324",/*source=*/ @@ -430,7 +411,6 @@ static ImmutableList groupFindingsWithSource(SourceName sourceName) throw new RuntimeException("Couldn't create client.", e); } } - // [END group_findings_with_source] // [END securitycenter_group_findings_with_source] /** @@ -440,7 +420,6 @@ static ImmutableList 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 groupActiveFindingsWithSource(SourceName sourceName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // SourceName sourceName = SourceName.of(/*organization=*/"123234324",/*source=*/ @@ -467,7 +446,6 @@ static ImmutableList groupActiveFindingsWithSource(SourceName sourc throw new RuntimeException("Couldn't create client.", e); } } - // [END group_active_findings_with_source] // [END securitycenter_group_active_findings_with_source] /** @@ -477,7 +455,6 @@ static ImmutableList 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 groupActiveFindingsWithSourceAtTime(SourceName sourceName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // SourceName sourceName = SourceName.of(/*organization=*/"123234324",/*source=*/ @@ -511,7 +488,6 @@ static ImmutableList 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] /** @@ -521,7 +497,6 @@ static ImmutableList 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 groupActiveFindingsWithSourceAndCompareDuration( SourceName sourceName, Duration duration) { try (SecurityCenterClient client = SecurityCenterClient.create()) { @@ -553,6 +528,5 @@ static ImmutableList 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] } diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/OrganizationSnippets.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/OrganizationSnippets.java index 76c16f21e143..ca45abfe2334 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/OrganizationSnippets.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/OrganizationSnippets.java @@ -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. @@ -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] /** @@ -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. @@ -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] } diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/SecurityMarkSnippets.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/SecurityMarkSnippets.java index b822ab45ee24..611ad9e43844 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/SecurityMarkSnippets.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/SecurityMarkSnippets.java @@ -42,7 +42,6 @@ private SecurityMarkSnippets() {} * @param assetName The asset resource to add the security mark for. */ // [START securitycenter_add_security_marks] - // [START add_to_asset] static SecurityMarks addToAsset(String assetName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // String assetName = "organizations/123123342/assets/12312321"; @@ -74,7 +73,6 @@ static SecurityMarks addToAsset(String assetName) { throw new RuntimeException("Couldn't create client.", e); } } - // [END add_to_asset] // [END securitycenter_add_security_marks] /** @@ -83,7 +81,6 @@ static SecurityMarks addToAsset(String assetName) { * @param assetName The asset resource to clear the security marks for. */ // [START securitycenter_delete_security_marks] - // [START clear_from_asset] static SecurityMarks clearFromAsset(String assetName) { // String assetName = "organizations/123123342/assets/12312321"; try (SecurityCenterClient client = SecurityCenterClient.create()) { @@ -110,7 +107,6 @@ static SecurityMarks clearFromAsset(String assetName) { throw new RuntimeException("Couldn't create client.", e); } } - // [END clear_from_asset] // [END securitycenter_delete_security_marks] /** @@ -119,7 +115,6 @@ static SecurityMarks clearFromAsset(String assetName) { * @param assetName The asset resource path to update and remove the security marks for. */ // [START securitycenter_add_delete_security_marks] - // [START delete_and_update_marks] static SecurityMarks deleteAndUpdateMarks(String assetName) { // String assetName = "organizations/123123342/assets/12312321"; try (SecurityCenterClient client = SecurityCenterClient.create()) { @@ -149,7 +144,6 @@ static SecurityMarks deleteAndUpdateMarks(String assetName) { throw new RuntimeException("Couldn't create client.", e); } } - // [END delete_and_update_marks] // [END securitycenter_add_delete_security_marks] /** @@ -158,7 +152,6 @@ static SecurityMarks deleteAndUpdateMarks(String assetName) { * @param findingName The finding resource path to add the security mark for. */ // [START securitycenter_add_finding_security_marks] - // [START add_to_finding] static SecurityMarks addToFinding(FindingName findingName) { // FindingName findingName = FindingName.of(/*organization=*/"123234324", // /*source=*/"423432321", /*findingId=*/"samplefindingid2"); @@ -191,7 +184,6 @@ static SecurityMarks addToFinding(FindingName findingName) { throw new RuntimeException("Couldn't create client.", e); } } - // [END add_to_finding] // [END securitycenter_add_finding_security_marks] /** @@ -200,7 +192,6 @@ static SecurityMarks addToFinding(FindingName findingName) { * @param organizationName The organization to list assets for. */ // [START securitycenter_list_assets_with_security_marks] - // [START list_assets_with_filter] static ImmutableList listAssetsWithQueryMarks( OrganizationName organizationName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { @@ -226,7 +217,6 @@ static ImmutableList listAssetsWithQueryMarks( throw new RuntimeException("Couldn't create client.", e); } } - // [END list_assets_with_filter] // [END securitycenter_list_assets_with_security_marks] /** @@ -235,7 +225,6 @@ static ImmutableList listAssetsWithQueryMarks( * @param sourceName The source to list filtered findings for. */ // [START securitycenter_list_findings_with_security_marks] - // [START list_filtered_findings] static ImmutableList listFindingsWithQueryMarks(SourceName sourceName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // Start setting up a request for to list all findings filtered by a specific security mark. @@ -262,7 +251,6 @@ static ImmutableList listFindingsWithQueryMarks(SourceName s throw new RuntimeException("Couldn't create client.", e); } } - // [END list_filtered_findings] // [END securitycenter_list_findings_with_security_marks] } diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/SourceSnippets.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/SourceSnippets.java index 8321b7088a6f..06abf90c5c77 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/SourceSnippets.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/securitycenter/snippets/SourceSnippets.java @@ -42,7 +42,6 @@ private SourceSnippets() {} * @param organizationName The organization for the source. */ // [START securitycenter_create_source] - // [START create_source] static Source createSource(OrganizationName organizationName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // Start setting up a request to create a source in an organization. @@ -65,7 +64,6 @@ static Source createSource(OrganizationName organizationName) { throw new RuntimeException("Couldn't create client.", e); } } - // [END create_source] // [END securitycenter_create_source] /** @@ -74,7 +72,6 @@ static Source createSource(OrganizationName organizationName) { * @param organizationName The organization for the source. */ // [START securitycenter_list_sources] - // [START list_source] static ImmutableList listSources(OrganizationName organizationName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // Start setting up a request to list sources in an organization. @@ -96,7 +93,6 @@ static ImmutableList listSources(OrganizationName organizationName) { throw new RuntimeException("Couldn't create client.", e); } } - // [END list_source] // [END securitycenter_list_sources] /** @@ -105,7 +101,6 @@ static ImmutableList listSources(OrganizationName organizationName) { * @param sourceName The source to update. */ // [START securitycenter_update_source] - // [START update_source] static Source updateSource(SourceName sourceName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // Start setting up a request to update a source. @@ -130,7 +125,6 @@ static Source updateSource(SourceName sourceName) { throw new RuntimeException("Couldn't create client.", e); } } - // [END update_source] // [END securitycenter_update_source] /** @@ -139,7 +133,6 @@ static Source updateSource(SourceName sourceName) { * @param sourceName The source to get. */ // [START securitycenter_get_source] - // [START get_source] static Source getSource(SourceName sourceName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // Start setting up a request to get a source. @@ -157,7 +150,6 @@ static Source getSource(SourceName sourceName) { throw new RuntimeException("Couldn't create client.", e); } } - // [END get_source] // [END securitycenter_get_source] /** @@ -166,7 +158,6 @@ static Source getSource(SourceName sourceName) { * @param sourceName The source to set IAM Policy for. */ // [START securitycenter_set_source_iam] - // [START set_source_iam_policy] static Policy setIamPolicySource(SourceName sourceName, String userEmail) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // userEmail = "someuser@domain.com" @@ -194,7 +185,6 @@ static Policy setIamPolicySource(SourceName sourceName, String userEmail) { throw new RuntimeException("Couldn't create client.", e); } } - // [END set_source_iam_policy] // [END securitycenter_set_source_iam] /** @@ -203,7 +193,6 @@ static Policy setIamPolicySource(SourceName sourceName, String userEmail) { * @param sourceName The source to set IAM Policy for. */ // [START securitycenter_get_source_iam] - // [START get_source_iam_policy] static Policy getIamPolicySource(SourceName sourceName) { try (SecurityCenterClient client = SecurityCenterClient.create()) { // Start setting up a request to get IAM policy for a source. @@ -221,7 +210,6 @@ static Policy getIamPolicySource(SourceName sourceName) { throw new RuntimeException("Couldn't create client.", e); } } - // [END get_source_iam_policy] // [END securitycenter_get_source_iam] }