-
Notifications
You must be signed in to change notification settings - Fork 4
/
userProfiles.clj
368 lines (317 loc) · 14 KB
/
userProfiles.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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
(ns happygapi.classroom.userProfiles
"Google Classroom API: userProfiles.
Manages classes, rosters, and invitations in Google Classroom.
See: https://developers.google.com/classroom/api/reference/rest/v1/userProfiles"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn get$
"https://developers.google.com/classroom/api/reference/rest/v1/userProfiles/get
Required parameters: userId
Optional parameters: none
Returns a user profile.
This method returns the following error codes:
* `PERMISSION_DENIED` if the requesting user is not permitted to access
this user profile, if no profile exists with the requested ID, or for
access errors."
{:scopes ["https://www.googleapis.com/auth/classroom.profile.emails"
"https://www.googleapis.com/auth/classroom.profile.photos"
"https://www.googleapis.com/auth/classroom.rosters"
"https://www.googleapis.com/auth/classroom.rosters.readonly"]}
[auth args]
{:pre [(util/has-keys? args #{:userId})]}
(util/get-response
(http/get
(util/get-url
"https://classroom.googleapis.com/"
"v1/userProfiles/{userId}"
#{:userId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn guardianInvitations-list$
"https://developers.google.com/classroom/api/reference/rest/v1/userProfiles/guardianInvitations/list
Required parameters: studentId
Optional parameters: invitedEmailAddress, states, pageSize, pageToken
Returns a list of guardian invitations that the requesting user is
permitted to view, filtered by the parameters provided.
This method returns the following error codes:
* `PERMISSION_DENIED` if a `student_id` is specified, and the requesting
user is not permitted to view guardian invitations for that student, if
`\"-\"` is specified as the `student_id` and the user is not a domain
administrator, if guardians are not enabled for the domain in question,
or for other access errors.
* `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot
be recognized (it is not an email address, nor a `student_id` from the
API, nor the literal string `me`). May also be returned if an invalid
`page_token` or `state` is provided.
* `NOT_FOUND` if a `student_id` is specified, and its format can be
recognized, but Classroom has no record of that student."
{:scopes ["https://www.googleapis.com/auth/classroom.guardianlinks.students"
"https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly"]}
[auth args]
{:pre [(util/has-keys? args #{:studentId})]}
(util/get-response
(http/get
(util/get-url
"https://classroom.googleapis.com/"
"v1/userProfiles/{studentId}/guardianInvitations"
#{:studentId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn guardianInvitations-get$
"https://developers.google.com/classroom/api/reference/rest/v1/userProfiles/guardianInvitations/get
Required parameters: invitationId, studentId
Optional parameters: none
Returns a specific guardian invitation.
This method returns the following error codes:
* `PERMISSION_DENIED` if the requesting user is not permitted to view
guardian invitations for the student identified by the `student_id`, if
guardians are not enabled for the domain in question, or for other
access errors.
* `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot
be recognized (it is not an email address, nor a `student_id` from the
API, nor the literal string `me`).
* `NOT_FOUND` if Classroom cannot find any record of the given student or
`invitation_id`. May also be returned if the student exists, but the
requesting user does not have access to see that student."
{:scopes ["https://www.googleapis.com/auth/classroom.guardianlinks.students"
"https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly"]}
[auth args]
{:pre [(util/has-keys? args #{:studentId :invitationId})]}
(util/get-response
(http/get
(util/get-url
"https://classroom.googleapis.com/"
"v1/userProfiles/{studentId}/guardianInvitations/{invitationId}"
#{:studentId :invitationId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn guardianInvitations-patch$
"https://developers.google.com/classroom/api/reference/rest/v1/userProfiles/guardianInvitations/patch
Required parameters: invitationId, studentId
Optional parameters: updateMask
Body:
{:creationTime string,
:invitationId string,
:studentId string,
:state string,
:invitedEmailAddress string}
Modifies a guardian invitation.
Currently, the only valid modification is to change the `state` from
`PENDING` to `COMPLETE`. This has the effect of withdrawing the invitation.
This method returns the following error codes:
* `PERMISSION_DENIED` if the current user does not have permission to
manage guardians, if guardians are not enabled for the domain in question
or for other access errors.
* `FAILED_PRECONDITION` if the guardian link is not in the `PENDING` state.
* `INVALID_ARGUMENT` if the format of the student ID provided
cannot be recognized (it is not an email address, nor a `user_id` from
this API), or if the passed `GuardianInvitation` has a `state` other than
`COMPLETE`, or if it modifies fields other than `state`.
* `NOT_FOUND` if the student ID provided is a valid student ID, but
Classroom has no record of that student, or if the `id` field does not
refer to a guardian invitation known to Classroom."
{:scopes ["https://www.googleapis.com/auth/classroom.guardianlinks.students"]}
[auth args body]
{:pre [(util/has-keys? args #{:studentId :invitationId})]}
(util/get-response
(http/patch
(util/get-url
"https://classroom.googleapis.com/"
"v1/userProfiles/{studentId}/guardianInvitations/{invitationId}"
#{:studentId :invitationId}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn guardianInvitations-create$
"https://developers.google.com/classroom/api/reference/rest/v1/userProfiles/guardianInvitations/create
Required parameters: studentId
Optional parameters: none
Body:
{:creationTime string,
:invitationId string,
:studentId string,
:state string,
:invitedEmailAddress string}
Creates a guardian invitation, and sends an email to the guardian asking
them to confirm that they are the student's guardian.
Once the guardian accepts the invitation, their `state` will change to
`COMPLETED` and they will start receiving guardian notifications. A
`Guardian` resource will also be created to represent the active guardian.
The request object must have the `student_id` and
`invited_email_address` fields set. Failing to set these fields, or
setting any other fields in the request, will result in an error.
This method returns the following error codes:
* `PERMISSION_DENIED` if the current user does not have permission to
manage guardians, if the guardian in question has already rejected
too many requests for that student, if guardians are not enabled for the
domain in question, or for other access errors.
* `RESOURCE_EXHAUSTED` if the student or guardian has exceeded the guardian
link limit.
* `INVALID_ARGUMENT` if the guardian email address is not valid (for
example, if it is too long), or if the format of the student ID provided
cannot be recognized (it is not an email address, nor a `user_id` from
this API). This error will also be returned if read-only fields are set,
or if the `state` field is set to to a value other than `PENDING`.
* `NOT_FOUND` if the student ID provided is a valid student ID, but
Classroom has no record of that student.
* `ALREADY_EXISTS` if there is already a pending guardian invitation for
the student and `invited_email_address` provided, or if the provided
`invited_email_address` matches the Google account of an existing
`Guardian` for this user."
{:scopes ["https://www.googleapis.com/auth/classroom.guardianlinks.students"]}
[auth args body]
{:pre [(util/has-keys? args #{:studentId})]}
(util/get-response
(http/post
(util/get-url
"https://classroom.googleapis.com/"
"v1/userProfiles/{studentId}/guardianInvitations"
#{:studentId}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn guardians-delete$
"https://developers.google.com/classroom/api/reference/rest/v1/userProfiles/guardians/delete
Required parameters: studentId, guardianId
Optional parameters: none
Deletes a guardian.
The guardian will no longer receive guardian notifications and the guardian
will no longer be accessible via the API.
This method returns the following error codes:
* `PERMISSION_DENIED` if no user that matches the provided `student_id`
is visible to the requesting user, if the requesting user is not
permitted to manage guardians for the student identified by the
`student_id`, if guardians are not enabled for the domain in question,
or for other access errors.
* `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot
be recognized (it is not an email address, nor a `student_id` from the
API).
* `NOT_FOUND` if the requesting user is permitted to modify guardians for
the requested `student_id`, but no `Guardian` record exists for that
student with the provided `guardian_id`."
{:scopes ["https://www.googleapis.com/auth/classroom.guardianlinks.students"]}
[auth args]
{:pre [(util/has-keys? args #{:guardianId :studentId})]}
(util/get-response
(http/delete
(util/get-url
"https://classroom.googleapis.com/"
"v1/userProfiles/{studentId}/guardians/{guardianId}"
#{:guardianId :studentId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn guardians-list$
"https://developers.google.com/classroom/api/reference/rest/v1/userProfiles/guardians/list
Required parameters: studentId
Optional parameters: pageToken, invitedEmailAddress, pageSize
Returns a list of guardians that the requesting user is permitted to
view, restricted to those that match the request.
To list guardians for any student that the requesting user may view
guardians for, use the literal character `-` for the student ID.
This method returns the following error codes:
* `PERMISSION_DENIED` if a `student_id` is specified, and the requesting
user is not permitted to view guardian information for that student, if
`\"-\"` is specified as the `student_id` and the user is not a domain
administrator, if guardians are not enabled for the domain in question,
if the `invited_email_address` filter is set by a user who is not a
domain administrator, or for other access errors.
* `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot
be recognized (it is not an email address, nor a `student_id` from the
API, nor the literal string `me`). May also be returned if an invalid
`page_token` is provided.
* `NOT_FOUND` if a `student_id` is specified, and its format can be
recognized, but Classroom has no record of that student."
{:scopes ["https://www.googleapis.com/auth/classroom.guardianlinks.me.readonly"
"https://www.googleapis.com/auth/classroom.guardianlinks.students"
"https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly"]}
[auth args]
{:pre [(util/has-keys? args #{:studentId})]}
(util/get-response
(http/get
(util/get-url
"https://classroom.googleapis.com/"
"v1/userProfiles/{studentId}/guardians"
#{:studentId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn guardians-get$
"https://developers.google.com/classroom/api/reference/rest/v1/userProfiles/guardians/get
Required parameters: guardianId, studentId
Optional parameters: none
Returns a specific guardian.
This method returns the following error codes:
* `PERMISSION_DENIED` if no user that matches the provided `student_id`
is visible to the requesting user, if the requesting user is not
permitted to view guardian information for the student identified by the
`student_id`, if guardians are not enabled for the domain in question,
or for other access errors.
* `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot
be recognized (it is not an email address, nor a `student_id` from the
API, nor the literal string `me`).
* `NOT_FOUND` if the requesting user is permitted to view guardians for
the requested `student_id`, but no `Guardian` record exists for that
student that matches the provided `guardian_id`."
{:scopes ["https://www.googleapis.com/auth/classroom.guardianlinks.me.readonly"
"https://www.googleapis.com/auth/classroom.guardianlinks.students"
"https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly"]}
[auth args]
{:pre [(util/has-keys? args #{:guardianId :studentId})]}
(util/get-response
(http/get
(util/get-url
"https://classroom.googleapis.com/"
"v1/userProfiles/{studentId}/guardians/{guardianId}"
#{:guardianId :studentId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))