6 sys.path.insert(0, './')
8 import ricxappframe.xapp_rest as ricrest
10 def respPostHandler(name, path, data, ctype):
14 response = ricrest.initResponse()
15 response['payload'] = ('{ "SubscriptionResponse": {'
16 '"SubscriptionId": "testing",'
17 '"SubscriptionInstances": [{'
18 '"XappEventInstanceID": "16253",'
19 '"E2EventInstanceID": "1241"'
26 def respSymptomGetHandler(name, path, data, ctype):
29 response = ricrest.initResponse()
30 response['payload'] = ('[{"service" : "xapp-test"}]')
31 print(json.loads(response['payload']))
34 def respGetHandler(name, path, data, ctype):
37 response = ricrest.initResponse()
38 response['payload'] = ('{ "SubscriptionList": [{'
39 '"SubscriptionId": "12345",'
40 '"Meid": "gnb123456",'
41 '"ClientEndpoint": ["127.0.0.1:4056"],'
42 '"SubscriptionInstances": [{'
43 '"XappEventInstanceID": "16253",'
44 '"E2EventInstanceID": "1241"'
50 def respDeleteHandler(name, path, data, ctype):
53 response = ricrest.initResponse()
54 response['payload'] = ('{}')
57 if __name__ == "__main__":
58 parser = argparse.ArgumentParser()
59 parser.add_argument('-port', dest='port', help='HTTP rest server listen port', required=False, type=int)
60 parser.add_argument('-address', dest='address', help='HTTP rest IP listen address, default all interfaces', required=False, type=str)
62 args = parser.parse_args()
66 if args.address is None:
67 args.address = "0.0.0.0"
69 # create the thread HTTP server
70 server = ricrest.ThreadedHTTPServer(args.address, args.port)
71 # trick to get the own handler with defined
72 server.handler.add_handler(server.handler, "GET", "response", "/ric/v1/subscriptions", respGetHandler)
73 server.handler.add_handler(server.handler, "DELETE", "delete", "/ric/v1/subscriptions/", respDeleteHandler)
74 server.handler.add_handler(server.handler, "GET", "lwsdget", "/ric/v1/lwsd", respSymptomGetHandler)
75 server.handler.add_handler(server.handler, "POST", "lwsdpost", "/ric/v1/lwsd", respSymptomGetHandler)
76 server.handler.add_handler(server.handler, "POST", "responsepost", "/ric/v1", respPostHandler)
77 # for symptomdata subscription