Skip to main content

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

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)

Source distribution for pySIR 0.46
File Size Uploaded
pySIR-0.46.tar.gz 7.8 kB Details

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

Release history Release notifications | RSS feed

This release

0.46 This release

1 release file

0.45

1 release file

0.44

1 release file

0.42

1 release file

0.41

1 release file

0.40

1 release file

0.3

1 release file

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page