45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
|
|
package rg
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"encoding/json"
|
||
|
|
"net/http"
|
||
|
|
|
||
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||
|
|
)
|
||
|
|
|
||
|
|
// GetACLAccessRequest struct to get detailed information about ACL account in a resource group
|
||
|
|
type GetACLAccessRequest struct {
|
||
|
|
ID uint64 `url:"id" json:"id" validate:"required"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// Get gets current configuration of the ACL access in a resource group as a RecordRGACLAccess struct
|
||
|
|
func (r RG) GetACLAccess(ctx context.Context, req GetACLAccessRequest) (*RecordRGACLAccess, error) {
|
||
|
|
res, err := r.GetACLAccessRaw(ctx, req)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
info := RecordRGACLAccess{}
|
||
|
|
|
||
|
|
err = json.Unmarshal(res, &info)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return &info, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetACLAccessRaw gets current configuration of the ACL access in a resource group as an array of bytes
|
||
|
|
func (r RG) GetACLAccessRaw(ctx context.Context, req GetACLAccessRequest) ([]byte, error) {
|
||
|
|
err := validators.ValidateRequest(req)
|
||
|
|
if err != nil {
|
||
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||
|
|
}
|
||
|
|
|
||
|
|
url := "/cloudapi/rg/get_acl_access"
|
||
|
|
|
||
|
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||
|
|
return res, err
|
||
|
|
}
|