Created
June 3, 2022 15:31
-
-
Save Neutrollized/c34f676226a91d2f9ae13010e2c84957 to your computer and use it in GitHub Desktop.
Medium: Managing your GCP inventory with Cloud Asset API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search_reserved_ips(): | |
# create client | |
client = asset_v1.AssetServiceClient() | |
# init request | |
request = asset_v1.SearchAllResourcesRequest( | |
scope="projects/myproject-123", | |
asset_types=[ | |
"compute.googleapis.com/Address", | |
], | |
query="NOT state:in_use", | |
) | |
# make request | |
page_result = client.search_all_resources(request=request) | |
# handle response | |
for response in page_result: | |
print(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment