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/cloudbroker/rg/audits.go

48 lines
834 B

package rg
import (
"context"
"encoding/json"
"errors"
"net/http"
)
// Request struct for get audit
type AuditsRequest struct {
// Resource group ID
// Required: true
RGID uint64 `url:"rgId" json:"rgId"`
}
func (rgrq AuditsRequest) validate() error {
if rgrq.RGID == 0 {
return errors.New("validation-error: field RGID must be set")
}
return nil
}
// 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 {
return nil, err
}
url := "/cloudbroker/rg/audits"
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
list := ListAudits{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return list, nil
}