OpenSIPS Python Packages
Project description
OpenSIPS Python Packages
This repository contains a collection of Python packages for OpenSIPS. These modules are designed to be as lightweight as possible and provide a simple interface for interacting with OpenSIPS. Alongside the source code, the repository also contains a Docker image that comes with the OpenSIPS Python packages pre-installed.
Features
Currently, the following packages are available:
mi- can be used to execute OpenSIPS Management Interface (MI) commands.event- allows you to use OpenSIPS Event Interface subscriptions.
Usage
-
Install the package from source code:
git clone cd python-opebsips pip install .
or from PyPI:
pip install opensips
-
Import the package in your Python code:
from opensips.mi import OpenSIPSMI, OpenSIPSMIException from opensips.event import OpenSIPSEvent, OpenSIPSEventException, OpenSIPSEventHandler
-
Use the methods provided by the modules:
mi = OpenSIPSMI('http', url='http://localhost:8888/mi') try: response = mi.execute('ps') # do something with the response except OpenSIPSMIException as e: # handle the exception
mi_connector = OpenSIPSMI('http', url='http://localhost:8888/mi') hdl = OpenSIPSEventHandler(mi_connector, 'datagram', ip='127.0.0.1', port=50012) def some_callback(message): # do something with the message (it is a JSON object) pass ev: OpenSIPSEvent = None try: event = hdl.subscribe('E_PIKE_BLOCKED', some_callback) except OpenSIPSEventException as e: # handle the exception try: ev.unsubscribe('E_PIKE_BLOCKED') except OpenSIPSEventException as e: # handle the exception
Documentation
- MI - contains information about supported MI communication types and required parameters for each type.
- Event Interface - lists the supported event transport protocols and provides information about the required parameters for each protocol.
- Docker - provides information about the Docker image that contains the OpenSIPS Python packages.
Scripts
MI
After installing the package, you can use the provided opensips-mi script to run MI commands. This script takes the following arguments:
-tor--type- the type of the MI communication (http,datagramorfifo).-ior--ip- the IP address of the OpenSIPS server.-por--port- the port of the OpenSIPS MI.-for--fifo-file- the path to the FIFO file.-fbor--fifo-fallback- the path to the FIFO fallback file.-fdor--fifo-reply-dir- the directory where the FIFO reply files are stored.--env-file- the path to the environment file that contains the MI parameters (by default, the script will look for the.envfile in the current directory); lower priority than the command line arguments.-dsor--datagram-socket- Unix Datagram Socket.-dtor--datagram-timeout- Datagram Socket timeout in seconds. Default is 0.1.-dbor--datagram-buffer-size- Datagram Socket buffer size in bytes. Default is 32768.
Usage
# general usage
opensips-mi -t datagram -p 8080 command_name [command_args ...]
# this will execute get_statistics command
opensips-mi -t datagram -p 8080 -s core: shmem:
# you can pass json string as argument with -j flag for commands that require arrays as arguments
opensips-mi -t datagram -p 8080 get_statistics -j "{'statistics': ['core:', 'shmem:']}"
Event
You can use the provided opensips-event script to subscribe for OpenSIPS events. This script takes the following arguments:
- all the above arguments for the MI communication
-Tor--transport- the transport protocol to use (datagram,stream).-lior--listen-ip- the IP address to listen on.-lpor--listen-port- the port to listen on.-eor--expire- the expiration time for the subscription.- the event name to subscribe for.
--env-file- the path to the environment file that contains the MI parameters (by default, the script will look for the.envfile in the current directory); lower priority than the command line arguments.
Usage
opensips-event -t datagram -p 8080 -T datagram -lp 50012 -e 3600 E_PIKE_BLOCKED
License
The python-opensips source code is licensed under the GNU General Public License v3.0
All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0
© 2024 - OpenSIPS Solutions
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opensips-0.1.7.tar.gz.
File metadata
- Download URL: opensips-0.1.7.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c8dc571136fd1fa84f5d83e5098a43ca7f5ee5f9314b139234a129c2792fb9f
|
|
| MD5 |
691858bbbd5d9926c16ebfc61f64f4da
|
|
| BLAKE2b-256 |
0c4fea7bbb40dc55c5288a7d683d29bac82eac3063083d060ca152f0981d9969
|
Provenance
The following attestation bundles were made for opensips-0.1.7.tar.gz:
Publisher:
pypi.yml on OpenSIPS/python-opensips
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opensips-0.1.7.tar.gz -
Subject digest:
8c8dc571136fd1fa84f5d83e5098a43ca7f5ee5f9314b139234a129c2792fb9f - Sigstore transparency entry: 727319311
- Sigstore integration time:
-
Permalink:
OpenSIPS/python-opensips@5a34cda180d303d3bf9dd6be17dcb53a411ecdeb -
Branch / Tag:
refs/tags/0.1.7 - Owner: https://github.com/OpenSIPS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@5a34cda180d303d3bf9dd6be17dcb53a411ecdeb -
Trigger Event:
push
-
Statement type:
File details
Details for the file opensips-0.1.7-py3-none-any.whl.
File metadata
- Download URL: opensips-0.1.7-py3-none-any.whl
- Upload date:
- Size: 39.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0e898237c141bd215cfc9027ef19f0c2c06623740132e1cf1added3e815fe15
|
|
| MD5 |
2712d804d6cf4c6a8cbdbb8ecaad6f65
|
|
| BLAKE2b-256 |
af28fd7f2de518e9fc124854f5a0ee9f17f82dfb6ed2f7bb5291b9d218b33268
|
Provenance
The following attestation bundles were made for opensips-0.1.7-py3-none-any.whl:
Publisher:
pypi.yml on OpenSIPS/python-opensips
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opensips-0.1.7-py3-none-any.whl -
Subject digest:
f0e898237c141bd215cfc9027ef19f0c2c06623740132e1cf1added3e815fe15 - Sigstore transparency entry: 727319321
- Sigstore integration time:
-
Permalink:
OpenSIPS/python-opensips@5a34cda180d303d3bf9dd6be17dcb53a411ecdeb -
Branch / Tag:
refs/tags/0.1.7 - Owner: https://github.com/OpenSIPS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@5a34cda180d303d3bf9dd6be17dcb53a411ecdeb -
Trigger Event:
push
-
Statement type: