v1.12.0
This commit is contained in:
38
pkg/cloudbroker/user/block.go
Normal file
38
pkg/cloudbroker/user/block.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// BlockRequest struct to block a user.
|
||||
type BlockRequest struct {
|
||||
// ID of the user to block.
|
||||
// Required: true
|
||||
UserID string `url:"user_id" json:"user_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Block blocks a user
|
||||
func (u User) Block(ctx context.Context, req BlockRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/user/block"
|
||||
|
||||
res, err := u.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
|
||||
}
|
||||
@@ -20,15 +20,17 @@ type CreateRequest struct {
|
||||
|
||||
// Password of user
|
||||
// Required: false
|
||||
// Default: strongpassword
|
||||
Password string `url:"password,omitempty" json:"password,omitempty"`
|
||||
|
||||
// List of groups this user belongs to.
|
||||
// Required: false
|
||||
Groups []string `url:"groups,omitempty" json:"groups,omitempty"`
|
||||
|
||||
// List of apiaccess groups this user belongs to.
|
||||
// Required: false
|
||||
APIAccess []uint64 `url:"apiaccess,omitempty" json:"apiaccess,omitempty"`
|
||||
|
||||
// Provider of user
|
||||
// one of: bvs, decs3o
|
||||
// Required: false
|
||||
Provider string `url:"provider,omitempty" json:"provider,omitempty" validate:"omitempty,userProvider"`
|
||||
}
|
||||
|
||||
// Create creates a user.
|
||||
|
||||
@@ -18,6 +18,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
Active interface{} `url:"active,omitempty" json:"active,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Find by email.
|
||||
// Required: false
|
||||
Email string `url:"email,omitempty" json:"email,omitempty"`
|
||||
|
||||
// Find by serviceaccount. True or False.
|
||||
// Required: false
|
||||
ServiceAccount interface{} `url:"serviceaccount,omitempty" json:"serviceaccount,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
@@ -21,6 +21,9 @@ type ItemUser struct {
|
||||
// AuthKeys
|
||||
AuthKeys []interface{}
|
||||
|
||||
// Blocked
|
||||
Blocked bool `json:"blocked"`
|
||||
|
||||
// Data
|
||||
Data string `json:"data"`
|
||||
|
||||
|
||||
38
pkg/cloudbroker/user/unblock.go
Normal file
38
pkg/cloudbroker/user/unblock.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// UnblockRequest struct to block a user.
|
||||
type UnblockRequest struct {
|
||||
// ID of the user to block.
|
||||
// Required: true
|
||||
UserID string `url:"user_id" json:"user_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Unblock unblocks a user
|
||||
func (u User) Unblock(ctx context.Context, req UnblockRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/user/unblock"
|
||||
|
||||
res, err := u.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