This commit is contained in:
asteam
2025-07-15 17:39:18 +03:00
parent 1f8637400f
commit 7dacf35cd6
163 changed files with 4322 additions and 504 deletions

View 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
}

View File

@@ -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.

View File

@@ -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"`

View File

@@ -21,6 +21,9 @@ type ItemUser struct {
// AuthKeys
AuthKeys []interface{}
// Blocked
Blocked bool `json:"blocked"`
// Data
Data string `json:"data"`

View 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
}