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/grid/purge_logs.go

44 lines
1.1 KiB

3 years ago
package grid
import (
"context"
"net/http"
"strconv"
3 years ago
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
3 years ago
)
2 years ago
// PurgeLogsRequest struct to purge logs
3 years ago
type PurgeLogsRequest struct {
// Grid (platform) ID
// Required: true
3 years ago
GID uint64 `url:"gid" json:"gid" validate:"required"`
3 years ago
// Age of the records to remove, e.g. -1h for records older than 1 hour, -1w - one week, etc
// Required: true
3 years ago
Age string `url:"age" json:"age" validate:"required"`
3 years ago
}
// PurgeLogs clear Log and ECO records that are older than the specified age.
// By default, records older than one week are removed
func (g Grid) PurgeLogs(ctx context.Context, req PurgeLogsRequest) (bool, error) {
3 years ago
err := validators.ValidateRequest(req)
3 years ago
if err != nil {
2 years ago
return false, validators.ValidationErrors(validators.GetErrors(err))
3 years ago
}
url := "/cloudbroker/grid/purgeLogs"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}