{ "info": { "author": "hm-distro", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 2" ], "description": "# Resources Inventory\n\n**This is not an official Google product.**\n\n\nThis is a package that can provide inventory of resources in GCP\nIn addition to accessing projects,zones and disks it also provides a method to keep routes in sync with the GCP services netblocks.\n\nSee the method sync_gcp_service_routes(...) for more details. \nsync_gcp_service_routes(...) can be executed at any frequency.This method can be called repeatedly and will continue from where it left off, in case of error. \nSee the bottom of the page for an example\n\n\nThe package can be installed by `pip install gcpinventory'\n\n def sync_gcp_service_routes(self, project, routes_prefix, priority, network, next_hop_gateway,\n apply_changes=False,\n add_callback=_default_add_callback,\n delete_callback=_default_delete_callback ):\n Update the routes for the given project to access GCP services with Google API Access for Private IPs.\n Use this method to publish routes to Google netblocks.\n Use this when you have a default route to something more preferred (ie VPN or NAT GW).\n The method will add/delete the routes to match the cidr ranges listed under _spf.google.com\n as described at https://github.com/hm-distro/netblocks/tree/master/netblocks.\n This method can be called repeatedly and will continue from where it left off, in case of error.\n \n Args:\n project: The project id\n routes_prefix: The prefix to use for all the routes created\n priority: The priority of the route(integer)\n network: The network for this route (FQDN)\n next_hop_gateway: The next hop gateway(FQDN)\n apply_changes : Boolean whether to apply the changes or not\n add_callback: the callback function to be called with the add_routes param. The default impl just logs the list\n delete_callback: The callback function to be called with the delete_routes param.The default impl just logs the list\n \n Raises:\n InventoryServiceException: An exception occurred\n \n \n def list_zones(self, project):\n List the zones for the given project\n \n Args:\n project: The project id\n \n Yields:\n The zones for this project\n \n Raises:\n InventoryServiceException: An exception occurred\n \n # https://developers.google.com/resources/api-libraries/documentation/compute/v1/python/latest/compute_v1.zones.html#list\n\n\n\n def list_projects(self):\n List the projects that the user has access to.\n\n Yields:\n The zones for this project\n\n Raises:\n InventoryServiceException: An exception occurred\n \n # https://developers.google.com/resources/api-libraries/documentation/cloudresourcemanager/v1/python/latest/cloudresourcemanager_v1.projects.html#list\n \n \n def list_disks(self, project, zone):\n List the disks for the given project and zone.\n\n Args:\n project: The project id\n zone: The zone id\n\n Yields:\n The disks for this project\n\n Raises:\n InventoryServiceException: An exception occurred\n \n # https://developers.google.com/resources/api-libraries/documentation/compute/v1/python/latest/compute_v1.disks.html#list\n \n def list_routes(self, project):\n List the routes for the given project and zone.\n\n Args:\n project: The project id\n\n Yields:\n The routes for this project\n\n Raises:\n InventoryServiceException: An exception occurred\n \n #https://developers.google.com/resources/api-libraries/documentation/compute/v1/python/latest/compute_v1.routes.html\n \n def create_route(self, project, name, priority, network, destination_range, next_hop_gateway):\n Create the routes.\n\n Args:\n project: The project id\n name: The name of the route\n priority: The priority for the route (integer)\n network: The network for this route (FQDN)\n destination_range: The cidr that the route is applicable to\n next_hop_gateway: The next hop gateway(FQDN)\n\n Yields:\n The response of the created route object\n\n Raises:\n InventoryServiceException: An exception occurred\n \n # https://developers.google.com/resources/api-libraries/documentation/compute/v1/python/latest/compute_v1.routes.html\n \n \n def delete_route(self, project, route):\n Delete the routes.\n\n Args:\n project: The project id\n route: The route name to delete\n Raises:\n InventoryServiceException: An exception occurred\n \n # https://developers.google.com/resources/api-libraries/documentation/compute/v1/python/latest/compute_v1.routes.html \n**NOTE:** Pls also consider [Forseti's Inventory Scanner](http://forsetisecurity.org/docs/quickstarts/inventory/index.html) \n\n\n### API Usage\nExample:\n\n from gcpinventory import gcpinventory as inventory_service \n import logging\n logger = logging.getLogger()\n logging.basicConfig()\n logger.setLevel(logging.INFO)\n \n inventory_service = inventory_service.InventoryService()\n\n\n def _my_add_callback(inventory_service,add_routes):\n \"\"\"\n callback to be invoked on the routes to be added\n :param inventory_service: The handle to the inventory_service\n :param add_routes: The routes that need to be added\n :return:\n \"\"\"\n inventory_service.logger.info(\"%d cidr blocks to add to routes\" % len(add_routes))\n return\n \n # The default implementation for add_callback and delete_callback , just print the list to the logger\n \n \n project_id = \"my-project-id\"\n inventory_service.sync_gcp_service_routes(routes_prefix=\"my-prefix\",\n project=project_id,\n priority=2000,\n network=(\"projects/%s/global/networks/mynetwork\" % project_id),\n next_hop_gateway=(\"projects/%s/global/gateways/default-internet-gateway\" % project_id),\n apply_changes=True,\n add_callback=_my_add_callback\n )\n\n\n \n\n\n## Helpful links\n\n - https://cloud.google.com/compute/docs/tutorials/python-guide\n - https://github.com/google/google-api-python-client\n - https://developers.google.com/resources/api-libraries/documentation/cloudresourcemanager/v1/python/latest/cloudresourcemanager_v1.projects.html#list\n - https://developers.google.com/resources/api-libraries/documentation/compute/v1/python/latest/compute_v1.disks.html#list\n - https://developers.google.com/resources/api-libraries/documentation/compute/v1/python/latest/compute_v1.zones.html#list\n - https://developers.google.com/resources/api-libraries/documentation/compute/v1/python/latest/compute_v1.routes.html", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/GoogleCloudPlatform/professional-services/tree/hm-distro-resources/infrastructure/inventory-resources", "keywords": "", "license": "Apache 2", "maintainer": "", "maintainer_email": "", "name": "gcpinventory", "package_url": "https://pypi.org/project/gcpinventory/", "platform": "any", "project_url": "https://pypi.org/project/gcpinventory/", "project_urls": { "Homepage": "https://github.com/GoogleCloudPlatform/professional-services/tree/hm-distro-resources/infrastructure/inventory-resources" }, "release_url": "https://pypi.org/project/gcpinventory/0.0.7/", "requires_dist": null, "requires_python": "", "summary": "Service to manage GCP inventory resource", "version": "0.0.7" }, "last_serial": 4075379, "releases": { "0.0.5": [ { "comment_text": "", "digests": { "md5": "fbb49b54c29e3ff985e24a51cd5940be", "sha256": "fc20824240b608cdd70e05b0e32b19ae41655c36e13c0cb698368489b9f65c4d" }, "downloads": -1, "filename": "gcpinventory-0.0.5.tar.gz", "has_sig": false, "md5_digest": "fbb49b54c29e3ff985e24a51cd5940be", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6316, "upload_time": "2018-07-11T15:27:11", "url": "https://files.pythonhosted.org/packages/22/dd/ba517411afa37d12bf7bc73d522634d28f1722039d714cf4e46e1ed8851e/gcpinventory-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "5656a8716ec68ae8a693dc36e56ef7b0", "sha256": "ee13b41854291e1e49103e34431ad9a89606a9c812b81a7ac23f8c31a9e83f94" }, "downloads": -1, "filename": "gcpinventory-0.0.6.tar.gz", "has_sig": false, "md5_digest": "5656a8716ec68ae8a693dc36e56ef7b0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6369, "upload_time": "2018-07-17T19:10:10", "url": "https://files.pythonhosted.org/packages/7f/75/43f645858e13c2b1532a3c7f62886769ddbe70f8e07069048fe1c28a3a95/gcpinventory-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "808245c66ad55e378584a9e86f37d753", "sha256": "16c11509bc2c7ab41348357f4b89b1e14c81750da44684aaeceb6b81130076e2" }, "downloads": -1, "filename": "gcpinventory-0.0.7.tar.gz", "has_sig": false, "md5_digest": "808245c66ad55e378584a9e86f37d753", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6395, "upload_time": "2018-07-17T21:05:04", "url": "https://files.pythonhosted.org/packages/1b/dd/a698522ea261e56086305fb43aaa50df37a0746152e30cf42345eef1cb9d/gcpinventory-0.0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "808245c66ad55e378584a9e86f37d753", "sha256": "16c11509bc2c7ab41348357f4b89b1e14c81750da44684aaeceb6b81130076e2" }, "downloads": -1, "filename": "gcpinventory-0.0.7.tar.gz", "has_sig": false, "md5_digest": "808245c66ad55e378584a9e86f37d753", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6395, "upload_time": "2018-07-17T21:05:04", "url": "https://files.pythonhosted.org/packages/1b/dd/a698522ea261e56086305fb43aaa50df37a0746152e30cf42345eef1cb9d/gcpinventory-0.0.7.tar.gz" } ] }