-
Notifications
You must be signed in to change notification settings - Fork 13
/
historyentry.go
135 lines (93 loc) · 3.08 KB
/
historyentry.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package platformclientv2
import (
"time"
"github.com/leekchan/timeutil"
"encoding/json"
"strconv"
"strings"
)
// Historyentry
type Historyentry struct {
// Action - The action performed
Action *string `json:"action,omitempty"`
// Resource - For actions performed not on the item itself, but on a sub-item, this field identifies the sub-item by name. For example, for actions performed on prompt resources, this will be the prompt resource name.
Resource *string `json:"resource,omitempty"`
// Timestamp - Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z
Timestamp *time.Time `json:"timestamp,omitempty"`
// User - User associated with this entry.
User *User `json:"user,omitempty"`
// Client - OAuth client associated with this entry.
Client *Domainentityref `json:"client,omitempty"`
// Version
Version *string `json:"version,omitempty"`
// Secure
Secure *bool `json:"secure,omitempty"`
}
func (o *Historyentry) MarshalJSON() ([]byte, error) {
// Redundant initialization to avoid unused import errors for models with no Time values
_ = timeutil.Timedelta{}
type Alias Historyentry
Timestamp := new(string)
if o.Timestamp != nil {
*Timestamp = timeutil.Strftime(o.Timestamp, "%Y-%m-%dT%H:%M:%S.%fZ")
} else {
Timestamp = nil
}
return json.Marshal(&struct {
Action *string `json:"action,omitempty"`
Resource *string `json:"resource,omitempty"`
Timestamp *string `json:"timestamp,omitempty"`
User *User `json:"user,omitempty"`
Client *Domainentityref `json:"client,omitempty"`
Version *string `json:"version,omitempty"`
Secure *bool `json:"secure,omitempty"`
*Alias
}{
Action: o.Action,
Resource: o.Resource,
Timestamp: Timestamp,
User: o.User,
Client: o.Client,
Version: o.Version,
Secure: o.Secure,
Alias: (*Alias)(o),
})
}
func (o *Historyentry) UnmarshalJSON(b []byte) error {
var HistoryentryMap map[string]interface{}
err := json.Unmarshal(b, &HistoryentryMap)
if err != nil {
return err
}
if Action, ok := HistoryentryMap["action"].(string); ok {
o.Action = &Action
}
if Resource, ok := HistoryentryMap["resource"].(string); ok {
o.Resource = &Resource
}
if timestampString, ok := HistoryentryMap["timestamp"].(string); ok {
Timestamp, _ := time.Parse("2006-01-02T15:04:05.999999Z", timestampString)
o.Timestamp = &Timestamp
}
if User, ok := HistoryentryMap["user"].(map[string]interface{}); ok {
UserString, _ := json.Marshal(User)
json.Unmarshal(UserString, &o.User)
}
if Client, ok := HistoryentryMap["client"].(map[string]interface{}); ok {
ClientString, _ := json.Marshal(Client)
json.Unmarshal(ClientString, &o.Client)
}
if Version, ok := HistoryentryMap["version"].(string); ok {
o.Version = &Version
}
if Secure, ok := HistoryentryMap["secure"].(bool); ok {
o.Secure = &Secure
}
return nil
}
// String returns a JSON representation of the model
func (o *Historyentry) String() string {
j, _ := json.Marshal(o)
str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\u`, `\u`, -1))
return str
}