2 * ============LICENSE_START=======================================================
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
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=========================================================
20 package org.onap.policy.pap.xacml.rest.elk.client;
25 import org.onap.policy.rest.adapter.PolicyRestAdapter;
27 import io.searchbox.client.JestResult;
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 {
42 public enum PolicyType {
53 public enum PolicyBodyType {
61 public boolean delete(PolicyRestAdapter policyData)
62 throws IllegalStateException;
64 public JestResult search(PolicyIndexType type, String text)
65 throws IllegalStateException, IllegalArgumentException;
67 public JestResult search(PolicyIndexType type, String text,
68 Map<String, String> searchKeyValue)
69 throws IllegalStateException, IllegalArgumentException;
71 public boolean update(PolicyRestAdapter policyData) throws IllegalStateException;
73 public ElkConnector singleton = new ElkConnectorImpl();
75 public static PolicyIndexType toPolicyIndexType(String policyName)
76 throws IllegalArgumentException {
77 if (policyName == null)
78 throw new IllegalArgumentException("Unsupported NULL policy name conversion");
80 if (policyName.startsWith("Config_Fault")) {
81 return PolicyIndexType.closedloop;
82 } else if (policyName.startsWith("Config_PM")) {
83 return PolicyIndexType.closedloop;
84 } else if (policyName.startsWith("Config_FW")) {
85 return PolicyIndexType.config;
86 } else if (policyName.startsWith("Config_MS")) {
87 return PolicyIndexType.config;
88 }else if (policyName.startsWith("Action")) {
89 return PolicyIndexType.action;
90 } else if (policyName.startsWith("Decision")) {
91 return PolicyIndexType.decision;
92 } else if (policyName.startsWith("Config")) {
93 return PolicyIndexType.config;
95 throw new IllegalArgumentException
96 ("Unsupported policy name conversion to index: " +