2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017, 2019 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policyengine;
23 import java.util.Collection;
24 import java.util.HashMap;
26 import java.util.UUID;
28 import org.onap.policy.api.ConfigRequestParameters;
29 import org.onap.policy.api.PolicyConfigException;
30 import org.onap.policy.api.PolicyEngine;
31 import org.onap.policy.api.PolicyEngineException;
32 import org.onap.policy.common.logging.flexlogger.FlexLogger;
33 import org.onap.policy.common.logging.flexlogger.Logger;
35 public class ListConfigPoliciesClient {
37 private static final Logger LOGGER = FlexLogger.getLogger(ListConfigPoliciesClient.class);
42 * @param args String[] args
44 public static void main(String[] args) {
45 PolicyEngine policyEngine;
47 // List Config Policies Example
49 policyEngine = new PolicyEngine("config.properties");
50 ConfigRequestParameters parameters = new ConfigRequestParameters();
52 parameters.setPolicyName(".*");
53 parameters.setOnapName(".*");
54 parameters.setConfigName(".*");
56 Map<String, String> configAttributes = new HashMap<>();
57 configAttributes.put("java", "java");
58 configAttributes.put("peach", "Tar");
59 configAttributes.put("true", "false");
60 configAttributes.put("small", "testPass");
61 parameters.setConfigAttributes(configAttributes);
63 parameters.setRequestID(UUID.randomUUID());
65 Collection<String> response = policyEngine.listConfig(parameters);
66 if (response != null && !response.contains("PE300")) {
67 for (String configList : response) {
68 System.out.println(configList.toString() + "\n");
71 System.out.println("Error! " + response);
74 } catch (PolicyConfigException e) {
75 LOGGER.error("Exception Occured" + e);
76 } catch (PolicyEngineException e) {
77 LOGGER.error("Exception Occured" + e);