Skip to content

Commit

Permalink
Renamed cluster alias field.
Browse files Browse the repository at this point in the history
Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
  • Loading branch information
AWSHurneyt committed Oct 4, 2023
1 parent b53813f commit 6f39143
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ data class ClusterMetricsInput(
var path: String,
var pathParams: String = "",
var url: String,
var clustersAliases: List<String> = listOf()
var clusters: List<String> = listOf()
) : Input {
val clusterMetricType: ClusterMetricType
val constructedUri: URI

// Verify parameters are valid during creation
init {
logger.info("hurneyt ClusterMetricsInput::clustersAliases = $clustersAliases")

// TODO hurneyt
// if (clustersAliases.isNullOrEmpty()) clustersAliases = listOf()
logger.info("hurneyt ClusterMetricsInput::clusters = $clusters")

require(validateFields()) {
"The uri.api_type field, uri.path field, or uri.uri field must be defined."
Expand Down Expand Up @@ -88,7 +85,7 @@ data class ClusterMetricsInput(
.field(PATH_FIELD, path)
.field(PATH_PARAMS_FIELD, pathParams)
.field(URL_FIELD, url)
.field(CLUSTER_ALIASES_FIELD, clustersAliases)
.field(CLUSTERS_FIELD, clusters)
.endObject()
.endObject()
}
Expand All @@ -102,7 +99,7 @@ data class ClusterMetricsInput(
out.writeString(path)
out.writeString(pathParams)
out.writeString(url)
out.writeStringArray(clustersAliases.toTypedArray())
out.writeStringArray(clusters.toTypedArray())
}

companion object {
Expand All @@ -115,7 +112,7 @@ data class ClusterMetricsInput(
const val PATH_PARAMS_FIELD = "path_params"
const val URL_FIELD = "url"
const val URI_FIELD = "uri"
const val CLUSTER_ALIASES_FIELD = "cluster_aliases"
const val CLUSTERS_FIELD = "clusters"

val XCONTENT_REGISTRY = NamedXContentRegistry.Entry(Input::class.java, ParseField(URI_FIELD), CheckedFunction { parseInner(it) })

Expand All @@ -128,7 +125,7 @@ data class ClusterMetricsInput(
var path = ""
var pathParams = ""
var url = ""
val clustersAliases = mutableListOf<String>()
val clusters = mutableListOf<String>()

XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.currentToken(), xcp)

Expand All @@ -139,20 +136,20 @@ data class ClusterMetricsInput(
PATH_FIELD -> path = xcp.text()
PATH_PARAMS_FIELD -> pathParams = xcp.text()
URL_FIELD -> url = xcp.text()
CLUSTER_ALIASES_FIELD -> {
CLUSTERS_FIELD -> {
XContentParserUtils.ensureExpectedToken(
XContentParser.Token.START_ARRAY,
xcp.currentToken(),
xcp
)
while (xcp.nextToken() != XContentParser.Token.END_ARRAY) {
logger.info("hurneyt ClusterMetricsInput::parseInner xcp.text() = ${xcp.text()}")
clustersAliases.add(xcp.text())
clusters.add(xcp.text())
}
}
}
}
return ClusterMetricsInput(path, pathParams, url, clustersAliases)
return ClusterMetricsInput(path, pathParams, url, clusters)
}
}

Expand Down

0 comments on commit 6f39143

Please sign in to comment.