Skip to content

Commit

Permalink
Add snapshot details DTO
Browse files Browse the repository at this point in the history
  • Loading branch information
emerkle826 committed Aug 17, 2023
1 parent 523934e commit 547c077
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 82 deletions.
72 changes: 34 additions & 38 deletions management-api-server/doc/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1011,45 +1011,8 @@
"200" : {
"content" : {
"application/json" : {
"example" : {
"entity" : [ {
"Column family name" : "size_estimates",
"Keyspace name" : "system",
"Size on disk" : "13 bytes",
"Snapshot name" : "truncated-1639687082845-size_estimates",
"True size" : "0 bytes"
}, {
"Column family name" : "table_estimates",
"Keyspace name" : "system",
"Size on disk" : "13 bytes",
"Snapshot name" : "truncated-1639687082982-table_estimates",
"True size" : "0 bytes"
} ],
"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/SnapshotDetails"
}
}
},
Expand Down Expand Up @@ -1955,6 +1918,39 @@
},
"required" : [ "check_data", "disable_snapshot", "jobs", "keyspace_name", "reinsert_overflowed_ttl", "skip_corrupted", "tables" ]
},
"SnapshotDetails" : {
"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" ]
},
"StreamingInfo" : {
"type" : "object",
"properties" : {
Expand Down
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.SnapshotDetails;
import com.datastax.mgmtapi.resources.models.StreamingInfo;
import com.datastax.mgmtapi.resources.models.TakeSnapshotRequest;
import com.datastax.oss.driver.api.core.cql.Row;
Expand Down Expand Up @@ -355,8 +356,7 @@ public Response getStreamInfo() {
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = SNAPSHOT_DETAILS_RESPONSE_EXAMPLE)))
schema = @Schema(implementation = SnapshotDetails.class)))
@Operation(summary = "Retrieve snapshot details", operationId = "getSnapshotDetails")
public Response getSnapshotDetails(
@QueryParam("snapshotNames") List<String> snapshotNames,
Expand Down Expand Up @@ -609,48 +609,6 @@ public Response move(@QueryParam(value = "newToken") String newToken) {
});
}

private static final String SNAPSHOT_DETAILS_RESPONSE_EXAMPLE =
"{\n"
+ " \"entity\": [\n"
+ " {\n"
+ " \"Column family name\": \"size_estimates\",\n"
+ " \"Keyspace name\": \"system\",\n"
+ " \"Size on disk\": \"13 bytes\",\n"
+ " \"Snapshot name\": \"truncated-1639687082845-size_estimates\",\n"
+ " \"True size\": \"0 bytes\"\n"
+ " },\n"
+ " {\n"
+ " \"Column family name\": \"table_estimates\",\n"
+ " \"Keyspace name\": \"system\",\n"
+ " \"Size on disk\": \"13 bytes\",\n"
+ " \"Snapshot name\": \"truncated-1639687082982-table_estimates\",\n"
+ " \"True size\": \"0 bytes\"\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"
+ "}";

private static final String FQL_QUERY_RESPONSE_EXAMPLE =
"{\n"
+ " \"entity\": false,\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright DataStax, Inc.
*
* Please see the included license file for details.
*/
package com.datastax.mgmtapi.resources.models;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class SnapshotDetails extends BaseEntity {

@JsonProperty(value = "entity", required = true)
public final List<Map<String, String>> entity;

@JsonCreator
public SnapshotDetails(
@JsonProperty("entity") List<Map<String, String>> entity,
@JsonProperty("variant") BaseEntity.Variant variant,
@JsonProperty("annotations") List<String> annotations,
@JsonProperty("mediaType") BaseEntity.MediaType mediaType,
@JsonProperty("language") String language,
@JsonProperty("encoding") String encoding) {
super(variant, annotations, mediaType, language, encoding);
this.entity = entity;
}

@Override
public int hashCode() {
int hash = super.hashCode();
hash = 83 * hash + Objects.hashCode(this.entity);
return hash;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final SnapshotDetails other = (SnapshotDetails) obj;
if (!Objects.equals(this.entity, other.entity)) {
return false;
}
return super.equals(obj);
}
}

0 comments on commit 547c077

Please sign in to comment.