c7e27ee4adf3fc0db0f71954d7b12503b685d5dd
[ccsdk/features.git] / sdnr / wt / common / src / main / java / org / onap / ccsdk / features / sdnr / wt / common / database / requests / CreateIndexRequest.java
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         public void mappings(JSONObject mappings) {
46                 this.mappings=mappings;
47                 this.setRequest();
48         }
49
50         public void settings(JSONObject settings) {
51                 this.settings = settings;
52                 this.setRequest();
53         }
54
55         public boolean hasMappings() {
56                 return this.mappings!=null;
57         }
58
59         public boolean hasSettings() {
60                 return this.settings!=null;
61         }
62
63 }