Skip to content

Commit 8f52a40

Browse files
authored
Fix getEndpoints Response (#343)
1 parent 680ffc4 commit 8f52a40

File tree

3 files changed

+298
-93
lines changed

3 files changed

+298
-93
lines changed

management-api-server/doc/openapi.json

Lines changed: 74 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -213,51 +213,8 @@
213213
"200" : {
214214
"content" : {
215215
"application/json" : {
216-
"example" : {
217-
"entity" : [ {
218-
"DC" : "datacenter1",
219-
"ENDPOINT_IP" : "172.17.0.2",
220-
"HOST_ID" : "5d2318b0-cfec-4697-8ed2-014b5f434ae8",
221-
"IS_ALIVE" : "true",
222-
"LOAD" : "135527.0",
223-
"NATIVE_ADDRESS_AND_PORT" : "172.17.0.2:9042",
224-
"NET_VERSION" : "12",
225-
"PARTITIONER" : "org.apache.cassandra.dht.Murmur3Partitioner",
226-
"RACK" : "rack1",
227-
"RELEASE_VERSION" : "4.0.1",
228-
"RPC_ADDRESS" : "172.17.0.2",
229-
"RPC_READY" : "true",
230-
"SCHEMA" : "2207c2a9-f598-3971-986b-2926e09e239d",
231-
"SSTABLE_VERSIONS" : "big-nb",
232-
"STATUS" : "NORMAL,-2444908528344618126",
233-
"STATUS_WITH_PORT" : "NORMAL,-2444908528344618126",
234-
"TOKENS" : "-2088271209278749360,-3055635452357284858,-4299155458037876832,-498266656764850722,-5378528265485478489,-6114443958196372130,-7190199839421951670,-8007871772034302464,-9025723176776729480,1120756638932192574,2098902091448306650,3877536392271893778,4973578292506832067,6064875403199044326,6909252050690206084,8349520280592789322"
235-
} ],
236-
"variant" : {
237-
"language" : null,
238-
"mediaType" : {
239-
"type" : "application",
240-
"subtype" : "json",
241-
"parameters" : { },
242-
"wildcardType" : false,
243-
"wildcardSubtype" : false
244-
},
245-
"encoding" : null,
246-
"languageString" : null
247-
},
248-
"annotations" : [ ],
249-
"mediaType" : {
250-
"type" : "application",
251-
"subtype" : "json",
252-
"parameters" : { },
253-
"wildcardType" : false,
254-
"wildcardSubtype" : false
255-
},
256-
"language" : null,
257-
"encoding" : null
258-
},
259216
"schema" : {
260-
"type" : "string"
217+
"$ref" : "#/components/schemas/EndpointStates"
261218
}
262219
}
263220
},
@@ -1842,6 +1799,39 @@
18421799
},
18431800
"required" : [ "columns", "keyspace_name", "table_name" ]
18441801
},
1802+
"EndpointStates" : {
1803+
"type" : "object",
1804+
"properties" : {
1805+
"annotations" : {
1806+
"type" : "array",
1807+
"items" : {
1808+
"type" : "string"
1809+
}
1810+
},
1811+
"encoding" : {
1812+
"type" : "string"
1813+
},
1814+
"entity" : {
1815+
"type" : "array",
1816+
"items" : {
1817+
"type" : "object",
1818+
"additionalProperties" : {
1819+
"type" : "string"
1820+
}
1821+
}
1822+
},
1823+
"language" : {
1824+
"type" : "string"
1825+
},
1826+
"mediaType" : {
1827+
"$ref" : "#/components/schemas/MediaType"
1828+
},
1829+
"variant" : {
1830+
"$ref" : "#/components/schemas/Variant"
1831+
}
1832+
},
1833+
"required" : [ "entity" ]
1834+
},
18451835
"FeatureSet" : {
18461836
"type" : "object",
18471837
"properties" : {
@@ -1905,6 +1895,29 @@
19051895
},
19061896
"required" : [ "jobs", "keyspace_name", "tables" ]
19071897
},
1898+
"MediaType" : {
1899+
"type" : "object",
1900+
"properties" : {
1901+
"parameters" : {
1902+
"type" : "object",
1903+
"additionalProperties" : {
1904+
"type" : "string"
1905+
}
1906+
},
1907+
"subtype" : {
1908+
"type" : "string"
1909+
},
1910+
"type" : {
1911+
"type" : "string"
1912+
},
1913+
"wildcardSubtype" : {
1914+
"type" : "string"
1915+
},
1916+
"wildcardType" : {
1917+
"type" : "string"
1918+
}
1919+
}
1920+
},
19081921
"RepairRequest" : {
19091922
"type" : "object",
19101923
"properties" : {
@@ -1992,6 +2005,23 @@
19922005
"type" : "string"
19932006
}
19942007
}
2008+
},
2009+
"Variant" : {
2010+
"type" : "object",
2011+
"properties" : {
2012+
"encoding" : {
2013+
"type" : "string"
2014+
},
2015+
"language" : {
2016+
"type" : "string"
2017+
},
2018+
"languageString" : {
2019+
"type" : "string"
2020+
},
2021+
"mediaType" : {
2022+
"$ref" : "#/components/schemas/MediaType"
2023+
}
2024+
}
19952025
}
19962026
}
19972027
}

management-api-server/src/main/java/com/datastax/mgmtapi/resources/MetadataResources.java

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.datastax.mgmtapi.ManagementApplication;
99
import com.datastax.mgmtapi.resources.common.BaseResources;
1010
import com.datastax.mgmtapi.resources.helpers.ResponseTools;
11+
import com.datastax.mgmtapi.resources.models.EndpointStates;
1112
import com.datastax.mgmtapi.resources.models.FeatureSet;
1213
import io.swagger.v3.oas.annotations.Operation;
1314
import io.swagger.v3.oas.annotations.media.Content;
@@ -56,8 +57,7 @@ public Response getReleaseVersion() {
5657
content =
5758
@Content(
5859
mediaType = MediaType.APPLICATION_JSON,
59-
schema = @Schema(implementation = String.class),
60-
examples = @ExampleObject(value = ENDPOINTS_RESPONSE_EXAMPLE)))
60+
schema = @Schema(implementation = EndpointStates.class)))
6161
public Response getEndpointStates() {
6262
return executeWithJSONResponse("CALL NodeOps.getEndpointStates()");
6363
}
@@ -102,51 +102,4 @@ public Response getFeatureSet() {
102102
return Response.ok(featureSet).build();
103103
});
104104
}
105-
106-
private static final String ENDPOINTS_RESPONSE_EXAMPLE =
107-
"{\n"
108-
+ " \"entity\": [\n"
109-
+ " {\n"
110-
+ " \"DC\": \"datacenter1\",\n"
111-
+ " \"ENDPOINT_IP\": \"172.17.0.2\",\n"
112-
+ " \"HOST_ID\": \"5d2318b0-cfec-4697-8ed2-014b5f434ae8\",\n"
113-
+ " \"IS_ALIVE\": \"true\",\n"
114-
+ " \"LOAD\": \"135527.0\",\n"
115-
+ " \"NATIVE_ADDRESS_AND_PORT\": \"172.17.0.2:9042\",\n"
116-
+ " \"NET_VERSION\": \"12\",\n"
117-
+ " \"PARTITIONER\": \"org.apache.cassandra.dht.Murmur3Partitioner\",\n"
118-
+ " \"RACK\": \"rack1\",\n"
119-
+ " \"RELEASE_VERSION\": \"4.0.1\",\n"
120-
+ " \"RPC_ADDRESS\": \"172.17.0.2\",\n"
121-
+ " \"RPC_READY\": \"true\",\n"
122-
+ " \"SCHEMA\": \"2207c2a9-f598-3971-986b-2926e09e239d\",\n"
123-
+ " \"SSTABLE_VERSIONS\": \"big-nb\",\n"
124-
+ " \"STATUS\": \"NORMAL,-2444908528344618126\",\n"
125-
+ " \"STATUS_WITH_PORT\": \"NORMAL,-2444908528344618126\"\n,"
126-
+ " \"TOKENS\": \"-2088271209278749360,-3055635452357284858,-4299155458037876832,-498266656764850722,-5378528265485478489,-6114443958196372130,-7190199839421951670,-8007871772034302464,-9025723176776729480,1120756638932192574,2098902091448306650,3877536392271893778,4973578292506832067,6064875403199044326,6909252050690206084,8349520280592789322\"\n"
127-
+ " }\n"
128-
+ " ],\n"
129-
+ " \"variant\": {\n"
130-
+ " \"language\": null,\n"
131-
+ " \"mediaType\": {\n"
132-
+ " \"type\": \"application\",\n"
133-
+ " \"subtype\": \"json\",\n"
134-
+ " \"parameters\": {},\n"
135-
+ " \"wildcardType\": false,\n"
136-
+ " \"wildcardSubtype\": false\n"
137-
+ " },\n"
138-
+ " \"encoding\": null,\n"
139-
+ " \"languageString\": null\n"
140-
+ " },\n"
141-
+ " \"annotations\": [],\n"
142-
+ " \"mediaType\": {\n"
143-
+ " \"type\": \"application\",\n"
144-
+ " \"subtype\": \"json\",\n"
145-
+ " \"parameters\": {},\n"
146-
+ " \"wildcardType\": false,\n"
147-
+ " \"wildcardSubtype\": false\n"
148-
+ " },\n"
149-
+ " \"language\": null,\n"
150-
+ " \"encoding\": null\n"
151-
+ "}";
152105
}

0 commit comments

Comments
 (0)