Skip to main content

A minimalist wrapper around the CPBM BSS API.

Project description


This project is a minimalist wrapper around the CPBM BSS API. Its
purpose is to provide a CPBM BSS library that works independent of the CPBM version.
Instead of having function stubs for all of the CPBM BSS features, this lib is used
in conjunction with the CPBM BSS API documentation and the `request` function takes
the JSON values needed for each call.

There are two ways in which this lib can be consumed:

1. The `API` class can be instantiated from any code. It has a single `request`
method, which is used to make API calls against the CPBM BSS API. This method
takes a python dictionary of request parameters and returns a python dictionary
with the result.

2. The `CLI` class is a subclass of `API` and is designed to be a convenience
class for working with stand alone scripts that populate the `API` constructor
using command line arguments parsed by `docopt`. The command line arguments can be
passed in directly or they can be added to a JSON file and the `--json` flag can
be used to reference the JSON file path. A `` file is included in
the package to give a working example of how to use this use case.

The core of this library is a single `request` method which is described as follows.

``` python
api.request(self, rest_path, params={}, payload={}, method='GET')

``` sphinx
Builds the request and returns a python dictionary of the result or None.

:param rest_path: appended to the 'endpoint'. remember to include the leading '/'
:type rest_path: str or unicode

:param params: the query parameters to be added to the url
:type params: dict

:param payload: the object to be passed to the server (may not work as expected
due to non standard bss api implementation)
:type payload: dict

:param method: the request method [ GET | POST | PUT | DELETE ]
:type method: str or unicode

:returns: the result of the request as a python dictionary
:rtype: dict or None

**An example using the parent `API` class:**

``` python
api = API(api_key="your_api_key",
accounts = api.request('/accounts')

**An example using the `CLI` sub-class:**

``` python
api = CLI(__doc__)
accounts = api.request('/accounts')

The easiest way to install this library is through `pip`.

``` bash
$ pip install cpbmapi

Alternatively, you can pull down the source code directly and install manually.

``` bash
$ git clone
$ cd cpbmapi
$ python install


The core functionality is documented above, but it is worth spending a minute
to better describe the `CLI` use case.

``` bash
$ ./ --help

Usage: [--json=<arg>] [--api_key=<arg> --secret_key=<arg>] [options] (-h | --help)

-h --help Show this screen.
--json=<arg> Path to a JSON config file with the same names as the
options (without the -- in front).
--api_key=<arg> CPBM Api Key.
--secret_key=<arg> CPBM Secret Key.
--endpoint=<arg> CPBM Endpoint
--logging=<arg> Boolean to turn on or off logging [default: True].
--log=<arg> The log file to be used [default: logs/cpbmapi.log].
--clear_log=<arg> Removes the log each time the API object is created
[default: True].

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

cpbmapi-0.0.2.tar.gz (4.9 kB view hashes)

Uploaded source

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