946a8fb4af31365aaa0b4ea4a7750d8a079bac6f
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.common.database.responses;
23
24 import org.elasticsearch.client.Response;
25 import org.json.JSONObject;
26 import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion;
27
28 public class GetInfoResponse extends BaseResponse {
29
30     /**
31      * { "name" : "kpOdXt-", "cluster_name" : "docker-cluster", "cluster_uuid" : "qags6CGGTrS75iBhrAdsgg", "version" : {
32      * "number" : "6.4.3", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "fe40335", "build_date" :
33      * "2018-10-30T23:17:19.084789Z", "build_snapshot" : false, "lucene_version" : "7.4.0",
34      * "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" :
35      * "You Know, for Search" }
36      */
37     private final String clusterName;
38     private final String name;
39
40     private final EsVersion version;
41
42     public GetInfoResponse(Response response) throws Exception {
43         super(response);
44         JSONObject o = this.getJson(response);
45         if (o == null) {
46             throw new Exception("unable to read response");
47         }
48         this.name = o.getString("name");
49         this.clusterName = o.getString("cluster_name");
50         this.version = new EsVersion(o.getJSONObject("version").getString("number"));
51     }
52
53     public String getClusterName() {
54         return clusterName;
55     }
56
57     public String getName() {
58         return name;
59     }
60
61     public EsVersion getVersion() {
62         return version;
63     }
64
65
66
67 }