This commit is contained in:
2024-04-16 14:26:06 +03:00
parent bc264c4d90
commit e7c968797b
298 changed files with 11066 additions and 398 deletions

View File

@@ -12,6 +12,22 @@ type GetAuditRequest struct {
// Required: false
Username string `url:"username,omitempty" json:"username,omitempty"`
// Find by api call.
// Required: false
Call string `url:"call,omitempty" json:"call,omitempty"`
// Find by HTTP status code
// Required: false
StatusCode uint64 `url:"statuscode,omitempty" json:"statuscode,omitempty"`
// Find all audits after point in time (unixtime)
// Required: false
TimestampAt uint64 `url:"timestampAt,omitempty" json:"timestampAt,omitempty"`
// Find all audits before point in time (unixtime)
// Required: false
TimestampTo uint64 `url:"timestampTo,omitempty" json:"timestampTo,omitempty"`
// Page number.
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
@@ -27,14 +43,14 @@ func (u User) GetAudit(ctx context.Context, req GetAuditRequest) (ListAudits, er
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
return ListAudits{}, err
}
list := ListAudits{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
return ListAudits{}, err
}
return list, nil

View File

@@ -4,13 +4,15 @@ import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ListRequest struct to get all non deleted user instances.
type ListRequest struct {
// Find by ID.
// Required: false
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
ByID string `url:"by_id,omitempty" json:"by_id,omitempty"`
// Find by active. True or False.
// Required: false
@@ -20,6 +22,10 @@ type ListRequest struct {
// Required: false
ServiceAccount bool `url:"serviceaccount,omitempty" json:"serviceaccount,omitempty"`
// Sort by one of supported fields, format +|-(field)
// Required: false
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
// Page number.
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
@@ -31,6 +37,7 @@ type ListRequest struct {
// List gets all non deleted user instances as a ListUsers struct
func (u User) List(ctx context.Context, req ListRequest) (*ListUsers, error) {
res, err := u.ListRaw(ctx, req)
if err != nil {
return nil, err
@@ -48,6 +55,12 @@ func (u User) List(ctx context.Context, req ListRequest) (*ListUsers, error) {
// ListRaw gets all non deleted user instances as an array of bytes
func (u User) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/user/list"
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)

View File

@@ -13,7 +13,7 @@ type ItemUser struct {
Active bool `json:"active"`
// APIAccess
APIAccess []uint64 `json:"apiaccess"`
APIAccess map[string]string `json:"apiaccess"`
// AuthKey
AuthKey string `json:"authkey"`
@@ -52,7 +52,7 @@ type ItemUser struct {
Mobile []interface{} `json:"mobile"`
// Password
Password string `json:"password"`
Password string `json:"passwd"`
// Protected
Protected bool `json:"protected"`
@@ -110,7 +110,13 @@ type ItemAudit struct {
Time float64 `json:"Time"`
}
type ListAudits []ItemAudit
type ListAudits struct {
// Data
Data []ItemAudit `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
type ResponseTime float64