diff options
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/network_function.py')
-rwxr-xr-x | components/pm-subscription-handler/pmsh_service/mod/network_function.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/components/pm-subscription-handler/pmsh_service/mod/network_function.py b/components/pm-subscription-handler/pmsh_service/mod/network_function.py index f7b682d4..2404c8b8 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/network_function.py +++ b/components/pm-subscription-handler/pmsh_service/mod/network_function.py @@ -19,7 +19,7 @@ import re from mod import logger, db -from mod.api.db_models import NetworkFunctionModel +from mod.api.db_models import NetworkFunctionModel, NetworkFunctionFilterModel class NetworkFunction: @@ -167,6 +167,20 @@ class NetworkFunctionFilter: self.model_names = kwargs.get('modelNames') self.regex_matcher = re.compile('|'.join(raw_regex for raw_regex in self.nf_names)) + @staticmethod + def get_network_function_filter(sub_name): + """Gets the network function filter from the Database + + Args: + sub_name (string): The name of the subscription + + Returns: + NetworkFunctionFilter: Returns network function filter for sub_name + """ + nf_filter = NetworkFunctionFilterModel.query.filter( + NetworkFunctionFilterModel.subscription_name == sub_name).one_or_none() + return NetworkFunctionFilter(**nf_filter.serialize()) + def is_nf_in_filter(self, nf): """Match the nf fields against values in Subscription.nfFilter |