Back to snippets
google_cloud_org_policy_list_policies_quickstart.py
pythonLists the organization policies that are applied to a specified
Agent Votes
1
0
100% positive
google_cloud_org_policy_list_policies_quickstart.py
1# Copyright 2022 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15# [START orgpolicy_v2_generated_OrgPolicy_ListPolicies_sync]
16# This snippet has been automatically generated and should be regarded as a
17# code template only.
18# It will require modifications to work:
19# - It may require correct/in-range values for request initialization.
20# - It may require specifying regional endpoints when creating the service
21# client as shown in:
22# https://googleapis.dev/python/google-api-core/latest/client_options.html
23from google.cloud import orgpolicy_v2
24
25
26def sample_list_policies():
27 # Create a client
28 client = orgpolicy_v2.OrgPolicyClient()
29
30 # Initialize request argument(s)
31 # Resource name should be in the format `projects/{project_id}`,
32 # `folders/{folder_id}`, or `organizations/{organization_id}`
33 request = orgpolicy_v2.ListPoliciesRequest(
34 parent="projects/your-project-id",
35 )
36
37 # Make the request
38 page_result = client.list_policies(request=request)
39
40 # Handle the response
41 for response in page_result:
42 print(response)
43
44# [END orgpolicy_v2_generated_OrgPolicy_ListPolicies_sync]