v1.3.0
This commit is contained in:
@@ -2,34 +2,29 @@ package rg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for disable several resource groups
|
||||
type MassDisableRequest struct {
|
||||
// IDs of the resource groups
|
||||
// Required: true
|
||||
RGIDs []uint64 `url:"rgIds" json:"rgIds"`
|
||||
RGIDs []uint64 `url:"rgIds" json:"rgIds" validate:"min=1"`
|
||||
|
||||
// Reason for action
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
func (rgrq MassDisableRequest) validate() error {
|
||||
if len(rgrq.RGIDs) == 0 {
|
||||
return errors.New("validation-error: field RGIDs must be set")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MassDisable start jobs to disable several resource groups
|
||||
func (r RG) MassDisable(ctx context.Context, req MassDisableRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/rg/massDisable"
|
||||
|
||||
Reference in New Issue
Block a user