mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-29 17:58:36 +08:00
fix(region): allow update rds account and database desc
This commit is contained in:
@@ -92,3 +92,7 @@ type DBInstanceAccountDetails struct {
|
||||
|
||||
ProjectId string `json:"tenant_id"`
|
||||
}
|
||||
|
||||
type DBInstanceAccountUpdateInput struct {
|
||||
apis.StatusStandaloneResourceBaseUpdateInput
|
||||
}
|
||||
|
||||
@@ -80,3 +80,7 @@ type DBInstanceparameterDetails struct {
|
||||
|
||||
SDBInstanceParameter
|
||||
}
|
||||
|
||||
type DBInstanceDatabaseUpdateInput struct {
|
||||
apis.StatusStandaloneResourceBaseUpdateInput
|
||||
}
|
||||
|
||||
@@ -130,7 +130,19 @@ func (self *SDBInstanceAccount) AllowGetDetails(ctx context.Context, userCred mc
|
||||
}
|
||||
|
||||
func (self *SDBInstanceAccount) AllowUpdateItem(ctx context.Context, userCred mcclient.TokenCredential) bool {
|
||||
return false
|
||||
return db.IsProjectAllowUpdate(userCred, self)
|
||||
}
|
||||
|
||||
func (self *SDBInstanceAccount) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.DBInstanceAccountUpdateInput) (api.DBInstanceAccountUpdateInput, error) {
|
||||
var err error
|
||||
input.StatusStandaloneResourceBaseUpdateInput, err = self.SStatusStandaloneResourceBase.ValidateUpdateData(ctx, userCred, query, input.StatusStandaloneResourceBaseUpdateInput)
|
||||
if err != nil {
|
||||
return input, errors.Wrapf(err, "SStatusStandaloneResourceBase.ValidateUpdateData")
|
||||
}
|
||||
if len(input.Name) > 0 && input.Name != self.Name {
|
||||
return input, httperrors.NewForbiddenError("not allow update rds account name")
|
||||
}
|
||||
return input, nil
|
||||
}
|
||||
|
||||
func (self *SDBInstanceAccount) AllowDeleteItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
|
||||
@@ -123,13 +123,20 @@ func (manager *SDBInstanceDatabaseManager) FilterByOwner(q *sqlchemy.SQuery, use
|
||||
return q
|
||||
}
|
||||
|
||||
//func (self *SDBInstanceDatabase) AllowUpdateItem(ctx context.Context, userCred mcclient.TokenCredential) bool {
|
||||
//只能创建或删除,避免update name后造成登录数据库名称异常
|
||||
// return false
|
||||
//}
|
||||
func (self *SDBInstanceDatabase) AllowUpdateItem(ctx context.Context, userCred mcclient.TokenCredential) bool {
|
||||
return db.IsProjectAllowUpdate(userCred, self)
|
||||
}
|
||||
|
||||
func (self *SDBInstanceDatabase) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
return nil, httperrors.ErrForbidden
|
||||
func (self *SDBInstanceDatabase) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.DBInstanceDatabaseUpdateInput) (api.DBInstanceDatabaseUpdateInput, error) {
|
||||
var err error
|
||||
input.StatusStandaloneResourceBaseUpdateInput, err = self.SStatusStandaloneResourceBase.ValidateUpdateData(ctx, userCred, query, input.StatusStandaloneResourceBaseUpdateInput)
|
||||
if err != nil {
|
||||
return input, errors.Wrapf(err, "SStatusStandaloneResourceBase.ValidateUpdateData")
|
||||
}
|
||||
if len(input.Name) > 0 && input.Name != self.Name {
|
||||
return input, httperrors.NewForbiddenError("not allow update rds database name")
|
||||
}
|
||||
return input, nil
|
||||
}
|
||||
|
||||
// RDS数据库列表
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package options
|
||||
|
||||
import "yunion.io/x/jsonutils"
|
||||
|
||||
type DBInstanceAccountListOptions struct {
|
||||
BaseListOptions
|
||||
DBInstance string `help:"ID or Name of DBInstance" json:"dbinstance"`
|
||||
}
|
||||
|
||||
func (opts *DBInstanceAccountListOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return ListStructToParams(opts)
|
||||
}
|
||||
|
||||
type DBInstanceAccountIdOptions struct {
|
||||
ID string `help:"ID of DBInstanceaccount"`
|
||||
}
|
||||
|
||||
func (opts *DBInstanceAccountIdOptions) GetId() string {
|
||||
return opts.ID
|
||||
}
|
||||
|
||||
func (opts *DBInstanceAccountIdOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package options
|
||||
|
||||
import "yunion.io/x/jsonutils"
|
||||
|
||||
type DBInstanceDatabaseListOptions struct {
|
||||
BaseListOptions
|
||||
DBInstance string `help:"ID or Name of DBInstance" json:"dbinstance"`
|
||||
}
|
||||
|
||||
func (opts *DBInstanceDatabaseListOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return ListStructToParams(opts)
|
||||
}
|
||||
|
||||
type DBInstanceDatabaseIdOptions struct {
|
||||
ID string `help:"ID of DBInstancedatabase"`
|
||||
}
|
||||
|
||||
func (opts *DBInstanceDatabaseIdOptions) GetId() string {
|
||||
return opts.ID
|
||||
}
|
||||
|
||||
func (opts *DBInstanceDatabaseIdOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type DBInstanceDatabaseCreateOptions struct {
|
||||
NAME string
|
||||
DBINSTANCE string `help:"ID or Name of DBInstance" json:"dbinstance"`
|
||||
CharacterSet string `help:"CharacterSet for database"`
|
||||
}
|
||||
|
||||
func (opts *DBInstanceDatabaseCreateOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return ListStructToParams(opts)
|
||||
}
|
||||
Reference in New Issue
Block a user