Listar regras de silenciamento
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Demonstra como listar todas as regras de silenciamento, para organizações, pastas ou projetos
Exemplo de código
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],[],[],[],null,["Demonstrates how to list all mute rules, for your organizations, folders, or projects\n\nCode sample \n\nGo\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import (\n \t\"context\"\n \t\"fmt\"\n \t\"io\"\n\n \tsecuritycenter \"cloud.google.com/go/securitycenter/apiv1\"\n \t\"cloud.google.com/go/securitycenter/apiv1/securitycenterpb\"\n \t\"google.golang.org/api/iterator\"\n )\n\n // listMuteRules lists mute configs at the organization level will return all the configs\n // at the org, folder, and project levels.\n // Similarly, listing configs at folder level will list all the configs\n // at the folder and project levels.\n func listMuteRules(w io.Writer, parent string) error {\n \t// Use any one of the following resource paths to list mute configurations:\n \t// - organizations/{organization_id}\n \t// - folders/{folder_id}\n \t// - projects/{project_id}\n \t// parent := fmt.Sprintf(\"projects/%s\", \"your-google-cloud-project-id\")\n \tctx := context.Background()\n \tclient, err := securitycenter.https://cloud.google.com/go/docs/reference/cloud.google.com/go/securitycenter/latest/apiv1.html#cloud_google_com_go_securitycenter_apiv1_Client_NewClient(ctx)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"securitycenter.NewClient: %w\", err)\n \t}\n \tdefer client.https://cloud.google.com/go/docs/reference/cloud.google.com/go/securitycenter/latest/apiv1.html#cloud_google_com_go_securitycenter_apiv1_Client_Close()\n\n \treq := &securitycenterpb.ListMuteConfigsRequest{Parent: parent}\n\n \t// List all mute configs present in the resource.\n \tit := client.ListMuteConfigs(ctx, req)\n \tfor {\n \t\tmuteconfig, err := it.Next()\n \t\tif err == iterator.Done {\n \t\t\tbreak\n \t\t}\n \t\tif err != nil {\n \t\t\treturn fmt.Errorf(\"it.Next: %w\", err)\n \t\t}\n \t\tfmt.Fprintf(w, \"Muteconfig Name: %s, \", muteconfig.Name)\n \t}\n \treturn nil\n }\n\nJava\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n import com.google.cloud.securitycenter.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.ListMuteConfigsRequest.html;\n import com.google.cloud.securitycenter.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.MuteConfig.html;\n import com.google.cloud.securitycenter.v1.https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.SecurityCenterClient.html;\n import java.io.IOException;\n\n public class ListMuteRules {\n\n public static void main(String[] args) {\n // TODO: Replace variables enclosed within {}\n\n // parent: Use any one of the following resource paths to list mute configurations:\n // - organizations/{organization_id}\n // - folders/{folder_id}\n // - projects/{project_id}\n String parentPath = String.format(\"projects/%s\", \"your-google-cloud-project-id\");\n listMuteRules(parentPath);\n }\n\n // Listing mute configs at the organization level will return all the configs\n // at the org, folder, and project levels.\n // Similarly, listing configs at folder level will list all the configs\n // at the folder and project levels.\n public static void listMuteRules(String parent) {\n // Initialize client that will be used to send requests. This client only needs to be created\n // once, and can be reused for multiple requests. After completing all of your requests, call\n // the \"close\" method on the client to safely clean up any remaining background resources.\n try (https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.SecurityCenterClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.SecurityCenterClient.html.create()) {\n\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.ListMuteConfigsRequest.html listMuteConfigsRequest =\n https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.ListMuteConfigsRequest.html.newBuilder().setParent(parent).build();\n\n // List all mute configs present in the resource.\n for (https://cloud.google.com/java/docs/reference/google-cloud-securitycenter/latest/com.google.cloud.securitycenter.v1.MuteConfig.html muteConfig : client.listMuteConfigs(listMuteConfigsRequest).iterateAll()) {\n System.out.println(muteConfig.getName());\n }\n } catch (IOException e) {\n System.out.println(\"Listing Mute rule failed! \\n Exception: \" + e);\n }\n }\n }\n\nPython\n\n\nTo authenticate to Security Command Center, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n def list_mute_rules(parent: str) -\u003e None:\n \"\"\"\n Listing mute configs at organization level will return all the configs\n at the org, folder and project levels.\n Similarly, listing configs at folder level will list all the configs\n at the folder and project levels.\n Args:\n parent: Use any one of the following resource paths to list mute configurations:\n - organizations/{organization_id}\n - folders/{folder_id}\n - projects/{project_id}\n \"\"\"\n from google.cloud import securitycenter\n\n client = securitycenter.SecurityCenterClient()\n\n request = securitycenter.https://cloud.google.com/python/docs/reference/securitycenter/latest/google.cloud.securitycenter_v1.types.ListMuteConfigsRequest.html()\n request.parent = parent\n\n # List all Mute Configs present in the resource.\n for mute_config in client.https://cloud.google.com/python/docs/reference/securitycenter/latest/google.cloud.securitycenter_v1.services.security_center.SecurityCenterClient.html#google_cloud_securitycenter_v1_services_security_center_SecurityCenterClient_list_mute_configs(request):\n print(mute_config.name)\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=securitycenter)."]]