45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package compute
|
|
|
|
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 vm
|
|
type GetACLAccessRequest struct {
|
|
ID uint64 `url:"id" json:"id" validate:"required"`
|
|
}
|
|
|
|
// Get gets current configuration of the ACL access in a vm as a RecordRGACLAccess struct
|
|
func (c Compute) GetACLAccess(ctx context.Context, req GetACLAccessRequest) (*RecordComputeACLAccess, error) {
|
|
res, err := c.GetACLAccessRaw(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
info := RecordComputeACLAccess{}
|
|
|
|
err = json.Unmarshal(res, &info)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &info, nil
|
|
}
|
|
|
|
// GetACLAccessRaw gets current configuration of the ACL access in a vm as an array of bytes
|
|
func (c Compute) GetACLAccessRaw(ctx context.Context, req GetACLAccessRequest) ([]byte, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudapi/compute/get_acl_access"
|
|
|
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
return res, err
|
|
}
|