{"id":16212538,"url":"https://github.com/p4irin/sbc_rest_client","last_synced_at":"2025-09-03T21:40:24.883Z","repository":{"id":200676557,"uuid":"681006510","full_name":"p4irin/sbc_rest_client","owner":"p4irin","description":"A REST client for the Oracle Communications Session Border Controller","archived":false,"fork":false,"pushed_at":"2025-02-21T12:29:49.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T16:04:57.383Z","etag":null,"topics":["acme-packet","api-client","configuration-management","iptelephony","oracle-communications","python","rest-api","restapi","session-border-controller","sip","voip"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p4irin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-21T04:06:56.000Z","updated_at":"2025-02-21T12:29:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"cce1ed5e-a2fd-434d-b6d5-5408e78bb3bd","html_url":"https://github.com/p4irin/sbc_rest_client","commit_stats":null,"previous_names":["p4irin/sbc_rest_client"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/p4irin/sbc_rest_client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fsbc_rest_client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fsbc_rest_client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fsbc_rest_client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fsbc_rest_client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p4irin","download_url":"https://codeload.github.com/p4irin/sbc_rest_client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fsbc_rest_client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273516324,"owners_count":25119763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acme-packet","api-client","configuration-management","iptelephony","oracle-communications","python","rest-api","restapi","session-border-controller","sip","voip"],"created_at":"2024-10-10T10:52:52.760Z","updated_at":"2025-09-03T21:40:24.874Z","avatar_url":"https://github.com/p4irin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sbc_rest_client - v0.1.1\n\nThis Python package provides a REST client class allowing you to remotely\nscript the management of an Oracle Communications Session Border Controller\nvia its REST API. Not all API calls are implemented! Only the ones I needed\nat the time and some I included randomly on the go. Feel free to have a go\nat it and add the calls you're missing.\n\n## Stack\n\n- Oracle Communications Session Border Controller\n  - Acme Packet OS VM SCZ8.3.0 MR-1 Patch 9 (Build 400)\n    Oracle Linux branches-7/el7-u8 {2020-04-08T07:00:00+0000}\n    Build Date=07/17/20\n- Ubuntu: 20.04.2 LTS\n- Python: 3.8.10\n- letsencrypt certificate\n- Visual Studio Code\n\n## Implemented API calls\n\nFor reference consult [REST API for Session Border Controller Release 8.3](https://docs.oracle.com/en/industries/communications/session-border-controller/8.3.0/rest/index.html)\n\nOperation | Method or property | Returns | Description\n---------|----------|---------|---------\n Request an access token | _get_token() | `None`. _Gets_ and _sets_ an access token on an `Sbc` object | This is done under the hood when instantiating an `Sbc` object. You do not call this method directly.\n Get system status information | @property role | A string value of either `standalone`, `active` or `standby`. Or, `False` if the API request failed | Get the role of a Session Border Controller\n Reboot the system | reboot() | A `bool` indicating the succes of the operation |\n Execute HA switchover | switchover() | A `bool` indicating the succes of the operation |\n Get supported REST API versions | @property supported_rest_api_versions() | A list of supported API versions |\n Get various statistics | @property global_cps | Global calls per second |\n | | @property global_con_sessions | The global number of connected sessions |\n Get the metadata for a configuration element type | config_element_key_attributes(self, element_type: str) | A list of a configuration element's _key_ attributes | _Key_ attributes uniquely identify configuration elements. You need them to update configuration elements. [ see update_config_element() ]. _element_type_ specifies the type of the element for which you want to get the _key_ attributes.\n Get one or more configuration element instances | get_config_elements(self, element_type: str, key_attribs: str = None) | `None`. Prints the configuration element instances to console | Specify the _element_type_ and _key_attribs_ of the configuration elements. _key_attribs_ is a string of query parameters that represent the _key_ attributes. E.g., \u0026name1=value1\u0026name2=value2. The string MUST start with an \u0026.\nLock the configuration | lock() | A `bool` indicating the succes of the operation |\nUnlock the configuration | unlock() | A `bool` indicating the succes of the operation |\nUpdate a single configuration element instance | update_config_element(self, xml_str: str) | A `bool` indicating the succes of the operation | To identify a configuration element you need to set the key attributes in _xml_str_. [Also see self.config_element_key_attributes()] and a usage example below.\nBack up or activate a configuration, Save, verify or restore a configuration | activate_config() | A `bool` indicating the succes of the operation | This will _verify_ and _save_ the configuration behind the scenes before it's _activated_\nAdd configuration element instance | add_config_element(self, xml_str: str) | A bool Indicating succes of the operation | To identify a configuration element you need to set the key attributes in xml_str. [Also see self.config_element_key_attributes()] [Important note on singletons](https://docs.oracle.com/en/industries/communications/session-border-controller/8.3.0/rest/op-rest-version-configuration-configelements-post.html#:~:text=If%20the%20configuration,already%2Dconfigured%20instance.)\nDelete configuration element instance | delete_config_element(self, element_type: str, key_attribs: Union[str, None] = None | A bool indicating succes or failure |\n\n## Installation\n\nCreate your new project directory and cd into it.\n```bash\n$ mkdir new_project\n$ cd new_project\n$\n```\nCreate a virtual environment and activate it.\n```bash\n$ python3 -m venv venv\n$ source venv/bin/activate\n(venv) $\n```\npip install from GitHub.\n```bash\n(venv) $ pip install git+https://github.com/p4irin/sbc_rest_client.git\n```\nVerify in a REPL. Replace \"admin\", \"password\" and \"sbc.example.com\" with your credentials and SBC hostname.\n```bash\n(venv) $ python\nPython 3.8.10 (default, Jun  2 2021, 10:49:15) \n[GCC 9.4.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e from sbc_rest_client.sbc import Sbc\n\u003e\u003e\u003e sbc = Sbc(\"admin\", \"password\", \"sbc.example.com\")\nGet a token from sbc.example.com: Ok!\n\u003e\u003e\u003e sbc.role\n'standalone'\n\u003e\u003e\u003e sbc.global_con_sessions\n'13'\n\u003e\u003e\u003e\n```\n\n### Notes\n\n- I used a letsencrypt certificate on the Session Border Controller.\nThe letsencrypt root ca is installed allongside and used by the sbc_rest_client package.\n- The Session Border Controller needs a reboot for the webserver to notice a TLS certificate update!\n\n## Usage examples\n\nIn general, you will follow these steps for configuration management related operations:\n\n1. Instantiate an Sbc object\n1. Lock the configuration\n1. Execute configuration changes\n1. Activate the configuration\n1. Unlock the configuration\n\nThe moment you instantiate an `Sbc` object an access token is acquired. The token is used behind the scenes to authenticate all your API calls. From this point you should lock the configuration, make your changes, activate it and finally unlock it.\n\nFor admin related operations locking and unlocking is not required.\n\n### Import\n\nFirst things first. This applies to and should precede all standalone examples below.\n\n```python\nfrom sbc_rest_client.sbc import Sbc\n\n\n# Use your credentials and the hostname or ip address of your Oracle Communications Session Border Controller\nsbc = Sbc(\"\u003cyour admin user\u003e\", \"\u003cyour password\u003e\", \"\u003csbc.your-domain.com\u003e\")\n\n# Verification of the letsencrypt TLS certificate I used on the\n# Session Border Controller is enabled by default\n# If you're using a self signed or other certificate you\n# can disable this by passing \"verify=False\".\n\n# sbc = Sbc(\"\u003cyour admin user\u003e\", \"\u003cyour password\u003e\", \"\u003csbc.your-domain.com\u003e\", verify=False)\n\n# Disabling certificate verification causes a bunch of SSL warnings\n# on the console. To suppress those, pass \"ssl_warnings=False\"\n\n# sbc = Sbc(\"\u003cyour admin user\u003e\", \"\u003cyour password\u003e\", \"\u003csbc.your-domain.com\u003e\", ssl_warnings=False, verify=False)\n```\n\nLet's start with some simple admin examples. As said, these don't need configuration locking.\n\n### Reboot an SBC\n\n```python\nif sbc.reboot():\n  print(\"Rebooting the SBC\")\nelse:\n  print(\"Something went wrong\")\n```\n\n### Execute a switchover in a High Availability setup\n\n```python\nif sbc.switchover():\n  print(\"Switching the active SBC\")\nelse:\n  print(\"Something went wrong)\n```\n\n### Change a configuration element\n\n```python\n# Decide what needs to be updated\n# Here, a session-group is modified\n# The attribute \"group-name\" is a key attribute and identifies the element\n# to be changed. Use the helper methods config_element_key_attributes and\n# get_config_elements to figure out which key attributes you need\n# and the structure and nodes of the configElement.\n# Notice, in the xml, that you only need to include the attributes\n# you want to have changed\nxml = \"\"\"\u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n  \u003cconfigElement\u003e\n    \u003celementType\u003esession-group\u003c/elementType\u003e\n    \u003cattribute\u003e\n      \u003cname\u003egroup-name\u003c/name\u003e\n      \u003cvalue\u003esg_proxies\u003c/value\u003e\n    \u003c/attribute\u003e\n    \u003cattribute\u003e\n      \u003cname\u003edest\u003c/name\u003e\n      \u003cvalue\u003eproxy1.example.com\u003c/value\u003e\n      \u003cvalue\u003eproxy2.example.com\u003c/value\u003e\n    \u003c/attribute\u003e\n  \u003c/configElement\u003e\n\"\"\"\n\n# Acquire a configuration lock and exit on failure\nif not sbc.lock():\n    print(\"Error: Failed to lock the config.! Exiting!\")\n    exit(1)\n\n# Update an element\nif not sbc.update_config_element(xml):\n    print(\"Error: Failed to update configuration element!\")\n\n# Activate the change\nif not sbc.activate_config(): print(\"Error: Failed to activate config.!\")\n\n# Free the lock\nif not sbc.unlock(): print(\n    \"Error: Failed to unlock config.\"\n)\n```\n\n## Notes\n\n- I've set the default api version used to _v1.1_. The API reference mentions a _v1.0_ but does not elaborate on it at all other than that it's in the output of the _supportedversions_ operation. Like, what are the differences or when and why to use or prefer one over the other. The reference examples use _v1.1_ so let's stick to that.\n- An access token is valid for 10 minutes. This is not accounted for. The scripts I use don't last that long so I didn't bother to handle token expiry. \n\n## Reference\n\n- [REST API for Session Border Controller Release 8.3](https://docs.oracle.com/en/industries/communications/session-border-controller/8.3.0/rest/index.html)\n- [Requests: HTTP for Humans](https://requests.readthedocs.io/en/latest/)\n- [XML and HTML with Python](https://lxml.de/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4irin%2Fsbc_rest_client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp4irin%2Fsbc_rest_client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4irin%2Fsbc_rest_client/lists"}