# pySIR
Python API to interact with the SIR agent.
# Installation
To install execute:
pip install pySIR
# Documentation
pySIR implements in python the SIR API. It is just a one to one mapping to avoid dealing with the specifics of making the calls, getting the data or catching the errors. It is just a convenient way of consuming the API. It brings no extra functionality.
You can use this library like this:
from pySIR.pySIR import pySIR sir = pySIR(’http://localhost:8080’)
result = sir.get_top_prefixes(start_time=”2015-07-25T14:00”, end_time=”2015-07-25T15:00”, limit_prefixes=10, net_masks=”24”, exclude_net_masks=1)
After every call you will get a `Call` object which has three attributes:
meta - Some information regarding the call.
result.meta {u’length’: 10, u’request_time’: 4.2649, u’error’: False}
result - The actual result of the call.
result.result [{u’as_dst’: 43650, u’sum_bytes’: 96527904, u’key’: u’194.132.196.0/22’}, {u’as_dst’: 1299, u’sum_bytes’: 50852480, u’key’: u’0.0.0.0/0’}, {u’as_dst’: 2856, u’sum_bytes’: 42289633, u’key’: u’86.128.0.0/10’}, {u’as_dst’: 43650, u’sum_bytes’: 27442840, u’key’: u’194.132.197.72/29’}, {u’as_dst’: 3320, u’sum_bytes’: 23312608, u’key’: u’79.192.0.0/10’}, {u’as_dst’: 2856, u’sum_bytes’: 22229909, u’key’: u’86.128.0.0/11’}, {u’as_dst’: 2856, u’sum_bytes’: 19337668, u’key’: u’86.128.0.0/12’}, {u’as_dst’: 3320, u’sum_bytes’: 19048046, u’key’: u’84.128.0.0/10’}, {u’as_dst’: 2856, u’sum_bytes’: 18816388, u’key’: u’109.144.0.0/12’}, {u’as_dst’: 3320, u’sum_bytes’: 18002994, u’key’: u’91.0.0.0/10’}]
parameters - The parameters used for the call.
result.parameters {u’exclude_net_masks’: u’1’, u’limit_prefixes’: 10, u’start_time’: u’2015-07-25T14:00’, u’end_time’: u’2015-07-25T15:00’, u’net_masks’: u’24’}
## Supported methods
As I mentioned before, this is a 1:1 mapping of the raw API. You can check the supported methods in the official documentation:
http://sdn-internet-router-sir.readthedocs.org/en/latest/api/api_v1.0.html
I recommend you to quickly check the code in the file `pySIR/pySIR.py` to quickly see the names of the methods supported. The code and the names are quite straightforward so the code should be easy to read.
## Passing variables
When passing variables to the methods just send them named using the same names they have in the original API. For example:
sir.get_top_prefixes(start_time=”2015-07-13T14:00”, end_time=”2015-07-13T15:00”, limit_prefixes=10, net_masks=”24”, exclude_net_masks=1) sir.put_variables_by_category_and_name(development, whatever, content=’231’, extra_vars=’{“asd”: “qwe” , “zxc”:”poi”}’)
The same apply when you want to send data (for example when storing or updating a variable). For example:
sir.post_variables(name=’this_is_a_variable’, content=’231’, category=’development’, extra_vars=’{“asd”: “qwe” , “zxc”:”poi”}’) sir.put_variables_by_category_and_name(development, whatever, content=’231’, extra_vars=’’)
## SSL Verification
By default pySIR is going to check SSL certificates and raise an exception if the SSL certificate is not valid. However, you can override this behavior and ignore certificates by initializing pySIR like this:
sir = pySIR(’https://localhost:8080’, verify_ssl=False)
Metadata
Release files for pySIR 0.46
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pySIR-0.46.tar.gz | 7.8 kB | Without provenance | Details for pySIR-0.46.tar.gz |
Release files / pySIR-0.46.tar.gz
| Download URL | pySIR-0.46.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
207691694d518262fa32e4c30b43a6dd9ebadcaf773940d0b7e32fe9af8dac98
|
|
BLAKE2b-256 checksum How to use checksums |
d7199b2b92888228cd7630e92c612b74ed0a2083bcc0ea735214ffc4dd5df1a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pySIR 0.46
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.