Fix/add use cases under SMO package
[it/dep.git] / smo-install / test / pythonsdk / src / oransdk / msb / msb_microservice.py
1 #!/usr/bin/env python3
2 ###
3 # ============LICENSE_START=======================================================
4 # ORAN SMO PACKAGE - PYTHONSDK TESTS
5 # ================================================================================
6 # Copyright (C) 2022 AT&T Intellectual Property. All rights
7 #                             reserved.
8 # ================================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12 #
13 # http://www.apache.org/licenses/LICENSE-2.0
14 #
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END============================================
21 # ===================================================================
22 #
23 ###
24 """Onap MSB module."""
25 from onapsdk.configuration import settings
26 from onapsdk.onap_service import OnapService
27 from onapsdk.utils.headers_creator import headers_msb_creator
28
29 class OranMsb(OnapService):
30     """MSB class."""
31
32     base_url = f"{settings.MSB_URL}/api/msdiscover/v1/services"
33     headers = headers_msb_creator(OnapService.headers)
34
35     def get_services(self) -> dict:
36         """
37         Get MSB instance services.
38
39         Returns:
40            the list of instance services
41
42         """
43         status = self.send_message_json('GET',
44                                         'Get status of MSB',
45                                         self.base_url,
46                                         headers=self.headers)
47         return status
48
49     def create_service(self, service_data) -> None:
50         """
51         Create an instance service.
52
53         Args:
54            service_data: the service to be created
55
56         """
57         self.send_message('POST', 'Create Instance Service', self.base_url, data=service_data, headers=self.headers)
58
59     def delete_service(self, service_name, version) -> None:
60         """
61         Delete an instance service.
62
63         Args:
64            service_name: the service to be deleted
65
66         """
67         url = f"{self.base_url}/{service_name}/version/{version}?namespace="
68         self.send_message('DELETE', 'Delete Instance Service', url, headers=self.headers)