# besapi
besapi is a Python library designed to interact with the BigFix [REST API](https://developer.bigfix.com/rest-api/api/).
Installation:
`pip install besapi`
Usage:
```
import besapi
b = besapi.BESConnection('my_username', 'my_password', 'https://rootserver.domain.org:52311')
rr = b.get('sites')
# rr.request contains the original request object
# rr.text contains the raw request.text data returned by the server
# rr.besxml contains the XML string converted from the request.text
# rr.besobj contains the requested lxml.objectify.ObjectifiedElement
>>>print rr
```
```xml
<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<ExternalSite Resource="http://rootserver.domain.org:52311/api/site/external/BES%20Support">
<Name>BES Support</Name>
</ExternalSite>
<!---...--->
<CustomSite Resource="http://rootserver.domain.org:52311/api/site/custom/Org">
<Name>Org</Name>
</CustomSite>
<CustomSite Resource="http://rootserver.domain.org:52311/api/site/custom/Org%2fMac">
<Name>Org/Mac</Name>
</CustomSite>
<CustomSite Resource="http://rootserver.domain.org:52311/api/site/custom/Org%2fWindows">
<Name>Org/Windows</Name>
</CustomSite>
<CustomSite Resource="http://rootserver.domain.org:52311/api/site/custom/ContentDev">
<Name>ContentDev</Name>
</CustomSite>
<OperatorSite Resource="http://rootserver.domain.org:52311/api/site/operator/mah60">
<Name>mah60</Name>
</OperatorSite>
<ActionSite Resource="http://rootserver.domain.org:52311/api/site/master">
<Name>ActionSite</Name>
</ActionSite>
</BESAPI>
```
```
>>>rr.besobj.attrib
{'{http://www.w3.org/2001/XMLSchema-instance}noNamespaceSchemaLocation': 'BESAPI.xsd'}
>>>rr.besobj.ActionSite.attrib
{'Resource': 'http://rootserver.domain.org:52311/api/site/master'}
>>>rr.besobj.ActionSite.attrib['Resource']
'http://rootserver.domain.org:52311/api/site/master'
>>>rr.besobj.ActionSite.Name
'ActionSite'
>>>rr.besobj.OperatorSite.Name
'mah60'
>>>for cSite in rr.besobj.CustomSite:
... print cSite.Name
Org
Org/Mac
Org/Windows
ContentDev
...
>>>rr = b.get('task/operator/mah60/823975')
>>>with open('/Users/Shared/Test.bes", "wb") as file:
... file.write(rr.text)
>>>b.delete('task/operator/mah60/823975')
>>> file = open('/Users/Shared/Test.bes')
>>> b.post('tasks/operator/mah60', file)
>>> b.put('task/operator/mah60/823975', file)
```
# Command-Line Interface
```
$ python bescli.py
OR
>>> import bescli
>>> bescli.main()
BigFix> login
User [mah60]: mah60
Root Server (ex. https://server.institution.edu:52311): https://my.company.org:52311
Password:
Login Successful!
BigFix> get help
...
BigFix> get sites
...
BigFix> get sites.OperatorSite.Name
mah60
BigFix> get help/fixlets
GET:
/api/fixlets/{site}
POST:
/api/fixlets/{site}
BigFix> get fixlets/operator/mah60
...
```
# BigFix REST API Documentation
- https://developer.bigfix.com/rest-api/
- http://bigfix.me/restapi
# Requirements
- Python 3.6 or later
- version 1.1.3 of besapi was the last to have partial python2 support
- lxml
- requests
- cmd2
# Examples using BESAPI
- https://github.com/jgstew/besapi/tree/master/examples
- https://github.com/jgstew/generate_bes_from_template/blob/master/examples/generate_uninstallers.py
- https://github.com/jgstew/jgstew-recipes/blob/main/SharedProcessors/BESImport.py
- https://github.com/jgstew/jgstew-recipes/blob/main/SharedProcessors/BigFixActioner.py
- https://github.com/jgstew/jgstew-recipes/blob/main/SharedProcessors/BigFixSessionRelevance.py
# Pyinstaller
- `pyinstaller --clean --collect-all besapi --onefile .\src\bescli\bescli.py`
- Note: using UPX to compress the binary only saves 2MB out of 16MB on Windows
# Related Items
- https://forum.bigfix.com/t/rest-api-python-module/2170
- https://gist.github.com/hansen-m/58667f370047af92f634
- https://docs.google.com/presentation/d/1pME28wdjkzj9378py9QjFyMOyOHcamB6bk4k8z-c-r0/edit#slide=id.g69e753e75_039
- https://forum.bigfix.com/t/bigfix-documentation-resources/12540
- https://forum.bigfix.com/t/query-for-finding-who-deleted-tasks-fixlets/13668/6
- https://forum.bigfix.com/t/rest-api-java-wrapper/12693
# LICENSE
- MIT License
Raw data
{
"_id": null,
"home_page": "https://github.com/jgstew/besapi",
"name": "besapi",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "bigfix iem tem rest api",
"author": "Matt Hansen, James Stewart",
"author_email": "hansen.m@psu.edu, james@jgstew.com",
"download_url": "https://files.pythonhosted.org/packages/18/13/9b82cc7d83c8281dbb189df274e8216e44092eb469b5f7e6a16926762e87/besapi-3.7.2.tar.gz",
"platform": null,
"description": "# besapi\n\nbesapi is a Python library designed to interact with the BigFix [REST API](https://developer.bigfix.com/rest-api/api/).\n\nInstallation:\n\n`pip install besapi`\n\nUsage:\n\n```\nimport besapi\nb = besapi.BESConnection('my_username', 'my_password', 'https://rootserver.domain.org:52311')\nrr = b.get('sites')\n\n# rr.request contains the original request object\n# rr.text contains the raw request.text data returned by the server\n# rr.besxml contains the XML string converted from the request.text\n# rr.besobj contains the requested lxml.objectify.ObjectifiedElement\n\n>>>print rr\n```\n\n```xml\n<BESAPI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"BESAPI.xsd\">\n<ExternalSite Resource=\"http://rootserver.domain.org:52311/api/site/external/BES%20Support\">\n<Name>BES Support</Name>\n</ExternalSite>\n<!---...--->\n<CustomSite Resource=\"http://rootserver.domain.org:52311/api/site/custom/Org\">\n<Name>Org</Name>\n</CustomSite>\n<CustomSite Resource=\"http://rootserver.domain.org:52311/api/site/custom/Org%2fMac\">\n<Name>Org/Mac</Name>\n</CustomSite>\n<CustomSite Resource=\"http://rootserver.domain.org:52311/api/site/custom/Org%2fWindows\">\n<Name>Org/Windows</Name>\n</CustomSite>\n<CustomSite Resource=\"http://rootserver.domain.org:52311/api/site/custom/ContentDev\">\n<Name>ContentDev</Name>\n</CustomSite>\n<OperatorSite Resource=\"http://rootserver.domain.org:52311/api/site/operator/mah60\">\n<Name>mah60</Name>\n</OperatorSite>\n<ActionSite Resource=\"http://rootserver.domain.org:52311/api/site/master\">\n<Name>ActionSite</Name>\n</ActionSite>\n</BESAPI>\n```\n\n```\n>>>rr.besobj.attrib\n{'{http://www.w3.org/2001/XMLSchema-instance}noNamespaceSchemaLocation': 'BESAPI.xsd'}\n\n>>>rr.besobj.ActionSite.attrib\n{'Resource': 'http://rootserver.domain.org:52311/api/site/master'}\n\n>>>rr.besobj.ActionSite.attrib['Resource']\n'http://rootserver.domain.org:52311/api/site/master'\n\n>>>rr.besobj.ActionSite.Name\n'ActionSite'\n\n>>>rr.besobj.OperatorSite.Name\n'mah60'\n\n>>>for cSite in rr.besobj.CustomSite:\n... print cSite.Name\nOrg\nOrg/Mac\nOrg/Windows\nContentDev\n...\n\n>>>rr = b.get('task/operator/mah60/823975')\n>>>with open('/Users/Shared/Test.bes\", \"wb\") as file:\n... file.write(rr.text)\n\n>>>b.delete('task/operator/mah60/823975')\n\n>>> file = open('/Users/Shared/Test.bes')\n>>> b.post('tasks/operator/mah60', file)\n>>> b.put('task/operator/mah60/823975', file)\n```\n\n# Command-Line Interface\n\n```\n$ python bescli.py\nOR\n>>> import bescli\n>>> bescli.main()\n\nBigFix> login\nUser [mah60]: mah60\nRoot Server (ex. https://server.institution.edu:52311): https://my.company.org:52311\nPassword:\nLogin Successful!\nBigFix> get help\n...\nBigFix> get sites\n...\nBigFix> get sites.OperatorSite.Name\nmah60\nBigFix> get help/fixlets\nGET:\n/api/fixlets/{site}\nPOST:\n/api/fixlets/{site}\nBigFix> get fixlets/operator/mah60\n...\n```\n\n# BigFix REST API Documentation\n\n- https://developer.bigfix.com/rest-api/\n- http://bigfix.me/restapi\n\n# Requirements\n\n- Python 3.6 or later\n - version 1.1.3 of besapi was the last to have partial python2 support\n- lxml\n- requests\n- cmd2\n\n# Examples using BESAPI\n\n- https://github.com/jgstew/besapi/tree/master/examples\n- https://github.com/jgstew/generate_bes_from_template/blob/master/examples/generate_uninstallers.py\n- https://github.com/jgstew/jgstew-recipes/blob/main/SharedProcessors/BESImport.py\n- https://github.com/jgstew/jgstew-recipes/blob/main/SharedProcessors/BigFixActioner.py\n- https://github.com/jgstew/jgstew-recipes/blob/main/SharedProcessors/BigFixSessionRelevance.py\n\n# Pyinstaller\n\n- `pyinstaller --clean --collect-all besapi --onefile .\\src\\bescli\\bescli.py`\n- Note: using UPX to compress the binary only saves 2MB out of 16MB on Windows\n\n# Related Items\n\n- https://forum.bigfix.com/t/rest-api-python-module/2170\n- https://gist.github.com/hansen-m/58667f370047af92f634\n- https://docs.google.com/presentation/d/1pME28wdjkzj9378py9QjFyMOyOHcamB6bk4k8z-c-r0/edit#slide=id.g69e753e75_039\n- https://forum.bigfix.com/t/bigfix-documentation-resources/12540\n- https://forum.bigfix.com/t/query-for-finding-who-deleted-tasks-fixlets/13668/6\n- https://forum.bigfix.com/t/rest-api-java-wrapper/12693\n\n# LICENSE\n\n- MIT License\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Library for working with the BigFix REST API",
"version": "3.7.2",
"project_urls": {
"Homepage": "https://github.com/jgstew/besapi"
},
"split_keywords": [
"bigfix",
"iem",
"tem",
"rest",
"api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "683c3531bb93d7c40c02b89aafabeaa0c8bea431f55b80b1e6571d500dd392f6",
"md5": "a31af81491c739220215d8fee7f78049",
"sha256": "4a531696369ba2e3c0e2e2046697219fe00eac34fdbb3d5be80d3e07d77590d8"
},
"downloads": -1,
"filename": "besapi-3.7.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a31af81491c739220215d8fee7f78049",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 30841,
"upload_time": "2024-09-27T16:30:43",
"upload_time_iso_8601": "2024-09-27T16:30:43.670071Z",
"url": "https://files.pythonhosted.org/packages/68/3c/3531bb93d7c40c02b89aafabeaa0c8bea431f55b80b1e6571d500dd392f6/besapi-3.7.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "18139b82cc7d83c8281dbb189df274e8216e44092eb469b5f7e6a16926762e87",
"md5": "5b1551e008bbf70cf941e0a7d3d21332",
"sha256": "b3ac37b0cc1b62c894c6b2545a21c86fa6f1e90b6674fe2d7404a4c72c18cc62"
},
"downloads": -1,
"filename": "besapi-3.7.2.tar.gz",
"has_sig": false,
"md5_digest": "5b1551e008bbf70cf941e0a7d3d21332",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 31871,
"upload_time": "2024-09-27T16:30:44",
"upload_time_iso_8601": "2024-09-27T16:30:44.808672Z",
"url": "https://files.pythonhosted.org/packages/18/13/9b82cc7d83c8281dbb189df274e8216e44092eb469b5f7e6a16926762e87/besapi-3.7.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-27 16:30:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jgstew",
"github_project": "besapi",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "cmd2",
"specs": []
},
{
"name": "lxml",
"specs": []
},
{
"name": "requests",
"specs": []
},
{
"name": "setuptools",
"specs": []
}
],
"lcname": "besapi"
}