v9.0.0
This commit is contained in:
70
pkg/cloudbroker/grid/set_password_policy.go
Normal file
70
pkg/cloudbroker/grid/set_password_policy.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package grid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// SetPasswordPolicyRequest struct to set password policy for a grid
|
||||
type SetPasswordPolicyRequest struct {
|
||||
// ID of the grid
|
||||
// Required: true
|
||||
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
||||
|
||||
// Available numbers in the password
|
||||
// Default value : true
|
||||
// Required: true
|
||||
Digits interface{} `url:"digits" json:"digits" validate:"isBool"`
|
||||
|
||||
// Available special characters in the password
|
||||
// Default value : false
|
||||
// Required: true
|
||||
SpecialSymbols bool `url:"specialSymbols" json:"specialSymbols"`
|
||||
|
||||
// Number of characters in the password
|
||||
// Default value : 9
|
||||
// Required: true
|
||||
PasswordLength uint64 `url:"passwordLength" json:"passwordLength"`
|
||||
|
||||
// Capital letters in the password are available
|
||||
// Default value : true
|
||||
// Required: true
|
||||
Uppercase interface{} `url:"uppercase" json:"uppercase" validate:"isBool"`
|
||||
}
|
||||
|
||||
// RemoveCustomBackupPath set set password policy for a grid
|
||||
func (g Grid) SetPasswordPolicy(ctx context.Context, req SetPasswordPolicyRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
if req.PasswordLength == 0 {
|
||||
req.PasswordLength = 9
|
||||
}
|
||||
|
||||
if req.Digits == nil {
|
||||
req.Digits = true
|
||||
}
|
||||
|
||||
if req.Uppercase == nil {
|
||||
req.Uppercase = true
|
||||
}
|
||||
|
||||
url := "/cloudbroker/grid/setPasswordPolicy"
|
||||
|
||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user