Policy 1707 commit to LF
[policy/engine.git] / PolicyEngineClient / src / main / java / org / openecomp / policyEngine / ListConfigPoliciesClient.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineClient
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.policyEngine;
22
23 import java.util.Collection;
24 import java.util.HashMap;
25 import java.util.Map;
26 import java.util.UUID;
27
28 import org.openecomp.policy.api.ConfigRequestParameters;
29 import org.openecomp.policy.api.PolicyConfigException;
30 import org.openecomp.policy.api.PolicyEngine;
31 import org.openecomp.policy.api.PolicyEngineException;
32
33 public class ListConfigPoliciesClient {
34         public static void main(String[] args) {
35                 PolicyEngine policyEngine;
36
37                 // List Config Policies Example 
38                 try {
39                         policyEngine = new PolicyEngine("config.properties");
40                         ConfigRequestParameters parameters = new ConfigRequestParameters();
41                         
42                         parameters.setPolicyName(".*");
43                         parameters.setEcompName(".*");
44                         parameters.setConfigName(".*");
45                         
46                         Map<String, String> configAttributes = new HashMap<String,String>();
47                         configAttributes.put("java", "java");
48                         configAttributes.put("peach", "Tar");
49                         configAttributes.put("true", "false");
50                         configAttributes.put("small", "testPass");
51                         parameters.setConfigAttributes(configAttributes);
52                         
53                         parameters.setRequestID(UUID.randomUUID());
54                         
55                         Collection<String> response = policyEngine.listConfig(parameters);
56                 if(response!=null && !response.contains("PE300")){
57                         for(String configList : response){
58                                 System.out.println(configList.toString()+"\n");
59                         }
60                 }else{
61                     System.out.println("Error! " +response);
62                 }
63
64                 } catch (PolicyConfigException e) {
65                         e.printStackTrace();
66                 } catch (PolicyEngineException e) {
67                         // TODO Auto-generated catch block
68                         e.printStackTrace();
69                 }
70         }
71         
72 }