override fun toXContent()

in src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ManagedIndexMetaData.kt [103:136]


    override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder {
        // The order we check values matters here as we are only trying to show what is needed for the customer
        // and can return early on certain checks like policyCompleted
        builder
            .field(INDEX, index)
            .field(INDEX_UUID, indexUuid)
            .field(POLICY_ID, policyID)
        if (policySeqNo != null) builder.field(POLICY_SEQ_NO, policySeqNo)
        if (policyPrimaryTerm != null) builder.field(POLICY_PRIMARY_TERM, policyPrimaryTerm)

        // Only show rolled_over if we have rolled over or we are in the rollover action
        if (rolledOver == true || (actionMetaData != null && actionMetaData.name == ActionConfig.ActionType.ROLLOVER.type)) {
            builder.field(ROLLED_OVER, rolledOver)
        }

        if (policyCompleted == true) {
            builder.field(POLICY_COMPLETED, policyCompleted)
            return builder
        }

        val transitionToExists = transitionTo != null
        if (transitionToExists) {
            builder.field(TRANSITION_TO, transitionTo)
        } else {
            builder.addObject(StateMetaData.STATE, stateMetaData, params)
                .addObject(ActionMetaData.ACTION, actionMetaData, params)
                .addObject(StepMetaData.STEP, stepMetaData, params)
        }
        builder.addObject(PolicyRetryInfoMetaData.RETRY_INFO, policyRetryInfo, params)

        if (info != null) builder.field(INFO, info)

        return builder
    }