X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=smo-install%2Ftest%2Fpythonsdk%2Fsrc%2Foransdk%2Fpolicy%2Fpolicy.py;h=304d6987ba047320d5de486d24e328e8b092ad3d;hb=7b4b4007db003d28ee347e3d373e8ac605581cb5;hp=a2d409f6a4c9a12b313ea356622d4027b5356538;hpb=a8414e7e44dea72da6f4f235e14f7fef59b4e266;p=it%2Fdep.git diff --git a/smo-install/test/pythonsdk/src/oransdk/policy/policy.py b/smo-install/test/pythonsdk/src/oransdk/policy/policy.py index a2d409f6..304d6987 100644 --- a/smo-install/test/pythonsdk/src/oransdk/policy/policy.py +++ b/smo-install/test/pythonsdk/src/oransdk/policy/policy.py @@ -64,8 +64,7 @@ class OranPolicy(OnapService): return status @classmethod - def get_policy_status(cls, - basic_auth: Dict[str, str]) -> Dict: + def get_policy_status(cls, basic_auth: Dict[str, str]) -> Dict: """ Get status of all the policies. @@ -81,11 +80,7 @@ class OranPolicy(OnapService): return status @classmethod - def get_policy(cls, - policy_type: PolicyType, - policy_name, - policy_version, - basic_auth: Dict[str, str]) -> Dict: + def get_policy(cls, policy_type: PolicyType, policy_name, policy_version, basic_auth: Dict[str, str]) -> Dict: """ Get the policy. @@ -96,22 +91,15 @@ class OranPolicy(OnapService): basic_auth: (Dict[str, str]) for example:{ 'username': 'bob', 'password': 'secret' } Returns: - the policy + the policy reponse """ - url = f"{cls.api_url}/policy/api/v1/policytypes/{policy_type.type}/versions/"\ - + f"{policy_type.version}/policies/{policy_name}/versions/{policy_version}" - policy = cls.send_message_json('GET', - 'Get the policy', - url, - basic_auth=basic_auth) - return policy + url = f"{cls.api_url}/policy/api/v1/policytypes/{policy_type.type}/versions/{policy_type.version}/policies/{policy_name}/versions/{policy_version}" + policy_response = cls.send_message('GET', 'Get the policy', url, basic_auth=basic_auth) + return policy_response @classmethod - def create_policy(cls, - policy_type: PolicyType, - policy_data, - basic_auth: Dict[str, str]) -> None: + def create_policy(cls, policy_type: PolicyType, policy_data, basic_auth: Dict[str, str]) -> None: """ Create a policy. @@ -121,19 +109,12 @@ class OranPolicy(OnapService): policy_data: the policy to be created, in binary format """ - url = f"{cls.api_url}/policy/api/v1/policytypes/{policy_type.type}/"\ - + f"versions/{policy_type.version}/policies" - cls.send_message('POST', - 'Create Policy', - url, - data=policy_data, - headers=cls.header, + url = f"{cls.api_url}/policy/api/v1/policytypes/{policy_type.type}/versions/{policy_type.version}/policies" + cls.send_message('POST', 'Create Policy', url, data=policy_data, headers=cls.header, basic_auth=basic_auth) @classmethod - def deploy_policy(cls, - policy_data, - basic_auth: Dict[str, str]) -> None: + def deploy_policy(cls, policy_data, basic_auth: Dict[str, str]) -> None: """ Deploy a policy. @@ -142,9 +123,31 @@ class OranPolicy(OnapService): """ url = f"{cls.pap_url}/policy/pap/v1/pdps/policies" - cls.send_message('POST', - 'Deploy Policy', - url, - data=policy_data, - headers=cls.header, - basic_auth=basic_auth) + cls.send_message('POST', 'Deploy Policy', url, data=policy_data, headers=cls.header, basic_auth=basic_auth) + + @classmethod + def undeploy_policy(cls, policy_id, policy_version, basic_auth: Dict[str, str]) -> None: + """ + Undeploy a policy. + + Args: + policy_id: The policy id as provided during the create + policy_version: The policy version as provided during the create + + """ + url = f"{cls.pap_url}/policy/pap/v1/pdps/policies/{policy_id}/versions/{policy_version}" + cls.send_message('DELETE', 'Undeploy Policy', url, headers=cls.header, basic_auth=basic_auth) + + @classmethod + def delete_policy(cls, policy_type: PolicyType, policy_id, policy_version, basic_auth: Dict[str, str]) -> None: + """ + Delete a policy. + + Args: + policy_type: the policy type + policy_id: The policy id as provided during the create + policy_version: The policy version as provided during the create + + """ + url = f"{cls.api_url}/policy/api/v1/policytypes/{policy_type.type}/versions/{policy_type.version}/policies/{policy_id}/versions/{policy_version}" + cls.send_message('DELETE', 'Delete Policy', url, headers=cls.header, basic_auth=basic_auth)