Skip to content

Commit

Permalink
Add getClusterName endpoint, add currentStreams DTO
Browse files Browse the repository at this point in the history
  • Loading branch information
emerkle826 committed Aug 16, 2023
1 parent 8f52a40 commit a55646c
Show file tree
Hide file tree
Showing 10 changed files with 396 additions and 230 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Changelog for Management API, new PRs should update the `main / unreleased` sect
[CHANGE] [#323](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/323) Rename Maven artifact groupId from com.datastax to io.k8ssandra
[FEATURE] [#323](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/323) Add OpenAPI Java client generation
[FEATURE] [#337](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/337) Publish Maven artifacts to Cloudsmith.io
[FEATURE] [#326](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/326) Provide topology endpoints in OpenAPI client
[FEATURE] [#345](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/345) Implement host related methods
[BUGFIX] [#339](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/339) OpenAPI client publish does not also publish other artifacts


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,4 +778,9 @@ public String move(

return submitJob("move", moveOperation, async);
}

@Rpc(name = "getClusterName")
public String getClusterName() {
return ShimLoader.instance.get().getStorageService().getClusterName();
}
}
87 changes: 60 additions & 27 deletions management-api-server/doc/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,25 @@
}
}
},
"/api/v0/metadata/clustername" : {
"get" : {
"operationId" : "getClusterName",
"responses" : {
"200" : {
"content" : {
"text/plain" : {
"example" : "myCluster",
"schema" : {
"type" : "string"
}
}
},
"description" : "Cassandra Cluster Name"
}
},
"summary" : "Returns the Cassandra cluster name"
}
},
"/api/v0/metadata/endpoints" : {
"get" : {
"operationId" : "getEndpointStates",
Expand Down Expand Up @@ -274,7 +293,7 @@
}
}
},
"description" : "Cassandra version'"
"description" : "Cassandra version"
}
},
"summary" : "Returns the Cassandra release version"
Expand Down Expand Up @@ -1103,33 +1122,8 @@
"200" : {
"content" : {
"application/json" : {
"example" : {
"entity" : [ ],
"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/StreamingInfo"
}
}
},
Expand Down Expand Up @@ -1980,6 +1974,45 @@
},
"required" : [ "check_data", "disable_snapshot", "jobs", "keyspace_name", "reinsert_overflowed_ttl", "skip_corrupted", "tables" ]
},
"StreamingInfo" : {
"type" : "object",
"properties" : {
"annotations" : {
"type" : "array",
"items" : {
"type" : "string"
}
},
"encoding" : {
"type" : "string"
},
"entity" : {
"type" : "array",
"items" : {
"type" : "object",
"additionalProperties" : {
"type" : "array",
"items" : {
"type" : "object",
"additionalProperties" : {
"type" : "string"
}
}
}
}
},
"language" : {
"type" : "string"
},
"mediaType" : {
"$ref" : "#/components/schemas/MediaType"
},
"variant" : {
"$ref" : "#/components/schemas/Variant"
}
},
"required" : [ "entity" ]
},
"TakeSnapshotRequest" : {
"type" : "object",
"properties" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MetadataResources(ManagementApplication application) {
@Produces(MediaType.TEXT_PLAIN)
@ApiResponse(
responseCode = "200",
description = "Cassandra version'",
description = "Cassandra version",
content =
@Content(
mediaType = MediaType.TEXT_PLAIN,
Expand Down Expand Up @@ -102,4 +102,20 @@ public Response getFeatureSet() {
return Response.ok(featureSet).build();
});
}

@GET
@Path("/clustername")
@Operation(summary = "Returns the Cassandra cluster name", operationId = "getClusterName")
@Produces(MediaType.TEXT_PLAIN)
@ApiResponse(
responseCode = "200",
description = "Cassandra Cluster Name",
content =
@Content(
mediaType = MediaType.TEXT_PLAIN,
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = "myCluster")))
public Response getClusterName() {
return executeWithStringResponse("CALL NodeOps.getClusterName()");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.datastax.mgmtapi.resources.common.BaseResources;
import com.datastax.mgmtapi.resources.helpers.ResponseTools;
import com.datastax.mgmtapi.resources.models.RepairRequest;
import com.datastax.mgmtapi.resources.models.StreamingInfo;
import com.datastax.mgmtapi.resources.models.TakeSnapshotRequest;
import com.datastax.oss.driver.api.core.cql.Row;
import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -329,8 +330,7 @@ public Response reloadLocalSchema() {
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = STREAMING_INFO_RESPONSE_EXAMPLE)))
schema = @Schema(implementation = StreamingInfo.class)))
@Operation(summary = "Retrieve Streaming status information", operationId = "getStreamInfo")
public Response getStreamInfo() {
return handle(
Expand Down Expand Up @@ -609,33 +609,6 @@ public Response move(@QueryParam(value = "newToken") String newToken) {
});
}

private static final String STREAMING_INFO_RESPONSE_EXAMPLE =
"{\n"
+ " \"entity\": [],\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"
+ "}";

private static final String SNAPSHOT_DETAILS_RESPONSE_EXAMPLE =
"{\n"
+ " \"entity\": [\n"
Expand Down
Loading

0 comments on commit a55646c

Please sign in to comment.