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 {
54 public enum PolicyBodyType {
62 public boolean delete(PolicyRestAdapter policyData)
63 throws IllegalStateException;
65 public JestResult search(PolicyIndexType type, String text)
66 throws IllegalStateException, IllegalArgumentException;
68 public JestResult search(PolicyIndexType type, String text,
69 Map<String, String> searchKeyValue)
70 throws IllegalStateException, IllegalArgumentException;
72 public boolean update(PolicyRestAdapter policyData) throws IllegalStateException;
74 public ElkConnector singleton = new ElkConnectorImpl();
76 public static PolicyIndexType toPolicyIndexType(String policyName)
77 throws IllegalArgumentException {
78 if (policyName == null)
79 throw new IllegalArgumentException("Unsupported NULL policy name conversion");
81 if (policyName.startsWith("Config_Fault")) {
82 return PolicyIndexType.closedloop;
83 } else if (policyName.startsWith("Config_PM")) {
84 return PolicyIndexType.closedloop;
85 } else if (policyName.startsWith("Config_FW")) {
86 return PolicyIndexType.config;
87 } else if (policyName.startsWith("Config_MS")) {
88 return PolicyIndexType.config;
89 } else if (policyName.startsWith("Config_OOF")) {
90 return PolicyIndexType.config;
91 }else if (policyName.startsWith("Action")) {
92 return PolicyIndexType.action;
93 } else if (policyName.startsWith("Decision")) {
94 return PolicyIndexType.decision;
95 } else if (policyName.startsWith("Config")) {
96 return PolicyIndexType.config;
98 throw new IllegalArgumentException
99 ("Unsupported policy name conversion to index: " +