Library for working with the BigFix REST API
Project description
besapi
besapi is a Python library designed to interact with the BigFix REST 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
<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()
BES> login
User [mah60]: mah60
Root Server (ex. https://server.institution.edu:52311): https://my.company.org:52311
Password:
Login Successful!
BES> get help
...
BES> get sites
...
BES> get sites.OperatorSite.Name
mah60
BES> get help/fixlets
GET:
/api/fixlets/{site}
POST:
/api/fixlets/{site}
BES> get fixlets/operator/mah60
...
REST API Help
Requirements
- Python 3.6 or later
- version 1.1.3 of besapi was the last to have partial python2 support
- lxml
- requests
- cmd2
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
- GNU General Public License v2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
besapi-3.0.1.tar.gz
(27.1 kB
view details)
Built Distribution
besapi-3.0.1-py3-none-any.whl
(27.2 kB
view details)
File details
Details for the file besapi-3.0.1.tar.gz
.
File metadata
- Download URL: besapi-3.0.1.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70d96c65459f44c4005530c572640389fed26bd2faebc05ee8a6d5cb08a9a063 |
|
MD5 | 3fb089151256e37cbf934a9652f6818e |
|
BLAKE2b-256 | 6914c5d40aafa1669cbf82649dbf9608d497f0fb24bc88d273f71cabef96f2cc |
File details
Details for the file besapi-3.0.1-py3-none-any.whl
.
File metadata
- Download URL: besapi-3.0.1-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbda250bbad29ae4c59e768f67bb455e4b96dc0e4c034f86583e3704e64c3a30 |
|
MD5 | 6aa774fdf075bfd3cd27d6ee97382445 |
|
BLAKE2b-256 | 763a5da4b38049fe1eb7582acc83b5c8df3b20d86e9f90fc7731edfe41fd7a95 |