@instructure/platform-mock-canvas-api 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1108 @@
1
+ /**
2
+ * A global announcement for an account.
3
+ */
4
+ export interface AccountNotification {
5
+ id?: Id;
6
+ /** The subject of the notification. */
7
+ subject?: string;
8
+ /** The message to be sent in the notification. */
9
+ message?: string;
10
+ /** When to send out the notification. */
11
+ start_at?: string;
12
+ /** When to expire the notification. */
13
+ end_at?: string;
14
+ /** The icon to display with the message. Defaults to warning. */
15
+ icon?: AccountNotificationIcon;
16
+ /**
17
+ * Role names the notification is sent to. Empty means all roles. Use
18
+ * `role_ids`.
19
+ * @deprecated
20
+ */
21
+ roles?: string[];
22
+ /** Roles the notification is sent to. Empty means all roles. */
23
+ role_ids?: number[];
24
+ /**
25
+ * The author of the notification. Available only to admins using
26
+ * `include_all`.
27
+ * @nullable
28
+ */
29
+ author?: AccountNotificationAuthor;
30
+ /**
31
+ * Cohorts the announcement is targeted at. Empty when the
32
+ * announcement is not cohort-targeted. Added by the cohorts feature.
33
+ */
34
+ cohort_ids?: Id[];
35
+ }
36
+ /**
37
+ * The author of the notification. Available only to admins using
38
+ * `include_all`.
39
+ * @nullable
40
+ */
41
+ export type AccountNotificationAuthor = {
42
+ id?: Id;
43
+ name?: string;
44
+ } | null;
45
+ /**
46
+ * Form body of the create and update global notification operations. The
47
+ * nested `account_notification[...]` keys are sent flat, exactly as
48
+ * Canvas documents them.
49
+ */
50
+ export interface AccountNotificationForm {
51
+ /** The subject of the notification. */
52
+ 'account_notification[subject]'?: string;
53
+ /** The message body of the notification. */
54
+ 'account_notification[message]'?: string;
55
+ /** When to start showing the notification. */
56
+ 'account_notification[start_at]'?: string;
57
+ /** When to stop showing the notification. */
58
+ 'account_notification[end_at]'?: string;
59
+ /** The icon to display with the notification. */
60
+ 'account_notification[icon]'?: AccountNotificationFormAccountNotificationIcon;
61
+ /**
62
+ * Roles to send the notification to, by role id or role name.
63
+ * Omitting this sends to everyone.
64
+ */
65
+ 'account_notification_roles[]'?: string[];
66
+ /**
67
+ * Cohorts to send the notification to. Active members of these
68
+ * cohorts and of every cohort beneath them see it. Added by the
69
+ * cohorts feature; sending an empty array on update clears cohort
70
+ * targeting.
71
+ */
72
+ 'account_notification_cohort_ids[]'?: Id[];
73
+ }
74
+ /**
75
+ * The icon to display with the notification.
76
+ */
77
+ export type AccountNotificationFormAccountNotificationIcon = (typeof AccountNotificationFormAccountNotificationIcon)[keyof typeof AccountNotificationFormAccountNotificationIcon];
78
+ export declare const AccountNotificationFormAccountNotificationIcon: {
79
+ readonly warning: "warning";
80
+ readonly information: "information";
81
+ readonly question: "question";
82
+ readonly error: "error";
83
+ readonly calendar: "calendar";
84
+ };
85
+ /**
86
+ * The icon to display with the message. Defaults to warning.
87
+ */
88
+ export type AccountNotificationIcon = (typeof AccountNotificationIcon)[keyof typeof AccountNotificationIcon];
89
+ export declare const AccountNotificationIcon: {
90
+ readonly warning: "warning";
91
+ readonly information: "information";
92
+ readonly question: "question";
93
+ readonly error: "error";
94
+ readonly calendar: "calendar";
95
+ };
96
+ export type AddCohortEnrollmentScopeBody = {
97
+ scopable_type: AddCohortEnrollmentScopeBodyScopableType;
98
+ /** Id of the course, account, collection, or program. */
99
+ scopable_id: string;
100
+ /**
101
+ * Optional. Omitting it stores `false`. Any non-boolean
102
+ * value, including `null` or the string `"true"`, is
103
+ * rejected with `400`.
104
+ */
105
+ applies_to_descendants?: boolean;
106
+ };
107
+ export type AddCohortEnrollmentScopeBodyScopableType = (typeof AddCohortEnrollmentScopeBodyScopableType)[keyof typeof AddCohortEnrollmentScopeBodyScopableType];
108
+ export declare const AddCohortEnrollmentScopeBodyScopableType: {
109
+ readonly course: "course";
110
+ readonly account: "account";
111
+ readonly collection: "collection";
112
+ readonly program: "program";
113
+ };
114
+ export type AddCohortLeaderBody = {
115
+ /** Id of an existing user in this root account. */
116
+ user_id: Id;
117
+ /**
118
+ * A role whose base type is `CohortLeader`. Defaults to the
119
+ * built-in Cohort Leader role.
120
+ */
121
+ role_id?: Id;
122
+ };
123
+ export type AddCohortMembersBody = {
124
+ /**
125
+ * Ids of existing users to add. At most 500 per request.
126
+ * @minItems 1
127
+ * @maxItems 500
128
+ */
129
+ user_ids: Id[];
130
+ };
131
+ /**
132
+ * Outcome of an add-members request. Ids that could not be added are
133
+ * reported rather than failing the whole request.
134
+ */
135
+ export interface AddMembersResult {
136
+ added: CohortMembership[];
137
+ skipped: AddMembersResultSkippedItem[];
138
+ }
139
+ export type AddMembersResultSkippedItem = {
140
+ user_id: Id;
141
+ reason: AddMembersResultSkippedItemReason;
142
+ };
143
+ export type AddMembersResultSkippedItemReason = (typeof AddMembersResultSkippedItemReason)[keyof typeof AddMembersResultSkippedItemReason];
144
+ export declare const AddMembersResultSkippedItemReason: {
145
+ readonly already_member: "already_member";
146
+ readonly user_not_found: "user_not_found";
147
+ readonly user_not_in_root_account: "user_not_in_root_account";
148
+ };
149
+ /**
150
+ * The request was rejected.
151
+ */
152
+ export type BadRequestResponse = Error | ValidationError;
153
+ /**
154
+ * Form body of the Canvas bulk enrolment operation, with the two
155
+ * cohort parameters added. Identical under either form encoding.
156
+ */
157
+ export type BulkEnrollmentForm = unknown & {
158
+ /**
159
+ * Ids of the users to enrol. Required unless `cohort_ids[]`
160
+ * is given.
161
+ */
162
+ 'user_ids[]'?: Id[];
163
+ /**
164
+ * Ids of the courses to enrol each user in.
165
+ * @minItems 1
166
+ */
167
+ 'course_ids[]': Id[];
168
+ /**
169
+ * Enrol each user as a student, teacher, TA, observer, or
170
+ * designer. When `enrollment_role_id` is given, this must
171
+ * match that role's base type, and when omitted alongside
172
+ * `enrollment_role_id` Canvas derives it from that role's base
173
+ * type instead of applying the default.
174
+ */
175
+ enrollment_type?: BulkEnrollmentFormEnrollmentType;
176
+ /** Custom course-level role to apply to the created enrolments. */
177
+ enrollment_role_id?: Id;
178
+ /**
179
+ * Pre-existing Canvas bulk_enrollment parameter. Canvas accepts it
180
+ * and ignores it; it has no effect on the enrolment created. Use
181
+ * `cohort_ids[]` to target cohorts.
182
+ * @deprecated
183
+ */
184
+ cohort?: boolean;
185
+ /**
186
+ * Existing Canvas bulk_enrollment parameter controlling
187
+ * whether each enrolled user is notified.
188
+ */
189
+ notify?: boolean;
190
+ /** Start time applied to every created enrolment. */
191
+ start_at?: string;
192
+ /** End time applied to every created enrolment. */
193
+ end_at?: string;
194
+ /**
195
+ * Cohorts whose active members should be enrolled. Added by
196
+ * the cohorts feature.
197
+ */
198
+ 'cohort_ids[]'?: Id[];
199
+ /**
200
+ * Also enrol the active members of every cohort beneath each
201
+ * listed cohort. Added by the cohorts feature.
202
+ */
203
+ include_descendant_cohorts?: boolean;
204
+ };
205
+ /**
206
+ * Enrol each user as a student, teacher, TA, observer, or
207
+ * designer. When `enrollment_role_id` is given, this must
208
+ * match that role's base type, and when omitted alongside
209
+ * `enrollment_role_id` Canvas derives it from that role's base
210
+ * type instead of applying the default.
211
+ */
212
+ export type BulkEnrollmentFormEnrollmentType = (typeof BulkEnrollmentFormEnrollmentType)[keyof typeof BulkEnrollmentFormEnrollmentType];
213
+ export declare const BulkEnrollmentFormEnrollmentType: {
214
+ readonly StudentEnrollment: "StudentEnrollment";
215
+ readonly TeacherEnrollment: "TeacherEnrollment";
216
+ readonly TaEnrollment: "TaEnrollment";
217
+ readonly ObserverEnrollment: "ObserverEnrollment";
218
+ readonly DesignerEnrollment: "DesignerEnrollment";
219
+ };
220
+ /**
221
+ * A group of people placed in a Canvas account.
222
+ */
223
+ export interface Cohort {
224
+ id: Id;
225
+ /**
226
+ * Root account at the top of `account_id`'s account hierarchy.
227
+ * Equal to `account_id` when the cohort is placed in the root
228
+ * account itself. The same value for every cohort in one
229
+ * parent/child hierarchy.
230
+ */
231
+ root_account_id: Id;
232
+ /**
233
+ * Root cohort at the top of this cohort's hierarchy tree: the
234
+ * ancestor whose own `parent_cohort_id` is null. Equal to `id`
235
+ * when this cohort is itself a root. A client walks up to the
236
+ * root structurally by fetching this id, with no dedicated route.
237
+ */
238
+ root_cohort_id: Id;
239
+ /**
240
+ * The account the cohort is placed in, a root account or a
241
+ * sub-account.
242
+ */
243
+ account_id: Id;
244
+ /**
245
+ * Cohort one level above this one. Null only for a root cohort,
246
+ * the anchor of a hierarchy tree. An account may anchor several
247
+ * independent root cohorts; see **Account scoping** in the API
248
+ * description.
249
+ */
250
+ parent_cohort_id: Id | null;
251
+ /**
252
+ * @minLength 1
253
+ * @maxLength 255
254
+ */
255
+ name: string;
256
+ /**
257
+ * Free-text description of the cohort.
258
+ * @nullable
259
+ */
260
+ description?: string | null;
261
+ /**
262
+ * Level in the hierarchy. The root cohort is 1.
263
+ * @minimum 1
264
+ * @maximum 10
265
+ */
266
+ depth: number;
267
+ workflow_state: WorkflowState;
268
+ /**
269
+ * Unique SIS identifier within the root account.
270
+ * @maxLength 255
271
+ * @nullable
272
+ */
273
+ sis_source_id?: string | null;
274
+ /** SIS import that last touched this cohort, if any. */
275
+ sis_batch_id?: Id | null;
276
+ /**
277
+ * Fields last changed outside SIS. A subsequent SIS import leaves
278
+ * these alone unless it explicitly overrides stickiness.
279
+ */
280
+ stuck_sis_fields?: string[];
281
+ created_at: string;
282
+ updated_at: string;
283
+ /**
284
+ * Active members of this cohort. Present with `include[]=member_count`.
285
+ * @minimum 0
286
+ */
287
+ member_count?: number;
288
+ /**
289
+ * Active leaders of this cohort. Present with `include[]=leader_count`.
290
+ * @minimum 0
291
+ */
292
+ leader_count?: number;
293
+ /**
294
+ * Active cohorts one level below this one. Present with
295
+ * `include[]=child_count`.
296
+ * @minimum 0
297
+ */
298
+ child_count?: number;
299
+ }
300
+ /**
301
+ * One course, account, collection, or program an admin has opted into
302
+ * a cohort's enrollment reach. Purely an allow-list entry: it grants no
303
+ * enrollment by itself and carries no `workflow_state`.
304
+ */
305
+ export interface CohortEnrollmentScope {
306
+ id: Id;
307
+ cohort_id: Id;
308
+ /** Kind of resource this scope grants enrollment reach into. */
309
+ scopable_type: CohortEnrollmentScopeScopableType;
310
+ /**
311
+ * Stored per scope row, never per cohort. Always present in the
312
+ * response.
313
+ *
314
+ * Defaults to `false`. This is the opposite of Canvas
315
+ * `role_overrides.applies_to_descendants`, which defaults to
316
+ * `true`. A scope created without this field, or from a blank SIS
317
+ * CSV cell, does not cascade.
318
+ *
319
+ * Only meaningful on an `account` scope. On a `course`, `program`,
320
+ * or `collection` scope it is accepted, stored, and returned, but
321
+ * has no effect.
322
+ *
323
+ * What an `account` scope reaches when this is `true` is not yet
324
+ * settled: either the sub-accounts beneath that account, or the
325
+ * cohort's child cohorts. Until this contract names one, a server
326
+ * stores and returns the value but does not resolve any cascade
327
+ * from it.
328
+ */
329
+ applies_to_descendants: boolean;
330
+ /**
331
+ * Id of the course, account, collection, or program. Course and
332
+ * account ids are Canvas ids; collection and program ids are
333
+ * Journey ids. Serialised as a string either way, since the two id
334
+ * spaces don't share a type.
335
+ */
336
+ scopable_id: string;
337
+ created_at: string;
338
+ updated_at: string;
339
+ }
340
+ /**
341
+ * Kind of resource this scope grants enrollment reach into.
342
+ */
343
+ export type CohortEnrollmentScopeScopableType = (typeof CohortEnrollmentScopeScopableType)[keyof typeof CohortEnrollmentScopeScopableType];
344
+ export declare const CohortEnrollmentScopeScopableType: {
345
+ readonly course: "course";
346
+ readonly account: "account";
347
+ readonly collection: "collection";
348
+ readonly program: "program";
349
+ };
350
+ /**
351
+ * A leader assignment. The rights it grants (managing membership of the
352
+ * cohort, and no content editing) always reach every cohort beneath the
353
+ * one the assignment lives on.
354
+ */
355
+ export interface CohortLeader {
356
+ /** Id of the assignment itself, used to remove it. */
357
+ id: Id;
358
+ /** Cohort this assignment was returned for. */
359
+ cohort_id: Id;
360
+ user_id: Id;
361
+ root_account_id: Id;
362
+ role_id: Id;
363
+ role: CohortLeaderRole;
364
+ /**
365
+ * Always true. A leader's rights cannot be confined to a single
366
+ * level of the hierarchy.
367
+ *
368
+ * Which cohorts an assignment reaches is resolved live against the
369
+ * current `parent_cohort_id` chain at request time. An
370
+ * implementation may instead maintain a cache or closure table of
371
+ * descendants, but only if it is invalidated within the same
372
+ * transaction that commits a delete (`deleteCohort`), so no
373
+ * request can ever observe a stale ancestor chain.
374
+ */
375
+ applies_to_descendants: true;
376
+ /**
377
+ * True when this assignment lives on an ancestor and was returned
378
+ * because of `include_inherited`. Remove it from `source_cohort_id`,
379
+ * not from `cohort_id`.
380
+ */
381
+ inherited: boolean;
382
+ /**
383
+ * Cohort the assignment actually lives on. Equal to `cohort_id`
384
+ * unless `inherited` is true.
385
+ */
386
+ source_cohort_id: Id;
387
+ workflow_state: WorkflowState;
388
+ created_at: string;
389
+ updated_at: string;
390
+ user?: UserDisplay;
391
+ }
392
+ export type CohortLeaderRole = {
393
+ id: Id;
394
+ label: string;
395
+ base_role_type: 'CohortLeader';
396
+ };
397
+ /**
398
+ * One person's place in one cohort.
399
+ */
400
+ export interface CohortMembership {
401
+ id: Id;
402
+ cohort_id: Id;
403
+ user_id: Id;
404
+ root_account_id: Id;
405
+ workflow_state: WorkflowState;
406
+ sis_batch_id?: Id | null;
407
+ created_at: string;
408
+ updated_at: string;
409
+ /**
410
+ * When the member was last active in Canvas, as shown in the
411
+ * members list "Last active" column and sortable via
412
+ * `sort=last_activity_at`. Null when no activity has been
413
+ * recorded for the user.
414
+ * @nullable
415
+ */
416
+ last_activity_at?: string | null;
417
+ /**
418
+ * True when this member also holds an active leader assignment
419
+ * on this cohort or on one of its ancestors, so the members list
420
+ * can badge them as a Leader without a second call. Reflects
421
+ * leadership that reaches this cohort, not membership.
422
+ */
423
+ is_leader?: boolean;
424
+ /**
425
+ * The member's role label as shown in the members list "Role"
426
+ * column. Null when the member has no role to display. This is a
427
+ * display-only label; a `CohortMembership` carries no permissions
428
+ * of its own.
429
+ * @nullable
430
+ */
431
+ role?: CohortMembershipRole;
432
+ /**
433
+ * Included by default so lists are renderable without a second
434
+ * call. Its identity fields are present by default; `sis_user_id`
435
+ * and `login_id` appear only under the permission rules on
436
+ * `UserDisplay`.
437
+ */
438
+ user?: UserDisplay;
439
+ }
440
+ /**
441
+ * The member's role label as shown in the members list "Role"
442
+ * column. Null when the member has no role to display. This is a
443
+ * display-only label; a `CohortMembership` carries no permissions
444
+ * of its own.
445
+ * @nullable
446
+ */
447
+ export type CohortMembershipRole = {
448
+ id?: Id | null;
449
+ label: string;
450
+ } | null;
451
+ /**
452
+ * The caller's effective `manage_cohorts_*` permissions on one cohort,
453
+ * combining account grants and Leader grants. Every permission is always present.
454
+ */
455
+ export interface CohortPermissions {
456
+ /** Whether the caller may view the cohort. */
457
+ manage_cohorts_view: boolean;
458
+ /** Whether the caller may create sub-cohorts under the cohort. */
459
+ manage_cohorts_create: boolean;
460
+ /** Whether the caller may edit the cohort. */
461
+ manage_cohorts_edit: boolean;
462
+ /** Whether the caller may delete the cohort. */
463
+ manage_cohorts_remove: boolean;
464
+ /** Whether the caller may choose which content Leaders can enrol members in. Account grant only. */
465
+ manage_cohorts_enrollment_scopes: boolean;
466
+ /** Whether the caller may add members to the cohort. */
467
+ manage_cohorts_add_members: boolean;
468
+ /** Whether the caller may remove members from the cohort. */
469
+ manage_cohorts_remove_members: boolean;
470
+ /** Whether the caller may assign Leaders to the cohort. */
471
+ manage_cohorts_add_leaders: boolean;
472
+ /** Whether the caller may remove Leaders from the cohort. */
473
+ manage_cohorts_remove_leaders: boolean;
474
+ /** Whether the caller may view analytics. Canvas allows this only on Horizon accounts. */
475
+ manage_cohorts_view_analytics: boolean;
476
+ }
477
+ /**
478
+ * A cohort and the subtree beneath it.
479
+ */
480
+ export interface CohortTreeNode {
481
+ cohort: Cohort;
482
+ /** Active direct children, newest first, capped at 100 per node. */
483
+ children: CohortTreeNode[];
484
+ /**
485
+ * True when this node has children that the requested `depth` cut
486
+ * off. Fetch the subtree again from this node to see them.
487
+ */
488
+ truncated: boolean;
489
+ /**
490
+ * True when this node has more than 100 active direct children and
491
+ * `children` holds only the first 100. Call `listCohorts` with
492
+ * `parent_cohort_id` set to this node's cohort id for the complete
493
+ * set. Independent of `truncated`: either, both, or neither may be
494
+ * true.
495
+ */
496
+ children_truncated: boolean;
497
+ }
498
+ /**
499
+ * The account notification form with the fields Canvas requires on
500
+ * create marked required.
501
+ */
502
+ export type CreateAccountNotificationForm = AccountNotificationForm & {
503
+ [key: string]: unknown;
504
+ } & Required<Pick<AccountNotificationForm & {
505
+ [key: string]: unknown;
506
+ }, 'account_notification[subject]' | 'account_notification[message]' | 'account_notification[start_at]' | 'account_notification[end_at]'>>;
507
+ export type CreateCohortBody = {
508
+ cohort: CreateCohortBodyCohort;
509
+ };
510
+ export type CreateCohortBodyCohort = {
511
+ /**
512
+ * Display name of the cohort.
513
+ * @minLength 1
514
+ * @maxLength 255
515
+ */
516
+ name: string;
517
+ /** Free-text description of the cohort. */
518
+ description?: string;
519
+ /**
520
+ * Cohort to nest the new cohort under. Null creates a
521
+ * root cohort instead, with no parent.
522
+ */
523
+ parent_cohort_id: Id | null;
524
+ /**
525
+ * Unique SIS identifier for the cohort within the root account.
526
+ * @maxLength 255
527
+ */
528
+ sis_source_id?: string;
529
+ };
530
+ /**
531
+ * One course enrollment, as returned by the Canvas List Enrollments
532
+ * operation. This contract lists the subset of fields the cohort
533
+ * Enrollments tab renders; a live Canvas response carries more, and a
534
+ * client should tolerate additional properties. This is a plain Canvas
535
+ * enrollment and holds no cohort reference.
536
+ */
537
+ export interface Enrollment {
538
+ id: Id;
539
+ user_id: Id;
540
+ course_id: Id;
541
+ course_section_id?: Id;
542
+ root_account_id: Id;
543
+ type: EnrollmentType;
544
+ /** Enrollment role name, a base type or a custom course-level role. */
545
+ role: string;
546
+ role_id: Id;
547
+ enrollment_state: EnrollmentEnrollmentState;
548
+ created_at: string;
549
+ updated_at: string;
550
+ /** @nullable */
551
+ last_activity_at?: string | null;
552
+ /**
553
+ * The enrolled user. Included by default so the tab renders without
554
+ * a second call, following the Canvas List Enrollments default.
555
+ */
556
+ user?: UserDisplay;
557
+ }
558
+ export type EnrollmentEnrollmentState = (typeof EnrollmentEnrollmentState)[keyof typeof EnrollmentEnrollmentState];
559
+ export declare const EnrollmentEnrollmentState: {
560
+ readonly active: "active";
561
+ readonly invited: "invited";
562
+ readonly creation_pending: "creation_pending";
563
+ readonly deleted: "deleted";
564
+ readonly rejected: "rejected";
565
+ readonly completed: "completed";
566
+ readonly inactive: "inactive";
567
+ };
568
+ export type EnrollmentType = (typeof EnrollmentType)[keyof typeof EnrollmentType];
569
+ export declare const EnrollmentType: {
570
+ readonly StudentEnrollment: "StudentEnrollment";
571
+ readonly TeacherEnrollment: "TeacherEnrollment";
572
+ readonly TaEnrollment: "TaEnrollment";
573
+ readonly ObserverEnrollment: "ObserverEnrollment";
574
+ readonly DesignerEnrollment: "DesignerEnrollment";
575
+ };
576
+ /**
577
+ * The general Canvas error shape. `error_code` is present when the
578
+ * failure has a machine-readable cause; clients should branch on it
579
+ * rather than on `message`, which is localised.
580
+ */
581
+ export interface CohortsApiError {
582
+ /** @minItems 1 */
583
+ errors: ErrorErrorsItem[];
584
+ }
585
+ /**
586
+ * Machine-readable cause of a rejected cohort request.
587
+ */
588
+ export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
589
+ export declare const ErrorCode: {
590
+ readonly feature_disabled: "feature_disabled";
591
+ readonly max_depth_exceeded: "max_depth_exceeded";
592
+ readonly max_cohorts_exceeded: "max_cohorts_exceeded";
593
+ readonly max_members_exceeded: "max_members_exceeded";
594
+ readonly cohort_has_children: "cohort_has_children";
595
+ readonly invalid_role: "invalid_role";
596
+ readonly too_many_enrollments: "too_many_enrollments";
597
+ readonly duplicate_scope: "duplicate_scope";
598
+ };
599
+ export type ErrorErrorsItem = {
600
+ message: string;
601
+ error_code?: ErrorCode;
602
+ };
603
+ /**
604
+ * Both grant sources were evaluated for this cohort and neither
605
+ * conveyed the required permission: no role the caller holds in an
606
+ * account this cohort is in or any account above it carries it, and no
607
+ * Leader assignment on this cohort or on one of its ancestors carries
608
+ * it either. See **Authorization** in the API description for how the
609
+ * two combine.
610
+ */
611
+ export type ForbiddenResponse = UnauthorizedError;
612
+ export type GetCohort200 = Cohort & {
613
+ /**
614
+ * Present when requested via `include[]=ancestors`.
615
+ * Ordered root first, excluding the cohort itself.
616
+ */
617
+ ancestors?: Cohort[];
618
+ };
619
+ export type GetCohortIncludeItem = (typeof GetCohortIncludeItem)[keyof typeof GetCohortIncludeItem];
620
+ export declare const GetCohortIncludeItem: {
621
+ readonly member_count: "member_count";
622
+ readonly leader_count: "leader_count";
623
+ readonly child_count: "child_count";
624
+ readonly ancestors: "ancestors";
625
+ };
626
+ export type GetCohortParams = {
627
+ /**
628
+ * Extra data to compute for the cohort. `ancestors` adds the chain of
629
+ * cohorts from the root down to the parent, root first. The
630
+ * permission is evaluated on the named cohort only; the ancestor
631
+ * chain is returned on the read reach set out under
632
+ * **Authorization**.
633
+ */
634
+ 'include[]'?: GetCohortIncludeItem[];
635
+ };
636
+ export type GetCohortTreeParams = {
637
+ /**
638
+ * How many levels of the tree to return, counting the requested
639
+ * cohort as level 1. `1` returns the cohort with no children.
640
+ * Defaults to `2`: the cohort and its direct children, so a client
641
+ * expands one level at a time unless it asks for more. `10` returns
642
+ * the full hierarchy.
643
+ * @minimum 1
644
+ * @maximum 10
645
+ */
646
+ depth?: number;
647
+ };
648
+ /**
649
+ * A Canvas id. Serialised as a JSON string instead when the request
650
+ * carries `Accept: application/json+canvas-string-ids`, so clients should
651
+ * accept both an integer and a numeric string here.
652
+ */
653
+ export type Id = number;
654
+ /**
655
+ * Extra data to compute for each cohort. Each value costs an extra
656
+ * aggregate, so ask only for what you display.
657
+ */
658
+ export type IncludeParameter = IncludeParameterItem[];
659
+ export type IncludeParameterItem = (typeof IncludeParameterItem)[keyof typeof IncludeParameterItem];
660
+ export declare const IncludeParameterItem: {
661
+ readonly member_count: "member_count";
662
+ readonly leader_count: "leader_count";
663
+ readonly child_count: "child_count";
664
+ };
665
+ /**
666
+ * The error shape the existing Canvas bulk enrolment validation emits
667
+ * today: one human-readable string, no error code. Only validation
668
+ * that predates the cohorts feature uses it.
669
+ */
670
+ export interface LegacyStringError {
671
+ errors: string;
672
+ }
673
+ export type ListCohortEnrollmentScopesParams = {
674
+ /**
675
+ * Restrict to scopes of these kinds. Omitting returns every kind.
676
+ */
677
+ 'scopable_type[]'?: ListCohortEnrollmentScopesScopableTypeItem[];
678
+ /**
679
+ * Field to sort enrollment scopes by. Defaults to `created_at`.
680
+ */
681
+ sort?: SortCohortEnrollmentScopesParameter;
682
+ /**
683
+ * Direction to sort in, applied to whichever field `sort` names.
684
+ * Defaults to `desc`. Ties on a non-unique sort field break by id
685
+ * ascending, so pagination stays stable across pages even when sorting
686
+ * by a non-unique field like `name` or `workflow_state`.
687
+ */
688
+ order?: OrderParameter;
689
+ /**
690
+ * Page of results to return. Prefer following the `Link` header.
691
+ * @minimum 1
692
+ */
693
+ page?: PageParameter;
694
+ /**
695
+ * Results per page.
696
+ * @minimum 1
697
+ * @maximum 100
698
+ */
699
+ per_page?: PerPageParameter;
700
+ };
701
+ export type ListCohortEnrollmentScopesScopableTypeItem = (typeof ListCohortEnrollmentScopesScopableTypeItem)[keyof typeof ListCohortEnrollmentScopesScopableTypeItem];
702
+ export declare const ListCohortEnrollmentScopesScopableTypeItem: {
703
+ readonly course: "course";
704
+ readonly account: "account";
705
+ readonly collection: "collection";
706
+ readonly program: "program";
707
+ };
708
+ export type ListCohortEnrollmentsParams = {
709
+ /**
710
+ * Partial, case-insensitive match against the name of the resource.
711
+ * Shorter than two characters is rejected.
712
+ * @minLength 2
713
+ */
714
+ search_term?: SearchTermParameter;
715
+ /**
716
+ * Also list the enrollments of members of cohorts beneath this
717
+ * one, de-duplicated by user.
718
+ */
719
+ include_descendants?: boolean;
720
+ /**
721
+ * Enrollment types to return. Omitting returns every type. Matches
722
+ * the Canvas List Enrollments `type[]` filter.
723
+ */
724
+ 'type[]'?: ListCohortEnrollmentsTypeItem[];
725
+ /**
726
+ * Enrollment states to return. Defaults to `active` and `invited`,
727
+ * matching the Canvas List Enrollments `state[]` filter.
728
+ */
729
+ 'state[]'?: ListCohortEnrollmentsStateItem[];
730
+ /**
731
+ * Field to sort enrollments by. Defaults to `created_at`. The
732
+ * `user_name` and `user_sortable_name` values sort on the enrolled
733
+ * user's `UserDisplay` field, same as members.
734
+ */
735
+ sort?: SortCohortEnrollmentsParameter;
736
+ /**
737
+ * Direction to sort in, applied to whichever field `sort` names.
738
+ * Defaults to `desc`. Ties on a non-unique sort field break by id
739
+ * ascending, so pagination stays stable across pages even when sorting
740
+ * by a non-unique field like `name` or `workflow_state`.
741
+ */
742
+ order?: OrderParameter;
743
+ /**
744
+ * Page of results to return. Prefer following the `Link` header.
745
+ * @minimum 1
746
+ */
747
+ page?: PageParameter;
748
+ /**
749
+ * Results per page.
750
+ * @minimum 1
751
+ * @maximum 100
752
+ */
753
+ per_page?: PerPageParameter;
754
+ };
755
+ export type ListCohortEnrollmentsStateItem = (typeof ListCohortEnrollmentsStateItem)[keyof typeof ListCohortEnrollmentsStateItem];
756
+ export declare const ListCohortEnrollmentsStateItem: {
757
+ readonly active: "active";
758
+ readonly invited: "invited";
759
+ readonly creation_pending: "creation_pending";
760
+ readonly deleted: "deleted";
761
+ readonly rejected: "rejected";
762
+ readonly completed: "completed";
763
+ readonly inactive: "inactive";
764
+ };
765
+ export type ListCohortEnrollmentsTypeItem = (typeof ListCohortEnrollmentsTypeItem)[keyof typeof ListCohortEnrollmentsTypeItem];
766
+ export declare const ListCohortEnrollmentsTypeItem: {
767
+ readonly StudentEnrollment: "StudentEnrollment";
768
+ readonly TeacherEnrollment: "TeacherEnrollment";
769
+ readonly TaEnrollment: "TaEnrollment";
770
+ readonly ObserverEnrollment: "ObserverEnrollment";
771
+ readonly DesignerEnrollment: "DesignerEnrollment";
772
+ };
773
+ export type ListCohortLeadersParams = {
774
+ /**
775
+ * Also return Leaders assigned to ancestor cohorts. The permission
776
+ * is evaluated on the named cohort only; the ancestor read reach is
777
+ * set out under **Authorization**.
778
+ */
779
+ include_inherited?: boolean;
780
+ /**
781
+ * Field to sort leader assignments by. Defaults to `created_at`. The
782
+ * `user_name` and `user_sortable_name` values sort on the nested user
783
+ * record's corresponding `UserDisplay` field, same as members.
784
+ */
785
+ sort?: SortCohortLeadersParameter;
786
+ /**
787
+ * Direction to sort in, applied to whichever field `sort` names.
788
+ * Defaults to `desc`. Ties on a non-unique sort field break by id
789
+ * ascending, so pagination stays stable across pages even when sorting
790
+ * by a non-unique field like `name` or `workflow_state`.
791
+ */
792
+ order?: OrderParameter;
793
+ /**
794
+ * Page of results to return. Prefer following the `Link` header.
795
+ * @minimum 1
796
+ */
797
+ page?: PageParameter;
798
+ /**
799
+ * Results per page.
800
+ * @minimum 1
801
+ * @maximum 100
802
+ */
803
+ per_page?: PerPageParameter;
804
+ };
805
+ export type ListCohortMembersParams = {
806
+ /**
807
+ * Partial, case-insensitive match against the name of the resource.
808
+ * Shorter than two characters is rejected.
809
+ * @minLength 2
810
+ */
811
+ search_term?: SearchTermParameter;
812
+ /**
813
+ * Also return members of cohorts beneath this one. The permission
814
+ * is evaluated on the named cohort only; the descendant reach is
815
+ * set out under **Authorization**.
816
+ */
817
+ include_descendants?: boolean;
818
+ /**
819
+ * Which lifecycle states to return. Repeatable, matching the Canvas
820
+ * `workflow_state[]` list filter: `active`, `deleted`, or `all` for
821
+ * both. Defaults to `active` only.
822
+ */
823
+ 'workflow_state[]'?: WorkflowStateFilterParameter;
824
+ /**
825
+ * Field to sort memberships by. Defaults to `created_at`. The
826
+ * `user_name` and `user_sortable_name` values sort on the nested
827
+ * user record's corresponding `UserDisplay` field (`name`,
828
+ * `sortable_name`). `last_activity_at` sorts on the member's most
829
+ * recent activity; rows with no recorded activity sort last
830
+ * regardless of `order`.
831
+ */
832
+ sort?: SortCohortMembersParameter;
833
+ /**
834
+ * Direction to sort in, applied to whichever field `sort` names.
835
+ * Defaults to `desc`. Ties on a non-unique sort field break by id
836
+ * ascending, so pagination stays stable across pages even when sorting
837
+ * by a non-unique field like `name` or `workflow_state`.
838
+ */
839
+ order?: OrderParameter;
840
+ /**
841
+ * Page of results to return. Prefer following the `Link` header.
842
+ * @minimum 1
843
+ */
844
+ page?: PageParameter;
845
+ /**
846
+ * Results per page.
847
+ * @minimum 1
848
+ * @maximum 100
849
+ */
850
+ per_page?: PerPageParameter;
851
+ };
852
+ export type ListCohortsParams = {
853
+ /**
854
+ * Partial, case-insensitive match against the name of the resource.
855
+ * Shorter than two characters is rejected.
856
+ * @minLength 2
857
+ */
858
+ search_term?: SearchTermParameter;
859
+ /**
860
+ * Return only the direct children of this cohort.
861
+ */
862
+ parent_cohort_id?: Id;
863
+ /**
864
+ * Return only the parentless cohorts placed in this account.
865
+ * Mutually exclusive with `parent_cohort_id`.
866
+ */
867
+ roots?: boolean;
868
+ /**
869
+ * Which lifecycle states to return. Repeatable, matching the Canvas
870
+ * `workflow_state[]` list filter: `active`, `deleted`, or `all` for
871
+ * both. Defaults to `active` only.
872
+ */
873
+ 'workflow_state[]'?: WorkflowStateFilterParameter;
874
+ /**
875
+ * Extra data to compute for each cohort. Each value costs an extra
876
+ * aggregate, so ask only for what you display.
877
+ */
878
+ 'include[]'?: IncludeParameter;
879
+ /**
880
+ * Field to sort cohorts by. Defaults to `created_at`. The computed
881
+ * counts gated behind `include[]` (`member_count`, `leader_count`,
882
+ * `child_count`) are not sortable, since they're only populated when
883
+ * explicitly requested.
884
+ */
885
+ sort?: SortCohortsParameter;
886
+ /**
887
+ * Direction to sort in, applied to whichever field `sort` names.
888
+ * Defaults to `desc`. Ties on a non-unique sort field break by id
889
+ * ascending, so pagination stays stable across pages even when sorting
890
+ * by a non-unique field like `name` or `workflow_state`.
891
+ */
892
+ order?: OrderParameter;
893
+ /**
894
+ * Page of results to return. Prefer following the `Link` header.
895
+ * @minimum 1
896
+ */
897
+ page?: PageParameter;
898
+ /**
899
+ * Results per page.
900
+ * @minimum 1
901
+ * @maximum 100
902
+ */
903
+ per_page?: PerPageParameter;
904
+ };
905
+ /**
906
+ * Nothing here for this caller. One response covers several causes on
907
+ * purpose, so that the API never reveals whether a cohort exists: the
908
+ * resource does not exist, the caller may not view it at all, the
909
+ * `institutional_cohorts` flag is off for this root account, or the
910
+ * account or cohort belongs to a different root account than the
911
+ * caller. A soft-deleted cohort still exists and remains addressable
912
+ * by id; it is not a `404`.
913
+ */
914
+ export type NotFoundResponse = Error;
915
+ export type OrderParameter = (typeof OrderParameter)[keyof typeof OrderParameter];
916
+ export declare const OrderParameter: {
917
+ readonly asc: "asc";
918
+ readonly desc: "desc";
919
+ };
920
+ /**
921
+ * Page of results to return. Prefer following the `Link` header.
922
+ */
923
+ export type PageParameter = number;
924
+ /**
925
+ * Results per page.
926
+ */
927
+ export type PerPageParameter = number;
928
+ /**
929
+ * Progress of an asynchronous Canvas job. Poll `url` until
930
+ * `workflow_state` is `completed` or `failed`.
931
+ */
932
+ export interface Progress {
933
+ /** The id of the Progress object. */
934
+ id?: number;
935
+ /** The context owning the job. */
936
+ context_id?: number;
937
+ context_type?: string;
938
+ /** The id of the user who started the job. */
939
+ user_id?: number;
940
+ /** The type of operation. */
941
+ tag?: string;
942
+ /** Percent completed. */
943
+ completion?: number;
944
+ workflow_state?: ProgressWorkflowState;
945
+ created_at?: string;
946
+ updated_at?: string;
947
+ /**
948
+ * Optional details about the job.
949
+ * @nullable
950
+ */
951
+ message?: string | null;
952
+ /**
953
+ * Optional results of the job. Omitted while the job is still pending.
954
+ * @nullable
955
+ */
956
+ results?: ProgressResults;
957
+ /** Url where a progress update can be retrieved. */
958
+ url?: string;
959
+ }
960
+ /**
961
+ * Optional results of the job. Omitted while the job is still pending.
962
+ * @nullable
963
+ */
964
+ export type ProgressResults = {
965
+ [key: string]: unknown;
966
+ } | null;
967
+ export type ProgressWorkflowState = (typeof ProgressWorkflowState)[keyof typeof ProgressWorkflowState];
968
+ export declare const ProgressWorkflowState: {
969
+ readonly queued: "queued";
970
+ readonly running: "running";
971
+ readonly completed: "completed";
972
+ readonly failed: "failed";
973
+ };
974
+ /**
975
+ * Partial, case-insensitive match against the name of the resource.
976
+ * Shorter than two characters is rejected.
977
+ */
978
+ export type SearchTermParameter = string;
979
+ export type SortCohortEnrollmentScopesParameter = (typeof SortCohortEnrollmentScopesParameter)[keyof typeof SortCohortEnrollmentScopesParameter];
980
+ export declare const SortCohortEnrollmentScopesParameter: {
981
+ readonly created_at: "created_at";
982
+ readonly scopable_type: "scopable_type";
983
+ };
984
+ export type SortCohortEnrollmentsParameter = (typeof SortCohortEnrollmentsParameter)[keyof typeof SortCohortEnrollmentsParameter];
985
+ export declare const SortCohortEnrollmentsParameter: {
986
+ readonly created_at: "created_at";
987
+ readonly user_name: "user_name";
988
+ readonly user_sortable_name: "user_sortable_name";
989
+ };
990
+ export type SortCohortLeadersParameter = (typeof SortCohortLeadersParameter)[keyof typeof SortCohortLeadersParameter];
991
+ export declare const SortCohortLeadersParameter: {
992
+ readonly created_at: "created_at";
993
+ readonly role_id: "role_id";
994
+ readonly user_name: "user_name";
995
+ readonly user_sortable_name: "user_sortable_name";
996
+ };
997
+ export type SortCohortMembersParameter = (typeof SortCohortMembersParameter)[keyof typeof SortCohortMembersParameter];
998
+ export declare const SortCohortMembersParameter: {
999
+ readonly created_at: "created_at";
1000
+ readonly user_name: "user_name";
1001
+ readonly user_sortable_name: "user_sortable_name";
1002
+ readonly last_activity_at: "last_activity_at";
1003
+ };
1004
+ export type SortCohortsParameter = (typeof SortCohortsParameter)[keyof typeof SortCohortsParameter];
1005
+ export declare const SortCohortsParameter: {
1006
+ readonly created_at: "created_at";
1007
+ readonly name: "name";
1008
+ readonly workflow_state: "workflow_state";
1009
+ readonly depth: "depth";
1010
+ };
1011
+ /**
1012
+ * The shape Canvas returns when a caller lacks a required permission.
1013
+ */
1014
+ export interface UnauthorizedError {
1015
+ status: 'unauthorized';
1016
+ errors: UnauthorizedErrorErrorsItem[];
1017
+ }
1018
+ export type UnauthorizedErrorErrorsItem = {
1019
+ message: string;
1020
+ };
1021
+ export type UpdateCohortBody = {
1022
+ cohort: UpdateCohortBodyCohort;
1023
+ /** Allow this request to change fields marked sticky by SIS. */
1024
+ override_sis_stickiness?: boolean;
1025
+ };
1026
+ export type UpdateCohortBodyCohort = {
1027
+ /**
1028
+ * @minLength 1
1029
+ * @maxLength 255
1030
+ */
1031
+ name?: string;
1032
+ /** Free-text description of the cohort. */
1033
+ description?: string;
1034
+ /** @maxLength 255 */
1035
+ sis_source_id?: string;
1036
+ };
1037
+ export type UpdateCohortLeaderBody = {
1038
+ /**
1039
+ * A role whose base type is `CohortLeader`. Required: an
1040
+ * update names the role to move to explicitly.
1041
+ */
1042
+ role_id: Id;
1043
+ };
1044
+ /**
1045
+ * The subset of a Canvas user shown alongside cohort records.
1046
+ */
1047
+ export interface UserDisplay {
1048
+ id: Id;
1049
+ name: string;
1050
+ sortable_name?: string;
1051
+ short_name?: string;
1052
+ avatar_url?: string;
1053
+ /**
1054
+ * Present only when the caller holds `read_sis` on the cohort's
1055
+ * account chain, or `manage_sis` on the root account. Omitted
1056
+ * entirely when the caller may not read SIS ids; `null` when the
1057
+ * caller may read them but the user has no SIS id. A Leader grant
1058
+ * never conveys this; it takes an account permission.
1059
+ * @nullable
1060
+ */
1061
+ sis_user_id?: string | null;
1062
+ /**
1063
+ * Present only when the caller holds `view_user_logins` on the
1064
+ * cohort's account chain. Omitted entirely when the caller may not
1065
+ * read login ids; `null` when the caller may read them but the user
1066
+ * has no login. A Leader grant never conveys this; it takes an
1067
+ * account permission.
1068
+ * @nullable
1069
+ */
1070
+ login_id?: string | null;
1071
+ }
1072
+ /**
1073
+ * Per-attribute validation failures, in the shape Canvas produces from
1074
+ * model errors. Keys are attribute names.
1075
+ */
1076
+ export interface ValidationError {
1077
+ errors: ValidationErrorErrors;
1078
+ }
1079
+ export type ValidationErrorErrors = {
1080
+ [key: string]: ValidationErrorErrorsItem[];
1081
+ };
1082
+ export type ValidationErrorErrorsItem = {
1083
+ attribute: string;
1084
+ type: string;
1085
+ message: string;
1086
+ };
1087
+ /**
1088
+ * Lifecycle state. Cohort records are never hard-deleted; they move to
1089
+ * `deleted` and stop appearing in default listings.
1090
+ */
1091
+ export type WorkflowState = (typeof WorkflowState)[keyof typeof WorkflowState];
1092
+ export declare const WorkflowState: {
1093
+ readonly active: "active";
1094
+ readonly deleted: "deleted";
1095
+ };
1096
+ /**
1097
+ * Which lifecycle states to return. Repeatable, matching the Canvas
1098
+ * `workflow_state[]` list filter: `active`, `deleted`, or `all` for
1099
+ * both. Defaults to `active` only.
1100
+ */
1101
+ export type WorkflowStateFilterParameter = WorkflowStateFilterParameterItem[];
1102
+ export type WorkflowStateFilterParameterItem = (typeof WorkflowStateFilterParameterItem)[keyof typeof WorkflowStateFilterParameterItem];
1103
+ export declare const WorkflowStateFilterParameterItem: {
1104
+ readonly active: "active";
1105
+ readonly deleted: "deleted";
1106
+ readonly all: "all";
1107
+ };
1108
+ //# sourceMappingURL=cohorts.d.ts.map