X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=it%2Fdep.git;a=blobdiff_plain;f=smo-install%2Ftest%2Fpythonsdk%2Fsrc%2Foransdk%2Fmsb%2Fmsb_microservice.py;fp=smo-install%2Ftest%2Fpythonsdk%2Fsrc%2Foransdk%2Fmsb%2Fmsb_microservice.py;h=28004fc69a0a206c4cdaf725a3f6df737a1d61db;hp=0000000000000000000000000000000000000000;hb=bc6231f7d4d44ab5f269683c42eb90c2ce4ec9a6;hpb=f97b292fa01903c18b71ec8a549824c7ec3bea93 diff --git a/smo-install/test/pythonsdk/src/oransdk/msb/msb_microservice.py b/smo-install/test/pythonsdk/src/oransdk/msb/msb_microservice.py new file mode 100644 index 00000000..28004fc6 --- /dev/null +++ b/smo-install/test/pythonsdk/src/oransdk/msb/msb_microservice.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +### +# ============LICENSE_START======================================================= +# ORAN SMO PACKAGE - PYTHONSDK TESTS +# ================================================================================ +# Copyright (C) 2022 AT&T Intellectual Property. All rights +# reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END============================================ +# =================================================================== +# +### +"""Onap MSB module.""" +from onapsdk.configuration import settings +from onapsdk.onap_service import OnapService +from onapsdk.utils.headers_creator import headers_msb_creator + +class OranMsb(OnapService): + """MSB class.""" + + base_url = f"{settings.MSB_URL}/api/msdiscover/v1/services" + headers = headers_msb_creator(OnapService.headers) + + def get_services(self) -> dict: + """ + Get MSB instance services. + + Returns: + the list of instance services + + """ + status = self.send_message_json('GET', + 'Get status of MSB', + self.base_url, + headers=self.headers) + return status + + def create_service(self, service_data) -> None: + """ + Create an instance service. + + Args: + service_data: the service to be created + + """ + self.send_message('POST', 'Create Instance Service', self.base_url, data=service_data, headers=self.headers) + + def delete_service(self, service_name, version) -> None: + """ + Delete an instance service. + + Args: + service_name: the service to be deleted + + """ + url = f"{self.base_url}/{service_name}/version/{version}?namespace=" + self.send_message('DELETE', 'Delete Instance Service', url, headers=self.headers)