2 # -*- coding: utf-8 -*-
3 # SPDX-License-Identifier: Apache-2.0
4 """ONAP A1 Policy Management."""
6 from typing import Dict
7 from oransdk.configuration import settings
8 from onapsdk.onap_service import OnapService
10 class A1policymanagement(OnapService):
11 """A1 Policy Management library."""
13 base_url = settings.A1_POLICY_MANAGEMENT_URL
14 header = {"Accept":"application/json", "Content-Type":"application/json"}
17 def check_status(cls) -> str:
19 Get the status of the A1 policy management component.
22 the status of the A1 policy management component
25 url = f"{cls.base_url}/status"
26 status = cls.send_message('GET',
27 'Get A1 policy management status',
32 def get_policy_types(cls) -> Dict:
34 Get all the policy types.
37 the list of policy types
40 url = f"{cls.base_url}/policy_types"
41 policy_types = cls.send_message_json('GET',
42 'Get all the policy types',
47 def get_policy_type_agent(cls) -> Dict:
49 Get all the policy types from policy agent.
52 the list of policy types
55 url = f"{cls.base_url}/a1-policy/v2/policy-types"
56 policy_types = cls.send_message_json('GET',
57 'Get all the policy types from policy agent',
62 def get_policy(cls, policy_id) -> Dict:
70 the details of the policy
73 url = f"{cls.base_url}/a1-policy/v2/policies/{policy_id}"
74 policy = cls.send_message_json('GET',
75 'Get the policy with policy id',
81 def create_service(cls,
82 service_data) -> None:
87 service_data: the service data in binary format
90 url = f"{cls.base_url}/a1-policy/v2/services"
91 cls.send_message('PUT',
98 def create_policy(cls,
104 policy_data: the policy data in binary format
107 url = f"{cls.base_url}/a1-policy/v2/policies"
108 cls.send_message('PUT',