-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathapi_user_events.go
More file actions
227 lines (191 loc) · 9.21 KB
/
Copy pathapi_user_events.go
File metadata and controls
227 lines (191 loc) · 9.21 KB
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/*
Administrative API
Manage users, accounts, and account groups in the ThousandEyes platform using the Administrative API. This API provides the following operations to manage your organization: * `/account-groups`: Account groups are used to divide an organization into different sections. These operations can be used to create, retrieve, update and delete account groups. * `/users`: Create, retrieve, update and delete users within an organization. * `/roles`: Create, retrieve and update roles for the current user. * `/permissions`: Retrieve all assignable permissions. Used in the context of modifying roles. * `/audit-user-events`: Retrieve all activity log events. For more information about the administrative models, see [Account Management](https://docs.thousandeyes.com/product-documentation/user-management).
API version: 7.0.57
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package administrative
import (
"bytes"
"github.com/thousandeyes/thousandeyes-sdk-go/v3/client"
internalerror "github.com/thousandeyes/thousandeyes-sdk-go/v3/internal/error"
"github.com/thousandeyes/thousandeyes-sdk-go/v3/internal/request"
"io"
"net/http"
"net/url"
"time"
)
// UserEventsAPIService UserEventsAPI service
type UserEventsAPIService client.Service
type ApiGetUserEventsRequest struct {
ApiService *UserEventsAPIService
aid *string
useAllPermittedAids *bool
window *string
startDate *time.Time
endDate *time.Time
cursor *string
}
// A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.
func (r ApiGetUserEventsRequest) Aid(aid string) ApiGetUserEventsRequest {
r.aid = &aid
return r
}
// Set to `true` to load data from all accounts the user has access to.
func (r ApiGetUserEventsRequest) UseAllPermittedAids(useAllPermittedAids bool) ApiGetUserEventsRequest {
r.useAllPermittedAids = &useAllPermittedAids
return r
}
// A dynamic time interval up to the current time of the request. Specify the interval as a number followed by an optional type: `s` for seconds (default if no type is specified), `m` for minutes, `h` for hours, `d` for days, and `w` for weeks. For a precise date range, use `startDate` and `endDate`.
func (r ApiGetUserEventsRequest) Window(window string) ApiGetUserEventsRequest {
r.window = &window
return r
}
// Use with the `endDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.
func (r ApiGetUserEventsRequest) StartDate(startDate time.Time) ApiGetUserEventsRequest {
r.startDate = &startDate
return r
}
// Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.
func (r ApiGetUserEventsRequest) EndDate(endDate time.Time) ApiGetUserEventsRequest {
r.endDate = &endDate
return r
}
// (Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.
func (r ApiGetUserEventsRequest) Cursor(cursor string) ApiGetUserEventsRequest {
r.cursor = &cursor
return r
}
func (r ApiGetUserEventsRequest) Execute() (*AuditUserEvents, *http.Response, error) {
return r.ApiService.GetUserEventsExecute(r)
}
/*
GetUserEvents List activity log events
Returns a list of activity log events in the current account group.
If `useAllPermittedAids=true` query parameter is passed and the user has permission `View activity log for all users in account group` the logs returned include events across all the account groups they belong to.
For more information about changing the account group context, see [Account Context](https://developer.thousandeyes.com/v7/#/accountcontext).
@return ApiGetUserEventsRequest
*/
func (a *UserEventsAPIService) GetUserEvents() ApiGetUserEventsRequest {
return ApiGetUserEventsRequest{
ApiService: a,
}
}
// Execute executes the request
// @return AuditUserEvents
func (a *UserEventsAPIService) GetUserEventsExecute(r ApiGetUserEventsRequest) (*AuditUserEvents, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
localVarReturnValue *AuditUserEvents
)
localBasePath := a.Client.GetConfig().ServerURL
localVarPath := localBasePath + "/audit-user-events"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.aid != nil {
request.ParameterAddToHeaderOrQuery(localVarQueryParams, "aid", r.aid, "")
}
if r.useAllPermittedAids != nil {
request.ParameterAddToHeaderOrQuery(localVarQueryParams, "useAllPermittedAids", r.useAllPermittedAids, "")
} else {
var defaultValue bool = false
r.useAllPermittedAids = &defaultValue
}
if r.window != nil {
request.ParameterAddToHeaderOrQuery(localVarQueryParams, "window", r.window, "")
}
if r.startDate != nil {
request.ParameterAddToHeaderOrQuery(localVarQueryParams, "startDate", r.startDate, "")
}
if r.endDate != nil {
request.ParameterAddToHeaderOrQuery(localVarQueryParams, "endDate", r.endDate, "")
}
if r.cursor != nil {
request.ParameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := request.SelectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/hal+json", "application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := request.SelectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.Client.PrepareRequest(localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.Client.CallAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &internalerror.GenericAPIError{
Body: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
var v ValidationError
a.decodeError(&v, localVarBody, localVarHTTPResponse, newErr)
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v UnauthorizedError
a.decodeError(&v, localVarBody, localVarHTTPResponse, newErr)
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v Error
a.decodeError(&v, localVarBody, localVarHTTPResponse, newErr)
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 404 {
var v Error
a.decodeError(&v, localVarBody, localVarHTTPResponse, newErr)
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 429 {
var v Error
a.decodeError(&v, localVarBody, localVarHTTPResponse, newErr)
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v Error
a.decodeError(&v, localVarBody, localVarHTTPResponse, newErr)
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &internalerror.GenericAPIError{
Body: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
func (a *UserEventsAPIService) decodeError(v interface{}, localVarBody []byte, localVarHTTPResponse *http.Response, newErr *internalerror.GenericAPIError) {
err := a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.ErrorMessage = err.Error()
return
}
newErr.ErrorMessage = internalerror.FormatErrorMessage(localVarHTTPResponse.Status, string(localVarBody), &v)
newErr.Model = v
}