// Code generated by applyconfiguration-gen. DO NOT EDIT.

package v1

import (
	configv1 "github.com/openshift/api/config/v1"
)

// TokenClaimValidationRuleApplyConfiguration represents a declarative configuration of the TokenClaimValidationRule type for use
// with apply.
//
// TokenClaimValidationRule represents a validation rule based on token claims.
// If type is RequiredClaim, requiredClaim must be set.
// If Type is CEL, CEL must be set and RequiredClaim must be omitted.
type TokenClaimValidationRuleApplyConfiguration struct {
	// type is an optional field that configures the type of the validation rule.
	//
	// Allowed values are "RequiredClaim" and "CEL".
	//
	// When set to 'RequiredClaim', the Kubernetes API server will be configured to validate that the incoming JWT contains the required claim and that its value matches the required value.
	//
	// When set to 'CEL', the Kubernetes API server will be configured to validate the incoming JWT against the configured CEL expression.
	Type *configv1.TokenValidationRuleType `json:"type,omitempty"`
	// requiredClaim allows configuring a required claim name and its expected value.
	// This field is required when `type` is set to RequiredClaim, and must be omitted when `type` is set to any other value.
	// The Kubernetes API server uses this field to validate if an incoming JWT is valid for this identity provider.
	RequiredClaim *TokenRequiredClaimApplyConfiguration `json:"requiredClaim,omitempty"`
	// cel holds the CEL expression and message for validation.
	// Must be set when Type is "CEL", and forbidden otherwise.
	CEL *TokenClaimValidationCELRuleApplyConfiguration `json:"cel,omitempty"`
}

// TokenClaimValidationRuleApplyConfiguration constructs a declarative configuration of the TokenClaimValidationRule type for use with
// apply.
func TokenClaimValidationRule() *TokenClaimValidationRuleApplyConfiguration {
	return &TokenClaimValidationRuleApplyConfiguration{}
}

// WithType sets the Type field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Type field is set to the value of the last call.
func (b *TokenClaimValidationRuleApplyConfiguration) WithType(value configv1.TokenValidationRuleType) *TokenClaimValidationRuleApplyConfiguration {
	b.Type = &value
	return b
}

// WithRequiredClaim sets the RequiredClaim field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the RequiredClaim field is set to the value of the last call.
func (b *TokenClaimValidationRuleApplyConfiguration) WithRequiredClaim(value *TokenRequiredClaimApplyConfiguration) *TokenClaimValidationRuleApplyConfiguration {
	b.RequiredClaim = value
	return b
}

// WithCEL sets the CEL field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the CEL field is set to the value of the last call.
func (b *TokenClaimValidationRuleApplyConfiguration) WithCEL(value *TokenClaimValidationCELRuleApplyConfiguration) *TokenClaimValidationRuleApplyConfiguration {
	b.CEL = value
	return b
}
