package ngoperation

import (
	"context"

	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
	"go.uber.org/mock/gomock"

	clusterng "github.com/tidbcloud/cluster-service-ng/api/cluster-service-ng/v1beta"
	baseapi "github.com/tidbcloud/devops/api"
	opent "github.com/tidbcloud/devops/entity/operation"
	"github.com/tidbcloud/devops/pkg/infra/clients/coresvccli"
	"github.com/tidbcloud/devops/pkg/infra/clients/mgmthttpcli"
	"github.com/tidbcloud/devops/pkg/infra/errs"
	"github.com/tidbcloud/devops/pkg/service/operation/actions"
	commonv1 "github.com/tidbcloud/tidb-management-service/api/spec/global/common/v1"
	nextgenv1 "github.com/tidbcloud/tidb-management-service/api/spec/global/nextgen/v1"
	mgmtv1 "github.com/tidbcloud/tidb-management-service/api/spec/tidb_mgmt_service/v1"
	"google.golang.org/grpc"
)

var _ = Describe("SetCassandra", func() {
	baseInstance := func(params map[opent.ParamName]string) *opent.Instance {
		result := &opent.Instance{
			Operation: operationScaleCassandra,
			Params: map[opent.ParamName]string{
				opent.ParamClusterID:      "1234567890",
				opent.ParamResourcePoolID: "2045660260714151936",
				opent.ParamMinNodeCount:   "2",
				opent.ParamMaxNodeCount:   "6",
				opent.ParamCpuCores:       "4",
				opent.ParamMemoryGi:       "8",
			},
		}
		for k, v := range params {
			result.Params[k] = v
		}
		return result
	}

	defaultResourcePool := func() *nextgenv1.ResourcePoolProfile {
		return &nextgenv1.ResourcePoolProfile{
			ResourcePool: &nextgenv1.ResourcePool{
				Id: 2045660260714151936,
			},
			Region: &commonv1.Region{
				LogicalName:     "us-west-2",
				CloudProviderId: commonv1.CloudProvider_AWS,
			},
		}
	}

	newActionWithResourcePool := func(ctrl *gomock.Controller, regional mgmthttpcli.NextGenRegionServer, rp *nextgenv1.ResourcePoolProfile, rpErr error, expectRegional bool) *setCassandra {
		mgmt := mgmthttpcli.NewMockMgmtHTTPClient(ctrl)
		if expectRegional {
			mgmt.EXPECT().NextGenRegionServer("us-west-2", "aws").Return(regional).AnyTimes()
		}
		return &setCassandra{comps: &actions.Components{
			MgmtHTTP: mgmt,
			CoreSvc: &coresvccli.CoreSvcCli{
				Mgmt: &coresvccli.MgmtService{
					ResourcePool: &fakeResourcePoolServiceClient{
						resourcePool: rp,
						err:          rpErr,
					},
				},
			},
		}}
	}

	newAction := func(ctrl *gomock.Controller, regional mgmthttpcli.NextGenRegionServer) *setCassandra {
		return newActionWithResourcePool(ctrl, regional, defaultResourcePool(), nil, true)
	}

	Describe("Metadata", func() {
		It("returns basic properties", func() {
			action := &setCassandra{}
			meta := action.Metadata()
			Expect(meta.Name).To(Equal(opent.ActionName("set_cassandra")))
			Expect(meta.Type).To(Equal(opent.ActionTypeAuto))
		})
	})

	Describe("getParam", func() {
		It("builds SetCassandraProxy request from scale params", func() {
			action := &setCassandra{}

			req, clusterID, sharedPoolID, err := action.getParam(baseInstance(nil))

			Expect(err).NotTo(HaveOccurred())
			Expect(clusterID).To(Equal("1234567890"))
			Expect(sharedPoolID).To(Equal("2045660260714151936"))
			Expect(req.GetClusterId()).To(Equal("1234567890"))
			Expect(req.GetNodeQuota().GetNodeCount()).To(Equal(uint32(2)))
			Expect(req.GetNodeQuota().GetMinNodeCount()).To(Equal(uint32(2)))
			Expect(req.GetNodeQuota().GetMaxNodeCount()).To(Equal(uint32(6)))
			Expect(req.GetNodeQuota().GetNodeSpec().GetCpu()).To(Equal(uint32(4)))
			Expect(req.GetNodeQuota().GetNodeSpec().GetMemoryGi()).To(Equal(uint32(8)))
			Expect(req.Image).To(BeNil())
			Expect(req.GetForce()).To(BeFalse())
		})

		It("sets force_scale only for ScaleCassandra", func() {
			action := &setCassandra{}
			instance := baseInstance(map[opent.ParamName]string{opent.ParamForceScale: "true"})

			req, _, _, err := action.getParam(instance)
			Expect(err).NotTo(HaveOccurred())
			Expect(req.GetForce()).To(BeTrue())

			instance.Operation = operationEnableCassandra
			req, _, _, err = action.getParam(instance)
			Expect(err).NotTo(HaveOccurred())
			Expect(req.GetForce()).To(BeFalse())
		})

		It("sets optional image when provided", func() {
			action := &setCassandra{}

			req, _, _, err := action.getParam(baseInstance(map[opent.ParamName]string{
				opent.ParamImage: "  ghcr.io/pingcap/cassandra-proxy:test  ",
			}))

			Expect(err).NotTo(HaveOccurred())
			Expect(req.Image).NotTo(BeNil())
			Expect(req.GetImage()).To(Equal("ghcr.io/pingcap/cassandra-proxy:test"))
		})

		It("rejects invalid replica bounds", func() {
			action := &setCassandra{}

			_, _, _, err := action.getParam(baseInstance(map[opent.ParamName]string{
				opent.ParamMinNodeCount: "7",
			}))

			Expect(err).To(HaveOccurred())
		})
	})

	Describe("PreCheck", func() {
		It("rejects missing cassandra proxy", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				getCassandraProxyErr: errs.APIErrorf(baseapi.ErrCodeNotFound, "not found"),
			}
			action := newAction(ctrl, regional)

			err := action.PreCheck(context.Background(), baseInstance(nil))

			Expect(err).To(HaveOccurred())
		})

		It("rejects non-available cassandra proxy", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				cassandraProxyStatus: &clusterng.GetCassandraProxyResponse{Phase: clusterng.Component_MODIFYING},
			}
			action := newAction(ctrl, regional)

			err := action.PreCheck(context.Background(), baseInstance(nil))

			Expect(err).To(HaveOccurred())
		})

		It("allows an unavailable cassandra proxy with force_scale", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				cassandraProxyStatus: &clusterng.GetCassandraProxyResponse{Phase: clusterng.Component_UNAVAILABLE},
				sharedPool: &mgmthttpcli.SharedPool{ComponentGroups: []*mgmthttpcli.Component{{
					Id:            "1234567890",
					ComponentType: cassandraProxyComponentType,
					NodeQuota: &mgmthttpcli.NodeQuota{
						NodeSpec:     &mgmthttpcli.NodeSpec{Cpu: 4, MemoryGi: 8},
						NodeCount:    1,
						MinNodeCount: 1,
						MaxNodeCount: 6,
					},
				}}},
			}
			instance := baseInstance(map[opent.ParamName]string{opent.ParamForceScale: "true"})
			action := newAction(ctrl, regional)

			err := action.PreCheck(context.Background(), instance)

			Expect(err).NotTo(HaveOccurred())
		})

		It("sets scale direction for available cassandra proxy", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				cassandraProxyStatus: &clusterng.GetCassandraProxyResponse{Phase: clusterng.Component_AVAILABLE},
				sharedPool: &mgmthttpcli.SharedPool{ComponentGroups: []*mgmthttpcli.Component{
					{
						Id:            "1234567890",
						ComponentType: cassandraProxyComponentType,
						NodeQuota: &mgmthttpcli.NodeQuota{
							NodeSpec:     &mgmthttpcli.NodeSpec{Cpu: 4, MemoryGi: 8},
							NodeCount:    1,
							MinNodeCount: 1,
							MaxNodeCount: 6,
						},
					},
				}},
			}
			instance := baseInstance(nil)
			action := newAction(ctrl, regional)

			err := action.PreCheck(context.Background(), instance)

			Expect(err).NotTo(HaveOccurred())
			Expect(instance.Params[cassandraScaleModeParam]).To(Equal(cassandraScaleModeScale))
			Expect(instance.Params[opent.ParamScaleDirection]).To(Equal("up"))
		})

		It("allows EnableCassandra when cassandra proxy is missing", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				getCassandraProxyErr: errs.APIErrorf(baseapi.ErrCodeNotFound, "not found"),
			}
			instance := baseInstance(nil)
			instance.Operation = operationEnableCassandra
			action := newAction(ctrl, regional)

			err := action.PreCheck(context.Background(), instance)

			Expect(err).NotTo(HaveOccurred())
		})

		It("rejects EnableCassandra when cassandra proxy already exists", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				cassandraProxyStatus: &clusterng.GetCassandraProxyResponse{Phase: clusterng.Component_AVAILABLE},
			}
			instance := baseInstance(nil)
			instance.Operation = operationEnableCassandra
			action := newAction(ctrl, regional)

			err := action.PreCheck(context.Background(), instance)

			Expect(err).To(HaveOccurred())
		})

		It("rejects when resource pool metadata is unavailable", func() {
			ctrl := gomock.NewController(GinkgoT())
			action := newActionWithResourcePool(ctrl, &fakeSetCassandraRegionServer{}, nil, errs.APIErrorf(baseapi.ErrCodeNotFound, "resource pool not found"), false)

			err := action.PreCheck(context.Background(), baseInstance(nil))

			Expect(err).To(HaveOccurred())
		})
	})

	Describe("Result", func() {
		It("returns succeeded when GetCassandraProxy is available", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				cassandraProxyStatus: &clusterng.GetCassandraProxyResponse{
					Phase:              clusterng.Component_AVAILABLE,
					InternalEndpoint:   "cassandra.svc:9042",
					PrivatelinkDnsName: "vpce.example.com",
				},
			}
			action := newAction(ctrl, regional)

			result, err := action.Result(context.Background(), baseInstance(nil))

			Expect(err).NotTo(HaveOccurred())
			Expect(result.Result).To(Equal(opent.ActionStatusSucceeded))
			Expect(result.ActionOutput).To(ContainSubstring("vpce.example.com"))
		})
	})

	Describe("Start", func() {
		It("does not call SetCassandraProxy when cassandra proxy is missing", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				getCassandraProxyErr: errs.APIErrorf(baseapi.ErrCodeNotFound, "not found"),
			}
			action := newAction(ctrl, regional)

			result, err := action.Start(context.Background(), baseInstance(nil))

			Expect(err).NotTo(HaveOccurred())
			Expect(result.Result).To(Equal(opent.ActionStatusFailed))
			Expect(regional.setCassandraProxyReq).To(BeNil())
		})

		It("does not call SetCassandraProxy when the desired quota is unchanged", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				cassandraProxyStatus: &clusterng.GetCassandraProxyResponse{Phase: clusterng.Component_AVAILABLE},
				sharedPool: &mgmthttpcli.SharedPool{ComponentGroups: []*mgmthttpcli.Component{
					{
						Id:            "1234567890",
						ComponentType: cassandraProxyComponentType,
						NodeQuota: &mgmthttpcli.NodeQuota{
							NodeSpec:     &mgmthttpcli.NodeSpec{Cpu: 4, MemoryGi: 8},
							NodeCount:    4,
							MinNodeCount: 2,
							MaxNodeCount: 6,
						},
					},
				}},
			}
			instance := baseInstance(nil)
			action := newAction(ctrl, regional)

			result, err := action.Start(context.Background(), instance)

			Expect(err).NotTo(HaveOccurred())
			Expect(result.Result).To(Equal(opent.ActionStatusSucceeded))
			Expect(result.ActionOutput).To(ContainSubstring("already matches"))
			Expect(instance.Params[cassandraScaleModeParam]).To(Equal(cassandraScaleModeNoop))
			Expect(instance.Params[opent.ParamScaleDirection]).To(Equal("up"))
			Expect(regional.setCassandraProxyReq).To(BeNil())
		})

		It("preserves legacy NodeCount when changing quota", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				cassandraProxyStatus: &clusterng.GetCassandraProxyResponse{Phase: clusterng.Component_AVAILABLE},
				sharedPool: &mgmthttpcli.SharedPool{ComponentGroups: []*mgmthttpcli.Component{
					{
						Id:            "1234567890",
						ComponentType: cassandraProxyComponentType,
						NodeQuota: &mgmthttpcli.NodeQuota{
							NodeSpec:     &mgmthttpcli.NodeSpec{Cpu: 4, MemoryGi: 8},
							NodeCount:    4,
							MinNodeCount: 2,
							MaxNodeCount: 6,
						},
					},
				}},
			}
			instance := baseInstance(map[opent.ParamName]string{
				opent.ParamMinNodeCount: "3",
			})
			action := newAction(ctrl, regional)

			result, err := action.Start(context.Background(), instance)

			Expect(err).NotTo(HaveOccurred())
			Expect(result.Result).To(Equal(opent.ActionStatusRunning))
			Expect(instance.Params[cassandraScaleModeParam]).To(Equal(cassandraScaleModeScale))
			Expect(instance.Params[opent.ParamScaleDirection]).To(Equal("up"))
			Expect(regional.setCassandraProxyReq).NotTo(BeNil())
			Expect(regional.setCassandraProxyReq.GetNodeQuota().GetNodeCount()).To(Equal(uint32(4)))
			Expect(regional.setCassandraProxyReq.GetNodeQuota().GetMinNodeCount()).To(Equal(uint32(3)))
		})

		It("calls SetCassandraProxy when only image is provided", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				cassandraProxyStatus: &clusterng.GetCassandraProxyResponse{Phase: clusterng.Component_AVAILABLE},
				sharedPool: &mgmthttpcli.SharedPool{ComponentGroups: []*mgmthttpcli.Component{
					{
						Id:            "1234567890",
						ComponentType: cassandraProxyComponentType,
						NodeQuota: &mgmthttpcli.NodeQuota{
							NodeSpec:     &mgmthttpcli.NodeSpec{Cpu: 4, MemoryGi: 8},
							NodeCount:    4,
							MinNodeCount: 2,
							MaxNodeCount: 6,
						},
					},
				}},
			}
			instance := baseInstance(map[opent.ParamName]string{
				opent.ParamImage: "ghcr.io/pingcap/cassandra-proxy:test",
			})
			action := newAction(ctrl, regional)

			result, err := action.Start(context.Background(), instance)

			Expect(err).NotTo(HaveOccurred())
			Expect(result.Result).To(Equal(opent.ActionStatusRunning))
			Expect(instance.Params[cassandraScaleModeParam]).To(Equal(cassandraScaleModeScale))
			Expect(instance.Params[opent.ParamScaleDirection]).To(Equal("up"))
			Expect(regional.setCassandraProxyReq).NotTo(BeNil())
			Expect(regional.setCassandraProxyReq.GetImage()).To(Equal("ghcr.io/pingcap/cassandra-proxy:test"))
			Expect(regional.setCassandraProxyReq.GetNodeQuota().GetNodeCount()).To(Equal(uint32(4)))
		})

		It("forces a retry for an unavailable cassandra proxy with unchanged quota", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				cassandraProxyStatus: &clusterng.GetCassandraProxyResponse{Phase: clusterng.Component_UNAVAILABLE},
				sharedPool: &mgmthttpcli.SharedPool{ComponentGroups: []*mgmthttpcli.Component{{
					Id:            "1234567890",
					ComponentType: cassandraProxyComponentType,
					NodeQuota: &mgmthttpcli.NodeQuota{
						NodeSpec:     &mgmthttpcli.NodeSpec{Cpu: 4, MemoryGi: 8},
						NodeCount:    2,
						MinNodeCount: 2,
						MaxNodeCount: 6,
					},
				}}},
			}
			instance := baseInstance(map[opent.ParamName]string{opent.ParamForceScale: "true"})
			action := newAction(ctrl, regional)

			result, err := action.Start(context.Background(), instance)

			Expect(err).NotTo(HaveOccurred())
			Expect(result.Result).To(Equal(opent.ActionStatusRunning))
			Expect(instance.Params[cassandraScaleModeParam]).To(Equal(cassandraScaleModeScale))
			Expect(regional.setCassandraProxyReq).NotTo(BeNil())
			Expect(regional.setCassandraProxyReq.GetForce()).To(BeTrue())
		})

		It("calls SetCassandraProxy for EnableCassandra when cassandra proxy is missing", func() {
			ctrl := gomock.NewController(GinkgoT())
			regional := &fakeSetCassandraRegionServer{
				getCassandraProxyErr: errs.APIErrorf(baseapi.ErrCodeNotFound, "not found"),
			}
			instance := baseInstance(nil)
			instance.Operation = operationEnableCassandra
			action := newAction(ctrl, regional)

			result, err := action.Start(context.Background(), instance)

			Expect(err).NotTo(HaveOccurred())
			Expect(result.Result).To(Equal(opent.ActionStatusRunning))
			Expect(result.ActionOutput).To(ContainSubstring("set cassandra proxy"))
			Expect(regional.setCassandraProxyReq).NotTo(BeNil())
			Expect(regional.setCassandraProxyReq.GetClusterId()).To(Equal("1234567890"))
		})

		It("rejects unsupported operations", func() {
			instance := baseInstance(nil)
			instance.Operation = "UnexpectedCassandra"
			action := &setCassandra{}

			result, err := action.Start(context.Background(), instance)

			Expect(err).NotTo(HaveOccurred())
			Expect(result.Result).To(Equal(opent.ActionStatusFailed))
		})
	})

	Describe("computeCassandraScaleDirection", func() {
		It("returns down when quota decreases", func() {
			current := &mgmthttpcli.NodeQuota{
				NodeSpec:     &mgmthttpcli.NodeSpec{Cpu: 4, MemoryGi: 8},
				MinNodeCount: 2,
				MaxNodeCount: 6,
			}
			desired := &mgmthttpcli.NodeQuota{
				NodeSpec:     &mgmthttpcli.NodeSpec{Cpu: 4, MemoryGi: 8},
				MinNodeCount: 2,
				MaxNodeCount: 4,
			}

			Expect(computeCassandraScaleDirection(current, desired)).To(Equal("down"))
		})

		It("returns mixed when quota increases and node spec decreases", func() {
			current := &mgmthttpcli.NodeQuota{
				NodeSpec:     &mgmthttpcli.NodeSpec{Cpu: 4, MemoryGi: 8},
				MinNodeCount: 2,
				MaxNodeCount: 6,
			}
			desired := &mgmthttpcli.NodeQuota{
				NodeSpec:     &mgmthttpcli.NodeSpec{Cpu: 2, MemoryGi: 8},
				MinNodeCount: 3,
				MaxNodeCount: 6,
			}

			Expect(computeCassandraScaleDirection(current, desired)).To(Equal("mixed"))
		})
	})

	Describe("cassandraAdvisoryTargetNodeCount", func() {
		It("keeps current count when it is within desired bounds", func() {
			desired := &clusterng.NodeQuota{
				MinNodeCount: 2,
				MaxNodeCount: 6,
			}

			Expect(cassandraAdvisoryTargetNodeCount(4, desired)).To(Equal(uint32(4)))
		})

		It("clamps to min count when current count is below desired bounds", func() {
			desired := &clusterng.NodeQuota{
				MinNodeCount: 3,
				MaxNodeCount: 6,
			}

			Expect(cassandraAdvisoryTargetNodeCount(2, desired)).To(Equal(uint32(3)))
		})

		It("clamps to max count when current count is above desired bounds", func() {
			desired := &clusterng.NodeQuota{
				MinNodeCount: 2,
				MaxNodeCount: 5,
			}

			Expect(cassandraAdvisoryTargetNodeCount(6, desired)).To(Equal(uint32(5)))
		})
	})
})

type fakeSetCassandraRegionServer struct {
	sharedPool             *mgmthttpcli.SharedPool
	getSharedPoolErr       error
	cassandraProxyStatus   *clusterng.GetCassandraProxyResponse
	getCassandraProxyErr   error
	setCassandraProxyReq   *clusterng.SetCassandraProxyRequest
	setCassandraProxyResp  *clusterng.SetCassandraProxyResponse
	setCassandraProxyError error
}

func (f *fakeSetCassandraRegionServer) GetNextGenDataplane(context.Context, string) (*mgmthttpcli.DataPlane, error) {
	return nil, nil
}

func (f *fakeSetCassandraRegionServer) GetSharedPool(context.Context, string) (*mgmthttpcli.SharedPool, error) {
	return f.sharedPool, f.getSharedPoolErr
}

func (f *fakeSetCassandraRegionServer) ScaleSharedPool(context.Context, string, *mgmthttpcli.ScaleSharedPoolRequest) (*mgmthttpcli.SharedPool, error) {
	return nil, nil
}

func (f *fakeSetCassandraRegionServer) ScaleSharedPoolQuota(context.Context, string, *clusterng.SetSharedPoolComponentQuotaRequest) (*clusterng.Component, error) {
	return nil, nil
}

func (f *fakeSetCassandraRegionServer) SetSharedPoolComponentConfigVersion(context.Context, *clusterng.SetSharedPoolComponentConfigVersionRequest) error {
	return nil
}

func (f *fakeSetCassandraRegionServer) ApplySemConfig(context.Context, *clusterng.ApplySemConfigRequest) error {
	return nil
}

func (f *fakeSetCassandraRegionServer) CreateTiKVGroup(context.Context, *clusterng.CreateTiKVGroupRequest) (*clusterng.Component, error) {
	return nil, nil
}

func (f *fakeSetCassandraRegionServer) DeleteTiKVGroup(context.Context, *mgmthttpcli.DeleteTiKVGroupRequest) error {
	return nil
}

func (f *fakeSetCassandraRegionServer) CreatePlacementPolicy(context.Context, *clusterng.CreatePlacementPolicyRequest) (*clusterng.PlacementPolicy, error) {
	return nil, nil
}

func (f *fakeSetCassandraRegionServer) GetPlacementPolicy(context.Context, *clusterng.GetPlacementPolicyRequest) (*clusterng.PlacementPolicy, error) {
	return nil, nil
}

func (f *fakeSetCassandraRegionServer) ListPlacementPolicies(context.Context, *clusterng.ListPlacementPoliciesRequest) (*clusterng.ListPlacementPoliciesResponse, error) {
	return nil, nil
}

func (f *fakeSetCassandraRegionServer) UpdatePlacementPolicy(context.Context, *clusterng.UpdatePlacementPolicyRequest) (*clusterng.PlacementPolicy, error) {
	return nil, nil
}

func (f *fakeSetCassandraRegionServer) DeletePlacementPolicy(context.Context, *clusterng.DeletePlacementPolicyRequest) error {
	return nil
}

func (f *fakeSetCassandraRegionServer) SetCassandraProxy(_ context.Context, _ string, request *clusterng.SetCassandraProxyRequest) (*clusterng.SetCassandraProxyResponse, error) {
	f.setCassandraProxyReq = request
	if f.setCassandraProxyResp != nil || f.setCassandraProxyError != nil {
		return f.setCassandraProxyResp, f.setCassandraProxyError
	}
	return &clusterng.SetCassandraProxyResponse{Phase: clusterng.Component_MODIFYING}, nil
}

func (f *fakeSetCassandraRegionServer) GetCassandraProxy(context.Context, string) (*clusterng.GetCassandraProxyResponse, error) {
	return f.cassandraProxyStatus, f.getCassandraProxyErr
}

func (f *fakeSetCassandraRegionServer) SetHPAScaleBehavior(context.Context, *clusterng.SetHPAScaleBehaviorRequest) error {
	return nil
}

func (f *fakeSetCassandraRegionServer) SetSharedPoolPDDeploymentMode(context.Context, *clusterng.SetSharedPoolPDDeploymentModeRequest) (*clusterng.SharedPool, error) {
	return nil, nil
}

func (f *fakeSetCassandraRegionServer) SetSharedPoolTiKVRemoteWorkers(context.Context, *clusterng.SetSharedPoolTiKVRemoteWorkersRequest) (*clusterng.SharedPool, error) {
	return nil, nil
}

type fakeResourcePoolServiceClient struct {
	mgmtv1.ResourcePoolServiceClient
	resourcePool *nextgenv1.ResourcePoolProfile
	err          error
}

func (f *fakeResourcePoolServiceClient) CreateResourcePool(context.Context, *nextgenv1.CreateResourcePoolRequest, ...grpc.CallOption) (*nextgenv1.ResourcePoolProfile, error) {
	return nil, nil
}

func (f *fakeResourcePoolServiceClient) ListResourcePools(context.Context, *nextgenv1.ListResourcePoolsRequest, ...grpc.CallOption) (*nextgenv1.ListResourcePoolsResponse, error) {
	return nil, nil
}

func (f *fakeResourcePoolServiceClient) UpdateResourcePoolName(context.Context, *nextgenv1.UpdateResourcePoolNameRequest, ...grpc.CallOption) (*nextgenv1.ResourcePool, error) {
	return nil, nil
}

func (f *fakeResourcePoolServiceClient) UpdateResourcePoolInstanceLimit(context.Context, *nextgenv1.UpdateResourcePoolInstanceLimitRequest, ...grpc.CallOption) (*nextgenv1.ResourcePool, error) {
	return nil, nil
}

func (f *fakeResourcePoolServiceClient) GetResourcePool(context.Context, *nextgenv1.GetResourcePoolRequest, ...grpc.CallOption) (*nextgenv1.ResourcePoolProfile, error) {
	return f.resourcePool, f.err
}

func (f *fakeResourcePoolServiceClient) DeleteResourcePool(context.Context, *nextgenv1.DeleteResourcePoolRequest, ...grpc.CallOption) (*nextgenv1.ResourcePool, error) {
	return nil, nil
}

func (f *fakeResourcePoolServiceClient) ListOrgResourcePools(context.Context, *mgmtv1.ListOrgResourcePoolsRequest, ...grpc.CallOption) (*nextgenv1.ListOwnerResourcePoolsResponse, error) {
	return nil, nil
}

func (f *fakeResourcePoolServiceClient) UpdateOrgDefaultResourcePool(context.Context, *mgmtv1.UpdateOrgDefaultResourcePoolRequest, ...grpc.CallOption) (*nextgenv1.ResourcePoolStrategy, error) {
	return nil, nil
}
