Skip to content

Commit 7c188ca

Browse files
authored
Merge pull request #9 from CloudBoltSoftware/v2023.1.1
Added get_key_value_objects function
2 parents 96c741e + c717cdc commit 7c188ca

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

onefuse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
Enables the execution of OneFuse policies via Python
55
"""
66

7-
__version__ = "2022.3.2"
7+
__version__ = "2023.1.1"
88
__credits__ = 'Cloudbolt Software, Inc.'

onefuse/cloudbolt_admin.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,34 @@ def get_matching_properties(self, prefix, properties_stack):
592592
self.logger.debug(f'Returning matching_properties: '
593593
f'{matching_properties}')
594594
return matching_properties
595+
596+
def get_key_value_objects(self, prefix, properties_stack):
597+
"""
598+
From a dict, return a list of key-value objects,
599+
that match the input prefix
600+
601+
Parameters
602+
----------
603+
prefix: str
604+
Prefix to search for. Ex: OneFuse_NamingPolicy_
605+
properties_stack: dict
606+
A dict containing all properties from the CB resource
607+
"""
608+
key_value_objects = []
609+
pattern = re.compile(prefix)
610+
for key in properties_stack.keys():
611+
result = pattern.match(key)
612+
if result is not None:
613+
suffix = key[len(prefix):]
614+
key_value_object = {
615+
"key": key,
616+
"value": properties_stack[key],
617+
"suffix": suffix
618+
}
619+
key_value_objects.append(key_value_object)
620+
self.logger.debug(f'Returning key_value_objects: '
621+
f'{key_value_objects}')
622+
return key_value_objects
595623

596624
def delete_output_job_results(self, managed_object, run_type):
597625
"""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='onefuse',
8-
version='2022.3.2',
8+
version='2023.1.1',
99
author='Cloudbolt Software, Inc.',
1010
author_email='[email protected]',
1111
description='OneFuse upstream provider package for Python',

0 commit comments

Comments
 (0)