mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
Merge pull request #4067 from rainzm/bugfix/guest_tempalte_param
fix(region): Guest template & Service catalog
This commit is contained in:
@@ -7,14 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type GuesttemplateCreateInput struct {
|
||||
apis.Meta
|
||||
|
||||
// description: guest template name
|
||||
// unique: true
|
||||
// required: true
|
||||
// example: hello
|
||||
Name string `json:"name"`
|
||||
|
||||
apis.SharableVirutalResourceCreateInput
|
||||
// description: the content of guest template
|
||||
// required: true
|
||||
Content jsonutils.JSONObject `json:"content"`
|
||||
|
||||
@@ -3,14 +3,7 @@ package compute
|
||||
import "yunion.io/x/onecloud/pkg/apis"
|
||||
|
||||
type ServiceCatalogCreateInput struct {
|
||||
apis.Meta
|
||||
|
||||
// description: service catalog name
|
||||
// uniqure: true
|
||||
// required: true
|
||||
// example: hello
|
||||
Name string `json:"name`
|
||||
|
||||
apis.SharableVirutalResourceCreateInput
|
||||
// description: service catalog icon url
|
||||
// example: https://yunion.io/files/hello.png
|
||||
IconUrl string `json:"icon_url"`
|
||||
@@ -27,3 +27,9 @@ type SharableVirtualResourceDetails struct {
|
||||
type SharableVirtualResourceListInput struct {
|
||||
StandaloneResourceListInput
|
||||
}
|
||||
|
||||
type SharableVirutalResourceCreateInput struct {
|
||||
VirtualResourceCreateInput
|
||||
IsPublic bool `json:"is_public"`
|
||||
PublicScope string `json:"public_scope"`
|
||||
}
|
||||
|
||||
@@ -27,3 +27,14 @@ type StandaloneResourceListInput struct {
|
||||
Tags []string `json:"tags"`
|
||||
WithoutUserMeta bool `json:"without_user_meta"`
|
||||
}
|
||||
|
||||
type StandaloneResourceCreatInput struct {
|
||||
Meta
|
||||
// description: resource name
|
||||
// unique: true
|
||||
// required: true
|
||||
// example: yunion
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
IsEmulated bool `json:"is_emulated"`
|
||||
}
|
||||
|
||||
@@ -17,3 +17,8 @@ package apis
|
||||
type VirtualResourceDetails struct {
|
||||
ModelBaseDetails
|
||||
}
|
||||
|
||||
type VirtualResourceCreateInput struct {
|
||||
StandaloneResourceCreatInput
|
||||
IsSystem bool `json:"is_system"`
|
||||
}
|
||||
|
||||
@@ -395,3 +395,16 @@ func (gt *SGuestTemplate) genForbiddenError(resourceName, resourceStr, scope str
|
||||
}
|
||||
return httperrors.NewForbiddenError(msg)
|
||||
}
|
||||
|
||||
func (gt *SGuestTemplate) ValidateDeleteCondition(ctx context.Context) error {
|
||||
q := ServiceCatalogManager.Query("name").Equals("guest_template_id", gt.Id)
|
||||
names := make([]string, 0, 1)
|
||||
err := q.All(&names)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "SQuery.All")
|
||||
}
|
||||
if len(names) > 0 {
|
||||
return httperrors.NewForbiddenError("guest template %s used by service catalog %s", gt.Id, names[0])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user