f5c6239b54239a7795cb90b1e5497bfc6e9006ed
[it/dep.git] / smo-install / test / pythonsdk / src / oransdk / a1sim / a1sim.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 # SPDX-License-Identifier: Apache-2.0
4 """Oran A1 Simulator module."""
5
6 from onapsdk.onap_service import OnapService
7
8 class A1sim(OnapService):
9     """Oran A1 Simulator library."""
10
11     @classmethod
12     def check_version(cls, base_url) -> str:
13         """
14         Return ric version.
15
16         Args:
17            base_url: the base url of the ric
18
19         Returns:
20             the ric version
21
22         """
23         url = f"{base_url}/counter/interface"
24         version = cls.send_message('GET',
25                                    'Get ric version',
26                                    url)
27         return version
28
29     @classmethod
30     def check_status(cls, url) -> str:
31         """
32         Return ric status.
33
34         Args:
35            url: the url of the ric
36
37         Returns:
38             the ric status
39
40         """
41         url = f"{url}"
42         status = cls.send_message('GET',
43                                   'Get ric status',
44                                   url)
45         return status
46
47     @classmethod
48     def get_policy_number(cls, url) -> str:
49         """
50         Policy numbers for ric.
51
52         Args:
53            url: the url of the ric
54
55         Returns:
56             the policy numbers for ric
57
58         """
59         url = f"{url}/counter/num_instances"
60         policy_number = cls.send_message('GET',
61                                          'Get policy numbers for ric',
62                                          url)
63         return policy_number
64
65     @classmethod
66     def create_policy_type(cls,
67                            url,
68                            policy_type_id,
69                            policy_type_data) -> None:
70         """
71         Create topic in Dmaap.
72
73         Args:
74            url: the url of the ric
75            policy_type_num: the policy type id
76            policy_type_data: the policy type data in binary format
77
78         """
79         url = f"{url}/policytype?id={policy_type_id}"
80         cls.send_message('PUT',
81                          'Create Policy Type',
82                          url,
83                          data=policy_type_data,
84                          headers={"Accept":"application/json", "Content-Type":"application/json"})