This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from EVOLVED-5G/CAPIF_backoffice_integration
CAPIF update internal resources
- Loading branch information
Showing
23 changed files
with
134 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/publisher.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import redis | ||
import sys | ||
from flask import current_app | ||
|
||
class Publisher(): | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/publisher.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import redis | ||
import sys | ||
|
||
class Publisher(): | ||
|
||
def __init__(self): | ||
self. r = redis.Redis(host='redis', port=6379, db=0) | ||
|
||
def publish_message(self, channel, message): | ||
self.r.publish(channel, message) |
4 changes: 3 additions & 1 deletion
4
services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/resources.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from abc import ABC, abstractmethod | ||
from ..db.db import MongoDatabse | ||
from .publisher import Publisher | ||
|
||
class Resource(ABC): | ||
|
||
def __init__(self): | ||
self.db = MongoDatabse() | ||
self.db = MongoDatabse() | ||
self.publish_ops = Publisher() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
services/TS29222_CAPIF_Publish_Service_API/published_apis/core/consumer_messager.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# subscriber.py | ||
import redis | ||
import time | ||
import sys | ||
import json | ||
import asyncio | ||
from threading import Thread | ||
from .internal_service_ops import InternalServiceOps | ||
from flask import current_app | ||
|
||
class Subscriber(): | ||
|
||
def __init__(self): | ||
self.r = redis.Redis(host='redis', port=6379, db=0) | ||
self.security_ops = InternalServiceOps() | ||
self.p = self.r.pubsub() | ||
self.p.subscribe("internal-messages") | ||
|
||
def listen(self): | ||
current_app.logger.info("Listening publish messages") | ||
for raw_message in self.p.listen(): | ||
if raw_message["type"] == "message" and raw_message["channel"].decode('utf-8') == "internal-messages": | ||
message, *ids = raw_message["data"].decode('utf-8').split(":") | ||
if message == "provider-removed": | ||
self.security_ops.delete_intern_service(ids[1]) | ||
|
||
|
||
|
||
|
13 changes: 13 additions & 0 deletions
13
services/TS29222_CAPIF_Publish_Service_API/published_apis/core/internal_service_ops.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
from flask import current_app | ||
from .resources import Resource | ||
|
||
class InternalServiceOps(Resource): | ||
|
||
def delete_intern_service(self, apf_id): | ||
|
||
current_app.logger.info("Provider removed, removing services published by APF") | ||
mycol = self.db.get_col_by_name(self.db.service_api_descriptions) | ||
my_query = {'apf_id': apf_id} | ||
mycol.delete_many(my_query) | ||
current_app.logger.info("Removed service") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters