|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +# Copyright 2022 Google LLC. All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | + |
| 18 | +import argparse |
| 19 | + |
| 20 | + |
| 21 | +def batch_get_effective_iam_policies(resource_names, scope): |
| 22 | + # [START asset_quickstart_batch_get_effective_iam_policies] |
| 23 | + from google.cloud import asset_v1 |
| 24 | + |
| 25 | + # TODO scope = 'Scope for resource names' |
| 26 | + # TODO resource_names = 'List of resource names' |
| 27 | + |
| 28 | + client = asset_v1.AssetServiceClient() |
| 29 | + |
| 30 | + response = client.batch_get_effective_iam_policies( |
| 31 | + request={"scope": scope, "names": resource_names} |
| 32 | + ) |
| 33 | + print(response) |
| 34 | + # [END asset_quickstart_batch_get_effective_iam_policies] |
| 35 | + |
| 36 | + |
| 37 | +if __name__ == "__main__": |
| 38 | + parser = argparse.ArgumentParser( |
| 39 | + description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter |
| 40 | + ) |
| 41 | + parser.add_argument("resource_names", help="Your specified accessible " |
| 42 | + "scope, such as a project, " |
| 43 | + "folder or organization") |
| 44 | + parser.add_argument("scope", help="Your specified list of resource names") |
| 45 | + |
| 46 | + args = parser.parse_args() |
| 47 | + |
| 48 | + batch_get_effective_iam_policies(args.resource_names, args.scope) |
0 commit comments