vault/api/sys_reporting_scan.go
Vault Automation e53661ce92
license: update headers to IBM Corp. on main (#10333) (#10361)
Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-23 20:54:04 +00:00

50 lines
1.1 KiB
Go

// Copyright IBM Corp. 2016, 2025
// SPDX-License-Identifier: MPL-2.0
package api
import (
"context"
"errors"
"net/http"
"github.com/mitchellh/mapstructure"
)
func (c *Sys) ReportingScan() (*ReportingScanOutput, error) {
return c.ReportingScanWithContext(context.Background())
}
func (c *Sys) ReportingScanWithContext(ctx context.Context) (*ReportingScanOutput, error) {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
defer cancelFunc()
r := c.c.NewRequest(http.MethodPost, "/v1/sys/reporting/scan")
resp, err := c.c.rawRequestWithContext(ctx, r)
if err != nil {
return nil, err
}
defer resp.Body.Close()
secret, err := ParseSecret(resp.Body)
if err != nil {
return nil, err
}
if secret == nil || secret.Data == nil {
return nil, errors.New("data from server response is empty")
}
var result ReportingScanOutput
err = mapstructure.Decode(secret.Data, &result)
if err != nil {
return nil, err
}
return &result, err
}
type ReportingScanOutput struct {
Timestamp string `json:"timestamp" structs:"timestamp" mapstructure:"timestamp"`
}