
io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceSubresourceScale.scala Maven / Gradle / Ivy
package io.k8s.apiextensions_apiserver.pkg.apis.apiextensions.v1
import dev.hnaderi.k8s.utils._
/** CustomResourceSubresourceScale defines how to serve the scale subresource for CustomResources. */
final case class CustomResourceSubresourceScale(
specReplicasPath : String,
statusReplicasPath : String,
labelSelectorPath : Option[String] = None
) {
/** Returns a new data with specReplicasPath set to new value */
def withSpecReplicasPath(value: String) : CustomResourceSubresourceScale = copy(specReplicasPath = value)
/** transforms specReplicasPath to result of function */
def mapSpecReplicasPath(f: String => String) : CustomResourceSubresourceScale = copy(specReplicasPath = f(specReplicasPath))
/** Returns a new data with statusReplicasPath set to new value */
def withStatusReplicasPath(value: String) : CustomResourceSubresourceScale = copy(statusReplicasPath = value)
/** transforms statusReplicasPath to result of function */
def mapStatusReplicasPath(f: String => String) : CustomResourceSubresourceScale = copy(statusReplicasPath = f(statusReplicasPath))
/** Returns a new data with labelSelectorPath set to new value */
def withLabelSelectorPath(value: String) : CustomResourceSubresourceScale = copy(labelSelectorPath = Some(value))
/** if labelSelectorPath has a value, transforms to the result of function*/
def mapLabelSelectorPath(f: String => String) : CustomResourceSubresourceScale = copy(labelSelectorPath = labelSelectorPath.map(f))
}
object CustomResourceSubresourceScale {
implicit val encoder : Encoder[io.k8s.apiextensions_apiserver.pkg.apis.apiextensions.v1.CustomResourceSubresourceScale] = new Encoder[io.k8s.apiextensions_apiserver.pkg.apis.apiextensions.v1.CustomResourceSubresourceScale] {
def apply[T : Builder](o: io.k8s.apiextensions_apiserver.pkg.apis.apiextensions.v1.CustomResourceSubresourceScale) : T = {
val obj = ObjectWriter[T]()
obj
.write("specReplicasPath", o.specReplicasPath)
.write("statusReplicasPath", o.statusReplicasPath)
.write("labelSelectorPath", o.labelSelectorPath)
.build
}
}
implicit val decoder: Decoder[CustomResourceSubresourceScale] = new Decoder[CustomResourceSubresourceScale] {
def apply[T : Reader](t: T): Either[String, CustomResourceSubresourceScale] = for {
obj <- ObjectReader(t)
specReplicasPath <- obj.read[String]("specReplicasPath")
statusReplicasPath <- obj.read[String]("statusReplicasPath")
labelSelectorPath <- obj.readOpt[String]("labelSelectorPath")
} yield CustomResourceSubresourceScale (
specReplicasPath = specReplicasPath,
statusReplicasPath = statusReplicasPath,
labelSelectorPath = labelSelectorPath
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy