Get the Cloud Provider netblocks (Python3 version)
This is not an official Google product.
The netblocks api module itself can be used outside App Engine.
Install the package with
pip install netblocks or
pip install git+https://github.com/hm-distro/netblocks/
Downstream systems can hook into the Object notification on the GCS bucket and accordingly do something with the file, with the updated CIDR ranges. The schedule of this refresh can be managed in the cron.yaml and the bucket and file where the CIDR ranges should be written to can be changed in the config.py
Potential listeners could be Cloud Functions.
import netblocks cidr_blocks = set() netblocks_api = netblocks.NetBlocks() try: cidr_blocks = netblocks_api.fetch() """ The cidr_blocks set contains strings like the below ip4:188.8.131.52/23 ... ip6:2600:1900::/35 """ except netblocks.NetBlockRetrievalException as err: #exception handling pass
The GAE App
This class creates a file in the GCS bucket as specified in config.py.
The files contains entries such as the below:
Make sure to create a bucket prior to deploying the app
This bucket-name should be changed in the config.py under GCS_BUCKET
gcloud app deploy app.yaml
gcloud app deploy cron.yaml
Run these steps before deploying the app
pip install -t ./lib/ google-api-python-client
pip install -t ./lib/ GoogleAppEngineCloudStorageClient
pip install -t ./lib/ requests
pip install -t ./lib/ oauth2client
pip install -t ./lib/ requests-toolbelt
Apache 2.0; see LICENSE for details.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size netblocks3-0.0.13-py3-none-any.whl (14.0 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size netblocks3-0.0.13.tar.gz (9.0 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for netblocks3-0.0.13-py3-none-any.whl