
io.k8s.api.authentication.v1.BoundObjectReference.scala Maven / Gradle / Ivy
package io.k8s.api.authentication.v1
import dev.hnaderi.k8s.utils._
/** BoundObjectReference is a reference to an object that a token is bound to. */
final case class BoundObjectReference(
apiVersion : Option[String] = None,
kind : Option[String] = None,
name : Option[String] = None,
uid : Option[String] = None
) {
/** Returns a new data with apiVersion set to new value */
def withApiVersion(value: String) : BoundObjectReference = copy(apiVersion = Some(value))
/** if apiVersion has a value, transforms to the result of function*/
def mapApiVersion(f: String => String) : BoundObjectReference = copy(apiVersion = apiVersion.map(f))
/** Returns a new data with kind set to new value */
def withKind(value: String) : BoundObjectReference = copy(kind = Some(value))
/** if kind has a value, transforms to the result of function*/
def mapKind(f: String => String) : BoundObjectReference = copy(kind = kind.map(f))
/** Returns a new data with name set to new value */
def withName(value: String) : BoundObjectReference = copy(name = Some(value))
/** if name has a value, transforms to the result of function*/
def mapName(f: String => String) : BoundObjectReference = copy(name = name.map(f))
/** Returns a new data with uid set to new value */
def withUid(value: String) : BoundObjectReference = copy(uid = Some(value))
/** if uid has a value, transforms to the result of function*/
def mapUid(f: String => String) : BoundObjectReference = copy(uid = uid.map(f))
}
object BoundObjectReference {
implicit val encoder : Encoder[io.k8s.api.authentication.v1.BoundObjectReference] = new Encoder[io.k8s.api.authentication.v1.BoundObjectReference] {
def apply[T : Builder](o: io.k8s.api.authentication.v1.BoundObjectReference) : T = {
val obj = ObjectWriter[T]()
obj
.write("apiVersion", o.apiVersion)
.write("kind", o.kind)
.write("name", o.name)
.write("uid", o.uid)
.build
}
}
implicit val decoder: Decoder[BoundObjectReference] = new Decoder[BoundObjectReference] {
def apply[T : Reader](t: T): Either[String, BoundObjectReference] = for {
obj <- ObjectReader(t)
apiVersion <- obj.readOpt[String]("apiVersion")
kind <- obj.readOpt[String]("kind")
name <- obj.readOpt[String]("name")
uid <- obj.readOpt[String]("uid")
} yield BoundObjectReference (
apiVersion = apiVersion,
kind = kind,
name = name,
uid = uid
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy