
io.k8s.api.events.v1.EventSeries.scala Maven / Gradle / Ivy
package io.k8s.api.events.v1
import dev.hnaderi.k8s.utils._
/** EventSeries contain information on series of events, i.e. thing that was/is happening continuously for some time. How often to update the EventSeries is up to the event reporters. The default event reporter in "k8s.io/client-go/tools/events/event_broadcaster.go" shows how this struct is updated on heartbeats and can guide customized reporter implementations. */
final case class EventSeries(
count : Int,
lastObservedTime : io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime
) {
/** Returns a new data with count set to new value */
def withCount(value: Int) : EventSeries = copy(count = value)
/** transforms count to result of function */
def mapCount(f: Int => Int) : EventSeries = copy(count = f(count))
/** Returns a new data with lastObservedTime set to new value */
def withLastObservedTime(value: io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime) : EventSeries = copy(lastObservedTime = value)
/** transforms lastObservedTime to result of function */
def mapLastObservedTime(f: io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime => io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime) : EventSeries = copy(lastObservedTime = f(lastObservedTime))
}
object EventSeries {
implicit val encoder : Encoder[io.k8s.api.events.v1.EventSeries] = new Encoder[io.k8s.api.events.v1.EventSeries] {
def apply[T : Builder](o: io.k8s.api.events.v1.EventSeries) : T = {
val obj = ObjectWriter[T]()
obj
.write("count", o.count)
.write("lastObservedTime", o.lastObservedTime)
.build
}
}
implicit val decoder: Decoder[EventSeries] = new Decoder[EventSeries] {
def apply[T : Reader](t: T): Either[String, EventSeries] = for {
obj <- ObjectReader(t)
count <- obj.read[Int]("count")
lastObservedTime <- obj.read[io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime]("lastObservedTime")
} yield EventSeries (
count = count,
lastObservedTime = lastObservedTime
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy