Skip to main content

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()

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

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

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

LICENSE

  • MIT License

Project details


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.1.6.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

besapi-3.1.6-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file besapi-3.1.6.tar.gz.

File metadata

  • Download URL: besapi-3.1.6.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for besapi-3.1.6.tar.gz
Algorithm Hash digest
SHA256 11e454586e2b42ae7705eeff0195d2a24fb269926f627a39b36da5557f8f0d0a
MD5 8b48ddd4358c24f75510bc68102be681
BLAKE2b-256 a437313386f6b0c373f2efbeb2a026bfbfd4145c5cca6cafc46c8aac5c34dd7b

See more details on using hashes here.

File details

Details for the file besapi-3.1.6-py3-none-any.whl.

File metadata

  • Download URL: besapi-3.1.6-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for besapi-3.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a2f0f6adb7516de976d8c57857a0318a47ec43734d4d3fa0cdbbed874fd8d973
MD5 137881e9a56624755d5ae0fc924e10a2
BLAKE2b-256 750ed041b113e1f236b37768098df39a376f09c6294e6cb6a9164db7755850be

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page