You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dynamix-golang-sdk/pkg/cloudbroker/grid/set_password_policy.go

71 lines
1.7 KiB

package grid
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/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
}