Add ORAN Python SDK first draft
[it/dep.git] / smo-install / test / pythonsdk / src / oransdk / sdnc / sdnc.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 # SPDX-License-Identifier: Apache-2.0
4 """Onap Sdnc module."""
5
6 from typing import Dict
7 from oransdk.configuration import settings
8 from onapsdk.sdnc.sdnc_element import SdncElement
9
10 class OranSdnc(SdncElement):
11     """SDNC library."""
12
13     base_url = settings.SDNC_URL
14
15     @classmethod
16     def get_status(cls) -> str:
17         """
18         Get status of SDNC component.
19
20         Returns:
21            the status of the SDNC component
22
23         """
24         url = f"{cls.base_url}/apidoc/explorer/"
25         status = cls.send_message('GET',
26                                   'Get status of SDNC component',
27                                   url)
28         return status
29
30     @classmethod
31     def get_odu_oru_status(cls,
32                            odu_node,
33                            oru_node,
34                            basic_auth: Dict[str, str]) -> dict:
35         """
36         Get status of SDNC component.
37
38         Args:
39            basic_auth: (Dict[str, str]) for example:{ 'username': 'bob', 'password': 'secret' }
40
41         Returns:
42            the status of the SDNC component
43
44         """
45         url = f"{cls.base_url}/rests/data/network-topology:network-topology/"\
46               + f"topology=topology-netconf/node={odu_node}/yang-ext:mount/"\
47               + f"o-ran-sc-du-hello-world:network-function/du-to-ru-connection={oru_node}"
48         status = cls.send_message_json('GET',
49                                        'Get status of Odu Oru connectivity',
50                                        url,
51                                        basic_auth=basic_auth)
52         return status