3 # ============LICENSE_START=======================================================
4 # ORAN SMO PACKAGE - PYTHONSDK TESTS
5 # ================================================================================
6 # Copyright (C) 2021-2022 AT&T Intellectual Property. All rights
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
13 # http://www.apache.org/licenses/LICENSE-2.0
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 # ===================================================================
25 """ONAP A1 Policy Management."""
27 from typing import Dict
28 from onapsdk.onap_service import OnapService
29 from oransdk.configuration import settings
31 class A1policymanagement(OnapService):
32 """A1 Policy Management library."""
34 base_url = settings.A1_POLICY_MANAGEMENT_URL
35 header = {"Accept":"application/json", "Content-Type":"application/json"}
38 def check_status(cls) -> str:
40 Get the status of the A1 policy management component.
43 the status of the A1 policy management component
46 url = f"{cls.base_url}/status"
47 status = cls.send_message('GET',
48 'Get A1 policy management status',
53 def get_policy_types(cls) -> Dict:
55 Get all the policy types.
58 the list of policy types
61 url = f"{cls.base_url}/policy_types"
62 policy_types = cls.send_message_json('GET',
63 'Get all the policy types',
68 def get_policy_type_agent(cls) -> Dict:
70 Get all the policy types from policy agent.
73 the list of policy types
76 url = f"{cls.base_url}/a1-policy/v2/policy-types"
77 policy_types = cls.send_message_json('GET',
78 'Get all the policy types from policy agent',
83 def get_policy(cls, policy_id) -> Dict:
91 the details of the policy
94 url = f"{cls.base_url}/a1-policy/v2/policies/{policy_id}"
95 policy = cls.send_message_json('GET',
96 'Get the policy with policy id',
102 def create_service(cls,
103 service_data) -> None:
108 service_data: the service data in binary format
111 url = f"{cls.base_url}/a1-policy/v2/services"
112 cls.send_message('PUT',
119 def create_policy(cls,
120 policy_data) -> None:
125 policy_data: the policy data in binary format
128 url = f"{cls.base_url}/a1-policy/v2/policies"
129 cls.send_message('PUT',