Package: besapi
besapibesapi is a Python library designed to interact with the BigFixREST API.Installation:pip install besapiUsage: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<BESAPIxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="BESAPI.xsd"><ExternalSiteResource="http://rootserver.domain.org:52311/api/site/external/BES%20Support"><Name>BESSupport</Name></ExternalSite><!---...---><CustomSiteResource="http://rootserver.domain.org:52311/api/site/custom/Org"><Name>Org</Name></CustomSite><CustomSiteResource="http://rootserver.domain.org:52311/api/site/custom/Org%2fMac"><Name>Org/Mac</Name></CustomSite><CustomSiteResource="http://rootserver.domain.org:52311/api/site/custom/Org%2fWindows"><Name>Org/Windows</Name></CustomSite><CustomSiteResource="http://rootserver.domain.org:52311/api/site/custom/ContentDev"><Name>ContentDev</Name></CustomSite><OperatorSiteResource="http://rootserver.domain.org:52311/api/site/operator/mah60"><Name>mah60</Name></OperatorSite><ActionSiteResource="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 Documentationhttps://developer.bigfix.com/rest-api/http://bigfix.me/restapiRequirementsPython 3.6 or laterversion 1.1.3 of besapi was the last to have partial python2 supportlxmlrequestscmd2Examples using BESAPIhttps://github.com/jgstew/besapi/tree/master/exampleshttps://github.com/jgstew/generate_bes_from_template/blob/master/examples/generate_uninstallers.pyhttps://github.com/jgstew/jgstew-recipes/blob/main/SharedProcessors/BESImport.pyhttps://github.com/jgstew/jgstew-recipes/blob/main/SharedProcessors/BigFixActioner.pyhttps://github.com/jgstew/jgstew-recipes/blob/main/SharedProcessors/BigFixSessionRelevance.pyPyinstallerpyinstaller --clean --collect-all besapi --onefile .\src\bescli\bescli.pyNote: using UPX to compress the binary only saves 2MB out of 16MB on WindowsRelated Itemshttps://forum.bigfix.com/t/rest-api-python-module/2170https://gist.github.com/hansen-m/58667f370047af92f634https://docs.google.com/presentation/d/1pME28wdjkzj9378py9QjFyMOyOHcamB6bk4k8z-c-r0/edit#slide=id.g69e753e75_039https://forum.bigfix.com/t/bigfix-documentation-resources/12540https://forum.bigfix.com/t/query-for-finding-who-deleted-tasks-fixlets/13668/6https://forum.bigfix.com/t/rest-api-java-wrapper/12693LICENSEMIT License