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;
24 import io.searchbox.client.JestResult;
26 import org.onap.policy.rest.adapter.PolicyRestAdapter;
28 public interface ElkConnector {
30 public static final String ELK_URL = "http://localhost:9200";
31 public static final String ELK_INDEX_POLICY = "policy";
33 public enum PolicyIndexType {
34 config, action, decision, closedloop, all,
37 public enum PolicyType {
38 Config, Action, Decision, Config_Fault, Config_PM, Config_FW, Config_MS, Config_OOF, none,
41 public enum PolicyBodyType {
42 json, xml, properties, txt, none,
45 public boolean delete(PolicyRestAdapter policyData) throws IllegalStateException;
47 public JestResult search(PolicyIndexType type, String text)
48 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)
58 throws IllegalArgumentException {
59 if (policyName == null)
60 throw new IllegalArgumentException("Unsupported NULL policy name conversion");
62 if (policyName.startsWith("Config_Fault")) {
63 return PolicyIndexType.closedloop;
64 } else if (policyName.startsWith("Config_PM")) {
65 return PolicyIndexType.closedloop;
66 } else if (policyName.startsWith("Config_FW")) {
67 return PolicyIndexType.config;
68 } else if (policyName.startsWith("Config_MS")) {
69 return PolicyIndexType.config;
70 } else if (policyName.startsWith("Config_OOF")) {
71 return PolicyIndexType.config;
72 } else if (policyName.startsWith("Action")) {
73 return PolicyIndexType.action;
74 } else if (policyName.startsWith("Decision")) {
75 return PolicyIndexType.decision;
76 } else if (policyName.startsWith("Config")) {
77 return PolicyIndexType.config;
79 throw new IllegalArgumentException(
80 "Unsupported policy name conversion to index: " + policyName);