You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decort-golang-sdk/pkg/cloudapi/rg/audits.go

48 lines
820 B

3 years ago
package rg
import (
"context"
"encoding/json"
"errors"
"net/http"
3 years ago
)
3 years ago
// Request struct for get audit
3 years ago
type AuditsRequest struct {
3 years ago
// Resource group ID
// Required: true
3 years ago
RGID uint64 `url:"rgId"`
}
3 years ago
func (rgrq AuditsRequest) validate() error {
3 years ago
if rgrq.RGID == 0 {
return errors.New("field RGID can not be empty or equal to 0")
}
return nil
}
3 years ago
// Audits gets audit records for the specified resource group object
func (r RG) Audits(ctx context.Context, req AuditsRequest) (ListAudits, error) {
err := req.validate()
if err != nil {
3 years ago
return nil, err
}
url := "/cloudapi/rg/audits"
3 years ago
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
3 years ago
if err != nil {
return nil, err
}
3 years ago
list := ListAudits{}
err = json.Unmarshal(res, &list)
if err != nil {
3 years ago
return nil, err
}
3 years ago
return list, nil
3 years ago
}