tenanthandler

package
v1.21.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SearchFields   = []string{"tenant_name"}
	FilterFields   = []string{"tenant_name"}
	PreloadFields  = []string{"ResourceQuotas", "Users", "Projects"}
	OrderFields    = []string{"tenant_name", "ID"}
	ModelName      = "Tenant"
	PrimaryKeyName = "tenant_id"
)

Functions

func AfterTenantResourceQuotaSave

func AfterTenantResourceQuotaSave(ctx context.Context, h base.BaseHandler, tx *gorm.DB, trq *models.TenantResourceQuota) error

func CheckOverSold

func CheckOverSold(clusterstatistics statistics.ClusterResourceStatistics, oversoldRate map[v1.ResourceName]float32, before, after v1.ResourceList) error

CheckOverSold To check: ((Capacity * OversoldRate) - (AllTenantAllocated - CurrentTenantAllocated)) > NewTenantAllocated

func CreateOrUpdateTenant

func CreateOrUpdateTenant(ctx context.Context, h base.BaseHandler, clustername, tenantname string, admins, members []string) error

func CreateOrUpdateTenantResourceQuota

func CreateOrUpdateTenantResourceQuota(ctx context.Context, h base.BaseHandler, clustername, tenantname string, data []byte) error

func ParseOversoldConfig

func ParseOversoldConfig(datda []byte) map[v1.ResourceName]float32

func Sub

Types

type GatewayAddr

type GatewayAddr struct {
	Addr   string
	Ready  bool
	Status string
}

type TenantGatewayDetail

type TenantGatewayDetail struct {
	TenantGatewayForm `json:"tenant_gateway"`
	Ingresses         []networkingv1.Ingress `json:"ingresses"`
	Pods              []v1.Pod               `json:"pods"`
	Addresses         []string               `json:"addresses"`
}

type TenantGatewayForm

type TenantGatewayForm struct {
	Cluster string `json:"cluster" binding:"required"`
	Tenant  string `json:"tenant" binding:"required"`
	Type    string `json:"type" binding:"required"`
	Name    string `json:"name" binding:"required"`

	Replicas      int32                   `json:"replicas"`
	Resources     v1.ResourceRequirements `json:"resources,omitempty"`
	ConfigmapData map[string]string       `json:"configmap_data"`
	IngressClass  string                  `json:"ingress_class"`

	HttpPort  int32 `json:"http_port"`
	HttpsPort int32 `json:"https_port"`
	IsHealthy bool  `json:"is_healthy"`
}

type TenantHandler

type TenantHandler struct {
	base.BaseHandler
}

TenantHandler 租户相关 Handler

func (*TenantHandler) CreateTenantGateway

func (h *TenantHandler) CreateTenantGateway(c *gin.Context)

@Tags Tenant @Summary 创建TenantGateway @Description 创建TenantGateway @Accept json @Produce json @Param cluster_id path string true "cluster_id" @Param tenant_id path string true "tenant_id" @Param param body v1beta1.TenantGateway true "表单" @Success 200 {object} handlers.ResponseStruct{Data=v1beta1.TenantGateway} "object" @Router /v1/tenant/{tenant_id}/cluster/{cluster_id}/tenantgateways [post] @Security JWT

func (*TenantHandler) CreateTenantResourceQuotaApply

func (h *TenantHandler) CreateTenantResourceQuotaApply(c *gin.Context)

CreateTenantTenantResourceQuotaApply 创建or修改租户集群资源变更申请 @Tags Tenant @Summary 创建or修改租户集群资源变更申请 @Description 创建or修改租户集群资源变更申请 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param cluster_id path uint true "cluster_id" @Param param body models.TenantResourceQuotaApply true "表单" @Success 200 {object} handlers.ResponseStruct{Data=models.TenantResourceQuotaApply} "models.TenantResourceQuotaApply" @Router /v1/tenant/{tenant_id}/cluster/{cluster_id}/resourceApply [post] @Security JWT

func (*TenantHandler) DeleteTenant

func (h *TenantHandler) DeleteTenant(c *gin.Context)

DeleteTenant 删除 Tenant @Tags Tenant @Summary 删除 Tenant @Description 删除 Tenant @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Success 204 {object} handlers.ResponseStruct "resp" @Router /v1/tenant/{tenant_id} [delete] @Security JWT

func (*TenantHandler) DeleteTenantGateway

func (h *TenantHandler) DeleteTenantGateway(c *gin.Context)

@Tags Tenant @Summary 删除TenantGateway @Description 删除TenantGateway @Accept json @Produce json @Param cluster_id path string true "cluster_id" @Param tenant_id path string true "tenant_id" @Param name path string true "name" @Success 200 {object} handlers.ResponseStruct{Data=string} "object" @Router /v1/tenant/{tenant_id}/cluster/{cluster_id}/tenantgateways/{name} [delete] @Security JWT

func (*TenantHandler) DeleteTenantResourceQuota

func (h *TenantHandler) DeleteTenantResourceQuota(c *gin.Context)

PatchTenantTenantResourceQuota 删除租户在一个集群下的资源 @Tags Tenant @Summary 删除租户在一个集群下的资源 @Description 删除租户在一个集群下的资源 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param cluster_id path uint true "cluster_id" @Success 200 {object} handlers.ResponseStruct{Data=object} "obj" @Router /v1/tenant/{tenant_id}/tenantresourcequota/{:cluster_id} [put] @Security JWT

func (*TenantHandler) DeleteTenantUser

func (h *TenantHandler) DeleteTenantUser(c *gin.Context)

DeleteTenantUser 删除 User 和 Tenant 的关系 @Tags Tenant @Summary 删除 User 和 Tenant 的关系 @Description 删除 User 和 Tenant 的关系 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param user_id path uint true "user_id" @Success 200 {object} handlers.ResponseStruct{Data=models.User} "models.User" @Router /v1/tenant/{tenant_id}/user/{user_id} [delete] @Security JWT

func (*TenantHandler) DisableTenant

func (h *TenantHandler) DisableTenant(c *gin.Context)

DisableTenant 取消激活租户 @Tags Tenant @Summary 取消激活租户,当租户为激活状态的时候才可用 @Description 取消激活租户,当租户为激活状态的时候才可用 @Accept json @Produce json @Param tenantid path int true "tenant_id" @Success 200 {object} handlers.ResponseStruct{Data=[]models.Tenant} "Tenant" @Router /v1/tenant/{tenant_id}/action/disable [post] @Security JWT

func (*TenantHandler) EnableTenant

func (h *TenantHandler) EnableTenant(c *gin.Context)

EnableTenant 激活租户 @Tags Tenant @Summary 激活租户,当租户为未激活状态的时候才可用 @Description 激活租户,当租户为未激活状态的时候才可用 @Accept json @Produce json @Param tenantid path int true "tenantid" @Success 200 {object} handlers.ResponseStruct{Data=[]models.Tenant} "Tenant" @Router /v1/tenant/{tenant_id}/action/enable [post] @Security JWT

func (*TenantHandler) GetObjectTenantGatewayAddr

func (h *TenantHandler) GetObjectTenantGatewayAddr(c *gin.Context)

@Tags Tenant @Summary 获取TenantGateway adddresses @Description 获取TenantGateway adddresses @Accept json @Produce json @Param cluster path string true "cluster" @Param name path string true "name" @Success 200 {object} handlers.ResponseStruct{Data=[]string} "object" @Router /v1/tenant/{tenant_id}/cluster/{cluster_id}/tenantgateways/{name}/addresses [get] @Security JWT

func (*TenantHandler) GetTenantGateway

func (h *TenantHandler) GetTenantGateway(c *gin.Context)

@Tags Tenant @Summary 获取TenantGateway @Description 获取TenantGateway @Accept json @Produce json @Param cluster_id path string true "cluster_id" @Param tenant_id path string true "tenant_id" @Param ingressClass query string true "ingressClass" @Success 200 {object} handlers.ResponseStruct{Data=v1beta1.TenantGateway} "object" @Router /v1/tenant/{tenant_id}/cluster/{cluster_id}/tenantgateways/{name} [get] @Security JWT

func (*TenantHandler) GetTenantTenantResourceQuotaApply

func (h *TenantHandler) GetTenantTenantResourceQuotaApply(c *gin.Context)

GetTenantTenantResourceQuotaApply 获取租户集群资源变更申请详情 @Tags Tenant @Summary 获取租户集群资源变更申请详情 @Description 获取租户集群资源变更申请详情 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param tenantresourcequotaapply_id path uint true "tenantresourcequotaapply_id" @Success 200 {object} handlers.ResponseStruct{Data=models.TenantResourceQuotaApply} "models.TenantResourceQuotaApply" @Router /v1/tenant/{tenant_id}/tenantresourcequotaapply/{tenantresourcequotaapply_id} [get] @Security JWT

func (*TenantHandler) ListEnvironment

func (h *TenantHandler) ListEnvironment(c *gin.Context)

ListEnvironment 获取租户下的所有环境列表 @Tags Tenant @Summary 获取租户下的所有Environment列表 @Description 获取租户下的所有Environment列表 @Accept json @Produce json @Param tenant_id path int true "tenant_id" @Param EnvironmentName query string false "EnvironmentName" @Param preload query string false "choices Creator,Cluster,Project,ResourceQuota,Applications,Users" @Param page query int false "page" @Param size query int false "page" @Param search query string false "search in (EnvironmentName)" @Success 200 {object} handlers.ResponseStruct{Data=handlers.PageData{List=[]models.Environment}} "Environment" @Router /v1/tenant/{tenant_id}/environment [get] @Security JWT

func (*TenantHandler) ListTenant

func (h *TenantHandler) ListTenant(c *gin.Context)

ListTenant 列表 Tenant @Tags Tenant @Summary Tenant列表 @Description Tenant列表 @Accept json @Produce json @Param TenantName query string false "TenantName" @Param preload query string false "choices ResourceQuotas,Users,Projects" @Param page query int false "page" @Param size query int false "page" @Param search query string false "search in (TenantName,Remark)" @Param containAllocatedResourcequota query bool false "是否包含已分配的resourcequota" @Success 200 {object} handlers.ResponseStruct{Data=handlers.PageData{List=[]models.Tenant}} "Tenant" @Router /v1/tenant [get] @Security JWT

func (*TenantHandler) ListTenantGateway

func (h *TenantHandler) ListTenantGateway(c *gin.Context)

@Tags Tenant @Summary 获取TenantGateway 列表 @Description 获取TenantGateway 列表 @Accept json @Produce json @Param cluster_id path string true "cluster_id" @Param tenant_id path string true "tenant_id" @Success 200 {object} handlers.ResponseStruct{Data=[]v1beta1.TenantGateway} "object" @Router /v1/tenant/{tenant_id}/cluster/{cluster_id}/tenantgateways [get] @Security JWT

func (*TenantHandler) ListTenantProject

func (h *TenantHandler) ListTenantProject(c *gin.Context)

ListTenantProject 获取属于Tenant的 Project 列表 @Tags Tenant @Summary 获取属于 Tenant 的 Project 列表 @Description 获取属于 Tenant 的 Project 列表 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param preload query string false "choices Applications,Environments,Registries,Users,Tenant" @Param page query int false "page" @Param size query int false "page" @Param search query string false "search in (ProjectName)" @Success 200 {object} handlers.ResponseStruct{Data=handlers.PageData{List=[]models.Project}} "models.Project" @Router /v1/tenant/{tenant_id}/project [get] @Security JWT

func (*TenantHandler) ListTenantTenantResourceQuota

func (h *TenantHandler) ListTenantTenantResourceQuota(c *gin.Context)

ListTenantTenantResourceQuota 获取属于Tenant的 TenantResourceQuota 列表 @Tags Tenant @Summary 获取属于 Tenant 的 TenantResourceQuota 列表 @Description 获取属于 Tenant 的 TenantResourceQuota 列表 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param preload query string false "choices Tenant,Cluster" @Param page query int false "page" @Param size query int false "page" @Success 200 {object} handlers.ResponseStruct{Data=handlers.PageData{List=[]models.TenantResourceQuota}} "models.TenantResourceQuota" @Router /v1/tenant/{tenant_id}/tenantresourcequota [get] @Security JWT

func (*TenantHandler) ListTenantUser

func (h *TenantHandler) ListTenantUser(c *gin.Context)

ListTenantUser 获取属于Tenant的 User 列表 @Tags Tenant @Summary 获取属于 Tenant 的 User 列表 @Description 获取属于 Tenant 的 User 列表 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param preload query string false "choices Tenants,SystemRole" @Param page query int false "page" @Param size query int false "page" @Param search query string false "search in (Username,Email)" @Success 200 {object} handlers.ResponseStruct{Data=handlers.PageData{List=[]models.User}} "models.User" @Router /v1/tenant/{tenant_id}/user [get] @Security JWT

func (*TenantHandler) PostTenant

func (h *TenantHandler) PostTenant(c *gin.Context)

PostTenant 创建Tenant @Tags Tenant @Summary 创建Tenant @Description 创建Tenant @Accept json @Produce json @Param param body models.Tenant true "表单" @Success 200 {object} handlers.ResponseStruct{Data=models.Tenant} "Tenant" @Router /v1/tenant [post] @Security JWT

func (*TenantHandler) PostTenantProject

func (h *TenantHandler) PostTenantProject(c *gin.Context)

PostTenantProject 创建一个属于 Tenant 的Project @Tags Tenant @Summary 创建一个属于 Tenant 的Project @Description 创建一个属于 Tenant 的Project @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param param body models.Project true "表单" @Success 200 {object} handlers.ResponseStruct{Data=models.Project} "models.Project" @Router /v1/tenant/{tenant_id}/project [post] @Security JWT

func (*TenantHandler) PostTenantTenantResourceQuota

func (h *TenantHandler) PostTenantTenantResourceQuota(c *gin.Context)

PostTenantTenantResourceQuota 创建一个属于 Tenant 的TenantResourceQuota @Tags Tenant @Summary 创建一个属于 Tenant 的TenantResourceQuota @Description 创建一个属于 Tenant 的TenantResourceQuota @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param param body models.TenantResourceQuota true "表单" @Success 200 {object} handlers.ResponseStruct{Data=models.TenantResourceQuota} "models.TenantResourceQuota" @Router /v1/tenant/{tenant_id}/tenantresourcequota [post] @Security JWT

func (*TenantHandler) PostTenantUser

func (h *TenantHandler) PostTenantUser(c *gin.Context)

PostTenantUser 在User和Tenant间添加关联关系 @Tags Tenant @Summary 在User和Tenant间添加关联关系 @Description 在User和Tenant间添加关联关系 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param param body models.TenantUserRels true "表单"` @Success 200 {object} handlers.ResponseStruct{Data=models.TenantUserRels} "models.User" @Router /v1/tenant/{tenant_id}/user [post] @Security JWT

func (*TenantHandler) PutTenant

func (h *TenantHandler) PutTenant(c *gin.Context)

PutTenant 修改Tenant @Tags Tenant @Summary 修改Tenant @Description 修改Tenant @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param param body models.Tenant true "表单" @Success 200 {object} handlers.ResponseStruct{Data=models.Tenant} "Tenant" @Router /v1/tenant/{tenant_id} [put] @Security JWT

func (*TenantHandler) PutTenantTenantResourceQuota

func (h *TenantHandler) PutTenantTenantResourceQuota(c *gin.Context)

PatchTenantTenantResourceQuota 修改一个属于 Tenant 的TenantResourceQuota @Tags Tenant @Summary 修改一个属于 Tenant 的TenantResourceQuota @Description 修改一个属于 Tenant 的TenantResourceQuota @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param cluster_id path uint true "cluster_id" @Param param body models.TenantResourceQuota true "表单" @Success 200 {object} handlers.ResponseStruct{Data=models.TenantResourceQuota} "models.TenantResourceQuota" @Router /v1/tenant/{tenant_id}/tenantresourcequota/{:cluster_id} [put] @Security JWT

func (*TenantHandler) PutTenantUser

func (h *TenantHandler) PutTenantUser(c *gin.Context)

PutTenantUser 修改 User 和 Tenant 的关联关系 @Tags Tenant @Summary 修改 User 和 Tenant 的关联关系 @Description 修改 User 和 Tenant 的关联关系 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param user_id path uint true "user_id" @Param param body models.TenantUserRels true "表单"` @Success 200 {object} handlers.ResponseStruct{Data=models.TenantUserRels} "models.User" @Router /v1/tenant/{tenant_id}/user/{user_id} [put] @Security JWT

func (*TenantHandler) RegistRouter

func (h *TenantHandler) RegistRouter(rg *gin.RouterGroup)

func (*TenantHandler) RetrieveTenant

func (h *TenantHandler) RetrieveTenant(c *gin.Context)

RetrieveTenant Tenant详情 @Tags Tenant @Summary Tenant详情 @Description get Tenant详情 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Success 200 {object} handlers.ResponseStruct{Data=models.Tenant} "Tenant" @Router /v1/tenant/{tenant_id} [get] @Security JWT

func (*TenantHandler) RetrieveTenantProject

func (h *TenantHandler) RetrieveTenantProject(c *gin.Context)

RetrieveTenantProject 获取Tenant 的一个 Project详情 @Tags Tenant @Summary 获取Tenant 的一个 Project详情 @Description 获取Tenant 的一个 Project详情 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param project_id path uint true "project_id" @Success 200 {object} handlers.ResponseStruct{Data=models.Project} "models.Project" @Router /v1/tenant/{tenant_id}/project/{project_id} [get] @Security JWT

func (*TenantHandler) RetrieveTenantTenantResourceQuota

func (h *TenantHandler) RetrieveTenantTenantResourceQuota(c *gin.Context)

RetrieveTenantTenantResourceQuota 获取Tenant 的一个 TenantResourceQuota详情 @Tags Tenant @Summary 获取Tenant 的一个 TenantResourceQuota详情 @Description 获取Tenant 的一个 TenantResourceQuota详情 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param tenantresourcequota_id path uint true "tenantresourcequota_id" @Success 200 {object} handlers.ResponseStruct{Data=models.TenantResourceQuota} "models.TenantResourceQuota" @Router /v1/tenant/{tenant_id}/tenantresourcequota/{tenantresourcequota_id} [get] @Security JWT

func (*TenantHandler) RetrieveTenantUser

func (h *TenantHandler) RetrieveTenantUser(c *gin.Context)

RetrieveTenantUser 获取Tenant 的一个 User详情 @Tags Tenant @Summary 获取Tenant 的一个 User详情 @Description 获取Tenant 的一个 User详情 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param user_id path uint true "user_id" @Success 200 {object} handlers.ResponseStruct{Data=models.User} "models.User" @Router /v1/tenant/{tenant_id}/user/{user_id} [get] @Security JWT

func (*TenantHandler) TenantEnvironments

func (h *TenantHandler) TenantEnvironments(c *gin.Context)

TenantEnvironments 获取租户下所有的环境 @Tags Tenant @Summary 获取租户下所有的环境以及资源状态 @Description 获取租户下所有的环境以及资源状态 @Accept json @Produce json @Param tenant_id path int true "tenant_id" @Param search query string false "search in (EnvironmentName)" @Success 200 {object} handlers.ResponseStruct{Data=[]object} "object" @Router /v1/tenant/{tenant_id}/environment_with_quotas [get] @Security JWT

func (*TenantHandler) TenantStatistics

func (h *TenantHandler) TenantStatistics(c *gin.Context)

TenantStatistics 租户非资源类型统计 @Tags Tenant @Summary 租户非资源类型统计 @Description 租户非资源类型统计 @Accept json @Produce json @Param tenant_id path int true "tenant_id" @Success 200 {object} handlers.ResponseStruct{Data=tenantStatisticsData} "statistics" @Router /v1/tenant/{tenant_id}/statistics [get] @Security JWT

func (*TenantHandler) TenantSwitch

func (h *TenantHandler) TenantSwitch(c *gin.Context)

@Tags NetworkIsolated @Summary 租户网络隔离开关 @Description 租户网络隔离开关 @Accept json @Produce json @Param tenant_id path uint true "tenant_id" @Param param body handlers.ClusterIsolatedSwitch true "表单" @Success 200 {object} handlers.ResponseStruct{Data=handlers.IsolatedSwitch} "object" @Router /v1/tenant/{tenant_id}/action/networkisolate [post] @Security JWT

func (*TenantHandler) UpdateTenantGateway

func (h *TenantHandler) UpdateTenantGateway(c *gin.Context)

@Tags Tenant @Summary 更新TenantGateway @Description 更新TenantGateway @Accept json @Produce json @Param cluster_id path string true "cluster_id" @Param tenant_id path string true "tenant_id" @Param param body v1beta1.TenantGateway true "表单" @Success 200 {object} handlers.ResponseStruct{Data=v1beta1.TenantGateway} "object" @Router /v1/tenant/{tenant_id}/cluster/{cluster_id}/tenantgateways/{name} [put] @Security JWT

func (*TenantHandler) ValidateTenantResourceQuota

func (h *TenantHandler) ValidateTenantResourceQuota(ctx context.Context, clustername string, clusterOversold []byte, origin, need []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL