defsearch_security_groups(service,identity_source_id,pageSize,view):# Set the label to search for all Google groupssearchQuery="&query=parent=='customers/{customer_id}'&&labels:cloudidentity.googleapis.com/groups.security" \
+"&pageSize="+pageSize+"&view="+viewtry:searchGroupsRequest=service.groups().search()searchGroupsRequest.uri+=searchQueryresponse=searchGroupsRequest.execute()print(response)exceptExceptionase:print(e)
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eThis page outlines the process of finding all security groups using the Cloud Identity Groups API.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the \u003ccode\u003egroups.search()\u003c/code\u003e method in the API with the query string \u003ccode\u003elabels:cloudidentity.googleapis.com/groups.security\u003c/code\u003e to search for security groups.\u003c/p\u003e\n"],["\u003cp\u003eWhen using methods that require the \u003ccode\u003ecustomer_id\u003c/code\u003e, ensure it is prepended with "C", like in the example 'C046psxkn'.\u003c/p\u003e\n"],["\u003cp\u003eThe Python example demonstrates a helper function that can be used to search for all security groups, specifying a customer ID and security label.\u003c/p\u003e\n"]]],[],null,["# Searching for security groups\n=============================\n\nThis page explains how to find all of your security groups with the\nCloud Identity Groups API.\n**Note:** When a method requires the `customer_id`, you must prepend a \"C\" to the ID that you can view in the Google Admin console (for example, 'C046psxkn'). \n\n### REST\n\nTo search for all security groups, call\n[`groups.search()`](/identity/docs/reference/rest/v1/groups/search)\nwith a query string of `labels:cloudidentity.googleapis.com/groups.security`.\n\n### Python\n\nThe following example shows a helper function to search for security groups\nusing the Python client library: \n\n def search_security_groups(service, identity_source_id, pageSize, view):\n # Set the label to search for all Google groups\n searchQuery = \"&query=parent=='customers/{customer_id}'&&labels:cloudidentity.googleapis.com/groups.security\" \\\n + \"&pageSize=\" + pageSize + \"&view=\" + view\n try:\n searchGroupsRequest = service.groups().search()\n searchGroupsRequest.uri += searchQuery\n response = searchGroupsRequest.execute()\n print(response)\n except Exception as e:\n print(e)"]]