- [Documentation] Delete the TCA Policy Type Version 2
- ${auth}= Create List healthcheck zb!XztG34
- Log Creating session https://${POLICY_API_IP}:6969
- ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
- ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
- ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 headers=${headers}
- Log Received response from policy ${resp.text}
- Should Be Equal As Strings ${resp.status_code} 200
- ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 headers=${headers}
- Should Be Equal As Strings ${resp.status_code} 404
+ [Documentation] Delete a policy type named 'onap.policies.monitoring.tcagen2' and version '2.0.0'
+ PeformDeleteRequest /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0
+
+*** Keywords ***
+
+CreatePolicyType
+ [Arguments] ${url} ${expectedstatus} ${jsonfile} ${policytypename} ${policytypeversion}
+ [Documentation] Create the specific policy type
+ ${resp}= PerformCreateRequest ${url} ${expectedstatus} ${jsonfile} ${CURDIR}/data
+ Run Keyword If ${expectedstatus}==200 List Should Contain Value ${resp.json()['policy_types']} ${policytypename}
+ Run Keyword If ${expectedstatus}==200 Should Be Equal As Strings ${resp.json()['policy_types']['${policytypename}']['version']} ${policytypeversion}
+
+FetchPolicyTypes
+ [Arguments] ${url} ${expectedLength}
+ [Documentation] Fetch all policy types
+ ${resp}= PeformGetRequest ${url} 200
+ Length Should Be ${resp.json()['policy_types']} ${expectedLength}
+
+CreatePolicy
+ [Arguments] ${url} ${expectedstatus} ${jsonfile} ${policyname} ${policyversion}
+ [Documentation] Create the specific policy
+ ${resp}= PerformCreateRequest ${url} ${expectedstatus} ${jsonfile} ${DATA}
+ Run Keyword If ${expectedstatus}==200 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${policyname}
+ Run Keyword If ${expectedstatus}==200 Should Be Equal As Strings ${resp.json()['topology_template']['policies'][0]['${policyname}']['version']} ${policyversion}
+
+FetchPolicy
+ [Arguments] ${url} ${keyword}
+ [Documentation] Fetch the specific policy
+ ${resp}= PeformGetRequest ${url} 200
+ Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${keyword}
+
+FetchPolicies
+ [Arguments] ${url} ${expectedLength}
+ [Documentation] Fetch all policies
+ ${resp}= PeformGetRequest ${url} 200
+ Length Should Be ${resp.json()['topology_template']['policies']} ${expectedLength}
+
+PerformCreateRequest
+ [Arguments] ${url} ${expectedstatus} ${jsonfile} ${filepath}
+ ${auth}= Create List healthcheck zb!XztG34
+ ${postjson}= Get file ${filepath}/${jsonfile}
+ Log Creating session https://${POLICY_API_IP}:6969
+ ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
+ ${resp}= POST On Session policy ${url} data=${postjson} headers=${headers} expected_status=${expectedstatus}
+ Log Received response from policy ${resp.text}
+ [return] ${resp}
+
+PeformGetRequest
+ [Arguments] ${url} ${expectedstatus}
+ ${auth}= Create List healthcheck zb!XztG34
+ Log Creating session https://${POLICY_API_IP}:6969
+ ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
+ ${resp}= GET On Session policy ${url} headers=${headers} expected_status=${expectedstatus}
+ Log Received response from policy ${resp.text}
+ [return] ${resp}
+
+PeformDeleteRequest
+ [Arguments] ${url}
+ ${auth}= Create List healthcheck zb!XztG34
+ Log Creating session https://${POLICY_API_IP}:6969
+ ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
+ ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
+ ${resp}= DELETE On Session policy ${url} headers=${headers} expected_status=200
+ Log Received response from policy ${resp.text}
+ ${resp}= DELETE On Session policy ${url} headers=${headers} expected_status=404
\ No newline at end of file