v9.0.0
This commit is contained in:
41
pkg/cloudapi/user/api_list.go
Normal file
41
pkg/cloudapi/user/api_list.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// APIListRequest struct for getting API list.
|
||||
type APIListRequest struct {
|
||||
// ID of the user.
|
||||
// Required: true
|
||||
UserID string `url:"userId" json:"userId" validate:"required"`
|
||||
}
|
||||
|
||||
// APIList gets a list of all API functions that a given user has
|
||||
// access to according to their apiaccess group membership.
|
||||
func (u User) APIList(ctx context.Context, req APIListRequest) (*APIsEndpoints, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/user/apiList"
|
||||
|
||||
info := APIsEndpoints{}
|
||||
|
||||
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
Reference in New Issue
Block a user