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

package v1

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

// UsernameClaimMappingApplyConfiguration represents a declarative configuration of the UsernameClaimMapping type for use
// with apply.
type UsernameClaimMappingApplyConfiguration struct {
	// claim is an optional field that configures the JWT token claim whose value is assigned to the cluster identity field associated with this mapping.
	// claim is required when the ExternalOIDCWithUpstreamParity feature gate is not enabled.
	// When the ExternalOIDCWithUpstreamParity feature gate is enabled, claim must not be set when expression is set.
	//
	// claim must not be an empty string ("") and must not exceed 256 characters.
	Claim *string `json:"claim,omitempty"`
	// expression is an optional CEL expression used to derive
	// the username from JWT claims.
	//
	// CEL expressions have access to the token claims
	// through a CEL variable, 'claims'.
	//
	// expression must be at least 1 character and must not exceed 1024 characters in length.
	// expression must not be set when claim is set.
	Expression *string `json:"expression,omitempty"`
	// prefixPolicy is an optional field that configures how a prefix should be applied to the value of the JWT claim specified in the 'claim' field.
	//
	// Allowed values are 'Prefix', 'NoPrefix', and omitted (not provided or an empty string).
	//
	// When set to 'Prefix', the value specified in the prefix field will be prepended to the value of the JWT claim.
	// The prefix field must be set when prefixPolicy is 'Prefix'.
	// Must not be set to 'Prefix' when expression is set.
	// When set to 'NoPrefix', no prefix will be prepended to the value of the JWT claim.
	// When omitted, this means no opinion and the platform is left to choose any prefixes that are applied which is subject to change over time.
	// Currently, the platform prepends `{issuerURL}#` to the value of the JWT claim when the claim is not 'email'.
	//
	// As an example, consider the following scenario:
	//
	// `prefix` is unset, `issuerURL` is set to `https://myoidc.tld`,
	// the JWT claims include "username":"userA" and "email":"userA@myoidc.tld",
	// and `claim` is set to:
	// - "username": the mapped value will be "https://myoidc.tld#userA"
	// - "email": the mapped value will be "userA@myoidc.tld"
	PrefixPolicy *configv1.UsernamePrefixPolicy `json:"prefixPolicy,omitempty"`
	// prefix configures the prefix that should be prepended to the value of the JWT claim.
	//
	// prefix must be set when prefixPolicy is set to 'Prefix' and must be unset otherwise.
	Prefix *UsernamePrefixApplyConfiguration `json:"prefix,omitempty"`
}

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

// WithClaim sets the Claim 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 Claim field is set to the value of the last call.
func (b *UsernameClaimMappingApplyConfiguration) WithClaim(value string) *UsernameClaimMappingApplyConfiguration {
	b.Claim = &value
	return b
}

// WithExpression sets the Expression 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 Expression field is set to the value of the last call.
func (b *UsernameClaimMappingApplyConfiguration) WithExpression(value string) *UsernameClaimMappingApplyConfiguration {
	b.Expression = &value
	return b
}

// WithPrefixPolicy sets the PrefixPolicy 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 PrefixPolicy field is set to the value of the last call.
func (b *UsernameClaimMappingApplyConfiguration) WithPrefixPolicy(value configv1.UsernamePrefixPolicy) *UsernameClaimMappingApplyConfiguration {
	b.PrefixPolicy = &value
	return b
}

// WithPrefix sets the Prefix 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 Prefix field is set to the value of the last call.
func (b *UsernameClaimMappingApplyConfiguration) WithPrefix(value *UsernamePrefixApplyConfiguration) *UsernameClaimMappingApplyConfiguration {
	b.Prefix = value
	return b
}
