Welcome to forumsentry-sdk-for-python

Quickstart

Quickstart

Installation

You can install the latest version of forumsentry with:

pip install forumsentry

Basic Usage

Import the Forum Sentry API and start using methods:

from forumsentry.api import api

forumsentry = api(username="admin",password="password")

# get a list of all listenerPolices
forumsentry.get_listener_polices()

Tutorial

Coming soon.

API Reference

If you are looking for information on a specific function, class or method, this part of the documentation is for you.

API

Note

Unless otherwise noted all arguments are of the str type.

forumsentry

forumsentry.api

forumsentry.helper

Models Reference

List of models which are currently supported

Models

Note

Unless otherwise noted all arguments are of the str type.

forumsentry_api

Models which represent objects in the forum sentry.

forumsentry_api.models

forumsentry_api.models.http_listener_policy

forumsentry_api.models.http_listener_policy

alias of forumsentry_api.models.http_listener_policy

forumsentry_api.models.http_remote_policy

forumsentry_api.models.http_remote_policy

alias of forumsentry_api.models.http_remote_policy

Developer Documentation

Developer Documentation

Installing Development Environment

Your life will be a lot better if you use a virtualenv when working with python.

  1. Fork and Clone this repo
  2. Install python-pip and virtualenv if you do not already have it.
  3. Create a new virtualenv with virtualenv forumsentry-sdk-for-python.
  4. Actiavte the new virtualenv with source forumsentry-sdk-for-python/bin/activate.
  5. Run make dev
  6. Hack away!

Running Tests

Tests can be found in the tests directory.

You can run tests with make tests.

If you want to run a specific test file you can do so with:

python -m unittest tests/sentry/test_$MODULE.py

This project has two main types of tests.

  • Unit tests. These are tests of specific functions using mocked API data.
  • Integration tests. These are tests that actually hit a forum sentry device. Unfortunately, this will need to be setup by the developer and conectivity from the machine running the tests established.

In order to run the intergration tests then setup the following environment variables.

::
export FORUM_REST_API_HOST=forumsentry-dev export FORUM_REST_API_PORT=8081 export FORUM_REST_API_USER=admin export FORUM_REST_API_PASSWORD=*******
Code Coverage

This project attempts to have 100% code coverage. when you run make test code coverage is automatically ran. You can view the code coverage report locally by opening up the index.html file in the htmlcov directory that gets created when you run make test.

Swagger

The forumsentry provide swagger documentation. A tools directory is provided with a script to generate python models from the swagger api.

To run this

cd tools
export FORUM_REST_API_HOST=xxxxxxxxxxxxx
export FORUM_REST_API_USER=xxxxxxxxxxxxx
export FORUM_REST_API_PASSWORD=xxxxxxxxxxx
./generate_code.sh

This will place the models swagger generated code in a folder _build

  • Note: _build is listed in the .gitignore file. For now you will need to manually merge/extract anything useful from there. *

If you need to make changes to the generate code first see if it can be made in the templates under tools/templates/python. That way adding new models will be easier in the future.

Documentation

This project uses sphinx for documentation. You can generate the latest docs locally by running make docs. You can then view them by opening up the index.html file in the docs/build/html directory.

Linting and Style

This project follows the PEP 8 style guidelines. You can install pylint in order to ensure that all of your code is compliant with this standard.

Changelog

Changelog

Here you can see the full list of changes between each forumsentry-sdk-for-python release.

Version 0.1

Released on Novemeber 17, 2017

  • Basic project setup.

    • Continuous Integration with CircleCI
    • Packaging and uploading to PyPI
    • Code Coverage
    • Testing with unittest
  • Basic Documentation in place

Attribution