c08ee880b5b84698e55be0aba2ca243208dbff38
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
19
20 import org.json.JSONObject;
21
22 //https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.create.json
23 //https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_mapping.json
24 public class CreateIndexRequest extends BaseRequest{
25
26     private JSONObject settings;
27     private JSONObject mappings;
28
29     public CreateIndexRequest(String index) {
30         super("PUT","/"+index);
31         this.mappings=new JSONObject();
32     }
33
34     private void setRequest() {
35
36         JSONObject o=new JSONObject();
37         if(this.mappings!=null) {
38             o.put("mappings", this.mappings);
39         }
40         if(this.settings!=null) {
41             o.put("settings", this.settings);
42         }
43         super.setQuery(o);
44     }
45     @SuppressWarnings("hiding")
46     public void mappings(JSONObject mappings) {
47         this.mappings=mappings;
48         this.setRequest();
49     }
50
51     public void settings(JSONObject settings) {
52         this.settings = settings;
53         this.setRequest();
54     }
55
56     public boolean hasMappings() {
57         return this.mappings!=null;
58     }
59
60     public boolean hasSettings() {
61         return this.settings!=null;
62     }
63
64 }