From 83cc48138faad8b76ce05e4c48c9e4e564c619e8 Mon Sep 17 00:00:00 2001 From: PrasadhNanjundan Date: Mon, 9 Jun 2025 16:22:49 +0530 Subject: [PATCH] CCLA-871: save pops sdk --- msa_sdk/msa_api.py | 11 +++++------ msa_sdk/pops.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 msa_sdk/pops.py diff --git a/msa_sdk/msa_api.py b/msa_sdk/msa_api.py index 7b3b0a1..57ea89b 100644 --- a/msa_sdk/msa_api.py +++ b/msa_sdk/msa_api.py @@ -9,7 +9,6 @@ from msa_sdk import constants from msa_sdk import context -from msa_sdk.variables import Variables logger = logging.getLogger("msa-sdk") @@ -93,7 +92,7 @@ def task_error(cls, comment, context, log_response=True): ---------- comment: String Comment - new_params: Dictionary + context: Dictionary Context log_response: Bool Write log to a file @@ -117,7 +116,7 @@ def task_success(cls, comment, context, log_response=True): ---------- comment: String Comment - new_params: Dictionary + context: Dictionary Context log_response: Bool Write log to a file @@ -193,10 +192,10 @@ def _call_post(self, data=None, timeout=60): if data is None: data = {} - if isinstance(data, dict): + if isinstance(data, (dict, list)): data = json.dumps(data) else: - raise TypeError('Parameters needs to be a dictionary') + raise TypeError('Parameters needs to be a dictionary or a list') url = self.url + self.path self.response = requests.post(url, headers=headers, data=data, @@ -286,7 +285,7 @@ def add_trace_headers(self, headers): headers['X-B3-TraceId'] = context['TRACEID'] headers['X-B3-SpanId'] = context['SPANID'] - def log_to_process_file(self, processId: str, log_message: str) -> bool: + def log_to_process_file(self, process_id: str, log_message: str) -> bool: """ Write log string with ISO timestamp to process log file. diff --git a/msa_sdk/pops.py b/msa_sdk/pops.py new file mode 100644 index 0000000..6a89e35 --- /dev/null +++ b/msa_sdk/pops.py @@ -0,0 +1,29 @@ +"""Module Pops.""" + +from msa_sdk.msa_api import MSA_API + + +class Pops(MSA_API): + """Class Pops.""" + + def __init__(self): + """Initialize.""" + MSA_API.__init__(self) + self.api_path = "/sase/pops" + + def save_pops(self, data): + """ + Save all pops. + + Parameters + ---------- + data: pops data in json + + Returns + ------- + None + + """ + self.action = 'Save Pops' + self.path = '{}'.format(self.api_path) + self._call_post(data) \ No newline at end of file