-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport of Add operator audit endpoint changes into release/1.16.x (#…
…18901) * backport of commit d0cc236 * fix license --------- Co-authored-by: Ronald Ekambi <ronekambi@gmail.com>
- Loading branch information
1 parent
ad696e2
commit 91930bd
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |