
io.k8s.api.flowcontrol.v1.NonResourcePolicyRule.scala Maven / Gradle / Ivy
package io.k8s.api.flowcontrol.v1
import dev.hnaderi.k8s.utils._
/** NonResourcePolicyRule is a predicate that matches non-resource requests according to their verb and the target non-resource URL. A NonResourcePolicyRule matches a request if and only if both (a) at least one member of verbs matches the request and (b) at least one member of nonResourceURLs matches the request. */
final case class NonResourcePolicyRule(
nonResourceURLs : Seq[String],
verbs : Seq[String]
) {
/** Returns a new data with nonResourceURLs set to new value */
def withNonResourceURLs(value: Seq[String]) : NonResourcePolicyRule = copy(nonResourceURLs = value)
/** Appends new values to nonResourceURLs */
def addNonResourceURLs(newValues: String*) : NonResourcePolicyRule = copy(nonResourceURLs = nonResourceURLs ++ newValues)
/** transforms nonResourceURLs to result of function */
def mapNonResourceURLs(f: Seq[String] => Seq[String]) : NonResourcePolicyRule = copy(nonResourceURLs = f(nonResourceURLs))
/** Returns a new data with verbs set to new value */
def withVerbs(value: Seq[String]) : NonResourcePolicyRule = copy(verbs = value)
/** Appends new values to verbs */
def addVerbs(newValues: String*) : NonResourcePolicyRule = copy(verbs = verbs ++ newValues)
/** transforms verbs to result of function */
def mapVerbs(f: Seq[String] => Seq[String]) : NonResourcePolicyRule = copy(verbs = f(verbs))
}
object NonResourcePolicyRule {
implicit val encoder : Encoder[io.k8s.api.flowcontrol.v1.NonResourcePolicyRule] = new Encoder[io.k8s.api.flowcontrol.v1.NonResourcePolicyRule] {
def apply[T : Builder](o: io.k8s.api.flowcontrol.v1.NonResourcePolicyRule) : T = {
val obj = ObjectWriter[T]()
obj
.write("nonResourceURLs", o.nonResourceURLs)
.write("verbs", o.verbs)
.build
}
}
implicit val decoder: Decoder[NonResourcePolicyRule] = new Decoder[NonResourcePolicyRule] {
def apply[T : Reader](t: T): Either[String, NonResourcePolicyRule] = for {
obj <- ObjectReader(t)
nonResourceURLs <- obj.read[Seq[String]]("nonResourceURLs")
verbs <- obj.read[Seq[String]]("verbs")
} yield NonResourcePolicyRule (
nonResourceURLs = nonResourceURLs,
verbs = verbs
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy