// Copyright 2025 Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by applyconfiguration-gen. DO NOT EDIT.

package v1alpha1

import (
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// SessionSpecApplyConfiguration represents a declarative configuration of the SessionSpec type for use
// with apply.
//
// SessionSpec defines the desired state of a Session. All fields are immutable after creation
// to ensure that all interactions remain auditable and to prevent privilege escalation.
// The spec identifies the target HCP, the management cluster hosting it, the access level
// granted, and the owner's identity.
type SessionSpecApplyConfiguration struct {
	// ttl is the time-to-live duration for the session. The session will automatically
	// expire after this duration from its creation time. The expiration timestamp is
	// recorded in status.expiresAt. Once expired, the session's provisioned resources
	// are cleaned up by the controller.
	TTL *v1.Duration `json:"ttl,omitempty"`
	// managementCluster identifies the AKS management cluster where the target HCP is running.
	// The controller uses this to locate and communicate with the correct management cluster
	// when provisioning session resources.
	ManagementCluster *ManagementClusterApplyConfiguration `json:"managementCluster,omitempty"`
	// hostedControlPlane identifies the Hypershift Hosted Control Plane that this session
	// provides access to.
	HostedControlPlane *HostedControlPlaneApplyConfiguration `json:"hostedControlPlane,omitempty"`
	// accessLevel defines the RBAC permissions granted to the session owner when accessing
	// the target HCP. This determines what operations the session owner can perform on the
	// HCP's Kubernetes API server.
	AccessLevel *AccessLevelApplyConfiguration `json:"accessLevel,omitempty"`
	// owner identifies the authenticated principal (user or service principal) that is authorized
	// to use this session. The owner's identity is cryptographically verified by matching JWT
	// claims against tokens presented during authentication.
	//
	// Security: The claims specified here form the sole basis for authentication. Only the entity
	// whose JWT token contains ALL matching claims can access the HCP through this session.
	// The identityName field is informational only and is NOT used for authentication decisions.
	Owner *PrincipalApplyConfiguration `json:"owner,omitempty"`
}

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

// WithTTL sets the TTL 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 TTL field is set to the value of the last call.
func (b *SessionSpecApplyConfiguration) WithTTL(value v1.Duration) *SessionSpecApplyConfiguration {
	b.TTL = &value
	return b
}

// WithManagementCluster sets the ManagementCluster 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 ManagementCluster field is set to the value of the last call.
func (b *SessionSpecApplyConfiguration) WithManagementCluster(value *ManagementClusterApplyConfiguration) *SessionSpecApplyConfiguration {
	b.ManagementCluster = value
	return b
}

// WithHostedControlPlane sets the HostedControlPlane 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 HostedControlPlane field is set to the value of the last call.
func (b *SessionSpecApplyConfiguration) WithHostedControlPlane(value *HostedControlPlaneApplyConfiguration) *SessionSpecApplyConfiguration {
	b.HostedControlPlane = value
	return b
}

// WithAccessLevel sets the AccessLevel 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 AccessLevel field is set to the value of the last call.
func (b *SessionSpecApplyConfiguration) WithAccessLevel(value *AccessLevelApplyConfiguration) *SessionSpecApplyConfiguration {
	b.AccessLevel = value
	return b
}

// WithOwner sets the Owner 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 Owner field is set to the value of the last call.
func (b *SessionSpecApplyConfiguration) WithOwner(value *PrincipalApplyConfiguration) *SessionSpecApplyConfiguration {
	b.Owner = value
	return b
}
