Skip to content

Commit 47f9620

Browse files
author
Praveenrajmani
committed
rename audit -> event
1 parent c9bd895 commit 47f9620

File tree

4 files changed

+49
-29
lines changed

4 files changed

+49
-29
lines changed

audit-event.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ import (
2626
"net/http"
2727
"net/url"
2828

29-
"github.com/minio/madmin-go/v3/logger/audit"
29+
"github.com/minio/madmin-go/v3/event"
3030
)
3131

32-
func (adm AdminClient) GetAuditEvents(ctx context.Context, node string, api string) <-chan audit.Event {
33-
logCh := make(chan audit.Event, 1)
32+
func (adm AdminClient) GetAPIEvents(ctx context.Context, node string, api string) <-chan event.API {
33+
logCh := make(chan event.API)
3434

3535
// Only success, start a routine to start reading line by line.
36-
go func(logCh chan<- audit.Event) {
36+
go func(logCh chan<- event.API) {
3737
defer close(logCh)
3838
urlValues := make(url.Values)
3939
urlValues.Set("node", node)
4040
urlValues.Set("api", api)
4141
// for {
4242
reqData := requestData{
43-
relPath: adminAPIPrefix + "/events/audit",
43+
relPath: adminAPIPrefix + "/events/api",
4444
queryValues: urlValues,
4545
}
4646
// Execute GET to call log handler
@@ -56,7 +56,7 @@ func (adm AdminClient) GetAuditEvents(ctx context.Context, node string, api stri
5656
}
5757
dec := json.NewDecoder(resp.Body)
5858
for {
59-
var info audit.Event
59+
var info event.API
6060
if err = dec.Decode(&info); err != nil {
6161
fmt.Println(err)
6262
break

event/api.go

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) 2015-2025 MinIO, Inc.
2+
//
3+
// This file is part of MinIO Object Storage stack
4+
//
5+
// This program is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU Affero General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU Affero General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU Affero General Public License
16+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+
package event
19+
20+
import "time"
21+
22+
// API represents the api event
23+
type API struct {
24+
Version string `json:"version"`
25+
DeploymentID string `json:"deploymentid,omitempty"`
26+
SiteName string `json:"siteName,omitempty"`
27+
Time time.Time `json:"time"`
28+
Event string `json:"event"`
29+
30+
Type string `json:"type,omitempty"`
31+
32+
API struct {
33+
Name string `json:"name,omitempty"`
34+
Bucket string `json:"bucket,omitempty"`
35+
Object string `json:"object,omitempty"`
36+
StatusCode int `json:"statusCode,omitempty"`
37+
} `json:"api"`
38+
39+
Error string `json:"error,omitempty"`
40+
}

examples/disklogger.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ func main() {
4848
// },
4949
// })
5050

51-
logCh := madmClnt.GetAuditEvents(context.Background(), "", "")
51+
eventCh := madmClnt.GetAPIEvents(context.Background(), "", "ListObjectsV2")
5252
i := 1
53-
for logInfo := range logCh {
53+
for event := range eventCh {
5454
fmt.Printf("count: %d\n", i)
5555
i++
5656
fmt.Println("************************")
57-
fmt.Println(logInfo)
57+
fmt.Println(event)
5858
fmt.Println("************************")
5959
}
6060
}

logger/audit/entry.go

-20
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,3 @@ type Entry struct {
7171

7272
Error string `json:"error,omitempty"`
7373
}
74-
75-
// Event represents the audit event
76-
type Event struct {
77-
Version string `json:"version"`
78-
DeploymentID string `json:"deploymentid,omitempty"`
79-
SiteName string `json:"siteName,omitempty"`
80-
Time time.Time `json:"time"`
81-
Event string `json:"event"`
82-
83-
Type string `json:"type,omitempty"`
84-
85-
API struct {
86-
Name string `json:"name,omitempty"`
87-
Bucket string `json:"bucket,omitempty"`
88-
Object string `json:"object,omitempty"`
89-
StatusCode int `json:"statusCode,omitempty"`
90-
} `json:"api"`
91-
92-
Error string `json:"error,omitempty"`
93-
}

0 commit comments

Comments
 (0)