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.
65 lines
1.6 KiB
65 lines
1.6 KiB
package audit
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
// ListRequest struct to give list of account audits
|
|
type ListRequest struct {
|
|
|
|
// Find all audits after point in time (unixtime)
|
|
// Required: false
|
|
TimestampAt uint64 `url:"timestampAt,omitempty" json:"timestampAt,omitempty"`
|
|
|
|
// Find all audits before point in time (unixtime)
|
|
// Required: false
|
|
TimestampTo uint64 `url:"timestampTo,omitempty" json:"timestampTo,omitempty"`
|
|
|
|
// Find by user (Mongo RegExp supported)
|
|
// Required: false
|
|
User string `url:"user,omitempty" json:"user,omitempty"`
|
|
|
|
// Find by api endpoint (Mongo RegExp supported)
|
|
// Required: false
|
|
Call string `url:"call,omitempty" json:"call,omitempty"`
|
|
|
|
// Find by HTTP status code
|
|
// Required: false
|
|
StatusCode uint64 `url:"statusCode,omitempty" json:"statusCode,omitempty"`
|
|
|
|
// Page number
|
|
// Required: false
|
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
|
|
|
// Page size
|
|
// Required: false
|
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
|
}
|
|
|
|
// List gets audit records for the specified account object
|
|
func (a Audit) List(ctx context.Context, req ListRequest) (*ListAudits, error) {
|
|
res, err := a.ListRaw(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
list := ListAudits{}
|
|
|
|
err = json.Unmarshal(res, &list)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &list, nil
|
|
}
|
|
|
|
// ListRaw gets list of audit records an array of bytes
|
|
func (a Audit) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|
url := "/cloudbroker/audit/list"
|
|
|
|
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
return res, err
|
|
}
|