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

io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceColumnDefinition.scala Maven / Gradle / Ivy

package io.k8s.apiextensions_apiserver.pkg.apis.apiextensions.v1

import dev.hnaderi.k8s.utils._

/** CustomResourceColumnDefinition specifies a column for server side printing. */
final case class CustomResourceColumnDefinition(
  name : String,
  jsonPath : String,
  `type` : String,
  format : Option[String] = None,
  priority : Option[Int] = None,
  description : Option[String] = None
) {

  /** Returns a new data with name set to new value */
  def withName(value: String) : CustomResourceColumnDefinition = copy(name = value)
  /** transforms name to result of function */
  def mapName(f: String => String) : CustomResourceColumnDefinition = copy(name = f(name))

  /** Returns a new data with jsonPath set to new value */
  def withJsonPath(value: String) : CustomResourceColumnDefinition = copy(jsonPath = value)
  /** transforms jsonPath to result of function */
  def mapJsonPath(f: String => String) : CustomResourceColumnDefinition = copy(jsonPath = f(jsonPath))

  /** Returns a new data with `type` set to new value */
  def withType(value: String) : CustomResourceColumnDefinition = copy(`type` = value)
  /** transforms `type` to result of function */
  def mapType(f: String => String) : CustomResourceColumnDefinition = copy(`type` = f(`type`))

  /** Returns a new data with format set to new value */
  def withFormat(value: String) : CustomResourceColumnDefinition = copy(format = Some(value))
  /** if format has a value, transforms to the result of function*/
  def mapFormat(f: String => String) : CustomResourceColumnDefinition = copy(format = format.map(f))

  /** Returns a new data with priority set to new value */
  def withPriority(value: Int) : CustomResourceColumnDefinition = copy(priority = Some(value))
  /** if priority has a value, transforms to the result of function*/
  def mapPriority(f: Int => Int) : CustomResourceColumnDefinition = copy(priority = priority.map(f))

  /** Returns a new data with description set to new value */
  def withDescription(value: String) : CustomResourceColumnDefinition = copy(description = Some(value))
  /** if description has a value, transforms to the result of function*/
  def mapDescription(f: String => String) : CustomResourceColumnDefinition = copy(description = description.map(f))
}

object CustomResourceColumnDefinition {

    implicit val encoder : Encoder[io.k8s.apiextensions_apiserver.pkg.apis.apiextensions.v1.CustomResourceColumnDefinition] = new Encoder[io.k8s.apiextensions_apiserver.pkg.apis.apiextensions.v1.CustomResourceColumnDefinition] {
        def apply[T : Builder](o: io.k8s.apiextensions_apiserver.pkg.apis.apiextensions.v1.CustomResourceColumnDefinition) : T = {
          val obj = ObjectWriter[T]()
          obj
            .write("name", o.name)
            .write("jsonPath", o.jsonPath)
            .write("type", o.`type`)
            .write("format", o.format)
            .write("priority", o.priority)
            .write("description", o.description)
            .build
        }
    }

    implicit val decoder: Decoder[CustomResourceColumnDefinition] = new Decoder[CustomResourceColumnDefinition] {
      def apply[T : Reader](t: T): Either[String, CustomResourceColumnDefinition] = for {
          obj <- ObjectReader(t)
          name <- obj.read[String]("name")
          jsonPath <- obj.read[String]("jsonPath")
          `type` <- obj.read[String]("type")
          format <- obj.readOpt[String]("format")
          priority <- obj.readOpt[Int]("priority")
          description <- obj.readOpt[String]("description")
      } yield CustomResourceColumnDefinition (
          name = name,
          jsonPath = jsonPath,
          `type` = `type`,
          format = format,
          priority = priority,
          description = description
        )
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy