Skip to content

Commit

Permalink
Fix getEndpoints Response
Browse files Browse the repository at this point in the history
  • Loading branch information
emerkle826 committed Aug 15, 2023
1 parent 680ffc4 commit 37e1cca
Show file tree
Hide file tree
Showing 3 changed files with 298 additions and 93 deletions.
118 changes: 74 additions & 44 deletions management-api-server/doc/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,51 +213,8 @@
"200" : {
"content" : {
"application/json" : {
"example" : {
"entity" : [ {
"DC" : "datacenter1",
"ENDPOINT_IP" : "172.17.0.2",
"HOST_ID" : "5d2318b0-cfec-4697-8ed2-014b5f434ae8",
"IS_ALIVE" : "true",
"LOAD" : "135527.0",
"NATIVE_ADDRESS_AND_PORT" : "172.17.0.2:9042",
"NET_VERSION" : "12",
"PARTITIONER" : "org.apache.cassandra.dht.Murmur3Partitioner",
"RACK" : "rack1",
"RELEASE_VERSION" : "4.0.1",
"RPC_ADDRESS" : "172.17.0.2",
"RPC_READY" : "true",
"SCHEMA" : "2207c2a9-f598-3971-986b-2926e09e239d",
"SSTABLE_VERSIONS" : "big-nb",
"STATUS" : "NORMAL,-2444908528344618126",
"STATUS_WITH_PORT" : "NORMAL,-2444908528344618126",
"TOKENS" : "-2088271209278749360,-3055635452357284858,-4299155458037876832,-498266656764850722,-5378528265485478489,-6114443958196372130,-7190199839421951670,-8007871772034302464,-9025723176776729480,1120756638932192574,2098902091448306650,3877536392271893778,4973578292506832067,6064875403199044326,6909252050690206084,8349520280592789322"
} ],
"variant" : {
"language" : null,
"mediaType" : {
"type" : "application",
"subtype" : "json",
"parameters" : { },
"wildcardType" : false,
"wildcardSubtype" : false
},
"encoding" : null,
"languageString" : null
},
"annotations" : [ ],
"mediaType" : {
"type" : "application",
"subtype" : "json",
"parameters" : { },
"wildcardType" : false,
"wildcardSubtype" : false
},
"language" : null,
"encoding" : null
},
"schema" : {
"type" : "string"
"$ref" : "#/components/schemas/EndpointStates"
}
}
},
Expand Down Expand Up @@ -1842,6 +1799,39 @@
},
"required" : [ "columns", "keyspace_name", "table_name" ]
},
"EndpointStates" : {
"type" : "object",
"properties" : {
"annotations" : {
"type" : "array",
"items" : {
"type" : "string"
}
},
"encoding" : {
"type" : "string"
},
"entity" : {
"type" : "array",
"items" : {
"type" : "object",
"additionalProperties" : {
"type" : "string"
}
}
},
"language" : {
"type" : "string"
},
"mediaType" : {
"$ref" : "#/components/schemas/MediaType"
},
"variant" : {
"$ref" : "#/components/schemas/Variant"
}
},
"required" : [ "entity" ]
},
"FeatureSet" : {
"type" : "object",
"properties" : {
Expand Down Expand Up @@ -1905,6 +1895,29 @@
},
"required" : [ "jobs", "keyspace_name", "tables" ]
},
"MediaType" : {
"type" : "object",
"properties" : {
"parameters" : {
"type" : "object",
"additionalProperties" : {
"type" : "string"
}
},
"subtype" : {
"type" : "string"
},
"type" : {
"type" : "string"
},
"wildcardSubtype" : {
"type" : "string"
},
"wildcardType" : {
"type" : "string"
}
}
},
"RepairRequest" : {
"type" : "object",
"properties" : {
Expand Down Expand Up @@ -1992,6 +2005,23 @@
"type" : "string"
}
}
},
"Variant" : {
"type" : "object",
"properties" : {
"encoding" : {
"type" : "string"
},
"language" : {
"type" : "string"
},
"languageString" : {
"type" : "string"
},
"mediaType" : {
"$ref" : "#/components/schemas/MediaType"
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.datastax.mgmtapi.ManagementApplication;
import com.datastax.mgmtapi.resources.common.BaseResources;
import com.datastax.mgmtapi.resources.helpers.ResponseTools;
import com.datastax.mgmtapi.resources.models.EndpointStates;
import com.datastax.mgmtapi.resources.models.FeatureSet;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
Expand Down Expand Up @@ -56,8 +57,7 @@ public Response getReleaseVersion() {
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = ENDPOINTS_RESPONSE_EXAMPLE)))
schema = @Schema(implementation = EndpointStates.class)))
public Response getEndpointStates() {
return executeWithJSONResponse("CALL NodeOps.getEndpointStates()");
}
Expand Down Expand Up @@ -102,51 +102,4 @@ public Response getFeatureSet() {
return Response.ok(featureSet).build();
});
}

private static final String ENDPOINTS_RESPONSE_EXAMPLE =
"{\n"
+ " \"entity\": [\n"
+ " {\n"
+ " \"DC\": \"datacenter1\",\n"
+ " \"ENDPOINT_IP\": \"172.17.0.2\",\n"
+ " \"HOST_ID\": \"5d2318b0-cfec-4697-8ed2-014b5f434ae8\",\n"
+ " \"IS_ALIVE\": \"true\",\n"
+ " \"LOAD\": \"135527.0\",\n"
+ " \"NATIVE_ADDRESS_AND_PORT\": \"172.17.0.2:9042\",\n"
+ " \"NET_VERSION\": \"12\",\n"
+ " \"PARTITIONER\": \"org.apache.cassandra.dht.Murmur3Partitioner\",\n"
+ " \"RACK\": \"rack1\",\n"
+ " \"RELEASE_VERSION\": \"4.0.1\",\n"
+ " \"RPC_ADDRESS\": \"172.17.0.2\",\n"
+ " \"RPC_READY\": \"true\",\n"
+ " \"SCHEMA\": \"2207c2a9-f598-3971-986b-2926e09e239d\",\n"
+ " \"SSTABLE_VERSIONS\": \"big-nb\",\n"
+ " \"STATUS\": \"NORMAL,-2444908528344618126\",\n"
+ " \"STATUS_WITH_PORT\": \"NORMAL,-2444908528344618126\"\n,"
+ " \"TOKENS\": \"-2088271209278749360,-3055635452357284858,-4299155458037876832,-498266656764850722,-5378528265485478489,-6114443958196372130,-7190199839421951670,-8007871772034302464,-9025723176776729480,1120756638932192574,2098902091448306650,3877536392271893778,4973578292506832067,6064875403199044326,6909252050690206084,8349520280592789322\"\n"
+ " }\n"
+ " ],\n"
+ " \"variant\": {\n"
+ " \"language\": null,\n"
+ " \"mediaType\": {\n"
+ " \"type\": \"application\",\n"
+ " \"subtype\": \"json\",\n"
+ " \"parameters\": {},\n"
+ " \"wildcardType\": false,\n"
+ " \"wildcardSubtype\": false\n"
+ " },\n"
+ " \"encoding\": null,\n"
+ " \"languageString\": null\n"
+ " },\n"
+ " \"annotations\": [],\n"
+ " \"mediaType\": {\n"
+ " \"type\": \"application\",\n"
+ " \"subtype\": \"json\",\n"
+ " \"parameters\": {},\n"
+ " \"wildcardType\": false,\n"
+ " \"wildcardSubtype\": false\n"
+ " },\n"
+ " \"language\": null,\n"
+ " \"encoding\": null\n"
+ "}";
}
Loading

0 comments on commit 37e1cca

Please sign in to comment.