Fix/add use cases under SMO package
[it/dep.git] / smo-install / test / pythonsdk / src / oransdk / sdc / category_management.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 SDC Category Management module."""
25 import json
26 from onapsdk.sdc.category_management import ServiceCategory
27
28 class OranServiceCategory(ServiceCategory):
29     """Onap SDC Category Management module ."""
30
31     @classmethod
32     def create(cls, name: str) -> "BaseCategory":
33         """Create category instance.
34
35         Checks if category with given name exists and if it already
36             exists just returns category with given name.
37
38         Returns:
39             BaseCategory: Created category instance
40
41         """
42         category_obj: "BaseCategory" = cls(name)
43         if category_obj.exists():
44             return category_obj
45         cls.send_message_json("POST",
46                               f"Create {name} {cls.category_name()}",
47                               cls._base_create_url(),
48                               data=json.dumps({"name": name, "models": ["SDC AID"], "metadataKeys": []}),
49                               headers=cls.headers())
50         category_obj.exists()
51         return category_obj