From 91930bd5e83ae0805cf7097ca1b22aca51a0d004 Mon Sep 17 00:00:00 2001 From: hc-github-team-consul-core Date: Tue, 19 Sep 2023 13:41:19 -0400 Subject: [PATCH] Backport of Add operator audit endpoint changes into release/1.16.x (#18901) * backport of commit d0cc236d70b3bdbe003b8555a0e0e20f407ca4aa * fix license --------- Co-authored-by: Ronald Ekambi --- api/operator_audit.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 api/operator_audit.go diff --git a/api/operator_audit.go b/api/operator_audit.go new file mode 100644 index 000000000000..5240d38a70d7 --- /dev/null +++ b/api/operator_audit.go @@ -0,0 +1,40 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// The /v1/operator/audit-hash endpoint is available only in Consul Enterprise and +// interact with its audit logging subsystem. + +package api + +type AuditHashRequest struct { + Input string +} + +type AuditHashResponse struct { + Hash string +} + +func (op *Operator) AuditHash(a *AuditHashRequest, q *QueryOptions) (*AuditHashResponse, error) { + r := op.c.newRequest("POST", "/v1/operator/audit-hash") + r.setQueryOptions(q) + r.obj = a + + rtt, resp, err := op.c.doRequest(r) + if err != nil { + return nil, err + } + defer closeResponseBody(resp) + if err := requireOK(resp); err != nil { + return nil, err + } + + wm := &WriteMeta{} + wm.RequestTime = rtt + + var out AuditHashResponse + if err := decodeBody(resp, &out); err != nil { + return nil, err + } + + return &out, nil +}