-
Notifications
You must be signed in to change notification settings - Fork 2
/
search_custom_schema.go
52 lines (44 loc) · 1.06 KB
/
search_custom_schema.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Search for events with a custom schema.
package main
import (
"context"
"examples/audit/util"
"fmt"
"log"
"os"
"time"
"github.com/pangeacyber/pangea-go/pangea-sdk/v4/pangea"
"github.com/pangeacyber/pangea-go/pangea-sdk/v4/service/audit"
)
func main() {
token := os.Getenv("PANGEA_AUDIT_CUSTOM_SCHEMA_TOKEN")
if token == "" {
log.Fatal("Unauthorized: No token present")
}
auditcli, err := audit.New(
&pangea.Config{
Token: token,
Domain: os.Getenv("PANGEA_DOMAIN"),
PollResultTimeout: 60 * time.Second,
QueuedRetryEnabled: true,
},
audit.WithCustomSchema(util.CustomSchemaEvent{}),
)
if err != nil {
log.Fatal("failed to create audit client")
}
ctx := context.Background()
input := &audit.SearchInput{
Query: `message:""`,
Limit: 3,
Verbose: pangea.Bool(false),
}
sr, err := auditcli.Search(ctx, input)
if err != nil {
log.Fatal(err)
}
for i, se := range sr.Result.Events {
ec := (se.EventEnvelope.Event).(*util.CustomSchemaEvent)
fmt.Printf("Event %d:\n %s\n", i, pangea.Stringify(*ec))
}
}