mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-29 03:51:54 +08:00
parameter create fix && itsm add quick complete method
This commit is contained in:
@@ -28,8 +28,16 @@ func SendHTTPErrorHeader(w http.ResponseWriter, statusCode int) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
}
|
||||
|
||||
func SetHTTPRedirectLocationHeader(w http.ResponseWriter, location string) {
|
||||
w.Header().Set("Location", location)
|
||||
}
|
||||
|
||||
func HTTPError(w http.ResponseWriter, msg string, statusCode int, class string, error httputils.Error) {
|
||||
SendHTTPErrorHeader(w, statusCode)
|
||||
if statusCode >= 300 && statusCode <= 400 {
|
||||
SetHTTPRedirectLocationHeader(w, msg)
|
||||
}
|
||||
|
||||
body := jsonutils.NewDict()
|
||||
body.Add(jsonutils.NewInt(int64(statusCode)), "code")
|
||||
body.Add(jsonutils.NewString(msg), "details")
|
||||
|
||||
@@ -72,6 +72,9 @@ func NewClient(authUrl string, timeout int, debug bool, insecure bool, certFile,
|
||||
debug: debug,
|
||||
httpconn: &http.Client{
|
||||
Transport: tr,
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
}, // 不自动处理重定向请求
|
||||
},
|
||||
}
|
||||
return &client
|
||||
|
||||
@@ -14,14 +14,38 @@
|
||||
|
||||
package modules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
type SProcessTasksManager struct {
|
||||
ResourceManager
|
||||
}
|
||||
|
||||
var (
|
||||
ProcessTasks ResourceManager
|
||||
ProcessTasks SProcessTasksManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
ProcessTasks = NewITSMManager("process-task", "process-tasks",
|
||||
ProcessTasks = SProcessTasksManager{NewITSMManager("process-task", "process-tasks",
|
||||
[]string{"id", "name", "description", "owner", "priority", "tenant_id"},
|
||||
[]string{},
|
||||
)
|
||||
)}
|
||||
|
||||
register(&ProcessTasks)
|
||||
}
|
||||
|
||||
func (this *SProcessTasksManager) QuickComplete(s *mcclient.ClientSession, params jsonutils.JSONObject) error {
|
||||
path := fmt.Sprintf("/%s/quick-complete", this.KeywordPlural)
|
||||
if params != nil {
|
||||
qs := params.QueryString()
|
||||
if len(qs) > 0 {
|
||||
path = fmt.Sprintf("%s?%s", path, qs)
|
||||
}
|
||||
}
|
||||
_, err := this._get(s, path, "")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -165,6 +165,10 @@ func (manager *SParameterManager) AllowListItems(ctx context.Context, userCred m
|
||||
return db.IsAdminAllowList(userCred, manager)
|
||||
}
|
||||
|
||||
func (manager *SParameterManager) NamespaceScope() rbacutils.TRbacScope {
|
||||
return rbacutils.ScopeUser
|
||||
}
|
||||
|
||||
func (manager *SParameterManager) AllowCreateItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
if !isAdminQuery(query) {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user