<commit_before>API
===

The steps to obtain the API Token key and using the different curl commands are listen below.

Note: Make sure to to ssh into your serve to run these commands.

Getting Your Token
^^^^^^^^^^^^^^^^^^

.. code-block:: bash

  cat /opt/dsiprouter/gui/settings.py | grep API_TOKEN


Executing Kamailio stats API
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: bash
  
  curl -H "Authorization: Bearer $DSIP_TOKEN" 
  -X GET http://<addressOfYourInstance>:5000/api/v1/kamailio/stats

One Line Version:

.. code-block:: bash
  
  curl -H "Authorization: Bearer $DSIP_TOKEN" -X GET http://<addressOfYourInstance>:5000/api/v1/kamailio/stats


Executing Lease Point API
^^^^^^^^^^^^^^^^^^^^^^^^^
Getting the endlease

.. code-block:: bash
 
 curl -H "Authorization: Bearer $DSIP_TOKEN" -H "Content-Type: application/json" 
 -X GET "http://demo.dsiprouter.org:5000/api/v1/endpoint/lease?ttl=15&email=<EMAIL>"


One Line Version:

.. code-block:: bash

 curl -H "Authorization: Bearer $DSIP_TOKEN" -H "Content-Type: application/json" -X GET "http://demo.dsiprouter.org:5000/api/v1/endpoint/lease?ttl=15&email=<EMAIL>"

Revoking and replacing with your own lease ID

.. code-block:: bash
 
 curl -H "Authorization: Bearer $DSIP_TOKEN" -H "Content-Type: application/json" 
 -X PUT "http://demo.dsiprouter.org:5000/api/v1/endpoint/lease/<leaseid>/revoke"


One Line Version:

.. code-block:: bash

 curl -H "Authorization: Bearer $DSIP_TOKEN" -H "Content-Type: application/json" -X PUT "http://demo.dsiprouter.org:5000/api/v1/endpoint/lease/<leaseid>/revoke"<commit_msg>Update api.rst<commit_after>API
===

+----------+----------------+---------------------------+
| METHODS  | FUNCTIONS      | ENDPOINTS THEY SUPPORT    |
+==========+================+===========================+
| PUT      | Update existing| - /api/v1/endpoint/lease/ |
|          | information at | <int:leaseid>/revoke      |
|          | endpoint       |                           |
+----------+----------------+---------------------------+
| GET      | Get Information| - /api/v1/kamailio/stats/ |
|          | from Endpoint  | - /api/v1/endpoint/lease/ |
|          |                | - /api/v1/kamailio/reload/|
+----------+----------------+---------------------------+
| POST     | Create new     | - api/v1/endpoint/<int:id>|
|          | information at |                           |
|          | endpoint       |                           |
+----------+----------------+---------------------------+

The steps to obtain the API Token key and using the different curl commands are listen below.

Note: Make sure to to ssh into your serve to run these commands.

Getting Your Token
^^^^^^^^^^^^^^^^^^

::

  DSIP_TOKEN=$(cat /opt/dsiprouter/gui/settings.py | grep API_TOKEN | cut -d "'" -f 2)
|

Executing Kamailio stats API
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::
  
  curl -H "Authorization: Bearer $DSIP_TOKEN" 
  -X GET http://demo.dsiprouter.org:5000/api/v1/kamailio/stats
|

One Line Version:
::
  
  curl -H "Authorization: Bearer $DSIP_TOKEN" -X GET http://<addressOfYourInstance>:5000/api/v1/kamailio/stats
|

Executing Lease Point API
^^^^^^^^^^^^^^^^^^^^^^^^^
Getting the endlease
::
 
 curl -H "Authorization: Bearer $DSIP_TOKEN" -H "Content-Type: application/json" 
 -X GET "http://demo.dsiprouter.org:5000/api/v1/endpoint/lease?ttl=15&email=<EMAIL>"
|

One Line Version:
::

 curl -H "Authorization: Bearer $DSIP_TOKEN" -H "Content-Type: application/json" -X GET "http://demo.dsiprouter.org:5000/api/v1/endpoint/lease?ttl=15&email=<EMAIL>"
|

Revoking and replacing with your own lease ID

::
 
 curl -H "Authorization: Bearer $DSIP_TOKEN" -H "Content-Type: application/json" 
 -X PUT "http://demo.dsiprouter.org:5000/api/v1/endpoint/lease/1/revoke"
|

One Line Version:
::

 curl -H "Authorization: Bearer $DSIP_TOKEN" -H "Content-Type: application/json" -X PUT "http://demo.dsiprouter.org:5000/api/v1/endpoint/lease/1/revoke"
|
{'fraction_non_alphanumeric': 0.2288265306122449, 'fraction_numerical': 0.019387755102040816, 'mean_word_length': 2.607175712971481, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '287870', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1281, 'n_words': 298}