-
Notifications
You must be signed in to change notification settings - Fork 4
/
users.clj
333 lines (285 loc) · 10.3 KB
/
users.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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
(ns happygapi.androidenterprise.users
"Google Play EMM API: users.
Manages the deployment of apps to Android for Work users.
See: https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn get$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/get
Required parameters: enterpriseId, userId
Optional parameters: none
Retrieves a user's details."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args]
{:pre [(util/has-keys? args #{:enterpriseId :userId})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users/{userId}"
#{:enterpriseId :userId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn insert$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/insert
Required parameters: enterpriseId
Optional parameters: none
Body:
{:accountIdentifier string,
:accountType string,
:displayName string,
:id string,
:kind string,
:managementType string,
:primaryEmail string}
Creates a new EMM-managed user.
The Users resource passed in the body of the request should include an accountIdentifier and an accountType.
If a corresponding user already exists with the same account identifier, the user will be updated with the resource. In this case only the displayName field can be changed."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args body]
{:pre [(util/has-keys? args #{:enterpriseId})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users"
#{:enterpriseId}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn generateToken$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/generateToken
Required parameters: enterpriseId, userId
Optional parameters: none
Generates a token (activation code) to allow this user to configure their managed account in the Android Setup Wizard. Revokes any previously generated token.
This call only works with Google managed accounts."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args]
{:pre [(util/has-keys? args #{:enterpriseId :userId})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users/{userId}/token"
#{:enterpriseId :userId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn generateAuthenticationToken$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/generateAuthenticationToken
Required parameters: enterpriseId, userId
Optional parameters: none
Generates an authentication token which the device policy client can use to provision the given EMM-managed user account on a device. The generated token is single-use and expires after a few minutes.
You can provision a maximum of 10 devices per user.
This call only works with EMM-managed accounts."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args]
{:pre [(util/has-keys? args #{:enterpriseId :userId})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users/{userId}/authenticationToken"
#{:enterpriseId :userId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn update$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/update
Required parameters: enterpriseId, userId
Optional parameters: none
Body:
{:accountIdentifier string,
:accountType string,
:displayName string,
:id string,
:kind string,
:managementType string,
:primaryEmail string}
Updates the details of an EMM-managed user.
Can be used with EMM-managed users only (not Google managed users). Pass the new details in the Users resource in the request body. Only the displayName field can be changed. Other fields must either be unset or have the currently active value."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args body]
{:pre [(util/has-keys? args #{:enterpriseId :userId})]}
(util/get-response
(http/put
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users/{userId}"
#{:enterpriseId :userId}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn delete$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/delete
Required parameters: enterpriseId, userId
Optional parameters: none
Deleted an EMM-managed user."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args]
{:pre [(util/has-keys? args #{:enterpriseId :userId})]}
(util/get-response
(http/delete
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users/{userId}"
#{:enterpriseId :userId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn revokeDeviceAccess$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/revokeDeviceAccess
Required parameters: enterpriseId, userId
Optional parameters: none
Revokes access to all devices currently provisioned to the user. The user will no longer be able to use the managed Play store on any of their managed devices.
This call only works with EMM-managed accounts."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args]
{:pre [(util/has-keys? args #{:enterpriseId :userId})]}
(util/get-response
(http/delete
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users/{userId}/deviceAccess"
#{:enterpriseId :userId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn list$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/list
Required parameters: email, enterpriseId
Optional parameters: none
Looks up a user by primary email address. This is only supported for Google-managed users. Lookup of the id is not needed for EMM-managed users because the id is already returned in the result of the Users.insert call."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args]
{:pre [(util/has-keys? args #{:email :enterpriseId})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users"
#{:email :enterpriseId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn getAvailableProductSet$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/getAvailableProductSet
Required parameters: enterpriseId, userId
Optional parameters: none
Retrieves the set of products a user is entitled to access."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args]
{:pre [(util/has-keys? args #{:enterpriseId :userId})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users/{userId}/availableProductSet"
#{:enterpriseId :userId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn revokeToken$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/revokeToken
Required parameters: enterpriseId, userId
Optional parameters: none
Revokes a previously generated token (activation code) for the user."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args]
{:pre [(util/has-keys? args #{:enterpriseId :userId})]}
(util/get-response
(http/delete
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users/{userId}/token"
#{:enterpriseId :userId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn setAvailableProductSet$
"https://developers.google.com/android/work/play/emm-apiapi/reference/rest/v1/users/setAvailableProductSet
Required parameters: enterpriseId, userId
Optional parameters: none
Body:
{:kind string,
:productId [string],
:productSetBehavior string,
:productVisibility [{:productId string,
:trackIds [string],
:tracks [string]}]}
Modifies the set of products that a user is entitled to access (referred to as whitelisted products). Only products that are approved or products that were previously approved (products with revoked approval) can be whitelisted."
{:scopes ["https://www.googleapis.com/auth/androidenterprise"]}
[auth args body]
{:pre [(util/has-keys? args #{:enterpriseId :userId})]}
(util/get-response
(http/put
(util/get-url
"https://www.googleapis.com/androidenterprise/v1/"
"enterprises/{enterpriseId}/users/{userId}/availableProductSet"
#{:enterpriseId :userId}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))