Add new tests to validate O1
[it/dep.git] / smo-install / test / pythonsdk / src / oransdk / a1sim / a1sim.py
1 #!/usr/bin/env python3
2 ###
3 # ============LICENSE_START=======================================================
4 # ORAN SMO PACKAGE - PYTHONSDK TESTS
5 # ================================================================================
6 # Copyright (C) 2021-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 """Oran A1 Simulator module."""
25
26 from onapsdk.onap_service import OnapService
27
28 class A1sim(OnapService):
29     """Oran A1 Simulator library."""
30
31     @classmethod
32     def check_version(cls, base_url) -> str:
33         """
34         Return ric version.
35
36         Args:
37            base_url: the base url of the ric
38
39         Returns:
40             the ric version
41
42         """
43         url = f"{base_url}/counter/interface"
44         version = cls.send_message('GET',
45                                    'Get ric version',
46                                    url)
47         return version
48
49     @classmethod
50     def check_status(cls, url) -> str:
51         """
52         Return ric status.
53
54         Args:
55            url: the url of the ric
56
57         Returns:
58             the ric status
59
60         """
61         url = f"{url}"
62         status = cls.send_message('GET',
63                                   'Get ric status',
64                                   url)
65         return status
66
67     @classmethod
68     def get_policy_number(cls, url) -> str:
69         """
70         Policy numbers for ric.
71
72         Args:
73            url: the url of the ric
74
75         Returns:
76             the policy numbers for ric
77
78         """
79         url = f"{url}/counter/num_instances"
80         policy_number = cls.send_message('GET',
81                                          'Get policy numbers for ric',
82                                          url)
83         return policy_number
84
85     @classmethod
86     def create_policy_type(cls,
87                            url,
88                            policy_type_id,
89                            policy_type_data) -> None:
90         """
91         Create topic in Dmaap.
92
93         Args:
94            url: the url of the ric
95            policy_type_num: the policy type id
96            policy_type_data: the policy type data in binary format
97
98         """
99         url = f"{url}/policytype?id={policy_type_id}"
100         cls.send_message('PUT',
101                          'Create Policy Type',
102                          url,
103                          data=policy_type_data,
104                          headers={"Accept":"application/json", "Content-Type":"application/json"})