{"id":20074279,"url":"https://github.com/juniper/healthbot-py-client","last_synced_at":"2025-07-14T03:42:54.891Z","repository":{"id":39825715,"uuid":"210760509","full_name":"Juniper/healthbot-py-client","owner":"Juniper","description":"Python library that provides REST interface to the HealthBot server","archived":false,"fork":false,"pushed_at":"2022-05-25T05:48:55.000Z","size":17414,"stargazers_count":8,"open_issues_count":4,"forks_count":5,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-06-18T00:41:19.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hbez.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Juniper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-25T05:12:35.000Z","updated_at":"2022-02-07T19:24:29.000Z","dependencies_parsed_at":"2022-09-19T05:50:55.858Z","dependency_job_id":null,"html_url":"https://github.com/Juniper/healthbot-py-client","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Juniper/healthbot-py-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Juniper%2Fhealthbot-py-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Juniper%2Fhealthbot-py-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Juniper%2Fhealthbot-py-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Juniper%2Fhealthbot-py-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Juniper","download_url":"https://codeload.github.com/Juniper/healthbot-py-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Juniper%2Fhealthbot-py-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265237795,"owners_count":23732520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T14:50:13.641Z","updated_at":"2025-07-14T03:42:54.831Z","avatar_url":"https://github.com/Juniper.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Documentation Status](https://readthedocs.org/projects/hbez/badge/?version=latest)](http://hbez.readthedocs.io)\n[![UnitTest Status](https://travis-ci.org/Juniper/healthbot-py-client.svg?branch=master)](https://travis-ci.org/Juniper/healthbot-py-client)\n\n# HealthBot Python Client\n\nThis repo contains a Python package to control HealthBot\n\nThe purpose of this package is to provide a Python library that \nautomates the provisioning of the HealthBot server.\n\nRequires: Python \u003e=3.6\n\n# Examples\n\n\n\n\n# Import HbEZ library\n\n\n```python\nfrom jnpr.healthbot import HealthBotClient\nfrom pprint import pprint\n```\n\n## Opening connection\n\n```python\nhb = HealthBotClient('xx.xx.xx.xxx', 'xxxxx', 'xxxxx', port=nnnn)\nhb.open()\n```\n\n### using Python `with`context manager\n* Takes care of login and logout with access tokens\n\n```python\nwith HealthBotClient('xx.xx.xx.xxx', 'xxxxx', 'xxxxx', port=nnnn) as hb:\n    pprint(hb.device.get_ids())\n```\n\n# Use Case: Device\n\n\n```python\npprint(hb.device.get_ids())\n```\n\n    ['edge', 'srx', 'qfx', 'mx-edge', 'core', 'node', 'demo']\n\n\n### Getting help for any given function\n\n\n```python\nhelp(hb.device.get_ids)\n```\n\n    Help on method get_ids in module jnpr.healthbot.modules.devices:\n    \n    get_ids() method of jnpr.healthbot.modules.devices.Device instance\n        Return Device IDs for all the devices in HealthBot system\n        \n        :return: list of device IDs\n        \n        Example:\n        ::\n        \n            from jnpr.healthbot import HealthBotClient\n            hb = HealthBotClient('xx.xxx.x.xx', 'xxxx', 'xxxx', port=nnnn)\n            print(hb.device.get_ids())\n    \n\n\n### Get config related to given device-id\n\n\n```python\n# Get config related to given device-id\nobj = hb.device.get('demo')\n```\n\n\n```python\nobj.host\n```\n\n\n\n\n    'xx.xxx.x.xx'\n\n\n\n\n```python\npprint(obj)\n```\n\n    {'authentication': {'password': {'password': 'xxx',\n                                     'username': 'xxxx'}},\n     'description': None,\n     'device_id': 'demo',\n     'host': 'xx.xxx.x.xx',\n     'i_agent': None,\n     'open_config': None,\n     'snmp': None,\n     'system_id': 'test:HbEZ',\n     'variable': None,\n     'vendor': None}\n\n\n### get facts for the given device id\n\n\n```python\n# Get device facts of a given device id\npprint(hb.device.get_facts('demo'))\n```\n\n    {'device-id': 'demo',\n     'facts': {'fpc': [],\n               'hostname': 'R1_re0',\n               'junos-info': [{'last-reboot-reason': 'Router rebooted after a '\n                                                     'normal shutdown.',\n                               'mastership-state': 'master',\n                               'model': 'RE-VMX',\n                               'name': 're0',\n                               'status': 'OK',\n                               'up-time': '98 days, 3 minutes, 49 seconds',\n                               'version-info': {'build': '0',\n                                                'major': [19, 3],\n                                                'minor': ['20190421_dev_common'],\n                                                'type': 'I'}}],\n               'platform': 'MX960',\n               'platform-info': [{'name': 're0', 'platform': 'MX960'}],\n               'product': 'MX',\n               'release': '19.3-20190421_dev_common.0.84473',\n               'serial-number': 'xxxx'}}\n\n\n### Add a new device\n\n\n```python\nfrom jnpr.healthbot import DeviceSchema\n\nds = DeviceSchema(device_id='demo', host='xx.xxx.x.xx',\n                  authentication={\"password\": {\"password\": \"xxxx\", \"username\": \"xxxx\"}})\nprint(hb.device.add(schema=ds))\n```\n\n    True\n\n\n\n```python\nhelp(DeviceSchema)\n```\n\n    Help on class DeviceSchema in module jnpr.healthbot.swagger.models.device_schema:\n    \n    class DeviceSchema(builtins.object)\n     |  NOTE: This class is auto generated by the swagger code generator program.\n     |  \n     |  Do not edit the class manually.\n     |  \n     |  Methods defined here:\n     |  \n     |  __eq__(self, other)\n     |      Returns true if both objects are equal\n     |  \n     |  __init__(self, authentication=None, description=None, device_id=None, host=None, i_agent=None, open_config=None, snmp=None, system_id=None, variable=None, vendor=None)\n     |      DeviceSchema - a model defined in Swagger\n     |  \n     |  __ne__(self, other)\n     |      Returns true if both objects are not equal\n     |  \n     |  __repr__(self)\n     |      For `print` and `pprint`\n     |  \n     |  to_dict(self)\n     |      Returns the model properties as a dict\n     |  \n     |  to_str(self)\n     |      Returns the string representation of the model\n     |  \n     |  ----------------------------------------------------------------------\n     |  Data descriptors defined here:\n     |  \n     |  __dict__\n     |      dictionary for instance variables (if defined)\n     |  \n     |  __weakref__\n     |      list of weak references to the object (if defined)\n     |  \n     |  authentication\n     |      Gets the authentication of this DeviceSchema.  # noqa: E501\n     |      \n     |      \n     |      :return: The authentication of this DeviceSchema.  # noqa: E501\n     |      :rtype: DeviceSchemaAuthentication\n     |  \n     |  description\n     |      Gets the description of this DeviceSchema.  # noqa: E501\n     |      \n     |      Description about the device  # noqa: E501\n     |      \n     |      :return: The description of this DeviceSchema.  # noqa: E501\n     |      :rtype: str\n     |  \n     |  device_id\n     |      Gets the device_id of this DeviceSchema.  # noqa: E501\n     |      \n     |      Identifier for the device. Should be of pattern [a-zA-Z][a-zA-Z0-9_-]*  # noqa: E501\n     |      \n     |      :return: The device_id of this DeviceSchema.  # noqa: E501\n     |      :rtype: str\n     |  \n     |  host\n     |      Gets the host of this DeviceSchema.  # noqa: E501\n     |      \n     |      Name or IP the device  # noqa: E501\n     |      \n     |      :return: The host of this DeviceSchema.  # noqa: E501\n     |      :rtype: str\n     |  \n     |  i_agent\n     |      Gets the i_agent of this DeviceSchema.  # noqa: E501\n     |      \n     |      \n     |      :return: The i_agent of this DeviceSchema.  # noqa: E501\n     |      :rtype: DeviceSchemaIAgent\n     |  \n     |  open_config\n     |      Gets the open_config of this DeviceSchema.  # noqa: E501\n     |      \n     |      \n     |      :return: The open_config of this DeviceSchema.  # noqa: E501\n     |      :rtype: DeviceSchemaOpenconfig\n     |  \n     |  snmp\n     |      Gets the snmp of this DeviceSchema.  # noqa: E501\n     |      \n     |      \n     |      :return: The snmp of this DeviceSchema.  # noqa: E501\n     |      :rtype: DeviceSchemaSnmp\n     |  \n     |  system_id\n     |      Gets the system_id of this DeviceSchema.  # noqa: E501\n     |      \n     |      ID which is sent in the JTI UDP messages  # noqa: E501\n     |      \n     |      :return: The system_id of this DeviceSchema.  # noqa: E501\n     |      :rtype: str\n     |  \n     |  variable\n     |      Gets the variable of this DeviceSchema.  # noqa: E501\n     |      \n     |      Playbook variable configuration  # noqa: E501\n     |      \n     |      :return: The variable of this DeviceSchema.  # noqa: E501\n     |      :rtype: list[DeviceSchemaVariable]\n     |  \n     |  vendor\n     |      Gets the vendor of this DeviceSchema.  # noqa: E501\n     |      \n     |      \n     |      :return: The vendor of this DeviceSchema.  # noqa: E501\n     |      :rtype: DeviceSchemaVendor\n     |  \n     |  ----------------------------------------------------------------------\n     |  Data and other attributes defined here:\n     |  \n     |  __hash__ = None\n     |  \n     |  attribute_map = {'authentication': 'authentication', 'description': 'd...\n     |  \n     |  swagger_types = {'authentication': 'DeviceSchemaAuthentication', 'desc...\n    \n\n\n\n```python\ndev = hb.device.get('demo')\npprint(dev)\n```\n\n    {'authentication': {'password': {'password': 'xxxx',\n                                     'username': 'xxxx'}},\n     'description': None,\n     'device_id': 'demo',\n     'host': 'xx.xxx.x.xx',\n     'i_agent': None,\n     'open_config': None,\n     'snmp': None,\n     'system_id': None,\n     'variable': None,\n     'vendor': None}\n\n\n### By default, get() returns uncommited data (from candidate DB)\n\n\n```python\npprint(hb.device.get('demo', uncommitted=False))\n```\n\n    {\n      \"detail\": \"Device id demo not found\",\n      \"status\": 404\n    }\n    \n\n\n\n    ---------------------------------------------------------------------------\n\n    HTTPError                                 Traceback (most recent call last)\n\n    \u003cipython-input-25-13c8b67cdb5c\u003e in \u003cmodule\u003e\n    ----\u003e 1 pprint(hb.device.get('demo', uncommitted=False))\n    \n\n    ~/Coding/git.juniper.net.iceberg/healthbot-py-client/lib/jnpr/healthbot/modules/devices.py in get(self, device_id, uncommitted)\n        217             if response.status_code != 200:\n        218                 logger.error(response.text)\n    --\u003e 219             response.raise_for_status()\n        220             return self.hbot._create_schema(response, DeviceSchema)\n        221         else:\n\n\n    /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/models.py in raise_for_status(self)\n        933 \n        934         if http_error_msg:\n    --\u003e 935             raise HTTPError(http_error_msg, response=self)\n        936 \n        937     def close(self):\n\n\n    HTTPError: 404 Client Error: NOT FOUND for url: https://10.209.7.33:8080/api/v1/device/demo\n\n\n### Why we choose to go with Schema. We can easily access and edit any attribute. \n\n\n```python\n# Existing system_id\nprint (dev.system_id)\n```\n\n    None\n\n\n\n```python\n# Editing system_id\ndev.system_id = \"Demo:HbEZ\"\n```\n\n\n```python\nprint(hb.device.update(dev))\n```\n\n    True\n\n\n### HealthBot API provide commit and rollback config\n\n\n```python\nhb.commit()\n```\n\n\n\n\n    True\n\n\n\n\n```python\ndev = hb.device.get('demo')\npprint(dev)\n```\n\n    {'authentication': {'password': {'password': 'xxxx',\n                                     'username': 'xxxx'}},\n     'description': None,\n     'device_id': 'demo',\n     'host': 'xx.xxx.x.xx',\n     'i_agent': None,\n     'open_config': None,\n     'snmp': None,\n     'system_id': 'Demo:HbEZ',\n     'variable': None,\n     'vendor': None}\n\n\n\n```python\nprint(dev.system_id)\n```\n\n    Demo:HbEZ\n\n\n\n```python\n# To delete a device\nhb.device.delete('demo')\n\n# if a device is part of device group, to make sure we delete it first from device group\nhb.device.delete('demo', force=True)\n```\n\n# Use Case: Devices\n\n### Get details of all devices in System\n\n\n```python\n# Get config details of all the device\nobj = hb.device.get()\n```\n\n\n```python\nobj\n```\n\n\n\n\n    [{'authentication': {'password': {'password': 'xxxx',\n                                      'username': 'xxxx'}},\n      'description': None,\n      'device_id': 'xxxx',\n      'host': 'xx.xxx.x.xx',\n      'i_agent': None,\n      'open_config': {'port': 32767},\n      'snmp': None,\n      'system_id': None,\n      'variable': [],\n      'vendor': {'juniper': {'operating-system': 'junos'}}},\n     {'authentication': {'password': {'password': 'xxxx',\n                                      'username': 'xxxx'}},\n      'description': None,\n      'device_id': 'xxx',\n      'host': 'xx.xxx.x.xx9',\n      'i_agent': {'port': 830},\n      'open_config': {'port': 32767},\n      'snmp': None,\n      'system_id': None,\n      'variable': [],\n      'vendor': {'juniper': {'operating-system': 'junos'}}},\n     {'authentication': {'password': {'password': 'xxxx',\n                                      'username': 'xxxx'}},\n      'description': None,\n      'device_id': 'xxx',\n      'host': 'xx.xxx.x.xx',\n      'i_agent': {'port': 830},\n      'open_config': {'port': 32767},\n      'snmp': None,\n      'system_id': 'changed description',\n      'variable': [],\n      'vendor': {'juniper': {'operating-system': 'junos'}}},\n     {'authentication': {'password': {'password': 'xxxx',\n                                      'username': 'xxxx'}},\n      'description': None,\n      'device_id': 'demo',\n      'host': 'xx.xxx.x.xx',\n      'i_agent': None,\n      'open_config': None,\n      'snmp': None,\n      'system_id': 'Demo:HbEZ',\n      'variable': None,\n      'vendor': None},\n     {'authentication': {'password': {'password': 'xxxx',\n                                      'username': 'xxxx'}},\n      'description': None,\n      'device_id': 'vmx_db',\n      'host': 'xx.xxx.x.xx',\n      'i_agent': {'port': 830},\n      'open_config': {'port': 32767},\n      'snmp': None,\n      'system_id': None,\n      'variable': [],\n      'vendor': {'juniper': {'operating-system': 'junos'}}},\n     {'authentication': {'password': {'password': 'xxxx',\n                                      'username': 'xxxx'}},\n      'description': None,\n      'device_id': 'core_db',\n      'host': 'xx.xxx.x.xx',\n      'i_agent': {'port': 830},\n      'open_config': {'port': 32767},\n      'snmp': None,\n      'system_id': None,\n      'variable': [],\n      'vendor': {'juniper': {'operating-system': 'junos'}}},\n     {'authentication': {'password': {'password': 'xxxx',\n                                      'username': 'xxxx'}},\n      'description': None,\n      'device_id': 'node1',\n      'host': 'node1',\n      'i_agent': None,\n      'open_config': {'port': 32767},\n      'snmp': None,\n      'system_id': None,\n      'variable': None,\n      'vendor': {'juniper': {'operating-system': 'junos'}}}]\n\n\n\n### Get device facts for all the devices in HB\n\n\n```python\npprint(hb.device.get_facts())\n```\n\n    [{'device-id': 'edge', 'facts': {}},\n     {'device-id': 'EVO',\n      'facts': {'fpc': [{'description': 'FPC-JNP10003-LOGICAL',\n                         'model-number': None,\n                         'name': 'FPC 1',\n                         'part-number': 'BUILTIN',\n                         'serial-number': 'BUILTIN',\n                         'version': None}],\n                'hostname': None,\n                'junos-info': [{'last-reboot-reason': 'Unknown',\n                                'mastership-state': 'Master',\n                                'model': 'Control Board',\n                                'name': 're0',\n                                'status': 'OK',\n                                'up-time': '0 second',\n                                'version-info': {'build': None,\n                                                 'major': [19, 4],\n                                                 'minor': ['20190731122440-EVO_soumikd'],\n                                                 'type': 'I'}}],\n                'platform': 'PTX10003-160C',\n                'platform-info': [{'name': 're0', 'platform': 'PTX10003-160C'}],\n                'product': 'PTX',\n                'release': '19.4I20190731122440-EVO_soumikd',\n                'serial-number': 'xxxx'}},\n     {'device-id': 'vmx',\n      'facts': {'fpc': [],\n                'hostname': 'R1_re0',\n                'junos-info': [{'last-reboot-reason': 'Router rebooted after a '\n                                                      'normal shutdown.',\n                                'mastership-state': 'master',\n                                'model': 'RE-VMX',\n                                'name': 're0',\n                                'status': 'OK',\n                                'up-time': '80 days, 1 hour, 20 minutes, 9 seconds',\n                                'version-info': {'build': '0',\n                                                 'major': [19, 3],\n                                                 'minor': ['20190421_dev_common'],\n                                                 'type': 'I'}}],\n                'platform': 'MX960',\n                'platform-info': [{'name': 're0', 'platform': 'MX960'}],\n                'product': 'MX',\n                'release': '19.3-20190421_dev_common.0.84473',\n                'serial-number': 'xxxx'}},\n     {'device-id': 'demo',\n      'facts': {'fpc': [],\n                'hostname': 'R1_re0',\n                'junos-info': [{'last-reboot-reason': 'Router rebooted after a '\n                                                      'normal shutdown.',\n                                'mastership-state': 'master',\n                                'model': 'RE-VMX',\n                                'name': 're0',\n                                'status': 'OK',\n                                'up-time': '98 days, 38 minutes, 25 seconds',\n                                'version-info': {'build': '0',\n                                                 'major': [19, 3],\n                                                 'minor': ['20190421_dev_common'],\n                                                 'type': 'I'}}],\n                'platform': 'MX960',\n                'platform-info': [{'name': 're0', 'platform': 'MX960'}],\n                'product': 'MX',\n                'release': '19.3-20190421_dev_common.0.84473',\n                'serial-number': 'xxxx'}},\n     {'device-id': 'vmx_db',\n      'facts': {'hostname': 'riad001-g',\n                'junos-info': [],\n                'platform': 'MX480',\n                'platform-info': [{'name': 're0', 'platform': 'MX480'}],\n                'product': None,\n                'release': '19.4I20190809_0730_madhus',\n                'serial-number': None}},\n     {'device-id': 'core_db',\n      'facts': {'fpc': [{'description': 'MPC Type 2 3D',\n                         'model-number': 'MX-MPC2-3D',\n                         'name': 'FPC 1',\n                         'part-number': '750-031089',\n                         'serial-number': 'xxxx',\n                         'version': 'REV 31'}],\n                'hostname': 'choc-mx480-b',\n                'junos-info': [{'last-reboot-reason': 'Router rebooted after a '\n                                                      'normal shutdown.',\n                                'mastership-state': 'master',\n                                'model': 'RE-S-2000',\n                                'name': 're0',\n                                'status': 'OK',\n                                'up-time': '5 hours, 27 minutes, 15 seconds',\n                                'version-info': {'build': None,\n                                                 'major': [19, 4],\n                                                 'minor': ['20190809_0730_madhus'],\n                                                 'type': 'I'}},\n                               {'last-reboot-reason': '0x1:power cycle/failure',\n                                'mastership-state': 'backup',\n                                'model': 'RE-S-2000',\n                                'name': 're1',\n                                'status': 'OK',\n                                'up-time': '14 days, 22 hours, 34 minutes, 13 '\n                                           'seconds',\n                                'version-info': {'build': 7,\n                                                 'major': [15, 1],\n                                                 'minor': ['6'],\n                                                 'type': 'R'}}],\n                'platform': 'MX480',\n                'platform-info': [{'name': 're0', 'platform': 'MX480'},\n                                  {'name': 're1', 'platform': 'MX480'}],\n                'product': 'MX',\n                'release': '19.4I20190809_0730_madhus',\n                'serial-number': 'xxxx'}},\n     {'device-id': 'node1', 'facts': {}}]\n\n\n### Add device group using DevicegroupSchema and APIs provided\n\n\n```python\nfrom jnpr.healthbot import DeviceGroupSchema\n```\n\n\n```python\ndgs = DeviceGroupSchema(device_group_name=\"edge\", devices=['demo'])\n```\n\n### We can also set any param/attribute after creating schema object\n\n\n```python\ndgs.description=\"All devices on the edge\"\n```\n\n### Now add device group using provided API\n\n\n```python\nprint(hb.device_group.add(dgs))\n```\n\n    True\n\n\n### Let see whats the plus point of using Schema\n\n     1\u003e Helps with any missing paramters\n     2\u003e Checks for any rule associated with given params\n\n\n```python\n# Error for missing mandatory parameters\n\ndgs = DeviceGroupSchema()\n```\n\n\n    ---------------------------------------------------------------------------\n\n    ValueError                                Traceback (most recent call last)\n\n    \u003cipython-input-39-4d61d231fd38\u003e in \u003cmodule\u003e\n          1 # Error for missing mandatory parameters\n          2 \n    ----\u003e 3 dgs = DeviceGroupSchema()\n    \n\n    ~/Coding/git.juniper.net.iceberg/healthbot-py-client/lib/jnpr/healthbot/swagger/models/device_group_schema.py in __init__(self, authentication, description, device_group_name, devices, logging, native_gpb, notification, playbooks, reports, retention_policy, variable)\n         85         if description is not None:\n         86             self.description = description\n    ---\u003e 87         self.device_group_name = device_group_name\n         88         if devices is not None:\n         89             self.devices = devices\n\n\n    ~/Coding/git.juniper.net.iceberg/healthbot-py-client/lib/jnpr/healthbot/swagger/models/device_group_schema.py in device_group_name(self, device_group_name)\n        168         \"\"\"\n        169         if device_group_name is None:\n    --\u003e 170             raise ValueError(\"Invalid value for `device_group_name`, must not be `None`\")  # noqa: E501\n        171         if device_group_name is not None and len(device_group_name) \u003e 64:\n        172             raise ValueError(\"Invalid value for `device_group_name`, length must be less than or equal to `64`\")  # noqa: E501\n\n\n    ValueError: Invalid value for `device_group_name`, must not be `None`\n\n\n\n```python\n# Error for not following rule for give parameter\n\ndgs = DeviceGroupSchema(device_group_name=\"edge group\")\n```\n\n\n    ---------------------------------------------------------------------------\n\n    ValueError                                Traceback (most recent call last)\n\n    \u003cipython-input-40-8617b5d8e365\u003e in \u003cmodule\u003e\n          1 # Error for not following rule for give parameter\n          2 \n    ----\u003e 3 dgs = DeviceGroupSchema(device_group_name=\"edge group\")\n    \n\n    ~/Coding/git.juniper.net.iceberg/healthbot-py-client/lib/jnpr/healthbot/swagger/models/device_group_schema.py in __init__(self, authentication, description, device_group_name, devices, logging, native_gpb, notification, playbooks, reports, retention_policy, variable)\n         85         if description is not None:\n         86             self.description = description\n    ---\u003e 87         self.device_group_name = device_group_name\n         88         if devices is not None:\n         89             self.devices = devices\n\n\n    ~/Coding/git.juniper.net.iceberg/healthbot-py-client/lib/jnpr/healthbot/swagger/models/device_group_schema.py in device_group_name(self, device_group_name)\n        172             raise ValueError(\"Invalid value for `device_group_name`, length must be less than or equal to `64`\")  # noqa: E501\n        173         if device_group_name is not None and not re.search('^[a-zA-Z][a-zA-Z0-9_-]*$', device_group_name):  # noqa: E501\n    --\u003e 174             raise ValueError(\"Invalid value for `device_group_name`, must be a follow pattern or equal to `/^[a-zA-Z][a-zA-Z0-9_-]*$/`\")  # noqa: E501\n        175 \n        176         self._device_group_name = device_group_name\n\n\n    ValueError: Invalid value for `device_group_name`, must be a follow pattern or equal to `/^[a-zA-Z][a-zA-Z0-9_-]*$/`\n\n\n\n```python\n# Now we are in compliance with rules\n\ndgs = DeviceGroupSchema(device_group_name=\"edge\")\n```\n\n\n```python\ndgs.devices = ['demo']\n```\n\n### We can also pass all Schema params to add_ APIs, internally it will use these params to create Schema\n\n\n```python\nprint(hb.device_group.add(device_group_name=\"edge\", description=\"All devices on the edge\", devices=['demo']))\nhb.commit()\n```\n\n    True\n\n\n\n\n\n    True\n\n\n\n\n```python\n# Get details for a given device group\nhb.device_group.get('real')\n```\n\n\n\n\n    {'authentication': None,\n     'description': None,\n     'device_group_name': 'real',\n     'devices': ['edge'],\n     'logging': None,\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': ['phyport'],\n     'reports': [],\n     'retention_policy': None,\n     'variable': [{'@': {'changed-seconds': 1563348601},\n                   'instance-id': 'ge-1-0-0',\n                   'playbook': 'phyport',\n                   'rule': 'external/interface-info',\n                   'variable-value': [{'name': 'interface_name',\n                                       'value': 'ge-1/0/0'}]},\n                  {'@': {'changed-seconds': 1563348601},\n                   'instance-id': 'ge-1-0-1',\n                   'playbook': 'phyport',\n                   'rule': 'external/interface-info',\n                   'variable-value': [{'name': 'interface_name',\n                                       'value': 'ge-1/0/1'}]}]}\n\n\n\n\n```python\nhb.device_group.delete('edge', force=True)\n```\n\n    \n\n\n\n\n\n    True\n\n\n\n### Add an existing device to existing group\n\n\n```python\nhb.device_group.add_device_in_group('vmx', 'edge')\n```\n\n\n\n\n    True\n\n\n\n\n```python\nobj = hb.device_group.get('edge')\nprint (obj)\n```\n\n    {'authentication': None,\n     'description': 'All devices on the edge',\n     'device_group_name': 'edge',\n     'devices': ['vmx', 'demo'],\n     'logging': {'log-level': 'warn'},\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'retention_policy': None,\n     'variable': [{'@': {'changed-seconds': 1565668543},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'forwarding-table-summary',\n                   'rule': 'protocol.routesummary/check-fib-summary'},\n                  {'@': {'changed-seconds': 1565669467},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'icmp-probe',\n                   'rule': 'protocol.icmp/check-icmp-statistics'}]}\n\n\n\n```python\nobj.devices\n```\n\n\n\n\n    ['vmx', 'demo']\n\n\n\n### Get details of all the device groups\n\n\n```python\nprint(hb.device_group.get())\n```\n\n    [{'authentication': None,\n     'description': None,\n     'device_group_name': 'real',\n     'devices': ['edge'],\n     'logging': None,\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': ['phyport'],\n     'reports': [],\n     'retention_policy': None,\n     'variable': [{'@': {'changed-seconds': 1563348601},\n                   'instance-id': 'ge-1-0-0',\n                   'playbook': 'phyport',\n                   'rule': 'external/interface-info',\n                   'variable-value': [{'name': 'interface_name',\n                                       'value': 'ge-1/0/0'}]},\n                  {'@': {'changed-seconds': 1563348601},\n                   'instance-id': 'ge-1-0-1',\n                   'playbook': 'phyport',\n                   'rule': 'external/interface-info',\n                   'variable-value': [{'name': 'interface_name',\n                                       'value': 'ge-1/0/1'}]}]}, {'authentication': None,\n     'description': 'UBS Demo',\n     'device_group_name': 'QFabric',\n     'devices': ['node1'],\n     'logging': None,\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'retention_policy': None,\n     'variable': []}, {'authentication': {'password': {'password': 'xxxx',\n                                     'username': 'xxxx'}},\n     'description': None,\n     'device_group_name': 'EVO_CORE',\n     'devices': ['EVO'],\n     'logging': None,\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'retention_policy': None,\n     'variable': []}, {'authentication': {'password': {'password': 'xxxx',\n                                     'username': 'xxxx'}},\n     'description': None,\n     'device_group_name': 'vmx_db',\n     'devices': ['core_db'],\n     'logging': {'log-level': 'critical'},\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'retention_policy': None,\n     'variable': []}, {'authentication': None,\n     'description': 'All devices on the edge',\n     'device_group_name': 'edge',\n     'devices': ['vmx', 'demo'],\n     'logging': {'log-level': 'warn'},\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'retention_policy': None,\n     'variable': [{'@': {'changed-seconds': 1565668543},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'forwarding-table-summary',\n                   'rule': 'protocol.routesummary/check-fib-summary'},\n                  {'@': {'changed-seconds': 1565669467},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'icmp-probe',\n                   'rule': 'protocol.icmp/check-icmp-statistics'}]}, {'authentication': None,\n     'description': 'learning',\n     'device_group_name': 'Core',\n     'devices': ['vmx'],\n     'logging': None,\n     'native_gpb': {'ports': [22000]},\n     'notification': {},\n     'playbooks': ['icmp-probe', 'rca-ospf-playbook'],\n     'reports': [],\n     'retention_policy': None,\n     'variable': [{'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'interface.statistics/check-host-loopback-status',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.fpc/check-fpc-memory',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.ospf/check-ddos-statistics',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-center-chip-host-path',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-cm-error-table',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-fpc-cpu-scheduler-info',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-fpc-threads',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-fpc-utilization-information',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-ithrottle',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-ithrottle-statistics',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-jnh-exceptions',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-jnh-interface-statistics',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-linecard-ethernet-statistics',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-pci-error-counters',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-pfe-traffic-statistics',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-pre-classifier-dropped-packets',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'linecard.statistics/check-traffic-offload-engine-status',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'protocol.infra/check-task-io-drops',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'protocol.infra/check-task-memory-usage',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'protocol.ospf/check-ospf-forwarding-table',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'protocol.ospf/check-ospf-io-statistics-information',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'protocol.ospf/check-ospf-neighbor-information',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'protocol.ospf/check-ospf-statistics-information',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'protocol.ospf/fpc-link-stats',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'protocol.ospf/pfe-ddos-policer',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'system.statistics/check-routing-engine-cpu-utilization',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'system.statistics/check-system-input-queues',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'system.statistics/check-system-output-queues',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'system.statistics/check-system-statistics-ip',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'system.statistics/check-system-storage-capacity',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'system.statistics/check-system-virtual-memory-information',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1564722219},\n                   'instance-id': 'test1',\n                   'playbook': 'rca-ospf-playbook',\n                   'rule': 'system.statistics/check-version',\n                   'variable-value': []},\n                  {'@': {'changed-seconds': 1565263889},\n                   'instance-id': 'set1',\n                   'playbook': 'icmp-probe',\n                   'rule': 'protocol.icmp/check-icmp-statistics',\n                   'variable-value': [{'name': 'host-var', 'value': '10.221.11.11'},\n                                      {'name': 'count-var', 'value': '2'}]}]}]\n\n\n### We can also update any given device group\n\n\n```python\nprint(hb.device_group.get('edge'))\n```\n\n    {'authentication': None,\n     'description': 'All devices on the edge',\n     'device_group_name': 'edge',\n     'devices': ['vmx', 'demo'],\n     'logging': {'log-level': 'warn'},\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'retention_policy': None,\n     'variable': [{'@': {'changed-seconds': 1565668543},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'forwarding-table-summary',\n                   'rule': 'protocol.routesummary/check-fib-summary'},\n                  {'@': {'changed-seconds': 1565669467},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'icmp-probe',\n                   'rule': 'protocol.icmp/check-icmp-statistics'}]}\n\n\n\n```python\ndgs = hb.device_group.get('edge')\ndgs.devices.append('vmx')\nhb.device_group.update(dgs)\n```\n\n\n\n\n    True\n\n\n\n\n```python\n# Check for devices list\ndgs = hb.device_group.get('edge')\nprint(dgs)\n```\n\n    {'authentication': None,\n     'description': 'All devices on the edge',\n     'device_group_name': 'edge',\n     'devices': ['vmx', 'demo'],\n     'logging': {'log-level': 'warn'},\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'retention_policy': None,\n     'variable': [{'@': {'changed-seconds': 1565668543},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'forwarding-table-summary',\n                   'rule': 'protocol.routesummary/check-fib-summary'},\n                  {'@': {'changed-seconds': 1565669467},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'icmp-probe',\n                   'rule': 'protocol.icmp/check-icmp-statistics'}]}\n\n\n\n```python\ndgs.devices = ['edge']\nhb.device_group.update(dgs)\n```\n\n\n\n\n    True\n\n\n\n\n```python\ndgs = hb.device_group.get('edge')\nprint(dgs)\n```\n\n    {'authentication': None,\n     'description': 'All devices on the edge',\n     'device_group_name': 'edge',\n     'devices': ['edge'],\n     'logging': {'log-level': 'warn'},\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'retention_policy': None,\n     'variable': [{'@': {'changed-seconds': 1565668543},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'forwarding-table-summary',\n                   'rule': 'protocol.routesummary/check-fib-summary'},\n                  {'@': {'changed-seconds': 1565669467},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'icmp-probe',\n                   'rule': 'protocol.icmp/check-icmp-statistics'}]}\n\n\n\n```python\n# can also update by passing Device Group Schema kwargs\ndgs = hb.device_group.get('edge')\npprint(dgs)\nfrom jnpr.healthbot import DevicegroupSchemaLogging\nlogSchema = DevicegroupSchemaLogging('warn')\nhb.device_group.update(device_group_name='edge', logging=logSchema)\n```\n\n    {'authentication': None,\n     'description': 'All devices on the edge',\n     'device_group_name': 'edge',\n     'devices': ['edge'],\n     'logging': {'log-level': 'warn'},\n     'native_gpb': None,\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'retention_policy': None,\n     'variable': [{'@': {'changed-seconds': 1565668543},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'forwarding-table-summary',\n                   'rule': 'protocol.routesummary/check-fib-summary'},\n                  {'@': {'changed-seconds': 1565669467},\n                   'instance-id': 'HbEZ-instance',\n                   'playbook': 'icmp-probe',\n                   'rule': 'protocol.icmp/check-icmp-statistics'}]}\n\n\n\n\n\n    True\n\n\n\n\n```python\n### Delete device and device group\n```\n\n\n```python\nhb.device_group.delete('edge')\n\n```\n\n    \n\n\n\n\n\n    True\n\n\n\n\n```python\nhb.device.delete('demo')\n```\n\n\n\n\n    True\n\n\n\n\n```python\n# Lets commit all the changes\nhb.commit()\n```\n\n\n\n\n    True\n\n\n\n### Add Network Group\n\n\n```python\nhb.network_group.add(network_group_name=\"HbEZ\")\n```\n\n\n\n\n    True\n\n\n\n\n```python\nprint(hb.network_group.get(network_group_name=\"HbEZ\"))\nhb.network_group.delete(network_group_name=\"HbEZ\")\n```\n\n    \n\n\n    {'description': None,\n     'network_group_name': 'HbEZ',\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'variable': None}\n\n\n\n\n\n    True\n\n\n\n### Add Network Group using Schema\n\n\n```python\nfrom jnpr.healthbot import NetworkGroupSchema\n```\n\n\n```python\nngs = NetworkGroupSchema(network_group_name=\"HbEZ\")\n```\n\n\n```python\nhb.network_group.add(ngs)\n```\n\n\n\n\n    True\n\n\n\n\n```python\nhb.network_group.get(network_group_name=\"HbEZ\")\n```\n\n\n\n\n    {'description': None,\n     'network_group_name': 'HbEZ',\n     'notification': {},\n     'playbooks': [],\n     'reports': [],\n     'variable': None}\n\n\n\n# Use Case: Rules\n\n\n```python\nhb.rule.get('linecard.ospf', 'check-ddos-statistics')\n```\n\n\n\n\n    {'description': 'Monitors ospf related distributed denial of service '\n                    'statistics',\n     'field': [{'constant': {'value': '{{ddos-arrival-rate-threshold}}'},\n                'description': 'This field is for ddos arive rate threshold',\n                'field-name': 'ddos-arrival-rate-threshold'},\n               {'constant': {'value': '{{ddos-drop-count-threshold}}'},\n                'description': 'This field is for ddos drop count threshold',\n                'field-name': 'ddos-drop-count-threshold'},\n               {'constant': {'value': '{{ddos-drop-rate-threshold}}'},\n                'description': 'This field is for ddos drop rate threshold',\n                'field-name': 'ddos-drop-rate-threshold'}],\n     'function': None,\n     'keys': ['group-name', 'protocol-states-locale'],\n     'network_rule': None,\n     'rule_frequency': None,\n     'rule_name': 'check-ddos-statistics',\n     'rule_properties': {'catalogue': {'tier': '1'},\n                         'contributor': 'juniper',\n                         'helper-files': [{'file-type': 'other',\n                                           'list-of-files': ['ddos-statistics.yml']}],\n                         'supported-devices': {'juniper': {'operating-system': [{'os-name': 'junos',\n                                                                                 'products': [{'product-name': 'ACX',\n                                                                                               'releases': [{'platform': ['All'],\n                                                                                                             'release-name': '15.2R1',\n                                                                                                             'release-support': 'min-supported-release'}]},\n                                                                                              {'product-name': 'EX',\n                                                                                               'releases': [{'platform': ['All'],\n                                                                                                             'release-name': '15.2R1',\n                                                                                                             'release-support': 'min-supported-release'}]},\n                                                                                              {'product-name': 'MX',\n                                                                                               'releases': [{'platform': ['All'],\n                                                                                                             'release-name': '15.2R1',\n                                                                                                             'release-support': 'min-supported-release'}]},\n                                                                                              {'product-name': 'PTX',\n                                                                                               'releases': [{'platform': ['All'],\n                                                                                                             'release-name': '15.2R1',\n                                                                                                             'release-support': 'min-supported-release'}]},\n                                                                                              {'product-name': 'QFX',\n                                                                                               'releases': [{'platform': ['All'],\n                                                                                                             'release-name': '15.2R1',\n                                                                                                             'release-support': 'min-supported-release'}]},\n                                                                                              {'product-name': 'SRX',\n                                                                                               'releases': [{'platform': ['All'],\n                                                                                                             'release-name': '15.2R1',\n                                                                                                             'release-support': 'min-supported-release'}]}]}]}},\n                         'supported-healthbot-version': '1.0.1',\n                         'version': 2},\n     'sensor': [{'description': 'Netconf rpc get-ddos-ospf-information iAgent '\n                                'sensor to collect telemetry data from network '\n                                'device',\n                 'iAgent': {'file': 'ddos-statistics.yml',\n                            'frequency': '60s',\n                            'table': 'ddosStats'},\n                 'sensor-name': 'ddosstats',\n                 'synopsis': 'ddos statistics sensor definition'}],\n     'synopsis': 'OSPF distributed denial of service statistics analyzer',\n     'trigger': [{'description': 'Sets health based on DDOS packet drop rate',\n                  'frequency': '60s',\n                  'synopsis': 'DDOS packet drops kpi',\n                  'term': [{'term-name': 'is-ddos-drops-increasing',\n                            'then': {'status': {'color': 'red',\n                                                'message': 'DDOS packet drops '\n                                                           '($dropped-packets) '\n                                                           'increasing'}},\n                            'when': {'min-rate-of-increase': [{'field-name': '$dropped-packets',\n                                                               'rate': '$ddos-drop-rate-threshold',\n                                                               'time-range': '5m'}]}},\n                           {'term-name': 'are-ddos-drops-over-threshold',\n                            'then': {'status': {'color': 'yellow',\n                                                'message': 'DDOS packet drops '\n                                                           '($dropped-packets) '\n                                                           'over threshold '\n                                                           '($ddos-drop-count-threshold)'}},\n                            'when': {'greater-than': [{'left-operand': '$dropped-packets',\n                                                       'right-operand': '$ddos-drop-count-threshold'}]}},\n                           {'term-name': 'ddos-drops-not-increasing',\n                            'then': {'status': {'color': 'green'}}}],\n                  'trigger-name': 'ddos-drops'},\n                 {'description': 'Sets health based on DDOS packet arrival rate',\n                  'frequency': '60s',\n                  'synopsis': 'DDOS packet arrival kpi',\n                  'term': [{'term-name': 'is-max-packet-arrival-rate-greater-than-threshold',\n                            'then': {'status': {'color': 'yellow',\n                                                'message': 'DDOS packet max '\n                                                           'arrival rate is over '\n                                                           'threshold '\n                                                           '($ddos-arrival-rate-threshold)'}},\n                            'when': {'greater-than-or-equal-to': [{'left-operand': '$packet-arrival-rate-max',\n                                                                   'right-operand': '$ddos-arrival-rate-threshold'}]}},\n                           {'term-name': 'max-packet-arrival-rate-less-than-threshold',\n                            'then': {'status': {'color': 'green'}}}],\n                  'trigger-name': 'ddos-packet-arrival-rate'},\n                 {'description': 'Sets health based on DDOS packet drop others',\n                  'frequency': '60s',\n                  'synopsis': 'DDOS packet drop other kpi',\n                  'term': [{'term-name': 'is-ddos-packet-dropped-others-increasing',\n                            'then': {'status': {'color': 'red',\n                                                'message': 'DDOS packet dropped '\n                                                           'others '\n                                                           '($dropped-packets-others) '\n                                                           'increasing'}},\n                            'when': {'min-rate-of-increase': [{'field-name': '$dropped-packets-others',\n                                                               'rate': '$ddos-drop-rate-threshold',\n                                                               'time-range': '5m'}]}},\n                           {'term-name': 'is-ddos-packet-drop-others-over-threshold',\n                            'then': {'status': {'color': 'yellow',\n                                                'message': 'DDOS packet dropped '\n                                                           'others '\n                                                           '($dropped-packets-others) '\n                                                           'over threshold '\n                                                           '($ddos-drop-count-threshold)'}},\n                            'when': {'greater-than': [{'left-operand': '$dropped-packets-others',\n                                                       'right-operand': '$ddos-drop-count-threshold'}]}},\n                           {'term-name': 'ddos-packet-drop-others-not-increasing',\n                            'then': {'status': {'color': 'green'}}}],\n                  'trigger-name': 'ddos-packet-dropped-others'}],\n     'variable': [{'description': 'DDOS arrival rate threshold value',\n                   'name': 'ddos-arrival-rate-threshold',\n                   'type': 'int',\n                   'value': '1000'},\n                  {'description': 'DDOS drop count threshold value',\n                   'name': 'ddos-drop-count-threshold',\n                   'type': 'int',\n                   'value': '0'},\n                  {'description': 'DDOS drop rate threshold value',\n                   'name': 'ddos-drop-rate-threshold',\n                   'type': 'int',\n                   'value': '1'}],\n     'vector': None}\n\n\n\n### Add new rule\n\n\n```python\nfrom jnpr.healthbot.modules.rules import RuleSchema\nrs = RuleSchema(rule_name=\"hbez-fpc-heap-utilization\")\n```\n\n### setting rule schema params\n\n\n```python\nrs.description = \"HealthBot EZ example\"\nrs.synopsis = \"Using python client for demo\"\nrs.sensor = [{'description': 'Monitors FPC buffer, heap and cpu utilization',\n              'iAgent': {'file': 'fpc-utilization.yml',\n                         'frequency': '30s',\n                         'table': 'FPCCPUHEAPutilizationTable'},\n              'sensor-name': 'fpccpuheaputilization'}]\n```\n\n\n```python\nfrom jnpr.healthbot.swagger.models.rule_schema_field import RuleSchemaField\nfrom jnpr.healthbot.swagger.models.rule_schema_constant import RuleSchemaConstant\n\nrs.field = [RuleSchemaField(constant=RuleSchemaConstant(value='{{fpc-buffer-usage-threshold}}'),\n                            description='This field is for buffer usage threshold',\n                            field_name='linecard-buffer-usage-threshold'),\n            RuleSchemaField(constant=RuleSchemaConstant(value='{{fpc-cpu-usage-threshold}}'),\n                            description='This field is for linecard cpu usage threshold',\n                            field_name='linecard-cpu-usage-threshold'),\n            RuleSchemaField(constant=RuleSchemaConstant(value='{{fpc-heap-usage-threshold}}'),\n                            description='This field is for linecard heap usage threshold',\n                            field_name='linecard-heap-usage-threshold')]\n\nrs.keys = ['slot']\n```\n\n\n```python\nrs.variable = [{'description': 'Linecard Buffer Memory usage threshold value',\n               'name': 'fpc-buffer-usage-threshold',\n               'type': 'int',\n               'value': '80'},\n              {'description': 'Linecard CPU usage threshold value',\n               'name': 'fpc-cpu-usage-threshold',\n               'type': 'int',\n               'value': '80'},\n              {'description': 'Linecard Heap Memory usage threshold value',\n               'name': 'fpc-heap-usage-threshold',\n               'type': 'int',\n               'value': '80'}]\n```\n\n\n```python\nrs.trigger = [{'description': 'Sets health based on linecard buffer memory',\n               'frequency': '60s',\n               'synopsis': 'Linecard buffer memory kpi',\n               'term': [{'term-name': 'is-buffer-memory-utilization-greater-than-threshold',\n                         'then': {'status': {'color': 'red',\n                                             'message': 'FPC buffer memory '\n                                                        'utilization '\n                                                        '($memory-buffer-utilization) '\n                                                        'is over threshold '\n                                                        '($linecard-buffer-usage-threshold)'}},\n                         'when': {'greater-than': [{'left-operand': '$memory-buffer-utilization',\n                                                    'right-operand': '$linecard-buffer-usage-threshold'}]}},\n                        {'term-name': 'buffer-utilization-less-than-threshold',\n                         'then': {'status': {'color': 'green'}}}],\n               'trigger-name': 'fpc-buffer-memory-utilization'},\n              {'description': 'Sets health based on linecard cpu utilization',\n               'frequency': '60s',\n               'synopsis': 'Linecard cpu utilization kpi',\n               'term': [{'term-name': 'is-cpu-utilization-greater-than-80',\n                         'then': {'status': {'color': 'red',\n                                             'message': 'FPC CPU utilization '\n                                                        '($cpu-total) is over '\n                                                        'threshold '\n                                                        '($linecard-cpu-usage-threshold)'}},\n                         'when': {'greater-than': [{'left-operand': '$cpu-total',\n                                                    'right-operand': '$linecard-cpu-usage-threshold',\n                                                    'time-range': '180s'}]}},\n                        {'term-name': 'cpu-utilization-less-than-threshold',\n                         'then': {'status': {'color': 'green'}}}],\n               'trigger-name': 'fpc-cpu-utilization'},\n              {'description': 'Sets health based on linecard heap memory '\n                              'utilization',\n               'frequency': '60s',\n               'synopsis': 'Linecard heap memory kpi',\n               'term': [{'term-name': 'is-heap-memory-utilization-greater-than-threshold',\n                         'then': {'status': {'color': 'red',\n                                             'message': 'FPC heap memory '\n                                                        'utilization '\n                                                        '($memory-heap-utilization) '\n                                                        'is over threshold '\n                                                        '($linecard-heap-usage-threshold)'}},\n                         'when': {'greater-than': [{'left-operand': '$memory-heap-utilization',\n                                                    'right-operand': '$linecard-heap-usage-threshold'}]}},\n                        {'term-name': 'heap-memory-utilization-less-than-threshold',\n                         'then': {'status': {'color': 'green'}}}],\n               'trigger-name': 'fpc-heap-memory-utilization'}]\n```\n\n### If the topic name is not present, first it will create given topic\n\n\n```python\nhb.rule.add('hbez', schema=rs)\n```\n\n\n\n\n    True\n\n\n\n\n```python\n# hb.rules.delete_rule(topic_name='external', rule_name=\"hbez-fpc-heap-utilization\")\n```\n\n# Use Case: Playbooks\n\n\n```python\npprint(hb.playbook.get('linecard-kpis-playbook'))\n```\n\n    {'description': 'Playbook checks linecard health i.e. cpu, memory and CM '\n                    'errors',\n     'playbook_name': 'linecard-kpis-playbook',\n     'rules': ['linecard.cm-events/check-cm-events',\n               'linecard.fpc/check-fpc-cpu',\n               'linecard.fpc/check-fpc-memory'],\n     'synopsis': 'Linecards key performance indicators'}\n\n\n\n```python\nfrom jnpr.healthbot.modules.playbooks import PlaybookSchema\n```\n\n\n```python\npbs = PlaybookSchema(playbook_name=\"HbEZ-example\")\n```\n\n\n```python\npbs.description = \"HbEZ Demo Examples\"\npbs.synopsis = 'fpc status'\n```\n\n\n```python\npbs.rules = ['hbez/hbez-fpc-heap-utilization']\n```\n\n\n```python\nhb.playbook.add(pbs)\n```\n\n\n\n\n    True\n\n\n\n\n```python\nhb.playbook.delete(playbook_name=\"HbEZ-example\")\n```\n\n    \n\n\n\n\n\n    True\n\n\n\n# Use Case: Health\n\n\n```python\npprint(hb.health.get_device_health('edge'))\n```\n\n    {'children': [{'children': [{'children': [], 'name': 'external'}],\n                   'name': 'real'}],\n     'color': None,\n     'data': None,\n     'name': 'edge',\n     'timestamp': None}\n\n\n\n```python\npprint(hb.health.get_device_group_health('real'))\n```\n\n    {'children': [{'children': [{'children': [], 'name': 'external'}],\n                   'name': 'edge'}],\n     'color': None,\n     'data': None,\n     'name': 'real',\n     'timestamp': None}\n\n\n# Use Case: Database\n    This we might need to take it off\n\n\n```python\nprint (hb.tsdb.query(\"show databases\"))\n```\n\n    ResultSet({'('databases', None)': [{'name': 'health'}, {'name': '_internal'}, {'name': 'Core:vmx'}, {'name': 'real:edge'}, {'name': 'Core:demo'}, {'name': 'EVO_Core:EVO'}, {'name': 'EVO_CORE:EVO'}, {'name': 'vmx_db:vmx_db'}, {'name': 'vmx_db:core_db'}]})\n\n\n\n```python\nobj = hb.tsdb.query('select * from \"protocol-eventd-host/check-host-traffic/packet-loss\" limit 10', database='Core:vmx')\npprint(obj.raw)\n```\n\n    {'statement_id': 0}\n\n\n\n```python\nprint(hb.version)\n```\n\n    2.0.1\n\n\n\n```python\n### Load any helper file\n```\n\n\n```python\nhb.upload_helper_file('/Users/nitinkr/xxx/xyz.rule')\n\n```\n\n# Use Case: Notification\n\n\n```python\nfrom jnpr.healthbot import NotificationSchema\nfrom jnpr.healthbot import NotificationSchemaSlack\n\n\nns = NotificationSchema(notification_name='HbEZ-notification')\nns.description = \"example of adding notification via API\"\nnss = NotificationSchemaSlack(channel=\"HbEZ\", url='http://testing')\nns.slack = nss\nhb.settings.notification.add(ns)\n```\n\n\n\n\n    True\n\n\n\n\n```python\nprint(hb.settings.notification.get())\n```\n\n    [{'description': 'example of adding notification via API',\n     'http_post': None,\n     'kafka_publish': None,\n     'notification_name': 'HbEZ-notification',\n     'slack': {'channel': 'HbEZ', 'url': 'http://testing'}}]\n\n\n\n```python\npprint(hb.settings.notification.delete('HbEZ-notification'))\n```\n\n    \n\n\n    True\n\n\n# Use Case: Settings\n\n\n```python\nfrom jnpr.healthbot import RetentionPolicySchema\n\nrps = RetentionPolicySchema(retention_policy_name='HbEZ-testing')\nhb.settings.retention_policy.add(rps)\n```\n\n\n\n\n    True\n\n\n\n\n```python\nprint(hb.settings.retention_policy.get())\n```\n\n    [{'duration': None, 'replication': None, 'retention_policy_name': 'HbEZ-testing'}, {'duration': None,\n     'replication': None,\n     'retention_policy_name': 'HbEZ-testing1'}, {'duration': None,\n     'replication': None,\n     'retention_policy_name': 'HbEZ-testing2'}]\n\n\n\n```python\nfrom jnpr.healthbot import SchedulerSchema\nsc = SchedulerSchema(name='HbEZ-schedule', repeat={'every': 'week'}, start_time=\"2019-07-22T05:32:23Z\")\nhb.settings.scheduler.add(sc)\n\nfrom jnpr.healthbot import DestinationSchema\nds = DestinationSchema(name='HbEZ-destination', email={'id': 'nitinkr@juniper.net'})\nhb.settings.destination.add(ds)\n\nfrom jnpr.healthbot import ReportSchema\nrs = ReportSchema(name=\"HbEZ-report\", destination=['HbEZ-destination'], format=\"html\", schedule=[\"HbEZ-schedule\"])\nhb.settings.report.add(rs)\n```\n\n\n\n\n    True\n\n\n```python\n# Adding a loadbalancer IP\nhb.settings.deployment.add(ip=\"1.1.1.1\")\nhb.commit()\n\n# Updating the loadbalancer IP\nhb.settings.deployment.update(ip=\"1.1.1.2\")\nhb.commit()\n\n# Getting the configured loadbalancer IP\npprint(hb.settings.deployment.get())\n```\n\n\n\n\n\n\n    {'deployment': {'kubernetes': {'loadbalancer': {'snmp-proxy': {'virtual-ip-address': '1.1.1.2'}}}}}\n\n\n\n```python\nfrom jnpr.healthbot.swagger.models.snmp_notification_schema import SnmpNotificationSchema\nfrom jnpr.healthbot.swagger.models.snmpnotification_schema_snmpnotification import SnmpnotificationSchemaSnmpnotification\nfrom jnpr.healthbot.swagger.models.snmpnotification_schema_snmpnotification_v3 import SnmpnotificationSchemaSnmpnotificationV3\nschema = SnmpNotificationSchema(\n    snmp_notification=SnmpnotificationSchemaSnmpnotification(\n        port=199,\n        v3=SnmpnotificationSchemaSnmpnotificationV3(\n            usm={\n                \"users\": [\n                            {\n                                \"authentication\": {\n                                    \"passphrase\": \"Testing@123\",\n                                    \"protocol\": \"SHA\"\n                                },\n                                \"privacy\": {\n                                    \"passphrase\": \"Testing@123\",\n                                    \"protocol\": \"AES\"\n                                },\n                                \"username\": \"snmp-collector\"\n                            }\n                        ]}\n        )))\nhb.settings.snmp_notification.add(schema)\nhb.commit()\n\n# Getting the configured SNMP notification settings\npprint(hb.settings.snmp_notification.get())\n\n```\n\n\n\n\n    {'snmp-notification': {'engine-id': '80004fb8056865616c7468626f742d766d310001b788', 'port': 199, 'v3': {'usm': {'users': [{'authentication': {'passphrase': '$9$pOEPuRcKvLNVY8XYoZjPf69AtpO1RhyevB1', 'protocol': 'SHA'}, 'privacy': {'passphrase': '$9$2MgGjmPQn9pTzpBRSMWdbsY2oJGDH.PaJ', 'protocol': 'AES'}, 'username': 'snmp-collector'}, {'authentication': {'passphrase': '$9$j.iPT6/tOIcApclvLVbaZUDjk.P5zn/q.', 'protocol': 'MD5'}]}}}}\n\n\n\n\n# Use Case: PlayBook Instance\n\n\n```python\nfrom jnpr.healthbot.modules.playbooks import PlayBookInstanceBuilder\n\n# case where we dont need to set any variable\npbb = PlayBookInstanceBuilder(hb, 'forwarding-table-summary', 'HbEZ-instance', 'Core')\npbb.apply()\n\n#hb.commit()\n```\n\n\n\n\n    True\n\n\n\n### when we need to set any rule variable for given device/group in playbook instance\n\n\n```python\nfrom jnpr.healthbot.modules.playbooks import PlayBookInstanceBuilder\n\npbb = PlayBookInstanceBuilder(hb, 'forwarding-table-summary', 'HbEZ-instance', 'Core')\n\nvariable = pbb.rule_variables[\"protocol.routesummary/check-fib-summary\"]\n\n\nvariable.route_address_family = 'pqr'\nvariable.route_count_threshold = 100\n\n# Apply variable to given device(s)\npbb.apply(device_ids=['vmx'])\n\n#clear all the variable if you want to set it something else for group or other device(s)\npbb.clear()\n\nvariable = pbb.rule_variables[\"protocol.routesummary/check-fib-summary\"]\nvariable.route_address_family = 'abc'\nvariable.route_count_threshold = 200\n\npbb.apply()\n\n#hb.commit()\n```\n\n\n\n\n    True\n\n\n### Configure hb charts when there is device-group present and there is a running playbook for it\n\n```python\nfrom jnpr.healthbot.swagger.models.hb_graphs_query import HbGraphsQuery\nfrom jnpr.healthbot.swagger.models.hb_graphs import HbGraphs\nfrom jnpr.healthbot import HealthBotClient\n\nwith HealthBotClient(ip, gui_username, gui_password, port=8080) as hb:\n\n    # group_name, device_name, measurement_name, field_name are compulsory fields here\n    query1 = HbGraphsQuery(group_name='dg-junos', device_name=\"d2\", measurement_name=\"system.commit/commit-history\",\n                           transformation=None, field_name=\"l1-threshold\", field_aggregation=\"mean\",\n                           where=[{'key': \"comment\", \"operator\": '=', \"value\": \"new\"}],\n                           group_by_interval=\"1s\", group_by_fill=\"fill(null)\", group_by_tag_key=[])\n    # Multiple queries can be present for a graph\n\n    # graph_name, graph_type, time_range are compulsory here\n    graph1 = HbGraphs(graph_name=\"graph1\", graph_description=None, graph_type=\"Heatmap\",\n                      time_range='3h', query=[query1], y_label=None, y_max=None,\n                      y_min=None, unit_type=None, decimals=None)\n    # Multiple graphs can be present for a canvas \n    \n    # Adding a new canvas with a single graph\n    hb.charts.add_canvas(canvas_name=\"mycanvas\", graphs=[graph1])\n    hb.commit()\n\n```\n\n\n\n\n    True\n\n        \n        \n# VERSIONS\n\nHealthbot versions upto 3.2.0 are supported by `https://pypi.org/project/hbez/2.0.0/`\n\nHealthbot/Paragon Insights 4.0.0 and above will be supported by `https://pypi.org/project/hbez/4.0.0/` and above\n\n# LICENSE\n\nApache 2.0\n\n# CONTRIBUTORS\n\nJuniper Networks is actively contributing to and maintaining this repo. Please contact healthbot-hackers at juniper.net for any queries.\n\n*Contributors:*\n\n* v1.0.0: [Nitin Kumar](https://github.com/vnitinv)\n* v2.0.0: [Nitin Kumar](https://github.com/vnitinv)\n* v4.0.0: [Sharanya Bhat](https://github.com/sharanyabhat)\n* v4.1.0: [Sharanya Bhat](https://github.com/sharanyabhat)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuniper%2Fhealthbot-py-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuniper%2Fhealthbot-py-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuniper%2Fhealthbot-py-client/lists"}