package privatelink

import (
	"context"

	eksv1alpha1 "github.com/tidbcloud/eks-provider/api/v1alpha1"
	"github.com/tidbcloud/infra-provider/pkg/procedure"
	"k8s.io/apimachinery/pkg/types"
	"sigs.k8s.io/controller-runtime/pkg/client"
)

// Procedure is the interface for async deploying a single resource.
type Procedure interface {
	// Deploy deploys resource for the specified tenant.
	// The operation needs to be idempotent.
	Deploy(ctx context.Context, base, infra client.Client, info ProcedureInfo) error
	// Status retrieves the status for the deploying step.
	Status(ctx context.Context, base client.Reader, infra client.Client, info ProcedureInfo) (bool, error)
	// Name returns the name of the step.
	Name() string
}

// ProcedureInfo contains the procedure information.
type ProcedureInfo struct {
	// Region specifies the AWS region for the privatelink.
	Region string
	// VpcID is the ID of the VPC.
	VpcID string
	// SubnetIDs is the subnet IDs of the VPC.
	SubnetIDs []string
	// SecurityGroupIDs is the list of security groups for the private link.
	SecurityGroupIDs []string
	// Service is the namespaced name of the service to be exposed.
	Service types.NamespacedName
	// NLBARN is the ARN of the NLB.
	NLBARN string
	// privatelink is the pointer to Privatelink object
	privatelink *eksv1alpha1.Privatelink
	// namespace is the namespace for procedure information
	namespace string
	// clientProviderInfo stores the crossplane provider information
	clientProviderInfo *procedure.AssumedRole
	// serverProviderInfo stores the crossplane provider information
	serverProviderInfo *procedure.AssumedRole
}
