Skip to content

Commit e3c51d5

Browse files
committed
Add SnapshotDetails DTO (#348)
1 parent 3a66619 commit e3c51d5

File tree

3 files changed

+94
-84
lines changed

3 files changed

+94
-84
lines changed

management-api-server/doc/openapi.json

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,49 +1011,12 @@
10111011
"200" : {
10121012
"content" : {
10131013
"application/json" : {
1014-
"example" : {
1015-
"entity" : [ {
1016-
"Column family name" : "size_estimates",
1017-
"Keyspace name" : "system",
1018-
"Size on disk" : "13 bytes",
1019-
"Snapshot name" : "truncated-1639687082845-size_estimates",
1020-
"True size" : "0 bytes"
1021-
}, {
1022-
"Column family name" : "table_estimates",
1023-
"Keyspace name" : "system",
1024-
"Size on disk" : "13 bytes",
1025-
"Snapshot name" : "truncated-1639687082982-table_estimates",
1026-
"True size" : "0 bytes"
1027-
} ],
1028-
"variant" : {
1029-
"language" : null,
1030-
"mediaType" : {
1031-
"type" : "application",
1032-
"subtype" : "json",
1033-
"parameters" : { },
1034-
"wildcardType" : false,
1035-
"wildcardSubtype" : false
1036-
},
1037-
"encoding" : null,
1038-
"languageString" : null
1039-
},
1040-
"annotations" : [ ],
1041-
"mediaType" : {
1042-
"type" : "application",
1043-
"subtype" : "json",
1044-
"parameters" : { },
1045-
"wildcardType" : false,
1046-
"wildcardSubtype" : false
1047-
},
1048-
"language" : null,
1049-
"encoding" : null
1050-
},
10511014
"schema" : {
1052-
"type" : "string"
1015+
"$ref" : "#/components/schemas/SnapshotDetails"
10531016
}
10541017
}
10551018
},
1056-
"description" : "Cassandra snapshot details"
1019+
"description" : "Cassandra snapshot details. Use 'null' values for query parameters to exclude result filtering against the parameter."
10571020
}
10581021
},
10591022
"summary" : "Retrieve snapshot details"
@@ -1955,6 +1918,39 @@
19551918
},
19561919
"required" : [ "check_data", "disable_snapshot", "jobs", "keyspace_name", "reinsert_overflowed_ttl", "skip_corrupted", "tables" ]
19571920
},
1921+
"SnapshotDetails" : {
1922+
"type" : "object",
1923+
"properties" : {
1924+
"annotations" : {
1925+
"type" : "array",
1926+
"items" : {
1927+
"type" : "string"
1928+
}
1929+
},
1930+
"encoding" : {
1931+
"type" : "string"
1932+
},
1933+
"entity" : {
1934+
"type" : "array",
1935+
"items" : {
1936+
"type" : "object",
1937+
"additionalProperties" : {
1938+
"type" : "string"
1939+
}
1940+
}
1941+
},
1942+
"language" : {
1943+
"type" : "string"
1944+
},
1945+
"mediaType" : {
1946+
"$ref" : "#/components/schemas/MediaType"
1947+
},
1948+
"variant" : {
1949+
"$ref" : "#/components/schemas/Variant"
1950+
}
1951+
},
1952+
"required" : [ "entity" ]
1953+
},
19581954
"StreamingInfo" : {
19591955
"type" : "object",
19601956
"properties" : {

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

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.datastax.mgmtapi.resources.common.BaseResources;
1212
import com.datastax.mgmtapi.resources.helpers.ResponseTools;
1313
import com.datastax.mgmtapi.resources.models.RepairRequest;
14+
import com.datastax.mgmtapi.resources.models.SnapshotDetails;
1415
import com.datastax.mgmtapi.resources.models.StreamingInfo;
1516
import com.datastax.mgmtapi.resources.models.TakeSnapshotRequest;
1617
import com.datastax.oss.driver.api.core.cql.Row;
@@ -351,12 +352,12 @@ public Response getStreamInfo() {
351352
@Produces(MediaType.APPLICATION_JSON)
352353
@ApiResponse(
353354
responseCode = "200",
354-
description = "Cassandra snapshot details",
355+
description =
356+
"Cassandra snapshot details. Use 'null' values for query parameters to exclude result filtering against the parameter.",
355357
content =
356358
@Content(
357359
mediaType = MediaType.APPLICATION_JSON,
358-
schema = @Schema(implementation = String.class),
359-
examples = @ExampleObject(value = SNAPSHOT_DETAILS_RESPONSE_EXAMPLE)))
360+
schema = @Schema(implementation = SnapshotDetails.class)))
360361
@Operation(summary = "Retrieve snapshot details", operationId = "getSnapshotDetails")
361362
public Response getSnapshotDetails(
362363
@QueryParam("snapshotNames") List<String> snapshotNames,
@@ -609,48 +610,6 @@ public Response move(@QueryParam(value = "newToken") String newToken) {
609610
});
610611
}
611612

612-
private static final String SNAPSHOT_DETAILS_RESPONSE_EXAMPLE =
613-
"{\n"
614-
+ " \"entity\": [\n"
615-
+ " {\n"
616-
+ " \"Column family name\": \"size_estimates\",\n"
617-
+ " \"Keyspace name\": \"system\",\n"
618-
+ " \"Size on disk\": \"13 bytes\",\n"
619-
+ " \"Snapshot name\": \"truncated-1639687082845-size_estimates\",\n"
620-
+ " \"True size\": \"0 bytes\"\n"
621-
+ " },\n"
622-
+ " {\n"
623-
+ " \"Column family name\": \"table_estimates\",\n"
624-
+ " \"Keyspace name\": \"system\",\n"
625-
+ " \"Size on disk\": \"13 bytes\",\n"
626-
+ " \"Snapshot name\": \"truncated-1639687082982-table_estimates\",\n"
627-
+ " \"True size\": \"0 bytes\"\n"
628-
+ " }\n"
629-
+ " ],\n"
630-
+ " \"variant\": {\n"
631-
+ " \"language\": null,\n"
632-
+ " \"mediaType\": {\n"
633-
+ " \"type\": \"application\",\n"
634-
+ " \"subtype\": \"json\",\n"
635-
+ " \"parameters\": {},\n"
636-
+ " \"wildcardType\": false,\n"
637-
+ " \"wildcardSubtype\": false\n"
638-
+ " },\n"
639-
+ " \"encoding\": null,\n"
640-
+ " \"languageString\": null\n"
641-
+ " },\n"
642-
+ " \"annotations\": [],\n"
643-
+ " \"mediaType\": {\n"
644-
+ " \"type\": \"application\",\n"
645-
+ " \"subtype\": \"json\",\n"
646-
+ " \"parameters\": {},\n"
647-
+ " \"wildcardType\": false,\n"
648-
+ " \"wildcardSubtype\": false\n"
649-
+ " },\n"
650-
+ " \"language\": null,\n"
651-
+ " \"encoding\": null\n"
652-
+ "}";
653-
654613
private static final String FQL_QUERY_RESPONSE_EXAMPLE =
655614
"{\n"
656615
+ " \"entity\": false,\n"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright DataStax, Inc.
3+
*
4+
* Please see the included license file for details.
5+
*/
6+
package com.datastax.mgmtapi.resources.models;
7+
8+
import com.fasterxml.jackson.annotation.JsonCreator;
9+
import com.fasterxml.jackson.annotation.JsonProperty;
10+
import java.util.List;
11+
import java.util.Map;
12+
import java.util.Objects;
13+
14+
public class SnapshotDetails extends BaseEntity {
15+
16+
@JsonProperty(value = "entity", required = true)
17+
public final List<Map<String, String>> entity;
18+
19+
@JsonCreator
20+
public SnapshotDetails(
21+
@JsonProperty("entity") List<Map<String, String>> entity,
22+
@JsonProperty("variant") BaseEntity.Variant variant,
23+
@JsonProperty("annotations") List<String> annotations,
24+
@JsonProperty("mediaType") BaseEntity.MediaType mediaType,
25+
@JsonProperty("language") String language,
26+
@JsonProperty("encoding") String encoding) {
27+
super(variant, annotations, mediaType, language, encoding);
28+
this.entity = entity;
29+
}
30+
31+
@Override
32+
public int hashCode() {
33+
int hash = super.hashCode();
34+
hash = 83 * hash + Objects.hashCode(this.entity);
35+
return hash;
36+
}
37+
38+
@Override
39+
public boolean equals(Object obj) {
40+
if (this == obj) {
41+
return true;
42+
}
43+
if (obj == null) {
44+
return false;
45+
}
46+
if (getClass() != obj.getClass()) {
47+
return false;
48+
}
49+
final SnapshotDetails other = (SnapshotDetails) obj;
50+
if (!Objects.equals(this.entity, other.entity)) {
51+
return false;
52+
}
53+
return super.equals(obj);
54+
}
55+
}

0 commit comments

Comments
 (0)