in reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/model/ReportInstance.kt [143:175]
override fun toXContent(builder: XContentBuilder?, params: ToXContent.Params?): XContentBuilder {
builder!!
builder.startObject()
if (params?.paramAsBoolean(ID_FIELD, false) == true) {
builder.field(ID_FIELD, id)
}
builder.field(UPDATED_TIME_FIELD, updatedTime.toEpochMilli())
.field(CREATED_TIME_FIELD, createdTime.toEpochMilli())
.field(BEGIN_TIME_FIELD, beginTime.toEpochMilli())
.field(END_TIME_FIELD, endTime.toEpochMilli())
.field(TENANT_FIELD, tenant)
if (params?.paramAsBoolean(ACCESS_LIST_FIELD, true) == true && access.isNotEmpty()) {
builder.field(ACCESS_LIST_FIELD, access)
}
if (reportDefinitionDetails != null) {
builder.field(REPORT_DEFINITION_DETAILS_FIELD)
val passingParams = if (params?.param(ID_FIELD) == null) { // If called from index operation
INSTANCE_INDEX_PARAMS
} else {
params
}
reportDefinitionDetails.toXContent(builder, passingParams)
}
builder.field(STATUS_FIELD, status.name)
if (statusText != null) {
builder.field(STATUS_TEXT_FIELD, statusText)
}
if (inContextDownloadUrlPath != null) {
builder.field(IN_CONTEXT_DOWNLOAD_URL_FIELD, inContextDownloadUrlPath)
}
builder.endObject()
return builder
}