besapi


Namebesapi JSON
Version 3.2.4 PyPI version JSON
download
home_pagehttps://github.com/jgstew/besapi
SummaryLibrary for working with the BigFix REST API
upload_time2024-04-01 17:04:06
maintainerNone
docs_urlNone
authorMatt Hansen, James Stewart
requires_python>=3.6
licenseMIT
keywords bigfix iem tem rest api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.6",
    "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/0e/3a/dd68cce8a66d39acb56bc215705f14c4b9d792ca57e97242dc75850f8c0a/besapi-3.2.4.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.2.4",
    "project_urls": {
        "Homepage": "https://github.com/jgstew/besapi"
    },
    "split_keywords": [
        "bigfix",
        "iem",
        "tem",
        "rest",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af4259aafe3809f62ba7fa7b51640d772a78ee8340f12401912ed7c91d068d4c",
                "md5": "6711979b6f8bbebd023727603b0aaed8",
                "sha256": "b5b3d89e1b6db644d56dab7b0791627bf229a4ea3eec3f2677423678576d3113"
            },
            "downloads": -1,
            "filename": "besapi-3.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6711979b6f8bbebd023727603b0aaed8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 28695,
            "upload_time": "2024-04-01T17:04:05",
            "upload_time_iso_8601": "2024-04-01T17:04:05.014916Z",
            "url": "https://files.pythonhosted.org/packages/af/42/59aafe3809f62ba7fa7b51640d772a78ee8340f12401912ed7c91d068d4c/besapi-3.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0e3add68cce8a66d39acb56bc215705f14c4b9d792ca57e97242dc75850f8c0a",
                "md5": "c018b48608655485893f02940f76d445",
                "sha256": "829f8edf37c597fff31d1d41b1854d5d79c42fb16a15342a2c083c783717e86d"
            },
            "downloads": -1,
            "filename": "besapi-3.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "c018b48608655485893f02940f76d445",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 29853,
            "upload_time": "2024-04-01T17:04:06",
            "upload_time_iso_8601": "2024-04-01T17:04:06.818367Z",
            "url": "https://files.pythonhosted.org/packages/0e/3a/dd68cce8a66d39acb56bc215705f14c4b9d792ca57e97242dc75850f8c0a/besapi-3.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-01 17:04:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jgstew",
    "github_project": "besapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "besapi"
}
        
Elapsed time: 0.21513s