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.policy.pap.xacml.rest.elk.client;
23 import io.searchbox.client.JestResult;
27 import org.onap.policy.rest.adapter.PolicyRestAdapter;
29 public interface ElkConnector {
31 public static final String ELK_URL = "http://localhost:9200";
32 public static final String ELK_INDEX_POLICY = "policy";
34 public enum PolicyIndexType {
35 config, action, decision, closedloop, all,
38 public enum PolicyType {
39 Config, Action, Decision, Config_Fault, Config_PM, Config_FW, Config_MS, Config_OOF, none,
42 public enum PolicyBodyType {
43 json, xml, properties, txt, none,
46 public boolean delete(PolicyRestAdapter policyData) throws IllegalStateException;
48 public JestResult search(PolicyIndexType type, String text) throws IllegalStateException, IllegalArgumentException;
50 public JestResult search(PolicyIndexType type, String text, Map<String, String> searchKeyValue)
51 throws IllegalStateException, IllegalArgumentException;
53 public boolean update(PolicyRestAdapter policyData) throws IllegalStateException;
55 public ElkConnector singleton = new ElkConnectorImpl();
57 public static PolicyIndexType toPolicyIndexType(String policyName) throws IllegalArgumentException {
58 if (policyName == null)
59 throw new IllegalArgumentException("Unsupported NULL policy name conversion");
61 if (policyName.startsWith("Config_Fault")) {
62 return PolicyIndexType.closedloop;
63 } else if (policyName.startsWith("Config_PM")) {
64 return PolicyIndexType.closedloop;
65 } else if (policyName.startsWith("Config_FW")) {
66 return PolicyIndexType.config;
67 } else if (policyName.startsWith("Config_MS")) {
68 return PolicyIndexType.config;
69 } else if (policyName.startsWith("Config_OOF")) {
70 return PolicyIndexType.config;
71 } else if (policyName.startsWith("Action")) {
72 return PolicyIndexType.action;
73 } else if (policyName.startsWith("Decision")) {
74 return PolicyIndexType.decision;
75 } else if (policyName.startsWith("Config")) {
76 return PolicyIndexType.config;
78 throw new IllegalArgumentException("Unsupported policy name conversion to index: " + policyName);