Documentation

GroupCategory extends AbstractBaseApi

Canvas LMS Group Categories API

Group Categories allow organizing groups together in Canvas. They provide a way to manage collections of groups with shared settings and permissions.

Tags
see
https://canvas.instructure.com/doc/api/group_categories.html

Table of Contents

Properties

$accountId  : int|null
The account ID if context_type is Account
$autoLeader  : string|null
Auto leader configuration: 'first', 'random', or null
$contextId  : int|null
The ID of the context (course_id or account_id)
$contextType  : string|null
The context type (Course or Account)
$courseId  : int|null
The course ID if context_type is Course
$groupLimit  : int|null
Maximum number of users in each group (if self-signup enabled)
$id  : int|null
The ID of the group category
$name  : string|null
The display name of the group category
$nonCollaborative  : bool|null
Indicates whether this group category is non-collaborative
$progress  : array<string, mixed>|null
Progress object for async operations
$role  : string|null
Special role designations: 'communities', 'student_organized', 'imported', or null
$selfSignup  : string|null
Self signup configuration: 'enabled', 'restricted', or null
$sisGroupCategoryId  : string|null
The SIS identifier for the group category
$sisImportId  : int|null
The unique identifier for the SIS import
$apiClient  : HttpClientInterface
$course  : Course|null
Course context for group categories
$methodAliases  : array<string|int, mixed>
Define method aliases

Methods

__callStatic()  : mixed
Magic method to handle function aliases
__construct()  : mixed
BaseApi constructor.
all()  : array<string|int, static>
Get all pages of results
assignUnassignedMembers()  : array<string|int, Group>|array<string|int, mixed>
Assign unassigned members to groups
checkCourse()  : bool
Check if course context is set
create()  : self
Create a new group category in the current account
delete()  : self
Delete the group category
export()  : array<string|int, mixed>
Export groups and users in this category
find()  : self
Get a single group category by ID
get()  : array<string|int, static>
Get first page of results
getAutoLeader()  : string|null
getContextId()  : int|null
getContextType()  : string|null
getGroupLimit()  : int|null
getId()  : int|null
getName()  : string|null
getNonCollaborative()  : bool|null
getProgress()  : array<string, mixed>|null
getRole()  : string|null
getSelfSignup()  : string|null
groups()  : array<string|int, Group>
List groups in this category
groupsPaginated()  : PaginatedResponse
Get paginated groups in this category
paginate()  : PaginationResult
Get paginated results with metadata
save()  : self
Save the group category (create or update)
setApiClient()  : void
Set the API client
setAutoLeader()  : void
setContextId()  : void
setContextType()  : void
setCourse()  : void
Set the course context for group category operations
setGroupLimit()  : void
setId()  : void
setName()  : void
setNonCollaborative()  : void
setProgress()  : void
setRole()  : void
setSelfSignup()  : void
toDtoArray()  : array<string, mixed>
Convert group category to DTO array
update()  : self
Update group category
users()  : array<string|int, User>
List users in this category
usersPaginated()  : PaginatedResponse
Get paginated users in this category
castValue()  : DateTime|mixed
Cast a value to the correct type
checkApiClient()  : void
Check if the API client is set, if not, instantiate a new one
convertPaginatedResponseToModels()  : array<string|int, static>
Helper method to convert paginated response data to model instances
createConfiguredHttpClient()  : HttpClient
Create an HttpClient with configured middleware
createPaginationResult()  : PaginationResult
Helper method to create PaginationResult from paginated response
getEndpoint()  : string
Get the endpoint for this resource.
getPaginatedResponse()  : PaginatedResponse
Helper method to get paginated response from API endpoint
populate()  : void
Populate the object with new data

Properties

$accountId

The account ID if context_type is Account

public int|null $accountId = null

$autoLeader

Auto leader configuration: 'first', 'random', or null

public string|null $autoLeader = null

$contextId

The ID of the context (course_id or account_id)

public int|null $contextId = null

$contextType

The context type (Course or Account)

public string|null $contextType = null

$courseId

The course ID if context_type is Course

public int|null $courseId = null

$groupLimit

Maximum number of users in each group (if self-signup enabled)

public int|null $groupLimit = null

$name

The display name of the group category

public string|null $name = null

$nonCollaborative

Indicates whether this group category is non-collaborative

public bool|null $nonCollaborative = null

$progress

Progress object for async operations

public array<string, mixed>|null $progress = null

$role

Special role designations: 'communities', 'student_organized', 'imported', or null

public string|null $role = null

$selfSignup

Self signup configuration: 'enabled', 'restricted', or null

public string|null $selfSignup = null

$sisGroupCategoryId

The SIS identifier for the group category

public string|null $sisGroupCategoryId = null

$sisImportId

The unique identifier for the SIS import

public int|null $sisImportId = null

$methodAliases

Define method aliases

protected static array<string|int, mixed> $methodAliases = ['get' => ['fetch', 'list', 'fetchAll'], 'all' => ['fetchAllPages', 'getAll'], 'paginate' => ['getPaginated', 'withPagination', 'fetchPage'], 'find' => ['one', 'getOne']]

Methods

__callStatic()

Magic method to handle function aliases

public static __callStatic(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
$name : string
$arguments : array<string|int, mixed>
Tags
throws
InvalidArgumentException

__construct()

BaseApi constructor.

public __construct(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>

all()

Get all pages of results

public static all([array<string, mixed> $params = [] ]) : array<string|int, static>
Parameters
$params : array<string, mixed> = []

Query parameters

Return values
array<string|int, static>

assignUnassignedMembers()

Assign unassigned members to groups

public assignUnassignedMembers([bool $sync = false ]) : array<string|int, Group>|array<string|int, mixed>
Parameters
$sync : bool = false

Whether to perform synchronously (default: false)

Tags
throws
CanvasApiException
Return values
array<string|int, Group>|array<string|int, mixed>

Groups if sync=true, progress object if async

checkCourse()

Check if course context is set

public static checkCourse() : bool
Return values
bool

export()

Export groups and users in this category

public export() : array<string|int, mixed>
Tags
throws
CanvasApiException
Return values
array<string|int, mixed>

find()

Get a single group category by ID

public static find(int $id[, array<string|int, mixed> $params = [] ]) : self
Parameters
$id : int

Group Category ID

$params : array<string|int, mixed> = []

Optional query parameters

Tags
throws
CanvasApiException
Return values
self

get()

Get first page of results

public static get([array<string, mixed> $params = [] ]) : array<string|int, static>
Parameters
$params : array<string, mixed> = []

Query parameters

Return values
array<string|int, static>

getAutoLeader()

public getAutoLeader() : string|null
Return values
string|null

getContextId()

public getContextId() : int|null
Return values
int|null

getContextType()

public getContextType() : string|null
Return values
string|null

getGroupLimit()

public getGroupLimit() : int|null
Return values
int|null

getName()

public getName() : string|null
Return values
string|null

getNonCollaborative()

public getNonCollaborative() : bool|null
Return values
bool|null

getProgress()

public getProgress() : array<string, mixed>|null
Return values
array<string, mixed>|null

getRole()

public getRole() : string|null
Return values
string|null

getSelfSignup()

public getSelfSignup() : string|null
Return values
string|null

groups()

List groups in this category

public groups([array<string, mixed> $params = [] ]) : array<string|int, Group>
Parameters
$params : array<string, mixed> = []

Query parameters

Tags
throws
CanvasApiException
Return values
array<string|int, Group>

setAutoLeader()

public setAutoLeader(string|null $autoLeader) : void
Parameters
$autoLeader : string|null

setContextId()

public setContextId(int|null $contextId) : void
Parameters
$contextId : int|null

setContextType()

public setContextType(string|null $contextType) : void
Parameters
$contextType : string|null

setCourse()

Set the course context for group category operations

public static setCourse(Course $course) : void
Parameters
$course : Course

setGroupLimit()

public setGroupLimit(int|null $groupLimit) : void
Parameters
$groupLimit : int|null

setId()

public setId(int|null $id) : void
Parameters
$id : int|null

setName()

public setName(string|null $name) : void
Parameters
$name : string|null

setNonCollaborative()

public setNonCollaborative(bool|null $nonCollaborative) : void
Parameters
$nonCollaborative : bool|null

setProgress()

public setProgress(array<string, mixed>|null $progress) : void
Parameters
$progress : array<string, mixed>|null

setRole()

public setRole(string|null $role) : void
Parameters
$role : string|null

setSelfSignup()

public setSelfSignup(string|null $selfSignup) : void
Parameters
$selfSignup : string|null

toDtoArray()

Convert group category to DTO array

public toDtoArray() : array<string, mixed>
Return values
array<string, mixed>

users()

List users in this category

public users([array<string, mixed> $params = [] ]) : array<string|int, User>
Parameters
$params : array<string, mixed> = []

Query parameters

Tags
throws
CanvasApiException
Return values
array<string|int, User>

castValue()

Cast a value to the correct type

protected castValue(string $key, mixed $value) : DateTime|mixed
Parameters
$key : string
$value : mixed
Tags
throws
Exception
Return values
DateTime|mixed

checkApiClient()

Check if the API client is set, if not, instantiate a new one

protected static checkApiClient() : void

convertPaginatedResponseToModels()

Helper method to convert paginated response data to model instances

protected static convertPaginatedResponseToModels(PaginatedResponse $paginatedResponse) : array<string|int, static>
Parameters
$paginatedResponse : PaginatedResponse
Return values
array<string|int, static>

getPaginatedResponse()

Helper method to get paginated response from API endpoint

protected static getPaginatedResponse(string $endpoint[, array<string|int, mixed> $params = [] ]) : PaginatedResponse
Parameters
$endpoint : string

The API endpoint path

$params : array<string|int, mixed> = []

Query parameters for the request

Return values
PaginatedResponse

populate()

Populate the object with new data

protected populate(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Tags
throws
Exception

        
On this page

Search results