-
Notifications
You must be signed in to change notification settings - Fork 13
/
apiusagerow.go
211 lines (139 loc) · 5.03 KB
/
apiusagerow.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package platformclientv2
import (
"time"
"github.com/leekchan/timeutil"
"encoding/json"
"strconv"
"strings"
)
// Apiusagerow
type Apiusagerow struct {
// ClientId - Client Id associated with this query result
ClientId *string `json:"clientId,omitempty"`
// ClientName - Client Name associated with this query result
ClientName *string `json:"clientName,omitempty"`
// OrganizationId - Organization Id associated with this query result
OrganizationId *string `json:"organizationId,omitempty"`
// UserId - User Id associated with this query result
UserId *string `json:"userId,omitempty"`
// TemplateUri - Template Uri associated with this query result
TemplateUri *string `json:"templateUri,omitempty"`
// HttpMethod - HTTP Method associated with this query result
HttpMethod *string `json:"httpMethod,omitempty"`
// Status200 - Number of requests resulting in a 2xx HTTP status code
Status200 *int `json:"status200,omitempty"`
// Status300 - Number of requests resulting in a 3xx HTTP status code
Status300 *int `json:"status300,omitempty"`
// Status400 - Number of requests resulting in a 4xx HTTP status code
Status400 *int `json:"status400,omitempty"`
// Status500 - Number of requests resulting in a 5xx HTTP status code
Status500 *int `json:"status500,omitempty"`
// Status429 - Number of requests resulting in a 429 HTTP status code, this is a subset of the count returned with status400
Status429 *int `json:"status429,omitempty"`
// Requests - Total number of requests
Requests *int `json:"requests,omitempty"`
// Date - Date of requests, based on granularity. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z
Date *time.Time `json:"date,omitempty"`
}
func (o *Apiusagerow) MarshalJSON() ([]byte, error) {
// Redundant initialization to avoid unused import errors for models with no Time values
_ = timeutil.Timedelta{}
type Alias Apiusagerow
Date := new(string)
if o.Date != nil {
*Date = timeutil.Strftime(o.Date, "%Y-%m-%dT%H:%M:%S.%fZ")
} else {
Date = nil
}
return json.Marshal(&struct {
ClientId *string `json:"clientId,omitempty"`
ClientName *string `json:"clientName,omitempty"`
OrganizationId *string `json:"organizationId,omitempty"`
UserId *string `json:"userId,omitempty"`
TemplateUri *string `json:"templateUri,omitempty"`
HttpMethod *string `json:"httpMethod,omitempty"`
Status200 *int `json:"status200,omitempty"`
Status300 *int `json:"status300,omitempty"`
Status400 *int `json:"status400,omitempty"`
Status500 *int `json:"status500,omitempty"`
Status429 *int `json:"status429,omitempty"`
Requests *int `json:"requests,omitempty"`
Date *string `json:"date,omitempty"`
*Alias
}{
ClientId: o.ClientId,
ClientName: o.ClientName,
OrganizationId: o.OrganizationId,
UserId: o.UserId,
TemplateUri: o.TemplateUri,
HttpMethod: o.HttpMethod,
Status200: o.Status200,
Status300: o.Status300,
Status400: o.Status400,
Status500: o.Status500,
Status429: o.Status429,
Requests: o.Requests,
Date: Date,
Alias: (*Alias)(o),
})
}
func (o *Apiusagerow) UnmarshalJSON(b []byte) error {
var ApiusagerowMap map[string]interface{}
err := json.Unmarshal(b, &ApiusagerowMap)
if err != nil {
return err
}
if ClientId, ok := ApiusagerowMap["clientId"].(string); ok {
o.ClientId = &ClientId
}
if ClientName, ok := ApiusagerowMap["clientName"].(string); ok {
o.ClientName = &ClientName
}
if OrganizationId, ok := ApiusagerowMap["organizationId"].(string); ok {
o.OrganizationId = &OrganizationId
}
if UserId, ok := ApiusagerowMap["userId"].(string); ok {
o.UserId = &UserId
}
if TemplateUri, ok := ApiusagerowMap["templateUri"].(string); ok {
o.TemplateUri = &TemplateUri
}
if HttpMethod, ok := ApiusagerowMap["httpMethod"].(string); ok {
o.HttpMethod = &HttpMethod
}
if Status200, ok := ApiusagerowMap["status200"].(float64); ok {
Status200Int := int(Status200)
o.Status200 = &Status200Int
}
if Status300, ok := ApiusagerowMap["status300"].(float64); ok {
Status300Int := int(Status300)
o.Status300 = &Status300Int
}
if Status400, ok := ApiusagerowMap["status400"].(float64); ok {
Status400Int := int(Status400)
o.Status400 = &Status400Int
}
if Status500, ok := ApiusagerowMap["status500"].(float64); ok {
Status500Int := int(Status500)
o.Status500 = &Status500Int
}
if Status429, ok := ApiusagerowMap["status429"].(float64); ok {
Status429Int := int(Status429)
o.Status429 = &Status429Int
}
if Requests, ok := ApiusagerowMap["requests"].(float64); ok {
RequestsInt := int(Requests)
o.Requests = &RequestsInt
}
if dateString, ok := ApiusagerowMap["date"].(string); ok {
Date, _ := time.Parse("2006-01-02T15:04:05.999999Z", dateString)
o.Date = &Date
}
return nil
}
// String returns a JSON representation of the model
func (o *Apiusagerow) String() string {
j, _ := json.Marshal(o)
str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\u`, `\u`, -1))
return str
}