-
Notifications
You must be signed in to change notification settings - Fork 4
/
alerts.clj
270 lines (226 loc) · 7.83 KB
/
alerts.clj
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
(ns happygapi.alertcenter.alerts
"Google Workspace Alert Center API: alerts.
Manages alerts on issues affecting your domain. Note: The current version of this API (v1beta1) is available to all Google Workspace customers.
See: https://developers.google.com/admin-sdk/alertcenter/api/reference/rest/v1beta1/alerts"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn list$
"https://developers.google.com/admin-sdk/alertcenter/api/reference/rest/v1beta1/alerts/list
Required parameters: none
Optional parameters: customerId, pageSize, pageToken, filter, orderBy
Lists the alerts."
{:scopes ["https://www.googleapis.com/auth/apps.alerts"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{})]}
(util/get-response
(http/get
(util/get-url
"https://alertcenter.googleapis.com/"
"v1beta1/alerts"
#{}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn get$
"https://developers.google.com/admin-sdk/alertcenter/api/reference/rest/v1beta1/alerts/get
Required parameters: alertId
Optional parameters: customerId
Gets the specified alert. Attempting to get a nonexistent alert returns `NOT_FOUND` error."
{:scopes ["https://www.googleapis.com/auth/apps.alerts"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:alertId})]}
(util/get-response
(http/get
(util/get-url
"https://alertcenter.googleapis.com/"
"v1beta1/alerts/{alertId}"
#{:alertId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn delete$
"https://developers.google.com/admin-sdk/alertcenter/api/reference/rest/v1beta1/alerts/delete
Required parameters: alertId
Optional parameters: customerId
Marks the specified alert for deletion. An alert that has been marked for deletion is removed from Alert Center after 30 days. Marking an alert for deletion has no effect on an alert which has already been marked for deletion. Attempting to mark a nonexistent alert for deletion results in a `NOT_FOUND` error."
{:scopes ["https://www.googleapis.com/auth/apps.alerts"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:alertId})]}
(util/get-response
(http/delete
(util/get-url
"https://alertcenter.googleapis.com/"
"v1beta1/alerts/{alertId}"
#{:alertId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn undelete$
"https://developers.google.com/admin-sdk/alertcenter/api/reference/rest/v1beta1/alerts/undelete
Required parameters: alertId
Optional parameters: none
Body:
{:customerId string}
Restores, or \"undeletes\", an alert that was marked for deletion within the past 30 days. Attempting to undelete an alert which was marked for deletion over 30 days ago (which has been removed from the Alert Center database) or a nonexistent alert returns a `NOT_FOUND` error. Attempting to undelete an alert which has not been marked for deletion has no effect."
{:scopes ["https://www.googleapis.com/auth/apps.alerts"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{:alertId})]}
(util/get-response
(http/post
(util/get-url
"https://alertcenter.googleapis.com/"
"v1beta1/alerts/{alertId}:undelete"
#{:alertId}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn getMetadata$
"https://developers.google.com/admin-sdk/alertcenter/api/reference/rest/v1beta1/alerts/getMetadata
Required parameters: alertId
Optional parameters: customerId
Returns the metadata of an alert. Attempting to get metadata for a non-existent alert returns `NOT_FOUND` error."
{:scopes ["https://www.googleapis.com/auth/apps.alerts"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:alertId})]}
(util/get-response
(http/get
(util/get-url
"https://alertcenter.googleapis.com/"
"v1beta1/alerts/{alertId}/metadata"
#{:alertId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn batchDelete$
"https://developers.google.com/admin-sdk/alertcenter/api/reference/rest/v1beta1/alerts/batchDelete
Required parameters: none
Optional parameters: none
Body:
{:customerId string, :alertId [string]}
Performs batch delete operation on alerts."
{:scopes ["https://www.googleapis.com/auth/apps.alerts"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{})]}
(util/get-response
(http/post
(util/get-url
"https://alertcenter.googleapis.com/"
"v1beta1/alerts:batchDelete"
#{}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn batchUndelete$
"https://developers.google.com/admin-sdk/alertcenter/api/reference/rest/v1beta1/alerts/batchUndelete
Required parameters: none
Optional parameters: none
Body:
{:customerId string, :alertId [string]}
Performs batch undelete operation on alerts."
{:scopes ["https://www.googleapis.com/auth/apps.alerts"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{})]}
(util/get-response
(http/post
(util/get-url
"https://alertcenter.googleapis.com/"
"v1beta1/alerts:batchUndelete"
#{}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn feedback-create$
"https://developers.google.com/admin-sdk/alertcenter/api/reference/rest/v1beta1/alerts/feedback/create
Required parameters: alertId
Optional parameters: customerId
Body:
{:customerId string,
:alertId string,
:feedbackId string,
:createTime string,
:type string,
:email string}
Creates new feedback for an alert. Attempting to create a feedback for a non-existent alert returns `NOT_FOUND` error. Attempting to create a feedback for an alert that is marked for deletion returns `FAILED_PRECONDITION' error."
{:scopes ["https://www.googleapis.com/auth/apps.alerts"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{:alertId})]}
(util/get-response
(http/post
(util/get-url
"https://alertcenter.googleapis.com/"
"v1beta1/alerts/{alertId}/feedback"
#{:alertId}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn feedback-list$
"https://developers.google.com/admin-sdk/alertcenter/api/reference/rest/v1beta1/alerts/feedback/list
Required parameters: alertId
Optional parameters: customerId, filter
Lists all the feedback for an alert. Attempting to list feedbacks for a non-existent alert returns `NOT_FOUND` error."
{:scopes ["https://www.googleapis.com/auth/apps.alerts"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:alertId})]}
(util/get-response
(http/get
(util/get-url
"https://alertcenter.googleapis.com/"
"v1beta1/alerts/{alertId}/feedback"
#{:alertId}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))