All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.nemerosa.ontrack.kdsl.spec.extension.av.AutoVersioningAuditMgt.kt Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.kdsl.spec.extension.av

import net.nemerosa.ontrack.kdsl.connector.Connected
import net.nemerosa.ontrack.kdsl.connector.Connector
import net.nemerosa.ontrack.kdsl.connector.graphql.schema.AutoVersioningAuditEntriesQuery
import net.nemerosa.ontrack.kdsl.connector.graphqlConnector

/**
 * Management interface for the audit of the auto versioning
 */
class AutoVersioningAuditMgt(connector: Connector) : Connected(connector) {


    /**
     * Gets the list of auto versioning audit entries
     */
    fun entries(
        offset: Int = 0,
        size: Int = 10,
        source: String? = null,
        project: String,
        branch: String? = null,
        version: String? = null,
    ): List =
        graphqlConnector.query(
            AutoVersioningAuditEntriesQuery.builder()
                .offset(offset)
                .size(size)
                .source(source)
                .project(project)
                .branch(branch)
                .version(version)
                .build()
        )?.autoVersioningAuditEntries()?.pageItems()?.map { item ->
            AutoVersioningAuditEntry(
                order = AutoVersioningOrder(
                    uuid = item.order().uuid(),
                ),
                running = item.running() ?: false,
                mostRecentState = AutoVersioningAuditEntryState(
                    state = item.mostRecentState().state().name,
                    data = item.mostRecentState().data(),
                ),
                audit = item.audit().map { auditEntry ->
                    AutoVersioningAuditEntryState(
                        state = auditEntry.state().name,
                        data = auditEntry.data(),
                    )
                },
                routing = item.routing(),
                queue = item.queue(),
            )
        } ?: emptyList()

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy