v12.0.0
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// APIListRequest struct for getting API list.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// APIAccessJoinRequest struct for joining user into apiaccess group.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// APIAccessLeaveRequest struct for leaving user from apiaccess group.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// APIAccessListRequest struct for showing list of dicts with information about
|
||||
|
||||
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/dynamix-golang-sdk/v12/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
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// CreateRequest struct for creating a user.
|
||||
@@ -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.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest struct for deleting a user.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteByGUIDRequest struct for deleting a user using user's GUID.
|
||||
|
||||
@@ -5,14 +5,14 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteUsersRequest struct for bulk delete a list of users.
|
||||
type DeleteUsersRequest struct {
|
||||
// List of user ids
|
||||
// Required: true
|
||||
UserIDs string `url:"userIds" json:"userIds" validate:"required"`
|
||||
UserIDs []string `url:"userIds" json:"userIds" validate:"required"`
|
||||
}
|
||||
|
||||
// DeleteUsers bulk delete a list of users.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get user details.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetMatchingUsernamesRequest struct for getting a list of the matching usernames for a given string.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get all non deleted user instances.
|
||||
@@ -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/dynamix-golang-sdk/v12/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
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package user
|
||||
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces"
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces"
|
||||
|
||||
// Structure for creating request to User
|
||||
type User struct {
|
||||
|
||||
Reference in New Issue
Block a user