1
1
package rows
2
2
3
3
import (
4
- "encoding/json"
5
4
"strconv"
6
5
"time"
7
6
8
7
"github.com/turbot/tailpipe-plugin-sdk/enrichment"
9
- "github.com/turbot/tailpipe-plugin-sdk/types"
10
8
)
11
9
12
10
/*
@@ -22,26 +20,26 @@ import (
22
20
type AuditLog struct {
23
21
enrichment.CommonFields
24
22
25
- Action * string `json:"action,omitempty"`
26
- Actor * string `json:"actor,omitempty"`
27
- ActorID * int64 `json:"actor_id,omitempty"`
28
- ActorIP * string `json:"actor_ip,omitempty"`
29
- ActorLocation * types. JSONString `json:"actor_location,omitempty"`
30
- Business * string `json:"business,omitempty"`
31
- BusinessID * int64 `json:"business_id,omitempty"`
32
- CreatedAt * time.Time `json:"created_at,omitempty"`
33
- DocumentID * string `json:"_document_id,omitempty"`
34
- ExternalIdentityNameID * string `json:"external_identity_nameid,omitempty"`
35
- ExternalIdentityUsername * string `json:"external_identity_username,omitempty"`
36
- HashedToken * string `json:"hashed_token,omitempty"`
37
- Org * string `json:"org,omitempty"`
38
- OrgID * string `json:"org_id,omitempty"`
39
- Timestamp * time.Time `json:"timestamp,omitempty"`
40
- TokenID * int64 `json:"token_id,omitempty"`
41
- TokenScopes * string `json:"token_scopes,omitempty"`
42
- User * string `json:"user,omitempty"`
43
- UserID * int64 `json:"user_id,omitempty"`
44
- AdditionalFields * types. JSONString `json:"additional_fields,omitempty"`
23
+ Action * string `json:"action,omitempty"`
24
+ Actor * string `json:"actor,omitempty"`
25
+ ActorID * int64 `json:"actor_id,omitempty"`
26
+ ActorIP * string `json:"actor_ip,omitempty"`
27
+ ActorLocation * map [ string ] interface {} `json:"actor_location,omitempty" parquet:"type=JSON "`
28
+ Business * string `json:"business,omitempty"`
29
+ BusinessID * int64 `json:"business_id,omitempty"`
30
+ CreatedAt * time.Time `json:"created_at,omitempty"`
31
+ DocumentID * string `json:"_document_id,omitempty"`
32
+ ExternalIdentityNameID * string `json:"external_identity_nameid,omitempty"`
33
+ ExternalIdentityUsername * string `json:"external_identity_username,omitempty"`
34
+ HashedToken * string `json:"hashed_token,omitempty"`
35
+ Org * string `json:"org,omitempty"`
36
+ OrgID * string `json:"org_id,omitempty"`
37
+ Timestamp * time.Time `json:"timestamp,omitempty"`
38
+ TokenID * int64 `json:"token_id,omitempty"`
39
+ TokenScopes * string `json:"token_scopes,omitempty"`
40
+ User * string `json:"user,omitempty"`
41
+ UserID * int64 `json:"user_id,omitempty"`
42
+ AdditionalFields * map [ string ] interface {} `json:"additional_fields,omitempty" parquet:"type=JSON "`
45
43
}
46
44
47
45
type ActorLocation struct {
@@ -77,11 +75,7 @@ func (a *AuditLog) FromMap(in map[string]interface{}) {
77
75
}
78
76
case "actor_location" :
79
77
if location , ok := value .(map [string ]interface {}); ok {
80
- locJSON , err := json .Marshal (location )
81
- if err == nil {
82
- locStr := types .JSONString (locJSON )
83
- a .ActorLocation = & locStr
84
- }
78
+ a .ActorLocation = & location
85
79
}
86
80
case "business" :
87
81
if strVal , ok := value .(string ); ok {
@@ -153,9 +147,6 @@ func (a *AuditLog) FromMap(in map[string]interface{}) {
153
147
154
148
// Marshal dynamic fields into JSON and store in AdditionalFields
155
149
if len (dynamicFields ) > 0 {
156
- if dynamicJSON , err := json .Marshal (dynamicFields ); err == nil {
157
- djStr := types .JSONString (dynamicJSON )
158
- a .AdditionalFields = & djStr
159
- }
150
+ a .AdditionalFields = & dynamicFields
160
151
}
161
152
}
0 commit comments