...
- Create policies on the PAP
- Update policies on the PAP
- Delete policies on the PAP or PDP
- Push policies from the PAP to the PDP
- List policies on the PDP
- Get config data of policies on the PDP
- Create Dictionary Items
- Update Dictionary Items
- Retrieve Dictionary Items
- Import Micro Services Models
- Retrieve Metrics for policy counts from PDP and PAP
POLICY ENGINE SERVICES
POLICY ENGINE API SAMPLE JAVA CLIENT CODE
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
/*- * ============LICENSE_START======================================================= * PolicyEngineClient * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ package org.onap.policyEngine; import java.util.Collection; import org.onap.policy.api.ConfigRequestParameters; import org.onap.policy.api.PolicyConfig; import org.onap.policy.api.PolicyEngine; public class GetConfigSample { public static void main(String[] args) throws Exception { PolicyEngine pe = new PolicyEngine("config.properties"); ConfigRequestParameters configRequestParams = new ConfigRequestParameters(); configRequestParams.setPolicyName(".*"); Collection<PolicyConfig> configs = pe.getConfig(configRequestParams); for (PolicyConfig config: configs){ System.out.println(config.getPolicyConfigMessage()); System.out.println(config.getPolicyConfigStatus()); } } } |
...
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
/*- * ============LICENSE_START======================================================= * PolicyEngineClient * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ package org.onap.policyEngine; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.UUID; import org.onap.policy.api.ConfigRequestParameters; import org.onap.policy.api.PolicyConfigException; import org.onap.policy.api.PolicyEngine; import org.onap.policy.api.PolicyEngineException; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; public class ListConfigPoliciesClient { private static final Logger LOGGER = FlexLogger.getLogger(ListConfigPoliciesClient.class); public static void main(String[] args) { PolicyEngine policyEngine; // List Config Policies Example try { policyEngine = new PolicyEngine("config.properties"); ConfigRequestParameters parameters = new ConfigRequestParameters(); parameters.setPolicyName(".*"); parameters.setOnapName(".*"); parameters.setConfigName(".*"); Map<String, String> configAttributes = new HashMap<>(); configAttributes.put("java", "java"); configAttributes.put("peach", "Tar"); configAttributes.put("true", "false"); configAttributes.put("small", "testPass"); parameters.setConfigAttributes(configAttributes); parameters.setRequestID(UUID.randomUUID()); Collection<String> response = policyEngine.listConfig(parameters); if(response!=null && !response.contains("PE300")){ for(String configList : response){ System.out.println(configList.toString()+"\n"); } }else{ System.out.println("Error! " +response); } } catch (PolicyConfigException e) { LOGGER.error("Exception Occured"+e); } catch (PolicyEngineException e) { LOGGER.error("Exception Occured"+e); } } } |
CURL JSON EXAMPLES
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
echo "pushPolicy API: PUT : com.vLoadBalancer" echo "pushPolicy createPolicy OPERATION: PUT REQUEST BODY: com.vLoadBalancer" curl -v --silent -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' --header 'ClientAuth: XYZ' { "configBody": "{ \"service\":\"ControllerServiceSampleSdnlServiceInstance\", \"location\":\"Edge\", \"uuid\":\"TestUUID\", \"policyName\":\"testRestCreateMicroServicesNewParams\", \"description\":\"testing Create\", \"configName\":\"TestName\", \"templateVersion\":\"1604\", \"priority\":\"4\", \"version\":\"0.1.0-SNAPSHOT\", \"policyScope\":\"resource=F5,service=vSCP,type=configuration,closedLoopControlName=vSCP_F5_Firewall_d925ed73-8231-4d02-9545-db4e101f88f8\", \"content\":{ \"taskOrchestratedConfiguration\":\"test\", \"taskCustomConfiguration\":\"set\", \"configuration\":\"test\", \"cdapUrl\":\"testurl\", \"taskName\":\"test\", \"taskNameTEST\":\"TEST\", \"users\":\"[tuser]\", \"adminUsers\":\"[lji]\", \"taskConfigFilePath\":\"test\", \"managerPortNumber\":\"999\", \"taskType\":\"test\", \"taskCommandFilePath\":\"tset\", \"contailIp\":\"test\", \"consoleUsers\":\"[odu-e2e]\", \"taskStatusFilePath\":\"test\" } }", "policyConfigType": "MicroService", "policyName": "MikeAPITesting.testRestCreateMicroServicesNewParams", "ecompName": "SDNC" } |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
API: updatePolicy
OPERATION: PUT
REQUEST BODY:
{
"configBody": "{
\"service\":\"ControllerServiceSampleSdnlServiceInstance\",
\"location\":\"Edge\",
\"uuid\":\"TestUUID\",
\"policyName\":\"testRestCreateMicroServicesNewParams\",
\"description\":\"testing Update\",
\"configName\":\"TestName\",
\"templateVersion\":\"1604\",
\"priority\":\"4\",
\"version\":\"0.1.0-SNAPSHOT\",
\"policyScope\":\"resource=F5,service=vSCP,type=configuration,closedLoopControlName=vSCP_F5_Firewall_d925ed73-8231-4d02-9545-db4e101f88f8\",
\"content\":{
\"taskOrchestratedConfiguration\":\"test\",
\"taskCustomConfiguration\":\"set\",
\"configuration\":\"test\",
\"cdapUrl\":\"testurl\",
\"taskName\":\"test\",
\"taskNameTEST\":\"TEST\",
\"users\":\"[tuser]\",
\"adminUsers\":\"[lji]\",
\"taskConfigFilePath\":\"test\",
\"managerPortNumber\":\"999\",
\"taskType\":\"test\",
\"taskCommandFilePath\":\"tset\",
\"contailIp\":\"test\",
\"consoleUsers\":\"[odu-e2e]\",
\"taskStatusFilePath\":\"test\"
}
}",
"policyConfigType": "MicroService",
"policyName": "MikeAPITesting.testRestUpdateMicroServicesNewParams",
"ecompName": "SDNC"
} |
CURLĀ EXAMPLES
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
echo "pushPolicy : PUT : com.vLoadBalancer"
echo "pushPolicy : PUT : com.vLoadBalancer"
curl -v --silent -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' --header 'ClientAuth: XYZ' --header 'Authorization: Basic XYZ' --header 'Environment: TEST' -d '{
"pdpGroup": "default",
"policyName": "com.vLoadBalancer",
"policyType": "MicroService"
}' 'http://pdp:8081/pdp/api/pushPolicy' |
...
Header parameters apply to each API.