Component API Additions #3304

Merged
merged 1 commit into from Mar 31, 2016

Projects

None yet

2 participants

@adaniels21487
Contributor
  • Added add, edit and delete API calls for components.
  • Added documentation for the new calls.

Testing:
Add a new component (type=APITEST):

    curl -X POST -H 'X-Auth-Token: 8d5d7bb5543a07ec74b8b2985ff0c720' http://librenms.laptop/api/v0/devices/1/components/APITEST
    {
        "status": "ok",
        "err-msg": "",
        "count": 1,
        "components": {
            "4463": {
                "type": "APITEST",
                "label": "",
                "status": 1,
                "ignore": 0,
                "disabled": 0,
                "error": ""
            }
        }
    }

Search for the component (it's there):

    curl -H 'X-Auth-Token: 8d5d7bb5543a07ec74b8b2985ff0c720' http://librenms.laptop/api/v0/devices/1/components?type=APITEST
    {
        "status": "ok",
        "err-msg": "",
        "count": 1,
        "components": {
            "4463": {
                "type": "APITEST",
                "label": "",
                "status": "1",
                "ignore": "0",
                "disabled": "0",
                "error": ""
            }
        }
    }

Edit the component. Set the label and add the field "TestField":

    curl -X PUT -d '{"4463": {"type": "APITEST","label": "This is a test component","status": 1,"ignore": 0,"disabled": 0,"error": "","TestField": "TestData"}}' -H 'X-Auth-Token: 8d5d7bb5543a07ec74b8b2985ff0c720' http://librenms.laptop/api/v0/devices/1/components
    {
        "status": "ok",
        "err-msg": "",
        "count": 1
    }

Search for the component (it has been edited):

    curl -H 'X-Auth-Token: 8d5d7bb5543a07ec74b8b2985ff0c720' http://librenms.laptop/api/v0/devices/1/components?type=APITEST
    {
        "status": "ok",
        "err-msg": "",
        "count": 1,
        "components": {
            "4463": {
                "TestField": "TestData",
                "type": "APITEST",
                "label": "This is a test component",
                "status": "1",
                "ignore": "0",
                "disabled": "0",
                "error": ""
            }
        }
    }

Delete the component:

    curl -X DELETE -H 'X-Auth-Token: 8d5d7bb5543a07ec74b8b2985ff0c720' http://librenms.laptop/api/v0/devices/1/components/4463
    {
        "status": "ok",
        "err-msg": ""
    }

Search for the component (it's no longer there):

    curl -H 'X-Auth-Token: 8d5d7bb5543a07ec74b8b2985ff0c720' http://librenms.laptop/api/v0/devices/1/components?type=APITEST
    {
        "status": "ok",
        "err-msg": "",
        "count": 0,
        "components": null
    }
@adaniels21487 adaniels21487 - Added add, edit and delete API calls for components.
- Added documentation for the new calls.
9706a85
@adaniels21487
Contributor

Resolves #3264

@laf laf merged commit edec771 into librenms:master Mar 31, 2016

2 checks passed

Scrutinizer 5 new issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@adaniels21487 adaniels21487 deleted the adaniels21487:issue-3264 branch Apr 1, 2016
@adaniels21487 adaniels21487 restored the adaniels21487:issue-3264 branch Apr 11, 2016
@adaniels21487 adaniels21487 deleted the adaniels21487:issue-3264 branch Apr 12, 2016
@adaniels21487 adaniels21487 restored the adaniels21487:issue-3264 branch Apr 17, 2016
@adaniels21487 adaniels21487 deleted the adaniels21487:issue-3264 branch Apr 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment