Skip to content

Commit

Permalink
Reverting to the state of the project at commit 33e4109 (clean branch…
Browse files Browse the repository at this point in the history
… master)
  • Loading branch information
rimarala committed Oct 29, 2021
1 parent c48c9bf commit 31a4f76
Show file tree
Hide file tree
Showing 71 changed files with 16 additions and 16,776 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ __pycache__/

# C extensions
*.so
.idea

# Distribution / packaging
.Python
env/
Expand Down
54 changes: 8 additions & 46 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*************
Evolved5G CLI & SDK
Evolved5G_CLI
*************


Expand All @@ -14,7 +14,7 @@ Evolved5G CLI & SDK



Evolved5G CLI prototype
Evolved5G CLI prototype


* Free software: Apache Software License 2.0
Expand All @@ -26,7 +26,6 @@ Features

* Generate a new python NetApp from a template
* Assist in connecting the new NetApp & repo with EVOLVED-5G CI/CD pipeline
* SDK Libraries for interacting with the 5G-API

============
Installation
Expand Down Expand Up @@ -79,9 +78,10 @@ Once you have a copy of the source, you can install it with:
.. _tarball: https://github.com/EVOLVED-5G/SDK-CLI/tarball/master

============
CLI Usage
Usage
============


Run the following command to access the documentation/help page and read about the various options

.. code-block:: console
Expand All @@ -96,56 +96,18 @@ To generate a new NetApp project run the following command. You will be asked fo
.. code-block:: console
$ evolved5g generate
or to learn more about the available options

.. code-block:: console
$ evolved5g generate --help
============
SDK - Libraries
============

At the current release the SDK contains one class "**LocationSubscriber**"
that allows you to track devices and retrieve updates about their location.
You can use LocationSubscriber to create subscriptions, where each one of them can be used to track a device.

Examples of usage /Have a look at the code
----
Have a look at the examples folder for code samples on how to use the SDK Library.

`Location subscriber example <https://github.com/EVOLVED-5G/SDK-CLI/blob/libraries/examples/location_subscriber_examples.py>`_

Prerequisites / How to start
----

Install the requirements_dev.txt

pip install -r requirements_dev.txt

Make sure you have initiated the NEF_EMULATOR at url http://localhost:8888 (See `here <https://github.com/EVOLVED-5G/NEF_emulator>`_ for instructions),
you have logged in to the interface, clicked on the map and have started the simulation.
Then run a webserver in order to capture the callback post requests from NEF EMULATOR: On the terminal run the following commands to initiaze the webserver.


export FLASK_APP=/home/user/evolved-5g/SDK-CLI/examples/api.py

export FLASK_ENV=development

python -m flask run --host=0.0.0.0

where FLASK_APP should point to the absolute path of the SDK-CLI/examples/api.py file.
These commands will initialize a web server at http://127.0.0.1:5000/

Now you can run `Location subscriber example <https://github.com/EVOLVED-5G/SDK-CLI/blob/libraries/examples/location_subscriber_examples.py>`_
You should be able to view the location updates, printed in the terminal that runs the FLASK webserver
Credits
-------

This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
3 changes: 1 addition & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Welcome to Evolved5G_CLI's documentation!

readme
installation
cli
libraries
usage
modules
contributing
history
Expand Down
37 changes: 0 additions & 37 deletions docs/libraries.rst

This file was deleted.

7 changes: 4 additions & 3 deletions docs/cli.rst → docs/usage.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
============
CLI
Usage
============


Expand All @@ -17,9 +17,10 @@ To generate a new NetApp project run the following command. You will be asked fo
.. code-block:: console
$ evolved5g generate
or to learn more about the available options

.. code-block:: console
$ evolved5g generate --help
150 changes: 1 addition & 149 deletions evolved5g/sdk.py
Original file line number Diff line number Diff line change
@@ -1,149 +1 @@
"""SDK module"""
from evolved5g import swagger_client
from evolved5g.swagger_client import MonitoringEventAPIApi, \
MonitoringEventSubscriptionCreate, MonitoringEventSubscription

"""
This SKD class allows you to track devices and retrieve updates about their location.
You can create subscriptions where each one of them can be used to track a device.
A notification is sent to a callback url you will provide, everytime the user device changes Cell
"""


class LocationSubscriber:

def __init__(self, host: str, bearer_access_token: str):
"""
Initializes class LocationSubscriber
:param str host: The url of the 5G-API
:param str bearer_access_token: The beared access token that will be used to authenticate with the 5G-API
"""
configuration = swagger_client.Configuration()
configuration.host = host
configuration.access_token = bearer_access_token
api_client = swagger_client.ApiClient(configuration=configuration)
self.monitoring_event_api = MonitoringEventAPIApi(api_client)

def __create_subscription_request(self,
external_id,
msisdn,
ipv4_addr,
ipv6_addr,
notification_destination,
maximum_number_of_reports,
monitor_expire_time) -> MonitoringEventSubscriptionCreate:
monitoring_type = "LOCATION_REPORTING"
return MonitoringEventSubscriptionCreate(external_id,
msisdn,
ipv4_addr,
ipv6_addr,
notification_destination,
monitoring_type,
maximum_number_of_reports,
monitor_expire_time)

def create_subscription(self,
netapp_id: str,
external_id,
misisdn,
ipv4_addr,
ipv6_addr,
notification_destination,
maximum_number_of_reports,
monitor_expire_time):
"""
Creates a subscription that will be used to retrieve Location information about a device.
:param str external_id: string (The ID of the Netapp that creates a subscription)
:param str external_id: Globally unique identifier containing a Domain Identifier and a Local Identifier. <Local Identifier>@<Domain Identifier>
:param str misisdn: Mobile Subscriber ISDN number that consists of Country Code, National Destination Code and Subscriber Number.
:param str ipv4_addr: String identifying an Ipv4 address
:param ipv6_addr: String identifying an Ipv6 address.
:param notification_destination: The url that you will notifications about the location of the user
:param maximum_number_of_reports: Identifies the maximum number of event reports to be generated. Value 1 makes the Monitoring Request a One-time Request
:param monitor_expire_time: Identifies the absolute time at which the related monitoring event request is considered to expire
"""
body = self.__create_subscription_request(external_id,
misisdn,
ipv4_addr,
ipv6_addr,
notification_destination,
maximum_number_of_reports,
monitor_expire_time)

# a monitoring event report
response = self.monitoring_event_api.create_item_api_v13gpp_monitoring_event_v1_scs_as_id_subscriptions_post(
body,
netapp_id)
return response

def update_subscription(self,
netapp_id: str,
subscription_id: str,
external_id,
misisd,
ipv4_addr,
ipv6_addr,
notification_destination,
maximum_number_of_reports,
monitor_expire_time) -> MonitoringEventSubscription:
"""
Creates a subscription that will be used to retrieve Location information about a device.
:param str netapp_id: string (The ID of the Netapp that creates a subscription)
:param str subscription_id: string (Identifier of the subscription resource)
:param str external_id: Globally unique identifier containing a Domain Identifier and a Local Identifier. <Local Identifier>@<Domain Identifier>
:param str misisdn: Mobile Subscriber ISDN number that consists of Country Code, National Destination Code and Subscriber Number.
:param str ipv4_addr: String identifying an Ipv4 address
:param ipv6_addr: String identifying an Ipv6 address.
:param notification_destination: The url that you will notifications about the location of the user
:param maximum_number_of_reports: Identifies the maximum number of event reports to be generated. Value 1 makes the Monitoring Request a One-time Request
:param monitor_expire_time: Identifies the absolute time at which the related monitoring event request is considered to expire
"""
body = self.__create_subscription_request(external_id,
misisd,
ipv4_addr,
ipv6_addr,
notification_destination,
maximum_number_of_reports,
monitor_expire_time)

return self.monitoring_event_api.update_item_api_v13gpp_monitoring_event_v1_scs_as_id_subscriptions_subscription_id_put(
body, netapp_id, subscription_id)

def get_all_subscriptions(self, netapp_id: str,skip:int =0, limit: int=100):
"""
Reads all active subscriptions
:param skip: The number of subscriptions to skip
:param limit: The maximum number of transcriptions to return
:param str netapp_id: string (The ID of the Netapp that creates a subscription)
"""

return self.monitoring_event_api.read_active_subscriptions_api_v13gpp_monitoring_event_v1_scs_as_id_subscriptions_get(
netapp_id,
skip=skip,
limit=limit)

def get_subscription(self, netapp_id: str, subscription_id: str) -> MonitoringEventSubscription:
"""
Gets subscription by id
:param str netapp_id: string (The ID of the Netapp that creates a subscription)
:param str subscription_id: string (Identifier of the subscription resource)
"""
return self.monitoring_event_api.read_item_api_v13gpp_monitoring_event_v1_scs_as_id_subscriptions_subscription_id_get(
netapp_id,
subscription_id)

def delete_subscription(self, netapp_id: str, subscription_id: str):
"""
Delete a subscription
:param str netapp_id: string (The ID of the Netapp that creates a subscription)
:param str subscription_id: string (Identifier of the subscription resource)
"""
return self.monitoring_event_api.delete_item_api_v13gpp_monitoring_event_v1_scs_as_id_subscriptions_subscription_id_delete(
netapp_id,
subscription_id)
"""SDK module"""
Loading

0 comments on commit 31a4f76

Please sign in to comment.