package server

import (
	"google.golang.org/genproto/googleapis/rpc/errdetails"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

const (
	reasonInvalidBootstrapCapacityMode      = "INVALID_BOOTSTRAP_CAPACITY_MODE"
	reasonInvalidBootstrapCapacity          = "INVALID_BOOTSTRAP_CAPACITY"
	reasonBootstrapRURangeUnavailable       = "BOOTSTRAP_RCU_RANGE_UNAVAILABLE"
	reasonNodeSpecsUnavailable              = "NODE_SPECS_UNAVAILABLE"
	reasonProvisionConfigurationUnavailable = "PROVISION_CONFIGURATION_UNAVAILABLE"
	reasonO11yCIDRConfigurationMissing      = "O11Y_CIDR_CONFIGURATION_MISSING"
	reasonO11yCIDRConflict                  = "O11Y_CIDR_CONFLICT"

	reasonPauseResumeOperationInProgress   = "OPERATION_IN_PROGRESS"
	reasonPauseResumeInvalidState          = "INVALID_STATE"
	reasonPauseResumeDependencyUnavailable = "DEPENDENCY_UNAVAILABLE"
)

func resourcePoolStatusError(code codes.Code, reason, message string) error {
	st := status.New(code, message)
	withDetails, err := st.WithDetails(&errdetails.ErrorInfo{
		Reason: reason,
		Domain: "cluster-service-ng",
	})
	if err != nil {
		return st.Err()
	}
	return withDetails.Err()
}
