Documentation
¶
Index ¶
- Variables
- func GetPageNumber(url string) string
- func GetPerPage(url string) string
- func IsAuthError(err error) bool
- func IsForbiddenError(err error) bool
- func IsNotFoundError(err error) bool
- func IsRateLimitError(err error) bool
- func ParseAPIError(resp *http.Response) error
- func ValidateNonEmpty(value, name string) error
- func ValidateNotNil(ptr interface{}, name string) error
- func ValidatePositiveID(id int64, name string) error
- type APIError
- type AcceptParams
- type Account
- type AccountsService
- func (s *AccountsService) Get(ctx context.Context, accountID int64) (*Account, error)
- func (s *AccountsService) List(ctx context.Context, opts *ListAccountsOptions) ([]Account, error)
- func (s *AccountsService) ListCourses(ctx context.Context, accountID int64, opts *ListAccountCoursesOptions) ([]Course, error)
- func (s *AccountsService) ListSubAccounts(ctx context.Context, accountID int64, opts *ListSubAccountsOptions) ([]Account, error)
- func (s *AccountsService) ListUsers(ctx context.Context, accountID int64, opts *ListAccountUsersOptions) ([]User, error)
- type AdaptiveRateLimiter
- type AnnouncementsService
- type Assignment
- type AssignmentOverride
- type AssignmentOverrideParams
- type AssignmentsService
- func (s *AssignmentsService) BulkUpdate(ctx context.Context, courseID int64, params *BulkUpdateParams) error
- func (s *AssignmentsService) Create(ctx context.Context, courseID int64, params *CreateAssignmentParams) (*Assignment, error)
- func (s *AssignmentsService) Delete(ctx context.Context, courseID, assignmentID int64) error
- func (s *AssignmentsService) Get(ctx context.Context, courseID, assignmentID int64, include []string) (*Assignment, error)
- func (s *AssignmentsService) List(ctx context.Context, courseID int64, opts *ListAssignmentsOptions) ([]Assignment, error)
- func (s *AssignmentsService) ListUserAssignments(ctx context.Context, userID int64, opts *ListAssignmentsOptions) ([]Assignment, error)
- func (s *AssignmentsService) Update(ctx context.Context, courseID, assignmentID int64, ...) (*Assignment, error)
- type Attachment
- type AvatarParams
- type BulkGradeParams
- type BulkUpdateParams
- type CalendarEvent
- type CalendarService
- func (s *CalendarService) Create(ctx context.Context, params *CreateCalendarEventParams) (*CalendarEvent, error)
- func (s *CalendarService) Delete(ctx context.Context, eventID int64, opts *DeleteOptions) error
- func (s *CalendarService) Get(ctx context.Context, eventID int64) (*CalendarEvent, error)
- func (s *CalendarService) List(ctx context.Context, opts *ListCalendarEventsOptions) ([]CalendarEvent, error)
- func (s *CalendarService) ListForUser(ctx context.Context, userID int64, opts *ListCalendarEventsOptions) ([]CalendarEvent, error)
- func (s *CalendarService) Reserve(ctx context.Context, eventID int64, participantID *int64, comments string, ...) (*CalendarEvent, error)
- func (s *CalendarService) Update(ctx context.Context, eventID int64, params *UpdateCalendarEventParams) (*CalendarEvent, error)
- type CanvasVersion
- type Client
- func (c *Client) CacheStats() cache.Stats
- func (c *Client) ClearCache()
- func (c *Client) Delete(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) Get(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) GetAllPages(ctx context.Context, path string, result interface{}) error
- func (c *Client) GetJSON(ctx context.Context, path string, result interface{}) error
- func (c *Client) GetQuotaTotal() float64
- func (c *Client) GetVersion() *CanvasVersion
- func (c *Client) IsCacheEnabled() bool
- func (c *Client) Post(ctx context.Context, path string, body io.Reader) (*http.Response, error)
- func (c *Client) PostJSON(ctx context.Context, path string, body interface{}, result interface{}) error
- func (c *Client) Put(ctx context.Context, path string, body io.Reader) (*http.Response, error)
- func (c *Client) PutJSON(ctx context.Context, path string, body interface{}, result interface{}) error
- func (c *Client) SetCacheEnabled(enabled bool)
- func (c *Client) SetQuotaTotal(quota float64)
- func (c *Client) SupportsFeature(feature string) bool
- type ClientConfig
- type CompletionRequirement
- type CompletionRequirementParams
- type ConcludeParams
- type ContentDetails
- type Course
- type CoursesService
- func (s *CoursesService) Create(ctx context.Context, params *CreateCourseParams) (*Course, error)
- func (s *CoursesService) Delete(ctx context.Context, courseID int64, event string) error
- func (s *CoursesService) Get(ctx context.Context, courseID int64, include []string) (*Course, error)
- func (s *CoursesService) List(ctx context.Context, opts *ListCoursesOptions) ([]Course, error)
- func (s *CoursesService) Update(ctx context.Context, courseID int64, params *UpdateCourseParams) (*Course, error)
- type CreateAssignmentParams
- type CreateCalendarEventParams
- type CreateCourseParams
- type CreateDiscussionParams
- type CreateModuleItemParams
- type CreateModuleParams
- type CreateNoteParams
- type CreateOverrideParams
- type CreatePageParams
- type CreateUserParams
- type DeleteOptions
- type DiscussionEntry
- type DiscussionTopic
- type DiscussionsService
- func (s *DiscussionsService) Create(ctx context.Context, courseID int64, params *CreateDiscussionParams) (*DiscussionTopic, error)
- func (s *DiscussionsService) Delete(ctx context.Context, courseID, topicID int64) error
- func (s *DiscussionsService) Get(ctx context.Context, courseID, topicID int64, include []string) (*DiscussionTopic, error)
- func (s *DiscussionsService) List(ctx context.Context, courseID int64, opts *ListDiscussionsOptions) ([]DiscussionTopic, error)
- func (s *DiscussionsService) ListEntries(ctx context.Context, courseID, topicID int64) ([]DiscussionEntry, error)
- func (s *DiscussionsService) MarkTopicRead(ctx context.Context, courseID, topicID int64) error
- func (s *DiscussionsService) MarkTopicUnread(ctx context.Context, courseID, topicID int64) error
- func (s *DiscussionsService) PostEntry(ctx context.Context, courseID, topicID int64, message string) (*DiscussionEntry, error)
- func (s *DiscussionsService) PostReply(ctx context.Context, courseID, topicID, entryID int64, message string) (*DiscussionEntry, error)
- func (s *DiscussionsService) Subscribe(ctx context.Context, courseID, topicID int64) error
- func (s *DiscussionsService) Unsubscribe(ctx context.Context, courseID, topicID int64) error
- func (s *DiscussionsService) Update(ctx context.Context, courseID, topicID int64, params *UpdateDiscussionParams) (*DiscussionTopic, error)
- type EnrollUserParams
- type Enrollment
- type EnrollmentsService
- func (s *EnrollmentsService) Accept(ctx context.Context, courseID, enrollmentID int64) error
- func (s *EnrollmentsService) Conclude(ctx context.Context, courseID, enrollmentID int64, task string) (*Enrollment, error)
- func (s *EnrollmentsService) EnrollUser(ctx context.Context, courseID int64, params *EnrollUserParams) (*Enrollment, error)
- func (s *EnrollmentsService) ListCourse(ctx context.Context, courseID int64, opts *ListEnrollmentsOptions) ([]Enrollment, error)
- func (s *EnrollmentsService) ListSection(ctx context.Context, sectionID int64, opts *ListEnrollmentsOptions) ([]Enrollment, error)
- func (s *EnrollmentsService) ListUser(ctx context.Context, userID int64, opts *ListEnrollmentsOptions) ([]Enrollment, error)
- func (s *EnrollmentsService) Reactivate(ctx context.Context, courseID, enrollmentID int64) (*Enrollment, error)
- func (s *EnrollmentsService) Reject(ctx context.Context, courseID, enrollmentID int64) error
- func (s *EnrollmentsService) UpdateLastAttended(ctx context.Context, courseID, enrollmentID int64, date string) (*Enrollment, error)
- type ErrorDetail
- type FeatureChecker
- type FileAttachment
- type FilesService
- func (s *FilesService) Delete(ctx context.Context, fileID int64) error
- func (s *FilesService) Download(ctx context.Context, fileID int64, destPath string) error
- func (s *FilesService) Get(ctx context.Context, fileID int64, include []string) (*Attachment, error)
- func (s *FilesService) GetCourseQuota(ctx context.Context, courseID int64) (*QuotaInfo, error)
- func (s *FilesService) GetUserQuota(ctx context.Context, userID int64) (*QuotaInfo, error)
- func (s *FilesService) ListCourseFiles(ctx context.Context, courseID int64, opts *ListFilesOptions) ([]Attachment, error)
- func (s *FilesService) ListFolderFiles(ctx context.Context, folderID int64, opts *ListFilesOptions) ([]Attachment, error)
- func (s *FilesService) ListUserFiles(ctx context.Context, userID int64, opts *ListFilesOptions) ([]Attachment, error)
- func (s *FilesService) Update(ctx context.Context, fileID int64, params *UpdateParams) (*Attachment, error)
- func (s *FilesService) UploadToCourse(ctx context.Context, courseID int64, filePath string, params *UploadParams) (*Attachment, error)
- func (s *FilesService) UploadToFolder(ctx context.Context, folderID int64, filePath string, params *UploadParams) (*Attachment, error)
- func (s *FilesService) UploadToUser(ctx context.Context, userID int64, filePath string, params *UploadParams) (*Attachment, error)
- type GradeData
- type GradeSubmissionParams
- type Grades
- type HTTPClient
- type LastAttendedParams
- type ListAccountCoursesOptions
- type ListAccountUsersOptions
- type ListAccountsOptions
- type ListAnnouncementsOptions
- type ListAssignmentsOptions
- type ListCalendarEventsOptions
- type ListCoursesOptions
- type ListDiscussionsOptions
- type ListEnrollmentsOptions
- type ListFilesOptions
- type ListModuleItemsOptions
- type ListModulesOptions
- type ListOverridesOptions
- type ListPagesOptions
- type ListPlannerItemsOptions
- type ListPlannerNotesOptions
- type ListSubAccountsOptions
- type ListSubmissionsOptions
- type ListUsersOptions
- type LockInfo
- type MediaComment
- type Module
- type ModuleItem
- type ModuleItemRef
- type ModuleItemSequence
- type ModuleItemSequenceNode
- type ModuleReference
- type ModulesService
- func (s *ModulesService) Create(ctx context.Context, courseID int64, params *CreateModuleParams) (*Module, error)
- func (s *ModulesService) CreateItem(ctx context.Context, courseID, moduleID int64, params *CreateModuleItemParams) (*ModuleItem, error)
- func (s *ModulesService) Delete(ctx context.Context, courseID, moduleID int64) error
- func (s *ModulesService) DeleteItem(ctx context.Context, courseID, moduleID, itemID int64) error
- func (s *ModulesService) Get(ctx context.Context, courseID, moduleID int64, include []string, ...) (*Module, error)
- func (s *ModulesService) GetItem(ctx context.Context, courseID, moduleID, itemID int64, include []string, ...) (*ModuleItem, error)
- func (s *ModulesService) GetItemSequence(ctx context.Context, courseID int64, assetType string, assetID int64) (*ModuleItemSequence, error)
- func (s *ModulesService) List(ctx context.Context, courseID int64, opts *ListModulesOptions) ([]Module, error)
- func (s *ModulesService) ListItems(ctx context.Context, courseID, moduleID int64, opts *ListModuleItemsOptions) ([]ModuleItem, error)
- func (s *ModulesService) MarkItemDone(ctx context.Context, courseID, moduleID, itemID int64) error
- func (s *ModulesService) MarkItemNotDone(ctx context.Context, courseID, moduleID, itemID int64) error
- func (s *ModulesService) MarkItemRead(ctx context.Context, courseID, moduleID, itemID int64) error
- func (s *ModulesService) Relock(ctx context.Context, courseID, moduleID int64) (*Module, error)
- func (s *ModulesService) Update(ctx context.Context, courseID, moduleID int64, params *UpdateModuleParams) (*Module, error)
- func (s *ModulesService) UpdateItem(ctx context.Context, courseID, moduleID, itemID int64, ...) (*ModuleItem, error)
- type Page
- type PageRevision
- type PagesService
- func (s *PagesService) Create(ctx context.Context, courseID int64, params *CreatePageParams) (*Page, error)
- func (s *PagesService) Delete(ctx context.Context, courseID int64, urlOrID string) error
- func (s *PagesService) Duplicate(ctx context.Context, courseID int64, urlOrID string) (*Page, error)
- func (s *PagesService) Get(ctx context.Context, courseID int64, urlOrID string) (*Page, error)
- func (s *PagesService) GetFrontPage(ctx context.Context, courseID int64) (*Page, error)
- func (s *PagesService) GetLatestRevision(ctx context.Context, courseID int64, urlOrID string, summary bool) (*PageRevision, error)
- func (s *PagesService) GetRevision(ctx context.Context, courseID int64, urlOrID string, revisionID int64, ...) (*PageRevision, error)
- func (s *PagesService) List(ctx context.Context, courseID int64, opts *ListPagesOptions) ([]Page, error)
- func (s *PagesService) ListRevisions(ctx context.Context, courseID int64, urlOrID string) ([]PageRevision, error)
- func (s *PagesService) RevertToRevision(ctx context.Context, courseID int64, urlOrID string, revisionID int64) (*PageRevision, error)
- func (s *PagesService) Update(ctx context.Context, courseID int64, urlOrID string, params *UpdatePageParams) (*Page, error)
- func (s *PagesService) UpdateFrontPage(ctx context.Context, courseID int64, params *UpdatePageParams) (*Page, error)
- type PaginationLinks
- type PlannerItem
- type PlannerNote
- type PlannerOverride
- type PlannerService
- func (s *PlannerService) CreateNote(ctx context.Context, params *CreateNoteParams) (*PlannerNote, error)
- func (s *PlannerService) CreateOverride(ctx context.Context, params *CreateOverrideParams) (*PlannerOverride, error)
- func (s *PlannerService) DeleteNote(ctx context.Context, noteID int64) error
- func (s *PlannerService) DeleteOverride(ctx context.Context, overrideID int64) error
- func (s *PlannerService) GetNote(ctx context.Context, noteID int64) (*PlannerNote, error)
- func (s *PlannerService) GetOverride(ctx context.Context, overrideID int64) (*PlannerOverride, error)
- func (s *PlannerService) ListItems(ctx context.Context, opts *ListPlannerItemsOptions) ([]PlannerItem, error)
- func (s *PlannerService) ListNotes(ctx context.Context, opts *ListPlannerNotesOptions) ([]PlannerNote, error)
- func (s *PlannerService) ListOverrides(ctx context.Context, opts *ListOverridesOptions) ([]PlannerOverride, error)
- func (s *PlannerService) UpdateNote(ctx context.Context, noteID int64, params *UpdateNoteParams) (*PlannerNote, error)
- func (s *PlannerService) UpdateOverride(ctx context.Context, overrideID int64, params *UpdateOverrideParams) (*PlannerOverride, error)
- type Progress
- type QuotaInfo
- type RateLimitInfo
- type ReactivateParams
- type RejectParams
- type RetryPolicy
- type RubricAssessment
- type RubricAssessmentParams
- type RubricCriterion
- type RubricRating
- type SectionGradingCount
- type Submission
- type SubmissionComment
- type SubmissionCommentParams
- type SubmissionsService
- func (s *SubmissionsService) BulkGrade(ctx context.Context, courseID, assignmentID int64, params *BulkGradeParams) ([]Submission, error)
- func (s *SubmissionsService) Get(ctx context.Context, courseID, assignmentID, userID int64, include []string) (*Submission, error)
- func (s *SubmissionsService) Grade(ctx context.Context, courseID, assignmentID, userID int64, ...) (*Submission, error)
- func (s *SubmissionsService) InitiateFileUpload(ctx context.Context, courseID, assignmentID int64, params *UploadFileParams) (map[string]interface{}, error)
- func (s *SubmissionsService) List(ctx context.Context, courseID, assignmentID int64, ...) ([]Submission, error)
- func (s *SubmissionsService) ListMultiple(ctx context.Context, courseID int64, studentIDs, assignmentIDs []int64, ...) ([]Submission, error)
- func (s *SubmissionsService) MarkAsRead(ctx context.Context, courseID, assignmentID, userID int64) error
- func (s *SubmissionsService) MarkAsUnread(ctx context.Context, courseID, assignmentID, userID int64) error
- func (s *SubmissionsService) Submit(ctx context.Context, courseID, assignmentID int64, params *SubmitParams) (*Submission, error)
- type SubmitParams
- type Term
- type TermOverride
- type UpdateAssignmentParams
- type UpdateCalendarEventParams
- type UpdateCourseParams
- type UpdateDiscussionParams
- type UpdateModuleItemParams
- type UpdateModuleParams
- type UpdateNoteParams
- type UpdateOverrideParams
- type UpdatePageParams
- type UpdateParams
- type UpdateUserParams
- type UploadFileParams
- type UploadParams
- type User
- type UsersService
- func (s *UsersService) Create(ctx context.Context, accountID int64, params *CreateUserParams) (*User, error)
- func (s *UsersService) Delete(ctx context.Context, accountID, userID int64) error
- func (s *UsersService) Get(ctx context.Context, userID int64, include []string) (*User, error)
- func (s *UsersService) GetCurrentUser(ctx context.Context) (*User, error)
- func (s *UsersService) List(ctx context.Context, accountID int64, opts *ListUsersOptions) ([]User, error)
- func (s *UsersService) ListCourseUsers(ctx context.Context, courseID int64, opts *ListUsersOptions) ([]User, error)
- func (s *UsersService) Search(ctx context.Context, searchTerm string) ([]User, error)
- func (s *UsersService) Update(ctx context.Context, userID int64, params *UpdateUserParams) (*User, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidCourseID = errors.New("course_id must be a positive integer") ErrInvalidModuleID = errors.New("module_id must be a positive integer") ErrInvalidItemID = errors.New("item_id must be a positive integer") ErrInvalidAccountID = errors.New("account_id must be a positive integer") ErrInvalidUserID = errors.New("user_id must be a positive integer") ErrInvalidAssignmentID = errors.New("assignment_id must be a positive integer") ErrInvalidFileID = errors.New("file_id must be a positive integer") ErrInvalidFolderID = errors.New("folder_id must be a positive integer") ErrMissingTitle = errors.New("title is required") ErrMissingName = errors.New("name is required") ErrMissingType = errors.New("type is required") ErrMissingURLOrID = errors.New("url or id is required") ErrNilParams = errors.New("params cannot be nil") )
Common validation errors
Functions ¶
func GetPageNumber ¶
GetPageNumber extracts the page number from a pagination URL
func GetPerPage ¶
GetPerPage extracts the per_page parameter from a URL
func IsAuthError ¶
IsAuthError checks if the error is an authentication error Uses errors.As to properly handle wrapped errors
func IsForbiddenError ¶
IsForbiddenError checks if the error is a forbidden error Uses errors.As to properly handle wrapped errors
func IsNotFoundError ¶
IsNotFoundError checks if the error is a not found error Uses errors.As to properly handle wrapped errors
func IsRateLimitError ¶
IsRateLimitError checks if the error is a rate limit error Uses errors.As to properly handle wrapped errors
func ParseAPIError ¶
ParseAPIError parses an error response from the Canvas API
func ValidateNonEmpty ¶ added in v1.2.0
ValidateNonEmpty validates that a string is not empty
func ValidateNotNil ¶ added in v1.2.0
ValidateNotNil validates that a pointer is not nil
func ValidatePositiveID ¶ added in v1.2.0
ValidatePositiveID validates that an ID is positive
Types ¶
type APIError ¶
type APIError struct {
StatusCode int `json:"-"`
Errors []ErrorDetail `json:"errors"`
ErrorReportID int64 `json:"error_report_id,omitempty"`
Suggestion string `json:"-"`
DocsURL string `json:"-"`
}
APIError represents an error from the Canvas API
type AcceptParams ¶
type AcceptParams struct {
}
AcceptParams holds parameters for accepting an enrollment invitation
type Account ¶
type Account struct {
ID int64 `json:"id"`
Name string `json:"name"`
UUID string `json:"uuid"`
ParentAccountID int64 `json:"parent_account_id"`
RootAccountID int64 `json:"root_account_id"`
DefaultStorageQuotaMB int64 `json:"default_storage_quota_mb"`
DefaultUserStorageQuotaMB int64 `json:"default_user_storage_quota_mb"`
DefaultGroupStorageQuotaMB int64 `json:"default_group_storage_quota_mb"`
DefaultTimeZone string `json:"default_time_zone"`
SISAccountID string `json:"sis_account_id"`
IntegrationID string `json:"integration_id"`
SISImportID int64 `json:"sis_import_id"`
LTIGuid string `json:"lti_guid"`
WorkflowState string `json:"workflow_state"`
}
Account represents a Canvas account (institution, sub-account)
type AccountsService ¶
type AccountsService struct {
// contains filtered or unexported fields
}
AccountsService handles account-related API operations
func NewAccountsService ¶
func NewAccountsService(client *Client) *AccountsService
NewAccountsService creates a new accounts service
func (*AccountsService) List ¶
func (s *AccountsService) List(ctx context.Context, opts *ListAccountsOptions) ([]Account, error)
List returns accounts the current user can view This typically returns accounts where the user has admin permissions
func (*AccountsService) ListCourses ¶
func (s *AccountsService) ListCourses(ctx context.Context, accountID int64, opts *ListAccountCoursesOptions) ([]Course, error)
ListCourses returns courses for a given account This requires admin permissions on the account
func (*AccountsService) ListSubAccounts ¶
func (s *AccountsService) ListSubAccounts(ctx context.Context, accountID int64, opts *ListSubAccountsOptions) ([]Account, error)
ListSubAccounts returns sub-accounts for a given account
func (*AccountsService) ListUsers ¶
func (s *AccountsService) ListUsers(ctx context.Context, accountID int64, opts *ListAccountUsersOptions) ([]User, error)
ListUsers returns users for a given account This requires admin permissions on the account
type AdaptiveRateLimiter ¶
type AdaptiveRateLimiter struct {
// contains filtered or unexported fields
}
AdaptiveRateLimiter implements adaptive rate limiting based on quota
func NewAdaptiveRateLimiter ¶
func NewAdaptiveRateLimiter(requestsPerSecond float64) *AdaptiveRateLimiter
NewAdaptiveRateLimiter creates a new adaptive rate limiter
func (*AdaptiveRateLimiter) AdjustRate ¶
func (l *AdaptiveRateLimiter) AdjustRate(remaining, total float64)
AdjustRate adjusts the rate based on remaining quota
func (*AdaptiveRateLimiter) GetCurrentRate ¶
func (l *AdaptiveRateLimiter) GetCurrentRate() float64
GetCurrentRate returns the current rate limit
type AnnouncementsService ¶ added in v1.1.0
type AnnouncementsService struct {
// contains filtered or unexported fields
}
AnnouncementsService handles announcement-specific API calls
func NewAnnouncementsService ¶ added in v1.1.0
func NewAnnouncementsService(client *Client) *AnnouncementsService
NewAnnouncementsService creates a new announcements service
func (*AnnouncementsService) List ¶ added in v1.1.0
func (s *AnnouncementsService) List(ctx context.Context, opts *ListAnnouncementsOptions) ([]DiscussionTopic, error)
List retrieves announcements for the given contexts
type Assignment ¶
type Assignment struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DueAt time.Time `json:"due_at"`
LockAt time.Time `json:"lock_at"`
UnlockAt time.Time `json:"unlock_at"`
HasOverrides bool `json:"has_overrides"`
CourseID int64 `json:"course_id"`
HTMLURL string `json:"html_url"`
SubmissionsDownloadURL string `json:"submissions_download_url"`
AssignmentGroupID int64 `json:"assignment_group_id"`
DueDateRequired bool `json:"due_date_required"`
AllowedExtensions []string `json:"allowed_extensions"`
MaxNameLength int `json:"max_name_length"`
TurnitinEnabled bool `json:"turnitin_enabled"`
VericiteEnabled bool `json:"vericite_enabled"`
TurnitinSettings map[string]interface{} `json:"turnitin_settings,omitempty"`
GradeGroupStudentsIndividually bool `json:"grade_group_students_individually"`
ExternalToolTagAttributes map[string]interface{} `json:"external_tool_tag_attributes,omitempty"`
PeerReviews bool `json:"peer_reviews"`
AutomaticPeerReviews bool `json:"automatic_peer_reviews"`
PeerReviewCount int `json:"peer_review_count"`
PeerReviewsAssignAt time.Time `json:"peer_reviews_assign_at"`
IntraGroupPeerReviews bool `json:"intra_group_peer_reviews"`
GroupCategoryID int64 `json:"group_category_id"`
NeedsGradingCount int `json:"needs_grading_count"`
NeedsGradingCountBySection []SectionGradingCount `json:"needs_grading_count_by_section,omitempty"`
Position int `json:"position"`
PostToSIS bool `json:"post_to_sis"`
IntegrationID string `json:"integration_id"`
IntegrationData map[string]interface{} `json:"integration_data,omitempty"`
PointsPossible float64 `json:"points_possible"`
SubmissionTypes []string `json:"submission_types"`
HasSubmittedSubmissions bool `json:"has_submitted_submissions"`
GradingType string `json:"grading_type"`
GradingStandardID int64 `json:"grading_standard_id"`
Published bool `json:"published"`
Unpublishable bool `json:"unpublishable"`
OnlyVisibleToOverrides bool `json:"only_visible_to_overrides"`
LockedForUser bool `json:"locked_for_user"`
LockInfo *LockInfo `json:"lock_info,omitempty"`
LockExplanation string `json:"lock_explanation"`
QuizID int64 `json:"quiz_id"`
AnonymousInstructorAnnotations bool `json:"anonymous_instructor_annotations"`
AnonymousPeerReviews bool `json:"anonymous_peer_reviews"`
AnonymousMarking bool `json:"anonymous_marking"`
AnonymousGrading bool `json:"anonymous_grading"`
GradersAnonymousToGraders bool `json:"graders_anonymous_to_graders"`
GraderCount int `json:"grader_count"`
GraderCommentsVisibleToGraders bool `json:"grader_comments_visible_to_graders"`
FinalGraderID int64 `json:"final_grader_id"`
GraderNamesVisibleToFinalGrader bool `json:"grader_names_visible_to_final_grader"`
AllowedAttempts int `json:"allowed_attempts"`
AnnotatableAttachmentID int64 `json:"annotatable_attachment_id"`
HideInGradebook bool `json:"hide_in_gradebook"`
SecureParams string `json:"secure_params"`
LTIContextID string `json:"lti_context_id"`
NameHash string `json:"name_hash,omitempty"`
CanDuplicate bool `json:"can_duplicate"`
OriginalCourseID int64 `json:"original_course_id"`
OriginalAssignmentID int64 `json:"original_assignment_id"`
OriginalLTIResourceLinkID string `json:"original_lti_resource_link_id"`
OriginalAssignmentName string `json:"original_assignment_name"`
OriginalQuizID int64 `json:"original_quiz_id"`
WorkflowState string `json:"workflow_state"`
ImportantDates bool `json:"important_dates"`
MutedTLN bool `json:"muted"`
HasGradableSubmissions bool `json:"has_gradable_submissions"`
URL string `json:"url,omitempty"`
IsQuizAssignment bool `json:"is_quiz_assignment"`
CanUpdate bool `json:"can_update"`
Frozen bool `json:"frozen"`
FrozenAttributes []string `json:"frozen_attributes,omitempty"`
Submission *Submission `json:"submission,omitempty"`
UseRubricForGrading bool `json:"use_rubric_for_grading"`
RubricSettings map[string]interface{} `json:"rubric_settings,omitempty"`
Rubric []RubricCriterion `json:"rubric,omitempty"`
AssignmentVisibility []int64 `json:"assignment_visibility,omitempty"`
Overrides []AssignmentOverride `json:"overrides,omitempty"`
OmitFromFinalGrade bool `json:"omit_from_final_grade"`
ModeratedGrading bool `json:"moderated_grading"`
}
Assignment represents a Canvas assignment
func NormalizeAssignment ¶
func NormalizeAssignment(assignment *Assignment) *Assignment
NormalizeAssignment ensures consistent data structure for an assignment
func NormalizeAssignments ¶
func NormalizeAssignments(assignments []Assignment) []Assignment
NormalizeAssignments normalizes a slice of assignments
type AssignmentOverride ¶
type AssignmentOverride struct {
ID int64 `json:"id"`
AssignmentID int64 `json:"assignment_id"`
StudentIDs []int64 `json:"student_ids,omitempty"`
GroupID int64 `json:"group_id,omitempty"`
CourseSectionID int64 `json:"course_section_id,omitempty"`
Title string `json:"title"`
DueAt time.Time `json:"due_at"`
AllDay bool `json:"all_day"`
AllDayDate string `json:"all_day_date"`
UnlockAt time.Time `json:"unlock_at"`
LockAt time.Time `json:"lock_at"`
}
AssignmentOverride represents an assignment override
type AssignmentOverrideParams ¶
type AssignmentOverrideParams struct {
StudentIDs []int64
Title string
DueAt string
UnlockAt string
LockAt string
}
AssignmentOverrideParams holds parameters for assignment overrides
type AssignmentsService ¶
type AssignmentsService struct {
// contains filtered or unexported fields
}
AssignmentsService handles assignment-related API calls
func NewAssignmentsService ¶
func NewAssignmentsService(client *Client) *AssignmentsService
NewAssignmentsService creates a new assignments service
func (*AssignmentsService) BulkUpdate ¶
func (s *AssignmentsService) BulkUpdate(ctx context.Context, courseID int64, params *BulkUpdateParams) error
BulkUpdate updates dates for multiple assignments at once
func (*AssignmentsService) Create ¶
func (s *AssignmentsService) Create(ctx context.Context, courseID int64, params *CreateAssignmentParams) (*Assignment, error)
Create creates a new assignment
func (*AssignmentsService) Delete ¶
func (s *AssignmentsService) Delete(ctx context.Context, courseID, assignmentID int64) error
Delete deletes an assignment
func (*AssignmentsService) Get ¶
func (s *AssignmentsService) Get(ctx context.Context, courseID, assignmentID int64, include []string) (*Assignment, error)
Get retrieves a single assignment by ID
func (*AssignmentsService) List ¶
func (s *AssignmentsService) List(ctx context.Context, courseID int64, opts *ListAssignmentsOptions) ([]Assignment, error)
List retrieves assignments for a course
func (*AssignmentsService) ListUserAssignments ¶
func (s *AssignmentsService) ListUserAssignments(ctx context.Context, userID int64, opts *ListAssignmentsOptions) ([]Assignment, error)
ListUserAssignments retrieves assignments for a specific user across all courses
func (*AssignmentsService) Update ¶
func (s *AssignmentsService) Update(ctx context.Context, courseID, assignmentID int64, params *UpdateAssignmentParams) (*Assignment, error)
Update updates an existing assignment
type Attachment ¶
type Attachment struct {
ID int64 `json:"id"`
UUID string `json:"uuid"`
FolderID int64 `json:"folder_id"`
DisplayName string `json:"display_name"`
Filename string `json:"filename"`
ContentType string `json:"content-type"`
URL string `json:"url"`
Size int64 `json:"size"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
UnlockAt time.Time `json:"unlock_at"`
Locked bool `json:"locked"`
Hidden bool `json:"hidden"`
LockAt time.Time `json:"lock_at"`
HiddenForUser bool `json:"hidden_for_user"`
ThumbnailURL string `json:"thumbnail_url"`
ModifiedAt time.Time `json:"modified_at"`
MIMEClass string `json:"mime_class"`
MediaEntryID string `json:"media_entry_id"`
LockedForUser bool `json:"locked_for_user"`
LockInfo *LockInfo `json:"lock_info,omitempty"`
LockExplanation string `json:"lock_explanation"`
PreviewURL string `json:"preview_url"`
}
Attachment represents a file attachment
type AvatarParams ¶
AvatarParams holds avatar upload parameters
type BulkGradeParams ¶
BulkGradeParams holds parameters for bulk grading
type BulkUpdateParams ¶
BulkUpdateParams holds parameters for bulk updating assignment dates
type CalendarEvent ¶ added in v1.1.0
type CalendarEvent struct {
ID int64 `json:"id"`
Title string `json:"title"`
StartAt *time.Time `json:"start_at,omitempty"`
EndAt *time.Time `json:"end_at,omitempty"`
Description string `json:"description,omitempty"`
LocationName string `json:"location_name,omitempty"`
LocationAddress string `json:"location_address,omitempty"`
ContextCode string `json:"context_code"`
EffectiveContextCode string `json:"effective_context_code,omitempty"`
ContextName string `json:"context_name,omitempty"`
AllContextCodes string `json:"all_context_codes,omitempty"`
WorkflowState string `json:"workflow_state"`
Hidden bool `json:"hidden"`
ParentEventID *int64 `json:"parent_event_id,omitempty"`
ChildEventsCount int `json:"child_events_count"`
ChildEvents []CalendarEvent `json:"child_events,omitempty"`
URL string `json:"url,omitempty"`
HTMLURL string `json:"html_url,omitempty"`
AllDayDate string `json:"all_day_date,omitempty"`
AllDay bool `json:"all_day"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
AppointmentGroupID *int64 `json:"appointment_group_id,omitempty"`
AppointmentGroupURL string `json:"appointment_group_url,omitempty"`
OwnReservation bool `json:"own_reservation"`
ReserveURL string `json:"reserve_url,omitempty"`
Reserved bool `json:"reserved"`
ParticipantType string `json:"participant_type,omitempty"`
ParticipantsPerAppt *int `json:"participants_per_appointment,omitempty"`
AvailableSlots *int `json:"available_slots,omitempty"`
User *User `json:"user,omitempty"`
Group interface{} `json:"group,omitempty"`
ImportantDates bool `json:"important_dates"`
SeriesUUID string `json:"series_uuid,omitempty"`
RRule string `json:"rrule,omitempty"`
SeriesHead *bool `json:"series_head,omitempty"`
SeriesNaturalLang string `json:"series_natural_language,omitempty"`
BlackoutDate bool `json:"blackout_date"`
}
CalendarEvent represents a Canvas calendar event
type CalendarService ¶ added in v1.1.0
type CalendarService struct {
// contains filtered or unexported fields
}
CalendarService handles calendar-related API calls
func NewCalendarService ¶ added in v1.1.0
func NewCalendarService(client *Client) *CalendarService
NewCalendarService creates a new calendar service
func (*CalendarService) Create ¶ added in v1.1.0
func (s *CalendarService) Create(ctx context.Context, params *CreateCalendarEventParams) (*CalendarEvent, error)
Create creates a new calendar event
func (*CalendarService) Delete ¶ added in v1.1.0
func (s *CalendarService) Delete(ctx context.Context, eventID int64, opts *DeleteOptions) error
Delete deletes a calendar event
func (*CalendarService) Get ¶ added in v1.1.0
func (s *CalendarService) Get(ctx context.Context, eventID int64) (*CalendarEvent, error)
Get retrieves a single calendar event
func (*CalendarService) List ¶ added in v1.1.0
func (s *CalendarService) List(ctx context.Context, opts *ListCalendarEventsOptions) ([]CalendarEvent, error)
List retrieves calendar events
func (*CalendarService) ListForUser ¶ added in v1.1.0
func (s *CalendarService) ListForUser(ctx context.Context, userID int64, opts *ListCalendarEventsOptions) ([]CalendarEvent, error)
ListForUser retrieves calendar events for a specific user
func (*CalendarService) Reserve ¶ added in v1.1.0
func (s *CalendarService) Reserve(ctx context.Context, eventID int64, participantID *int64, comments string, cancelExisting bool) (*CalendarEvent, error)
Reserve reserves a time slot
func (*CalendarService) Update ¶ added in v1.1.0
func (s *CalendarService) Update(ctx context.Context, eventID int64, params *UpdateCalendarEventParams) (*CalendarEvent, error)
Update updates an existing calendar event
type CanvasVersion ¶
CanvasVersion represents the Canvas version information
func DetectCanvasVersion ¶
func DetectCanvasVersion(ctx context.Context, client *http.Client, baseURL string) (*CanvasVersion, error)
DetectCanvasVersion detects the Canvas version from the API
func ParseVersion ¶
func ParseVersion(version string) (*CanvasVersion, error)
ParseVersion parses a version string into a CanvasVersion
func (*CanvasVersion) IsAtLeast ¶
func (v *CanvasVersion) IsAtLeast(major, minor, patch int) bool
IsAtLeast checks if the version is at least the specified version
func (*CanvasVersion) String ¶
func (v *CanvasVersion) String() string
String returns the string representation of the version
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Canvas API client
func NewClient ¶
func NewClient(config ClientConfig) (*Client, error)
NewClient creates a new Canvas API client
func (*Client) CacheStats ¶ added in v1.2.0
CacheStats returns cache statistics
func (*Client) ClearCache ¶ added in v1.2.0
func (c *Client) ClearCache()
ClearCache clears all cached responses
func (*Client) GetAllPages ¶
GetAllPages fetches all pages of a paginated endpoint If caching is enabled, cached responses will be returned when available
func (*Client) GetJSON ¶
GetJSON performs a GET request and decodes JSON response If caching is enabled, cached responses will be returned when available
func (*Client) GetQuotaTotal ¶
GetQuotaTotal returns the current quota total setting
func (*Client) GetVersion ¶
func (c *Client) GetVersion() *CanvasVersion
GetVersion returns the detected Canvas version
func (*Client) IsCacheEnabled ¶ added in v1.2.0
IsCacheEnabled returns whether caching is enabled
func (*Client) PostJSON ¶
func (c *Client) PostJSON(ctx context.Context, path string, body interface{}, result interface{}) error
PostJSON performs a POST request with JSON body and decodes JSON response
func (*Client) PutJSON ¶
func (c *Client) PutJSON(ctx context.Context, path string, body interface{}, result interface{}) error
PutJSON performs a PUT request with JSON body and decodes JSON response
func (*Client) SetCacheEnabled ¶ added in v1.2.0
SetCacheEnabled enables or disables caching
func (*Client) SetQuotaTotal ¶
SetQuotaTotal allows configuring the Canvas API quota total This is useful when the actual quota differs from the default (700)
func (*Client) SupportsFeature ¶
SupportsFeature checks if a feature is supported
type ClientConfig ¶
type ClientConfig struct {
BaseURL string
Token string
RequestsPerSec float64
Timeout time.Duration
Logger *slog.Logger
AsUserID int64 // For admin masquerading (appends as_user_id param)
Cache cache.CacheInterface
CacheEnabled bool
}
ClientConfig holds configuration for the API client
type CompletionRequirement ¶ added in v1.1.0
type CompletionRequirement struct {
Type string `json:"type"`
MinScore float64 `json:"min_score,omitempty"`
MinPercentage float64 `json:"min_percentage,omitempty"`
Completed bool `json:"completed,omitempty"`
}
CompletionRequirement represents how a module item must be completed
type CompletionRequirementParams ¶ added in v1.1.0
type CompletionRequirementParams struct {
Type string // must_view, must_contribute, must_submit, must_mark_done, min_score
MinScore float64
}
CompletionRequirementParams holds completion requirement parameters
type ConcludeParams ¶
type ConcludeParams struct {
Task string // conclude, delete, inactivate, deactivate
}
ConcludeParams holds parameters for concluding an enrollment
type ContentDetails ¶ added in v1.1.0
type ContentDetails struct {
PointsPossible float64 `json:"points_possible,omitempty"`
DueAt *time.Time `json:"due_at,omitempty"`
UnlockAt *time.Time `json:"unlock_at,omitempty"`
LockAt *time.Time `json:"lock_at,omitempty"`
LockedForUser bool `json:"locked_for_user"`
LockExplanation string `json:"lock_explanation,omitempty"`
}
ContentDetails represents additional details for module item content
type Course ¶
type Course struct {
ID int64 `json:"id"`
Name string `json:"name"`
CourseCode string `json:"course_code"`
WorkflowState string `json:"workflow_state"`
AccountID int64 `json:"account_id"`
StartAt time.Time `json:"start_at"`
EndAt time.Time `json:"end_at"`
EnrollmentTermID int64 `json:"enrollment_term_id"`
GradingStandardID int64 `json:"grading_standard_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DefaultView string `json:"default_view"`
SyllabusBody string `json:"syllabus_body"`
NeedsGradingCount int `json:"needs_grading_count"`
Term *Term `json:"term,omitempty"`
CourseProgress *Progress `json:"course_progress,omitempty"`
ApplyAssignmentGroupWeights bool `json:"apply_assignment_group_weights"`
Permissions map[string]bool `json:"permissions,omitempty"`
IsPublic bool `json:"is_public"`
IsPublicToAuthUsers bool `json:"is_public_to_auth_users"`
PublicSyllabus bool `json:"public_syllabus"`
PublicSyllabusToAuth bool `json:"public_syllabus_to_auth"`
PublicDescription string `json:"public_description"`
StorageQuotaMB int `json:"storage_quota_mb"`
StorageQuotaUsedMB float64 `json:"storage_quota_used_mb"`
HideFinalGrades bool `json:"hide_final_grades"`
License string `json:"license"`
AllowStudentAssignmentEdits bool `json:"allow_student_assignment_edits"`
AllowWikiComments bool `json:"allow_wiki_comments"`
AllowStudentForumAttachments bool `json:"allow_student_forum_attachments"`
OpenEnrollment bool `json:"open_enrollment"`
SelfEnrollment bool `json:"self_enrollment"`
RestrictEnrollmentsToCourseDates bool `json:"restrict_enrollments_to_course_dates"`
CourseFormat string `json:"course_format"`
AccessRestrictedByDate bool `json:"access_restricted_by_date"`
TimeZone string `json:"time_zone"`
Blueprint bool `json:"blueprint"`
BlueprintRestrictions map[string]bool `json:"blueprint_restrictions,omitempty"`
BlueprintRestrictionsByObjectType map[string]map[string]bool `json:"blueprint_restrictions_by_object_type,omitempty"`
}
Course represents a Canvas course
func NormalizeCourse ¶
NormalizeCourse ensures consistent data structure for a course
func NormalizeCourses ¶
NormalizeCourses normalizes a slice of courses
type CoursesService ¶
type CoursesService struct {
// contains filtered or unexported fields
}
CoursesService handles course-related API calls
func NewCoursesService ¶
func NewCoursesService(client *Client) *CoursesService
NewCoursesService creates a new courses service
func (*CoursesService) Create ¶
func (s *CoursesService) Create(ctx context.Context, params *CreateCourseParams) (*Course, error)
Create creates a new course
func (*CoursesService) Get ¶
func (s *CoursesService) Get(ctx context.Context, courseID int64, include []string) (*Course, error)
Get retrieves a single course by ID
func (*CoursesService) List ¶
func (s *CoursesService) List(ctx context.Context, opts *ListCoursesOptions) ([]Course, error)
List retrieves all courses for the current user
func (*CoursesService) Update ¶
func (s *CoursesService) Update(ctx context.Context, courseID int64, params *UpdateCourseParams) (*Course, error)
Update updates an existing course
type CreateAssignmentParams ¶
type CreateAssignmentParams struct {
Name string
Position int
SubmissionTypes []string // online_text_entry, online_url, online_upload, media_recording, etc.
AllowedExtensions []string // For online_upload submission type
TurnitinEnabled bool
VericiteEnabled bool
TurnitinSettings map[string]interface{}
IntegrationData map[string]interface{}
IntegrationID string
PeerReviews bool
AutomaticPeerReviews bool
NotifyOfUpdate bool
GroupCategoryID int64
GradeGroupStudentsIndividually bool
ExternalToolTagAttributes map[string]interface{}
PointsPossible float64
GradingType string // pass_fail, percent, letter_grade, gpa_scale, points
DueAt string // ISO8601 format
LockAt string
UnlockAt string
Description string
AssignmentGroupID int64
AssignmentOverrides []AssignmentOverrideParams
OnlyVisibleToOverrides bool
Published bool
GradingStandardID int64
OmitFromFinalGrade bool
ModeratedGrading bool
GraderCount int
FinalGraderID int64
GraderCommentsVisibleToGraders bool
GradersAnonymousToGraders bool
GraderNamesVisibleToFinalGrader bool
AnonymousInstructorAnnotations bool
AnonymousGrading bool
AllowedAttempts int
AnnotatableAttachmentID int64
HideInGradebook bool
PostToSIS bool
ImportantDates bool
}
CreateAssignmentParams holds parameters for creating an assignment
type CreateCalendarEventParams ¶ added in v1.1.0
type CreateCalendarEventParams struct {
ContextCode string // Required: course_123, user_456, etc.
Title string
Description string
StartAt string // ISO 8601
EndAt string // ISO 8601
LocationName string
LocationAddress string
TimeZoneEdited string
AllDay bool
RRule string
BlackoutDate bool
}
CreateCalendarEventParams holds parameters for creating a calendar event
type CreateCourseParams ¶
type CreateCourseParams struct {
AccountID int64
Name string
CourseCode string
StartAt string
EndAt string
License string
IsPublic bool
IsPublicToAuthUsers bool
PublicSyllabus bool
PublicSyllabusToAuth bool
PublicDescription string
AllowStudentWikiEdits bool
AllowWikiComments bool
AllowStudentForumAttachments bool
OpenEnrollment bool
SelfEnrollment bool
RestrictEnrollmentsToCourseDates bool
TermID int64
SISCourseID string
IntegrationID string
HideFinalGrades bool
ApplyAssignmentGroupWeights bool
TimeZone string
Offer bool
EnrollMe bool
DefaultView string
SyllabusBody string
GradingStandardID int64
CourseFormat string
}
CreateCourseParams holds parameters for creating a course
type CreateDiscussionParams ¶ added in v1.1.0
type CreateDiscussionParams struct {
Title string
Message string
DiscussionType string // side_comment, threaded, not_threaded
Published bool
DelayedPostAt string
AllowRating bool
LockAt string
PodcastEnabled bool
PodcastHasStudentPosts bool
RequireInitialPost bool
IsAnnouncement bool
Pinned bool
PositionAfter string
GroupCategoryID int64
OnlyGradersCanRate bool
SpecificSections string
}
CreateDiscussionParams holds parameters for creating a discussion
type CreateModuleItemParams ¶ added in v1.1.0
type CreateModuleItemParams struct {
Title string
Type string // File, Page, Discussion, Assignment, Quiz, SubHeader, ExternalUrl, ExternalTool
ContentID int64
Position int
Indent int
PageURL string
ExternalURL string
NewTab bool
CompletionRequirement *CompletionRequirementParams
IframeWidth int
IframeHeight int
}
CreateModuleItemParams holds parameters for creating a module item
type CreateModuleParams ¶ added in v1.1.0
type CreateModuleParams struct {
Name string
UnlockAt string
Position int
RequireSequentialProgress bool
PrerequisiteModuleIDs []int64
PublishFinalGrade bool
}
CreateModuleParams holds parameters for creating a module
type CreateNoteParams ¶ added in v1.1.0
type CreateNoteParams struct {
Title string
Details string
TodoDate string // ISO 8601
CourseID int64
LinkedObjectType string
LinkedObjectID int64
}
CreateNoteParams holds parameters for creating a planner note
type CreateOverrideParams ¶ added in v1.1.0
type CreateOverrideParams struct {
PlannableType string // Required: Assignment, Quiz, CalendarEvent, etc.
PlannableID int64 // Required
MarkedComplete bool
Dismissed bool
}
CreateOverrideParams holds parameters for creating a planner override
type CreatePageParams ¶ added in v1.1.0
type CreatePageParams struct {
Title string
Body string
EditingRoles string
NotifyOfUpdate bool
Published bool
FrontPage bool
PublishAt string
}
CreatePageParams holds parameters for creating a page
type CreateUserParams ¶
type CreateUserParams struct {
Name string
ShortName string
SortableName string
TimeZone string
Locale string
TermsOfUse bool
SkipRegistration bool
ForceValidations bool
EnableSISReactivation bool
// Pseudonym (login) information
UniqueID string
SISUserID string
IntegrationID string
AuthenticationProviderID string
Password string
// Communication channel (email)
Email string
SkipConfirmation bool
}
CreateUserParams holds parameters for creating a user
type DeleteOptions ¶ added in v1.1.0
DeleteOptions holds options for deleting a calendar event
type DiscussionEntry ¶ added in v1.1.0
type DiscussionEntry struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
ParentID *int64 `json:"parent_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Message string `json:"message"`
Rating int `json:"rating"`
RatingSum int `json:"rating_sum"`
ReadState string `json:"read_state"`
ForcedReadState bool `json:"forced_read_state"`
User *User `json:"user,omitempty"`
Replies []DiscussionEntry `json:"replies,omitempty"`
}
DiscussionEntry represents an entry in a discussion
type DiscussionTopic ¶ added in v1.1.0
type DiscussionTopic struct {
ID int64 `json:"id"`
Title string `json:"title"`
Message string `json:"message"`
HTMLURL string `json:"html_url"`
PostedAt *time.Time `json:"posted_at,omitempty"`
LastReplyAt *time.Time `json:"last_reply_at,omitempty"`
RequireInitialPost bool `json:"require_initial_post"`
UserCanSeePosts bool `json:"user_can_see_posts"`
DiscussionSubentryCount int `json:"discussion_subentry_count"`
ReadState string `json:"read_state"`
UnreadCount int `json:"unread_count"`
Subscribed bool `json:"subscribed"`
SubscriptionHold string `json:"subscription_hold,omitempty"`
AssignmentID *int64 `json:"assignment_id,omitempty"`
DelayedPostAt *time.Time `json:"delayed_post_at,omitempty"`
Published bool `json:"published"`
LockAt *time.Time `json:"lock_at,omitempty"`
Locked bool `json:"locked"`
Pinned bool `json:"pinned"`
LockedForUser bool `json:"locked_for_user"`
LockInfo *LockInfo `json:"lock_info,omitempty"`
LockExplanation string `json:"lock_explanation,omitempty"`
UserName string `json:"user_name,omitempty"`
RootTopicID *int64 `json:"root_topic_id,omitempty"`
PodcastURL string `json:"podcast_url,omitempty"`
DiscussionType string `json:"discussion_type"`
GroupCategoryID *int64 `json:"group_category_id,omitempty"`
Attachments []FileAttachment `json:"attachments,omitempty"`
Permissions map[string]bool `json:"permissions,omitempty"`
AllowRating bool `json:"allow_rating"`
OnlyGradersCanRate bool `json:"only_graders_can_rate"`
SortByRating bool `json:"sort_by_rating"`
ContextCode string `json:"context_code,omitempty"`
Author *User `json:"author,omitempty"`
IsAnnouncement bool `json:"is_announcement,omitempty"`
}
DiscussionTopic represents a Canvas discussion topic or announcement
type DiscussionsService ¶ added in v1.1.0
type DiscussionsService struct {
// contains filtered or unexported fields
}
DiscussionsService handles discussion-related API calls
func NewDiscussionsService ¶ added in v1.1.0
func NewDiscussionsService(client *Client) *DiscussionsService
NewDiscussionsService creates a new discussions service
func (*DiscussionsService) Create ¶ added in v1.1.0
func (s *DiscussionsService) Create(ctx context.Context, courseID int64, params *CreateDiscussionParams) (*DiscussionTopic, error)
Create creates a new discussion topic
func (*DiscussionsService) Delete ¶ added in v1.1.0
func (s *DiscussionsService) Delete(ctx context.Context, courseID, topicID int64) error
Delete deletes a discussion topic
func (*DiscussionsService) Get ¶ added in v1.1.0
func (s *DiscussionsService) Get(ctx context.Context, courseID, topicID int64, include []string) (*DiscussionTopic, error)
Get retrieves a single discussion topic
func (*DiscussionsService) List ¶ added in v1.1.0
func (s *DiscussionsService) List(ctx context.Context, courseID int64, opts *ListDiscussionsOptions) ([]DiscussionTopic, error)
List retrieves all discussion topics for a course
func (*DiscussionsService) ListEntries ¶ added in v1.1.0
func (s *DiscussionsService) ListEntries(ctx context.Context, courseID, topicID int64) ([]DiscussionEntry, error)
ListEntries retrieves all entries for a discussion topic
func (*DiscussionsService) MarkTopicRead ¶ added in v1.1.0
func (s *DiscussionsService) MarkTopicRead(ctx context.Context, courseID, topicID int64) error
MarkTopicRead marks a topic as read
func (*DiscussionsService) MarkTopicUnread ¶ added in v1.1.0
func (s *DiscussionsService) MarkTopicUnread(ctx context.Context, courseID, topicID int64) error
MarkTopicUnread marks a topic as unread
func (*DiscussionsService) PostEntry ¶ added in v1.1.0
func (s *DiscussionsService) PostEntry(ctx context.Context, courseID, topicID int64, message string) (*DiscussionEntry, error)
PostEntry posts a new entry to a discussion topic
func (*DiscussionsService) PostReply ¶ added in v1.1.0
func (s *DiscussionsService) PostReply(ctx context.Context, courseID, topicID, entryID int64, message string) (*DiscussionEntry, error)
PostReply posts a reply to an entry
func (*DiscussionsService) Subscribe ¶ added in v1.1.0
func (s *DiscussionsService) Subscribe(ctx context.Context, courseID, topicID int64) error
Subscribe subscribes to a topic
func (*DiscussionsService) Unsubscribe ¶ added in v1.1.0
func (s *DiscussionsService) Unsubscribe(ctx context.Context, courseID, topicID int64) error
Unsubscribe unsubscribes from a topic
func (*DiscussionsService) Update ¶ added in v1.1.0
func (s *DiscussionsService) Update(ctx context.Context, courseID, topicID int64, params *UpdateDiscussionParams) (*DiscussionTopic, error)
Update updates an existing discussion topic
type EnrollUserParams ¶
type EnrollUserParams struct {
UserID int64
Type string // StudentEnrollment, TeacherEnrollment, TaEnrollment, ObserverEnrollment, DesignerEnrollment
RoleID int64
EnrollmentState string // active, invited, inactive
CourseSectionID int64
LimitPrivilegesToCourseSection bool
Notify bool
SelfEnrollmentCode string
SelfEnrolled bool
AssociatedUserID int64 // For observer enrollments
}
EnrollUserParams holds parameters for enrolling a user
type Enrollment ¶
type Enrollment struct {
ID int64 `json:"id"`
CourseID int64 `json:"course_id"`
CourseSectionID int64 `json:"course_section_id"`
EnrollmentState string `json:"enrollment_state"`
LimitPrivilegesToCourseSection bool `json:"limit_privileges_to_course_section"`
RootAccountID int64 `json:"root_account_id"`
Type string `json:"type"`
UserID int64 `json:"user_id"`
AssociatedUserID int64 `json:"associated_user_id"`
Role string `json:"role"`
RoleID int64 `json:"role_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
StartAt time.Time `json:"start_at"`
EndAt time.Time `json:"end_at"`
LastActivityAt time.Time `json:"last_activity_at"`
LastAttendedAt time.Time `json:"last_attended_at"`
TotalActivityTime int `json:"total_activity_time"`
HTMLURL string `json:"html_url"`
Grades *Grades `json:"grades,omitempty"`
User *User `json:"user,omitempty"`
OverrideGrade string `json:"override_grade"`
OverrideScore float64 `json:"override_score"`
UnpostedCurrentGrade string `json:"unposted_current_grade"`
UnpostedCurrentScore float64 `json:"unposted_current_score"`
UnpostedFinalGrade string `json:"unposted_final_grade"`
UnpostedFinalScore float64 `json:"unposted_final_score"`
HasGradingPeriods bool `json:"has_grading_periods"`
TotalsForAllGradingPeriodsOption bool `json:"totals_for_all_grading_periods_option"`
CurrentGradingPeriodTitle string `json:"current_grading_period_title"`
CurrentGradingPeriodID int64 `json:"current_grading_period_id"`
CurrentPeriodOverrideGrade string `json:"current_period_override_grade"`
CurrentPeriodOverrideScore float64 `json:"current_period_override_score"`
CurrentPeriodUnpostedCurrentGrade string `json:"current_period_unposted_current_grade"`
CurrentPeriodUnpostedCurrentScore float64 `json:"current_period_unposted_current_score"`
CurrentPeriodUnpostedFinalGrade string `json:"current_period_unposted_final_grade"`
CurrentPeriodUnpostedFinalScore float64 `json:"current_period_unposted_final_score"`
}
Enrollment represents a Canvas enrollment
func NormalizeEnrollment ¶
func NormalizeEnrollment(enrollment *Enrollment) *Enrollment
NormalizeEnrollment ensures consistent data structure for an enrollment
func NormalizeEnrollments ¶
func NormalizeEnrollments(enrollments []Enrollment) []Enrollment
NormalizeEnrollments normalizes a slice of enrollments
type EnrollmentsService ¶
type EnrollmentsService struct {
// contains filtered or unexported fields
}
EnrollmentsService handles enrollment-related API calls
func NewEnrollmentsService ¶
func NewEnrollmentsService(client *Client) *EnrollmentsService
NewEnrollmentsService creates a new enrollments service
func (*EnrollmentsService) Accept ¶
func (s *EnrollmentsService) Accept(ctx context.Context, courseID, enrollmentID int64) error
Accept accepts a pending enrollment invitation
func (*EnrollmentsService) Conclude ¶
func (s *EnrollmentsService) Conclude(ctx context.Context, courseID, enrollmentID int64, task string) (*Enrollment, error)
Conclude concludes, deletes, or deactivates an enrollment
func (*EnrollmentsService) EnrollUser ¶
func (s *EnrollmentsService) EnrollUser(ctx context.Context, courseID int64, params *EnrollUserParams) (*Enrollment, error)
EnrollUser enrolls a user in a course
func (*EnrollmentsService) ListCourse ¶
func (s *EnrollmentsService) ListCourse(ctx context.Context, courseID int64, opts *ListEnrollmentsOptions) ([]Enrollment, error)
ListCourse retrieves enrollments for a course
func (*EnrollmentsService) ListSection ¶
func (s *EnrollmentsService) ListSection(ctx context.Context, sectionID int64, opts *ListEnrollmentsOptions) ([]Enrollment, error)
ListSection retrieves enrollments for a section
func (*EnrollmentsService) ListUser ¶
func (s *EnrollmentsService) ListUser(ctx context.Context, userID int64, opts *ListEnrollmentsOptions) ([]Enrollment, error)
ListUser retrieves enrollments for a user
func (*EnrollmentsService) Reactivate ¶
func (s *EnrollmentsService) Reactivate(ctx context.Context, courseID, enrollmentID int64) (*Enrollment, error)
Reactivate reactivates a deactivated enrollment
func (*EnrollmentsService) Reject ¶
func (s *EnrollmentsService) Reject(ctx context.Context, courseID, enrollmentID int64) error
Reject rejects a pending enrollment invitation
func (*EnrollmentsService) UpdateLastAttended ¶
func (s *EnrollmentsService) UpdateLastAttended(ctx context.Context, courseID, enrollmentID int64, date string) (*Enrollment, error)
UpdateLastAttended updates the last attended date for an enrollment
type ErrorDetail ¶
type ErrorDetail struct {
Message string `json:"message"`
ErrorCode string `json:"error_code,omitempty"`
}
ErrorDetail represents detailed error information
type FeatureChecker ¶
type FeatureChecker struct {
// contains filtered or unexported fields
}
FeatureChecker checks if a feature is available based on Canvas version
func NewFeatureChecker ¶
func NewFeatureChecker(version *CanvasVersion) *FeatureChecker
NewFeatureChecker creates a new FeatureChecker
func (*FeatureChecker) SupportsFeature ¶
func (f *FeatureChecker) SupportsFeature(feature string) bool
SupportsFeature checks if a feature is supported based on version
func (*FeatureChecker) WarnIfUnsupported ¶
func (f *FeatureChecker) WarnIfUnsupported(feature string) bool
WarnIfUnsupported logs a warning if a feature is unsupported
type FileAttachment ¶ added in v1.1.0
type FileAttachment struct {
ContentType string `json:"content-type"`
URL string `json:"url"`
Filename string `json:"filename"`
DisplayName string `json:"display_name"`
}
FileAttachment represents a file attachment
type FilesService ¶
type FilesService struct {
// contains filtered or unexported fields
}
FilesService handles file-related API calls
func NewFilesService ¶
func NewFilesService(client *Client) *FilesService
NewFilesService creates a new files service
func (*FilesService) Delete ¶
func (s *FilesService) Delete(ctx context.Context, fileID int64) error
Delete deletes a file
func (*FilesService) Get ¶
func (s *FilesService) Get(ctx context.Context, fileID int64, include []string) (*Attachment, error)
Get retrieves a single file by ID
func (*FilesService) GetCourseQuota ¶
GetQuota retrieves quota information for a course or user
func (*FilesService) GetUserQuota ¶
GetUserQuota retrieves quota information for a user
func (*FilesService) ListCourseFiles ¶
func (s *FilesService) ListCourseFiles(ctx context.Context, courseID int64, opts *ListFilesOptions) ([]Attachment, error)
ListCourseFiles retrieves files for a course
func (*FilesService) ListFolderFiles ¶
func (s *FilesService) ListFolderFiles(ctx context.Context, folderID int64, opts *ListFilesOptions) ([]Attachment, error)
ListFolderFiles retrieves files in a folder
func (*FilesService) ListUserFiles ¶
func (s *FilesService) ListUserFiles(ctx context.Context, userID int64, opts *ListFilesOptions) ([]Attachment, error)
ListUserFiles retrieves files for a user
func (*FilesService) Update ¶
func (s *FilesService) Update(ctx context.Context, fileID int64, params *UpdateParams) (*Attachment, error)
Update updates file metadata
func (*FilesService) UploadToCourse ¶
func (s *FilesService) UploadToCourse(ctx context.Context, courseID int64, filePath string, params *UploadParams) (*Attachment, error)
UploadToCourse uploads a file to a course
func (*FilesService) UploadToFolder ¶
func (s *FilesService) UploadToFolder(ctx context.Context, folderID int64, filePath string, params *UploadParams) (*Attachment, error)
UploadToFolder uploads a file to a specific folder
func (*FilesService) UploadToUser ¶
func (s *FilesService) UploadToUser(ctx context.Context, userID int64, filePath string, params *UploadParams) (*Attachment, error)
UploadToUser uploads a file to a user's files
type GradeData ¶
type GradeData struct {
PostedGrade string
Excuse bool
LatePolicyStatus string
RubricAssessment map[string]RubricAssessmentParams
}
GradeData holds grade information for a single student
type GradeSubmissionParams ¶
type GradeSubmissionParams struct {
PostedGrade string // The grade to assign (letter grade, percentage, points, etc.)
Excuse bool // Excuse the submission
LatePolicyStatus string // late, missing, none
SecondsLateOverride *int // Override seconds late calculation
Comment *SubmissionCommentParams
RubricAssessment map[string]RubricAssessmentParams
}
GradeSubmissionParams holds parameters for grading a submission
type Grades ¶
type Grades struct {
HTMLURL string `json:"html_url"`
CurrentGrade string `json:"current_grade"`
CurrentScore float64 `json:"current_score"`
FinalGrade string `json:"final_grade"`
FinalScore float64 `json:"final_score"`
UnpostedCurrentGrade string `json:"unposted_current_grade"`
UnpostedCurrentScore float64 `json:"unposted_current_score"`
UnpostedFinalGrade string `json:"unposted_final_grade"`
UnpostedFinalScore float64 `json:"unposted_final_score"`
}
Grades represents enrollment grades
type HTTPClient ¶
type HTTPClient interface {
// Low-level HTTP methods
Get(ctx context.Context, path string) (*http.Response, error)
Post(ctx context.Context, path string, body io.Reader) (*http.Response, error)
Put(ctx context.Context, path string, body io.Reader) (*http.Response, error)
Delete(ctx context.Context, path string) (*http.Response, error)
// JSON convenience methods
GetJSON(ctx context.Context, path string, result interface{}) error
PostJSON(ctx context.Context, path string, body interface{}, result interface{}) error
PutJSON(ctx context.Context, path string, body interface{}, result interface{}) error
// Pagination support
GetAllPages(ctx context.Context, path string, result interface{}) error
// Feature detection
SupportsFeature(feature string) bool
GetVersion() *CanvasVersion
}
HTTPClient defines the interface for making HTTP requests to Canvas API This interface allows for easier testing and mocking of the API client
type LastAttendedParams ¶
type LastAttendedParams struct {
Date string // ISO8601 format
}
LastAttendedParams holds parameters for updating last attended date
type ListAccountCoursesOptions ¶
type ListAccountCoursesOptions struct {
// Filter options
WithEnrollments bool `url:"with_enrollments,omitempty"` // Only courses with at least one enrollment
EnrollmentType []string `url:"enrollment_type[],omitempty"` // teacher, student, ta, observer, designer
Published bool `url:"published,omitempty"` // Only published courses
Completed bool `url:"completed,omitempty"` // Only completed courses
Blueprint bool `url:"blueprint,omitempty"` // Only blueprint courses
BlueprintAssociated bool `url:"blueprint_associated,omitempty"` // Only courses associated with blueprints
// Search options
SearchTerm string `url:"search_term,omitempty"` // Search by name/code
ByTeachers []int64 `url:"by_teachers[],omitempty"` // Filter by teacher IDs
BySubaccounts []int64 `url:"by_subaccounts[],omitempty"` // Filter by sub-account IDs
// State options
State []string `url:"state[],omitempty"` // created, claimed, available, completed, deleted, all
EnrollmentTermID int64 `url:"enrollment_term_id,omitempty"` // Filter by term
// Sorting options
Sort string `url:"sort,omitempty"` // course_name, sis_course_id, teacher, account_name
Order string `url:"order,omitempty"` // asc, desc
// Include options
Include []string `url:"include[],omitempty"` // syllabus_body, term, course_progress, etc.
// Pagination
PerPage int `url:"per_page,omitempty"`
}
ListAccountCoursesOptions holds options for listing courses in an account
type ListAccountUsersOptions ¶
type ListAccountUsersOptions struct {
SearchTerm string `url:"search_term,omitempty"` // Search by name/email
EnrollmentType string `url:"enrollment_type,omitempty"` // Filter by enrollment type
Sort string `url:"sort,omitempty"` // username, email, sis_id, last_login
Order string `url:"order,omitempty"` // asc, desc
Include []string `url:"include[],omitempty"` // avatar_url, email, last_login, etc.
PerPage int `url:"per_page,omitempty"`
}
ListAccountUsersOptions holds options for listing users in an account
type ListAccountsOptions ¶
type ListAccountsOptions struct {
Include []string `url:"include[],omitempty"` // lti_guid, registration_settings, services
PerPage int `url:"per_page,omitempty"`
}
ListAccountsOptions holds options for listing accounts
type ListAnnouncementsOptions ¶ added in v1.1.0
type ListAnnouncementsOptions struct {
ContextCodes []string // course_123, course_456
StartDate string // yyyy-mm-dd or ISO 8601
EndDate string
ActiveOnly bool
LatestOnly bool
Include []string // sections, sections_user_count
}
ListAnnouncementsOptions holds options for listing announcements
type ListAssignmentsOptions ¶
type ListAssignmentsOptions struct {
Include []string // Additional data to include (submission, assignment_visibility, overrides, observed_users, etc.)
SearchTerm string // Search by assignment name
OverrideAssignmentDates bool // Apply assignment overrides for each assignment
NeedsGradingCountBySection bool // Include needs_grading_count split by section
Bucket string // Filter by assignment bucket (past, overdue, undated, ungraded, unsubmitted, upcoming, future)
AssignmentIDs []int64 // Filter by assignment IDs
OrderBy string // Order by (position, name, due_at)
PostToSIS *bool // Filter by post_to_sis
Page int
PerPage int
}
ListAssignmentsOptions holds options for listing assignments
type ListCalendarEventsOptions ¶ added in v1.1.0
type ListCalendarEventsOptions struct {
Type string // event, assignment, sub_assignment
StartDate string // yyyy-mm-dd or ISO 8601
EndDate string // yyyy-mm-dd or ISO 8601
Undated bool
AllEvents bool
ContextCodes []string // course_123, user_456, etc.
Excludes []string // description, child_events, assignment
Includes []string // web_conference, series_natural_language
ImportantDates bool
BlackoutDate bool
Page int
PerPage int
}
ListCalendarEventsOptions holds options for listing calendar events
type ListCoursesOptions ¶
type ListCoursesOptions struct {
EnrollmentType string // student, teacher, ta, observer, designer
EnrollmentState string // active, invited_or_pending, completed
Include []string // needs_grading_count, syllabus_body, total_scores, term, etc.
State []string // unpublished, available, completed, deleted
Page int
PerPage int
}
ListCoursesOptions holds options for listing courses
type ListDiscussionsOptions ¶ added in v1.1.0
type ListDiscussionsOptions struct {
Include []string // all_dates, sections, sections_user_count, overrides
OrderBy string // position, recent_activity, title
Scope string // locked, unlocked, pinned, unpinned
OnlyAnnouncements bool
FilterBy string // all, unread
SearchTerm string
Page int
PerPage int
}
ListDiscussionsOptions holds options for listing discussions
type ListEnrollmentsOptions ¶
type ListEnrollmentsOptions struct {
Type []string // Enrollment types to include (StudentEnrollment, TeacherEnrollment, TaEnrollment, DesignerEnrollment, ObserverEnrollment)
Role []string // Deprecated, use RoleID instead
RoleID []int64 // Filter by role ID
State []string // Filter by enrollment state (active, invited, creation_pending, deleted, rejected, completed, inactive, current_and_future, etc.)
Include []string // Additional data to include (avatar_url, group_ids, locked, observed_users, can_be_removed, uuid, current_points)
UserID int64 // Filter by user ID
GradingPeriodID int64 // Filter by grading period
EnrollmentTermID int64 // Filter by enrollment term
SISAccountID []string // Filter by SIS account ID
SISCourseID []string // Filter by SIS course ID
SISSectionID []string // Filter by SIS section ID
SISUserID []string // Filter by SIS user ID
CreatedForSISID []string // Filter by created_for_sis_id
Page int
PerPage int
}
ListEnrollmentsOptions holds options for listing enrollments
type ListFilesOptions ¶
type ListFilesOptions struct {
ContentTypes []string // Filter by MIME type
SearchTerm string // Search by file name
Include []string // Additional data to include (user)
Only []string // Filter by type (names, folders)
Sort string // Sort by (name, size, created_at, updated_at, content_type)
Order string // Order direction (asc, desc)
Page int
PerPage int
}
ListFilesOptions holds options for listing files
type ListModuleItemsOptions ¶ added in v1.1.0
type ListModuleItemsOptions struct {
Include []string // content_details
SearchTerm string
StudentID string
Page int
PerPage int
}
ListModuleItemsOptions holds options for listing module items
type ListModulesOptions ¶ added in v1.1.0
type ListModulesOptions struct {
Include []string // items, content_details
SearchTerm string
StudentID string
Page int
PerPage int
}
ListModulesOptions holds options for listing modules
type ListOverridesOptions ¶ added in v1.1.0
ListOverridesOptions holds options for listing planner overrides
type ListPagesOptions ¶ added in v1.1.0
type ListPagesOptions struct {
Sort string // title, created_at, updated_at
Order string // asc, desc
SearchTerm string
Published *bool
Include []string // body
Page int
PerPage int
}
ListPagesOptions holds options for listing pages
type ListPlannerItemsOptions ¶ added in v1.1.0
type ListPlannerItemsOptions struct {
StartDate string // ISO 8601
EndDate string // ISO 8601
ContextCodes []string // course_123, group_456
Filter string // all_ungraded_todo_items, all_assignments, all_quizzes, all_calendar_events, all_planner_notes
Page int
PerPage int
}
ListPlannerItemsOptions holds options for listing planner items
type ListPlannerNotesOptions ¶ added in v1.1.0
type ListPlannerNotesOptions struct {
StartDate string
EndDate string
ContextCodes []string
CourseID int64
Page int
PerPage int
}
ListPlannerNotesOptions holds options for listing planner notes
type ListSubAccountsOptions ¶
type ListSubAccountsOptions struct {
Recursive bool `url:"recursive,omitempty"` // If true, returns the entire account tree
PerPage int `url:"per_page,omitempty"`
}
ListSubAccounts returns sub-accounts for a given account
type ListSubmissionsOptions ¶
type ListSubmissionsOptions struct {
Include []string // Additional data to include (submission_history, submission_comments, rubric_assessment, assignment, visibility, course, user, etc.)
Grouped bool // Group submissions by student
PostToSIS *bool // Filter by post_to_sis
SubmittedSince string // ISO8601 timestamp
GradedSince string // ISO8601 timestamp
GradingPeriodID int64 // Filter by grading period
WorkflowState string // Filter by workflow state (submitted, unsubmitted, graded, pending_review)
EnrollmentState string // Filter by enrollment state (active, concluded)
StateBasedOnDate bool // If true, filter by state based on assignment due date
Order string // Order by (id, graded_at)
OrderDirection string // Order direction (ascending, descending)
Page int
PerPage int
}
ListSubmissionsOptions holds options for listing submissions
type ListUsersOptions ¶
type ListUsersOptions struct {
SearchTerm string // Search by name, login ID, or email
EnrollmentType string // Filter by enrollment type
EnrollmentState string // Filter by enrollment state
Include []string // Additional data to include
Page int
PerPage int
}
ListUsersOptions holds options for listing users
type LockInfo ¶
type LockInfo struct {
AssetString string `json:"asset_string"`
UnlockAt time.Time `json:"unlock_at"`
LockAt time.Time `json:"lock_at"`
ContextModule string `json:"context_module"`
ManuallyLocked bool `json:"manually_locked"`
}
LockInfo represents lock information
type MediaComment ¶
type MediaComment struct {
ContentType string `json:"content-type"`
DisplayName string `json:"display_name"`
MediaID string `json:"media_id"`
MediaType string `json:"media_type"`
URL string `json:"url"`
}
MediaComment represents a media comment
type Module ¶ added in v1.1.0
type Module struct {
ID int64 `json:"id"`
WorkflowState string `json:"workflow_state"`
Position int `json:"position"`
Name string `json:"name"`
UnlockAt *time.Time `json:"unlock_at,omitempty"`
RequireSequentialProgress bool `json:"require_sequential_progress"`
RequirementType string `json:"requirement_type"`
PrerequisiteModuleIDs []int64 `json:"prerequisite_module_ids"`
ItemsCount int `json:"items_count"`
ItemsURL string `json:"items_url"`
Items []ModuleItem `json:"items,omitempty"`
State string `json:"state,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
PublishFinalGrade bool `json:"publish_final_grade"`
Published bool `json:"published"`
}
Module represents a Canvas course module
type ModuleItem ¶ added in v1.1.0
type ModuleItem struct {
ID int64 `json:"id"`
ModuleID int64 `json:"module_id"`
Position int `json:"position"`
Title string `json:"title"`
Indent int `json:"indent"`
Type string `json:"type"`
ContentID int64 `json:"content_id,omitempty"`
HTMLURL string `json:"html_url"`
URL string `json:"url,omitempty"`
PageURL string `json:"page_url,omitempty"`
ExternalURL string `json:"external_url,omitempty"`
NewTab bool `json:"new_tab,omitempty"`
CompletionRequirement *CompletionRequirement `json:"completion_requirement,omitempty"`
ContentDetails *ContentDetails `json:"content_details,omitempty"`
Published bool `json:"published"`
}
ModuleItem represents an item within a module
type ModuleItemRef ¶ added in v1.1.0
type ModuleItemRef struct {
ID int64 `json:"id"`
ModuleID int64 `json:"module_id"`
Title string `json:"title"`
Type string `json:"type"`
}
ModuleItemRef is a reference to a module item in a sequence
type ModuleItemSequence ¶ added in v1.1.0
type ModuleItemSequence struct {
Items []ModuleItemSequenceNode `json:"items"`
Modules []ModuleReference `json:"modules"`
}
ModuleItemSequence represents a sequence of module items
type ModuleItemSequenceNode ¶ added in v1.1.0
type ModuleItemSequenceNode struct {
Prev *ModuleItemRef `json:"prev,omitempty"`
Current *ModuleItemRef `json:"current,omitempty"`
Next *ModuleItemRef `json:"next,omitempty"`
MasteryPath interface{} `json:"mastery_path,omitempty"`
}
ModuleItemSequenceNode represents a node in the module item sequence
type ModuleReference ¶ added in v1.1.0
ModuleReference is a reference to a module
type ModulesService ¶ added in v1.1.0
type ModulesService struct {
// contains filtered or unexported fields
}
ModulesService handles module-related API calls
func NewModulesService ¶ added in v1.1.0
func NewModulesService(client *Client) *ModulesService
NewModulesService creates a new modules service
func (*ModulesService) Create ¶ added in v1.1.0
func (s *ModulesService) Create(ctx context.Context, courseID int64, params *CreateModuleParams) (*Module, error)
Create creates a new module in a course
func (*ModulesService) CreateItem ¶ added in v1.1.0
func (s *ModulesService) CreateItem(ctx context.Context, courseID, moduleID int64, params *CreateModuleItemParams) (*ModuleItem, error)
CreateItem creates a new module item
func (*ModulesService) Delete ¶ added in v1.1.0
func (s *ModulesService) Delete(ctx context.Context, courseID, moduleID int64) error
Delete deletes a module
func (*ModulesService) DeleteItem ¶ added in v1.1.0
func (s *ModulesService) DeleteItem(ctx context.Context, courseID, moduleID, itemID int64) error
DeleteItem deletes a module item
func (*ModulesService) Get ¶ added in v1.1.0
func (s *ModulesService) Get(ctx context.Context, courseID, moduleID int64, include []string, studentID string) (*Module, error)
Get retrieves a single module by ID
func (*ModulesService) GetItem ¶ added in v1.1.0
func (s *ModulesService) GetItem(ctx context.Context, courseID, moduleID, itemID int64, include []string, studentID string) (*ModuleItem, error)
GetItem retrieves a single module item
func (*ModulesService) GetItemSequence ¶ added in v1.1.0
func (s *ModulesService) GetItemSequence(ctx context.Context, courseID int64, assetType string, assetID int64) (*ModuleItemSequence, error)
GetItemSequence gets the module item sequence for an asset
func (*ModulesService) List ¶ added in v1.1.0
func (s *ModulesService) List(ctx context.Context, courseID int64, opts *ListModulesOptions) ([]Module, error)
List retrieves all modules for a course
func (*ModulesService) ListItems ¶ added in v1.1.0
func (s *ModulesService) ListItems(ctx context.Context, courseID, moduleID int64, opts *ListModuleItemsOptions) ([]ModuleItem, error)
ListItems retrieves all items for a module
func (*ModulesService) MarkItemDone ¶ added in v1.1.0
func (s *ModulesService) MarkItemDone(ctx context.Context, courseID, moduleID, itemID int64) error
MarkItemDone marks a module item as done
func (*ModulesService) MarkItemNotDone ¶ added in v1.1.0
func (s *ModulesService) MarkItemNotDone(ctx context.Context, courseID, moduleID, itemID int64) error
MarkItemNotDone marks a module item as not done
func (*ModulesService) MarkItemRead ¶ added in v1.1.0
func (s *ModulesService) MarkItemRead(ctx context.Context, courseID, moduleID, itemID int64) error
MarkItemRead marks a module item as read
func (*ModulesService) Update ¶ added in v1.1.0
func (s *ModulesService) Update(ctx context.Context, courseID, moduleID int64, params *UpdateModuleParams) (*Module, error)
Update updates an existing module
func (*ModulesService) UpdateItem ¶ added in v1.1.0
func (s *ModulesService) UpdateItem(ctx context.Context, courseID, moduleID, itemID int64, params *UpdateModuleItemParams) (*ModuleItem, error)
UpdateItem updates an existing module item
type Page ¶ added in v1.1.0
type Page struct {
PageID int64 `json:"page_id"`
URL string `json:"url"`
Title string `json:"title"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
HideFromStudents bool `json:"hide_from_students"`
EditingRoles string `json:"editing_roles"`
LastEditedBy *User `json:"last_edited_by,omitempty"`
Body string `json:"body,omitempty"`
Published bool `json:"published"`
PublishAt *time.Time `json:"publish_at,omitempty"`
FrontPage bool `json:"front_page"`
LockedForUser bool `json:"locked_for_user"`
LockInfo *LockInfo `json:"lock_info,omitempty"`
LockExplanation string `json:"lock_explanation,omitempty"`
Editor string `json:"editor,omitempty"`
BlockEditorAttributes map[string]interface{} `json:"block_editor_attributes,omitempty"`
}
Page represents a Canvas wiki page
type PageRevision ¶ added in v1.1.0
type PageRevision struct {
RevisionID int64 `json:"revision_id"`
UpdatedAt time.Time `json:"updated_at"`
Latest bool `json:"latest"`
EditedBy *User `json:"edited_by,omitempty"`
URL string `json:"url,omitempty"`
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
}
PageRevision represents a revision of a wiki page
type PagesService ¶ added in v1.1.0
type PagesService struct {
// contains filtered or unexported fields
}
PagesService handles page-related API calls
func NewPagesService ¶ added in v1.1.0
func NewPagesService(client *Client) *PagesService
NewPagesService creates a new pages service
func (*PagesService) Create ¶ added in v1.1.0
func (s *PagesService) Create(ctx context.Context, courseID int64, params *CreatePageParams) (*Page, error)
Create creates a new page in a course
func (*PagesService) Duplicate ¶ added in v1.1.0
func (s *PagesService) Duplicate(ctx context.Context, courseID int64, urlOrID string) (*Page, error)
Duplicate duplicates a page
func (*PagesService) GetFrontPage ¶ added in v1.1.0
GetFrontPage retrieves the front page for a course
func (*PagesService) GetLatestRevision ¶ added in v1.1.0
func (s *PagesService) GetLatestRevision(ctx context.Context, courseID int64, urlOrID string, summary bool) (*PageRevision, error)
GetLatestRevision retrieves the latest revision
func (*PagesService) GetRevision ¶ added in v1.1.0
func (s *PagesService) GetRevision(ctx context.Context, courseID int64, urlOrID string, revisionID int64, summary bool) (*PageRevision, error)
GetRevision retrieves a specific revision
func (*PagesService) List ¶ added in v1.1.0
func (s *PagesService) List(ctx context.Context, courseID int64, opts *ListPagesOptions) ([]Page, error)
List retrieves all pages for a course
func (*PagesService) ListRevisions ¶ added in v1.1.0
func (s *PagesService) ListRevisions(ctx context.Context, courseID int64, urlOrID string) ([]PageRevision, error)
ListRevisions retrieves all revisions for a page
func (*PagesService) RevertToRevision ¶ added in v1.1.0
func (s *PagesService) RevertToRevision(ctx context.Context, courseID int64, urlOrID string, revisionID int64) (*PageRevision, error)
RevertToRevision reverts a page to a specific revision
func (*PagesService) Update ¶ added in v1.1.0
func (s *PagesService) Update(ctx context.Context, courseID int64, urlOrID string, params *UpdatePageParams) (*Page, error)
Update updates an existing page
func (*PagesService) UpdateFrontPage ¶ added in v1.1.0
func (s *PagesService) UpdateFrontPage(ctx context.Context, courseID int64, params *UpdatePageParams) (*Page, error)
UpdateFrontPage updates the front page
type PaginationLinks ¶
PaginationLinks represents pagination links from Link header
func ParsePaginationLinks ¶
func ParsePaginationLinks(resp *http.Response) *PaginationLinks
ParsePaginationLinks parses the Link header for pagination
func (*PaginationLinks) HasNextPage ¶
func (p *PaginationLinks) HasNextPage() bool
HasNextPage checks if there is a next page
func (*PaginationLinks) HasPrevPage ¶
func (p *PaginationLinks) HasPrevPage() bool
HasPrevPage checks if there is a previous page
type PlannerItem ¶ added in v1.1.0
type PlannerItem struct {
CourseID *int64 `json:"course_id,omitempty"`
GroupID *int64 `json:"group_id,omitempty"`
UserID *int64 `json:"user_id,omitempty"`
ContextType string `json:"context_type,omitempty"`
ContextName string `json:"context_name,omitempty"`
PlannableType string `json:"plannable_type"`
PlannableID int64 `json:"plannable_id"`
PlannableDate *time.Time `json:"plannable_date,omitempty"`
Submissions interface{} `json:"submissions,omitempty"`
Plannable interface{} `json:"plannable,omitempty"`
HTMLURL string `json:"html_url,omitempty"`
NewActivity bool `json:"new_activity"`
ContextImage string `json:"context_image,omitempty"`
}
PlannerItem represents a planner item (assignment, quiz, calendar event, etc.)
type PlannerNote ¶ added in v1.1.0
type PlannerNote struct {
ID int64 `json:"id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
UserID int64 `json:"user_id"`
CourseID *int64 `json:"course_id,omitempty"`
TodoDate *time.Time `json:"todo_date,omitempty"`
Details string `json:"details,omitempty"`
WorkflowState string `json:"workflow_state"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LinkedObjectType string `json:"linked_object_type,omitempty"`
LinkedObjectID *int64 `json:"linked_object_id,omitempty"`
LinkedObjectHTMLURL string `json:"linked_object_html_url,omitempty"`
LinkedObjectURL string `json:"linked_object_url,omitempty"`
}
PlannerNote represents a planner note
type PlannerOverride ¶ added in v1.1.0
type PlannerOverride struct {
ID int64 `json:"id"`
PlannableType string `json:"plannable_type"`
PlannableID int64 `json:"plannable_id"`
UserID int64 `json:"user_id"`
AssignmentID *int64 `json:"assignment_id,omitempty"`
WorkflowState string `json:"workflow_state"`
MarkedComplete bool `json:"marked_complete"`
Dismissed bool `json:"dismissed"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
PlannerOverride represents a planner override
type PlannerService ¶ added in v1.1.0
type PlannerService struct {
// contains filtered or unexported fields
}
PlannerService handles planner-related API calls
func NewPlannerService ¶ added in v1.1.0
func NewPlannerService(client *Client) *PlannerService
NewPlannerService creates a new planner service
func (*PlannerService) CreateNote ¶ added in v1.1.0
func (s *PlannerService) CreateNote(ctx context.Context, params *CreateNoteParams) (*PlannerNote, error)
CreateNote creates a new planner note
func (*PlannerService) CreateOverride ¶ added in v1.1.0
func (s *PlannerService) CreateOverride(ctx context.Context, params *CreateOverrideParams) (*PlannerOverride, error)
CreateOverride creates a new planner override
func (*PlannerService) DeleteNote ¶ added in v1.1.0
func (s *PlannerService) DeleteNote(ctx context.Context, noteID int64) error
DeleteNote deletes a planner note
func (*PlannerService) DeleteOverride ¶ added in v1.1.0
func (s *PlannerService) DeleteOverride(ctx context.Context, overrideID int64) error
DeleteOverride deletes a planner override
func (*PlannerService) GetNote ¶ added in v1.1.0
func (s *PlannerService) GetNote(ctx context.Context, noteID int64) (*PlannerNote, error)
GetNote retrieves a single planner note
func (*PlannerService) GetOverride ¶ added in v1.1.0
func (s *PlannerService) GetOverride(ctx context.Context, overrideID int64) (*PlannerOverride, error)
GetOverride retrieves a single planner override
func (*PlannerService) ListItems ¶ added in v1.1.0
func (s *PlannerService) ListItems(ctx context.Context, opts *ListPlannerItemsOptions) ([]PlannerItem, error)
ListItems retrieves planner items for the current user
func (*PlannerService) ListNotes ¶ added in v1.1.0
func (s *PlannerService) ListNotes(ctx context.Context, opts *ListPlannerNotesOptions) ([]PlannerNote, error)
ListNotes retrieves planner notes for the current user
func (*PlannerService) ListOverrides ¶ added in v1.1.0
func (s *PlannerService) ListOverrides(ctx context.Context, opts *ListOverridesOptions) ([]PlannerOverride, error)
ListOverrides retrieves planner overrides for the current user
func (*PlannerService) UpdateNote ¶ added in v1.1.0
func (s *PlannerService) UpdateNote(ctx context.Context, noteID int64, params *UpdateNoteParams) (*PlannerNote, error)
UpdateNote updates an existing planner note
func (*PlannerService) UpdateOverride ¶ added in v1.1.0
func (s *PlannerService) UpdateOverride(ctx context.Context, overrideID int64, params *UpdateOverrideParams) (*PlannerOverride, error)
UpdateOverride updates an existing planner override
type Progress ¶
type Progress struct {
RequirementCount int `json:"requirement_count"`
RequirementCompletedCount int `json:"requirement_completed_count"`
NextRequirementURL string `json:"next_requirement_url"`
CompletedAt time.Time `json:"completed_at"`
}
Progress represents course progress
type RateLimitInfo ¶
RateLimitInfo represents rate limit information from response headers
type ReactivateParams ¶
type ReactivateParams struct {
}
ReactivateParams holds parameters for reactivating an enrollment
type RejectParams ¶
type RejectParams struct {
}
RejectParams holds parameters for rejecting an enrollment invitation
type RetryPolicy ¶
type RetryPolicy struct {
MaxRetries int
InitialBackoff time.Duration
MaxBackoff time.Duration
Logger *slog.Logger
}
RetryPolicy defines retry behavior for HTTP requests
func DefaultRetryPolicy ¶
func DefaultRetryPolicy() *RetryPolicy
DefaultRetryPolicy returns the default retry policy
func (*RetryPolicy) ExecuteWithRetry ¶
func (p *RetryPolicy) ExecuteWithRetry(ctx context.Context, fn func() (*http.Response, error)) (*http.Response, error)
ExecuteWithRetry executes a function with retry logic
func (*RetryPolicy) GetBackoff ¶
func (p *RetryPolicy) GetBackoff(attempt int) time.Duration
GetBackoff calculates the backoff duration for a given attempt
func (*RetryPolicy) ShouldRetry ¶
func (p *RetryPolicy) ShouldRetry(resp *http.Response, err error) bool
ShouldRetry determines if a request should be retried based on the response
type RubricAssessment ¶
type RubricAssessment struct {
CriterionID string `json:"criterion_id"`
Points float64 `json:"points"`
Comments string `json:"comments"`
RatingID string `json:"rating_id"`
}
RubricAssessment represents a rubric assessment
type RubricAssessmentParams ¶
RubricAssessmentParams holds parameters for rubric assessment
type RubricCriterion ¶
type RubricCriterion struct {
ID string `json:"id"`
Description string `json:"description"`
LongDescription string `json:"long_description"`
Points float64 `json:"points"`
CriterionUseRange bool `json:"criterion_use_range"`
Ratings []RubricRating `json:"ratings"`
}
RubricCriterion represents a rubric criterion
type RubricRating ¶
type RubricRating struct {
ID string `json:"id"`
Description string `json:"description"`
LongDescription string `json:"long_description"`
Points float64 `json:"points"`
}
RubricRating represents a rubric rating
type SectionGradingCount ¶
type SectionGradingCount struct {
SectionID int64 `json:"section_id"`
NeedsGradingCount int `json:"needs_grading_count"`
}
SectionGradingCount represents grading count by section
type Submission ¶
type Submission struct {
ID int64 `json:"id"`
Body string `json:"body"`
URL string `json:"url"`
Grade string `json:"grade"`
Score float64 `json:"score"`
SubmittedAt time.Time `json:"submitted_at"`
AssignmentID int64 `json:"assignment_id"`
UserID int64 `json:"user_id"`
SubmissionType string `json:"submission_type"`
WorkflowState string `json:"workflow_state"`
GradeMatchesCurrentSubmission bool `json:"grade_matches_current_submission"`
GradedAt time.Time `json:"graded_at"`
GraderID int64 `json:"grader_id"`
Attempt int `json:"attempt"`
CachedDueDate time.Time `json:"cached_due_date"`
ExcusedTLN bool `json:"excused"`
LatePolicyStatus string `json:"late_policy_status"`
PointsDeducted float64 `json:"points_deducted"`
GradingPeriodID int64 `json:"grading_period_id"`
ExtraAttempts int `json:"extra_attempts"`
PostedAt time.Time `json:"posted_at"`
Late bool `json:"late"`
Missing bool `json:"missing"`
SecondsLate int `json:"seconds_late"`
EnteredGrade string `json:"entered_grade"`
EnteredScore float64 `json:"entered_score"`
PreviewURL string `json:"preview_url"`
AnonymousID string `json:"anonymous_id"`
User *User `json:"user,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
SubmissionComments []SubmissionComment `json:"submission_comments,omitempty"`
Assignment *Assignment `json:"assignment,omitempty"`
Course *Course `json:"course,omitempty"`
Rubric []RubricAssessment `json:"rubric_assessment,omitempty"`
}
Submission represents a Canvas submission
func NormalizeSubmission ¶
func NormalizeSubmission(submission *Submission) *Submission
NormalizeSubmission ensures consistent data structure for a submission
func NormalizeSubmissions ¶
func NormalizeSubmissions(submissions []Submission) []Submission
NormalizeSubmissions normalizes a slice of submissions
type SubmissionComment ¶
type SubmissionComment struct {
ID int64 `json:"id"`
AuthorID int64 `json:"author_id"`
AuthorName string `json:"author_name"`
Author *User `json:"author,omitempty"`
Comment string `json:"comment"`
CreatedAt time.Time `json:"created_at"`
EditedAt time.Time `json:"edited_at"`
MediaComment *MediaComment `json:"media_comment,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
}
SubmissionComment represents a comment on a submission
type SubmissionCommentParams ¶
type SubmissionCommentParams struct {
TextComment string
GroupComment bool
MediaCommentID string
MediaCommentType string
FileIDs []int64
}
SubmissionCommentParams holds parameters for adding a submission comment
type SubmissionsService ¶
type SubmissionsService struct {
// contains filtered or unexported fields
}
SubmissionsService handles submission-related API calls
func NewSubmissionsService ¶
func NewSubmissionsService(client *Client) *SubmissionsService
NewSubmissionsService creates a new submissions service
func (*SubmissionsService) BulkGrade ¶
func (s *SubmissionsService) BulkGrade(ctx context.Context, courseID, assignmentID int64, params *BulkGradeParams) ([]Submission, error)
BulkGrade grades multiple submissions at once
func (*SubmissionsService) Get ¶
func (s *SubmissionsService) Get(ctx context.Context, courseID, assignmentID, userID int64, include []string) (*Submission, error)
Get retrieves a single submission
func (*SubmissionsService) Grade ¶
func (s *SubmissionsService) Grade(ctx context.Context, courseID, assignmentID, userID int64, params *GradeSubmissionParams) (*Submission, error)
Grade grades a submission
func (*SubmissionsService) InitiateFileUpload ¶
func (s *SubmissionsService) InitiateFileUpload(ctx context.Context, courseID, assignmentID int64, params *UploadFileParams) (map[string]interface{}, error)
InitiateFileUpload initiates a file upload for submission
func (*SubmissionsService) List ¶
func (s *SubmissionsService) List(ctx context.Context, courseID, assignmentID int64, opts *ListSubmissionsOptions) ([]Submission, error)
List retrieves all submissions for an assignment
func (*SubmissionsService) ListMultiple ¶
func (s *SubmissionsService) ListMultiple(ctx context.Context, courseID int64, studentIDs, assignmentIDs []int64, opts *ListSubmissionsOptions) ([]Submission, error)
ListMultiple retrieves submissions for multiple assignments and users
func (*SubmissionsService) MarkAsRead ¶
func (s *SubmissionsService) MarkAsRead(ctx context.Context, courseID, assignmentID, userID int64) error
MarkAsRead marks a submission as read
func (*SubmissionsService) MarkAsUnread ¶
func (s *SubmissionsService) MarkAsUnread(ctx context.Context, courseID, assignmentID, userID int64) error
MarkAsUnread marks a submission as unread
func (*SubmissionsService) Submit ¶
func (s *SubmissionsService) Submit(ctx context.Context, courseID, assignmentID int64, params *SubmitParams) (*Submission, error)
Submit submits an assignment
type SubmitParams ¶
type SubmitParams struct {
SubmissionType string // online_text_entry, online_url, online_upload, media_recording
Body string // For online_text_entry
URL string // For online_url
FileIDs []int64 // For online_upload
MediaCommentID string // For media_recording
MediaCommentType string // audio or video
UserID int64 // Submit on behalf of user (requires permission)
Comment *SubmissionCommentParams
}
SubmitParams holds parameters for submitting an assignment
type Term ¶
type Term struct {
ID int64 `json:"id"`
Name string `json:"name"`
StartAt time.Time `json:"start_at"`
EndAt time.Time `json:"end_at"`
CreatedAt time.Time `json:"created_at"`
WorkflowState string `json:"workflow_state"`
GradingPeriodGroupID int64 `json:"grading_period_group_id"`
SISTermID string `json:"sis_term_id"`
SISImportID int64 `json:"sis_import_id"`
Overrides map[string]TermOverride `json:"overrides,omitempty"`
}
Term represents a Canvas enrollment term
func NormalizeTerm ¶
NormalizeTerm ensures consistent data structure for a term
type TermOverride ¶
TermOverride represents date overrides for a term
type UpdateAssignmentParams ¶
type UpdateAssignmentParams struct {
Name string
Position *int
SubmissionTypes []string
AllowedExtensions []string
TurnitinEnabled *bool
VericiteEnabled *bool
TurnitinSettings map[string]interface{}
IntegrationData map[string]interface{}
IntegrationID string
PeerReviews *bool
AutomaticPeerReviews *bool
NotifyOfUpdate *bool
GroupCategoryID *int64
GradeGroupStudentsIndividually *bool
ExternalToolTagAttributes map[string]interface{}
PointsPossible *float64
GradingType string
DueAt *string
LockAt *string
UnlockAt *string
Description string
AssignmentGroupID *int64
AssignmentOverrides []AssignmentOverrideParams
OnlyVisibleToOverrides *bool
Published *bool
GradingStandardID *int64
OmitFromFinalGrade *bool
ModeratedGrading *bool
GraderCount *int
FinalGraderID *int64
GraderCommentsVisibleToGraders *bool
GradersAnonymousToGraders *bool
GraderNamesVisibleToFinalGrader *bool
AnonymousInstructorAnnotations *bool
AnonymousGrading *bool
AllowedAttempts *int
AnnotatableAttachmentID *int64
HideInGradebook *bool
PostToSIS *bool
ImportantDates *bool
}
UpdateAssignmentParams holds parameters for updating an assignment
type UpdateCalendarEventParams ¶ added in v1.1.0
type UpdateCalendarEventParams struct {
ContextCode *string
Title *string
Description *string
StartAt *string
EndAt *string
LocationName *string
LocationAddress *string
TimeZoneEdited *string
AllDay *bool
RRule *string
BlackoutDate *bool
Which string // one, all, following (for series)
}
UpdateCalendarEventParams holds parameters for updating a calendar event
type UpdateCourseParams ¶
type UpdateCourseParams struct {
Name string
CourseCode string
StartAt string
EndAt string
License string
IsPublic *bool
IsPublicToAuthUsers *bool
PublicSyllabus *bool
PublicSyllabusToAuth *bool
PublicDescription string
AllowStudentWikiEdits *bool
AllowWikiComments *bool
AllowStudentForumAttachments *bool
OpenEnrollment *bool
SelfEnrollment *bool
RestrictEnrollmentsToCourseDates *bool
HideFinalGrades *bool
ApplyAssignmentGroupWeights *bool
TimeZone string
DefaultView string
SyllabusBody string
GradingStandardID int64
CourseFormat string
ImageID int64
ImageURL string
RemoveImage bool
}
UpdateCourseParams holds parameters for updating a course
type UpdateDiscussionParams ¶ added in v1.1.0
type UpdateDiscussionParams struct {
Title *string
Message *string
DiscussionType *string
Published *bool
DelayedPostAt *string
AllowRating *bool
LockAt *string
PodcastEnabled *bool
RequireInitialPost *bool
Pinned *bool
Locked *bool
}
UpdateDiscussionParams holds parameters for updating a discussion
type UpdateModuleItemParams ¶ added in v1.1.0
type UpdateModuleItemParams struct {
Title *string
Position *int
Indent *int
ExternalURL *string
NewTab *bool
CompletionRequirement *CompletionRequirementParams
Published *bool
MoveToModuleID *int64
}
UpdateModuleItemParams holds parameters for updating a module item
type UpdateModuleParams ¶ added in v1.1.0
type UpdateModuleParams struct {
Name *string
UnlockAt *string
Position *int
RequireSequentialProgress *bool
PrerequisiteModuleIDs []int64
PublishFinalGrade *bool
Published *bool
}
UpdateModuleParams holds parameters for updating a module
type UpdateNoteParams ¶ added in v1.1.0
UpdateNoteParams holds parameters for updating a planner note
type UpdateOverrideParams ¶ added in v1.1.0
UpdateOverrideParams holds parameters for updating a planner override
type UpdatePageParams ¶ added in v1.1.0
type UpdatePageParams struct {
Title *string
Body *string
EditingRoles *string
NotifyOfUpdate *bool
Published *bool
FrontPage *bool
PublishAt *string
}
UpdatePageParams holds parameters for updating a page
type UpdateParams ¶
type UpdateParams struct {
Name string // New file name
ParentFolderID *int64 // Move to different folder
LockAt *string // ISO8601 date
UnlockAt *string // ISO8601 date
Locked *bool
Hidden *bool
}
UpdateParams holds parameters for updating a file
type UpdateUserParams ¶
type UpdateUserParams struct {
Name string
ShortName string
SortableName string
TimeZone string
Locale string
Email string
Avatar *AvatarParams
}
UpdateUserParams holds parameters for updating a user
type UploadFileParams ¶
type UploadFileParams struct {
Name string
Size int64
ContentType string
OnDuplicate string // overwrite, rename
}
UploadFileParams holds parameters for uploading a file
type UploadParams ¶
type UploadParams struct {
Name string // File name
Size int64 // File size in bytes (required for Canvas)
ContentType string // MIME type
ParentFolderID int64 // Folder to upload to
OnDuplicate string // How to handle duplicates: overwrite, rename
LockAt string // ISO8601 date
UnlockAt string // ISO8601 date
Locked bool // Lock the file
Hidden bool // Hide from students
}
UploadParams holds parameters for uploading a file
type User ¶
type User struct {
ID int64 `json:"id"`
Name string `json:"name"`
SortableName string `json:"sortable_name"`
ShortName string `json:"short_name"`
SisUserID string `json:"sis_user_id"`
SisImportID int64 `json:"sis_import_id"`
IntegrationID string `json:"integration_id"`
LoginID string `json:"login_id"`
AvatarURL string `json:"avatar_url"`
Enrollments []Enrollment `json:"enrollments,omitempty"`
Email string `json:"email"`
Locale string `json:"locale"`
LastLogin time.Time `json:"last_login"`
TimeZone string `json:"time_zone"`
Bio string `json:"bio"`
}
User represents a Canvas user
func NormalizeUser ¶
NormalizeUser ensures consistent data structure for a user
func NormalizeUsers ¶
NormalizeUsers normalizes a slice of users
type UsersService ¶
type UsersService struct {
// contains filtered or unexported fields
}
UsersService handles user-related API calls
func NewUsersService ¶
func NewUsersService(client *Client) *UsersService
NewUsersService creates a new users service
func (*UsersService) Create ¶
func (s *UsersService) Create(ctx context.Context, accountID int64, params *CreateUserParams) (*User, error)
Create creates a new user
func (*UsersService) Delete ¶
func (s *UsersService) Delete(ctx context.Context, accountID, userID int64) error
Delete deletes/suspends a user
func (*UsersService) GetCurrentUser ¶
func (s *UsersService) GetCurrentUser(ctx context.Context) (*User, error)
GetCurrentUser retrieves the current authenticated user
func (*UsersService) List ¶
func (s *UsersService) List(ctx context.Context, accountID int64, opts *ListUsersOptions) ([]User, error)
List retrieves users for an account
func (*UsersService) ListCourseUsers ¶
func (s *UsersService) ListCourseUsers(ctx context.Context, courseID int64, opts *ListUsersOptions) ([]User, error)
ListCourseUsers retrieves users enrolled in a course
func (*UsersService) Update ¶
func (s *UsersService) Update(ctx context.Context, userID int64, params *UpdateUserParams) (*User, error)
Update updates an existing user