pub struct Canvas { /* private fields */ }Expand description
The Canvas LMS API client. All interaction starts here.
§Example
let canvas = canvas_lms_api::Canvas::new("https://canvas.example.edu", "my-token")?;
let course = canvas.get_course(1).await?;
println!("{}", course.name.unwrap_or_default());Implementations§
Source§impl Canvas
impl Canvas
Sourcepub fn new(base_url: &str, access_token: &str) -> Result<Self>
pub fn new(base_url: &str, access_token: &str) -> Result<Self>
Create a new Canvas client.
base_url should be the institution root (e.g. https://canvas.example.edu),
not including /api/v1.
Sourcepub fn with_client(
base_url: &str,
access_token: &str,
client: Client,
) -> Result<Self>
pub fn with_client( base_url: &str, access_token: &str, client: Client, ) -> Result<Self>
Create a Canvas client with a custom reqwest::Client (for proxy, TLS config, etc.).
Sourcepub async fn get_course(&self, course_id: u64) -> Result<Course>
pub async fn get_course(&self, course_id: u64) -> Result<Course>
Sourcepub fn get_courses(&self) -> PageStream<Course>
pub fn get_courses(&self) -> PageStream<Course>
Sourcepub async fn create_course(
&self,
account_id: u64,
params: CreateCourseParams,
) -> Result<Course>
pub async fn create_course( &self, account_id: u64, params: CreateCourseParams, ) -> Result<Course>
Sourcepub async fn delete_course(&self, course_id: u64) -> Result<Course>
pub async fn delete_course(&self, course_id: u64) -> Result<Course>
Delete a course by ID. Canvas returns the deleted course object.
§Canvas API
DELETE /api/v1/courses/:id
Sourcepub async fn get_user(&self, user_id: UserId) -> Result<User>
pub async fn get_user(&self, user_id: UserId) -> Result<User>
Fetch a single user by ID or UserId::Current for the authenticated user.
§Canvas API
GET /api/v1/users/:id
Sourcepub async fn get_current_user(&self) -> Result<CurrentUser>
pub async fn get_current_user(&self) -> Result<CurrentUser>
Sourcepub async fn create_user(
&self,
account_id: u64,
params: CreateUserParams,
) -> Result<User>
pub async fn create_user( &self, account_id: u64, params: CreateUserParams, ) -> Result<User>
Sourcepub async fn get_account(&self, account_id: u64) -> Result<Account>
pub async fn get_account(&self, account_id: u64) -> Result<Account>
Sourcepub async fn get_outcome(&self, outcome_id: u64) -> Result<Outcome>
pub async fn get_outcome(&self, outcome_id: u64) -> Result<Outcome>
Sourcepub fn get_accounts(&self) -> PageStream<Account>
pub fn get_accounts(&self) -> PageStream<Account>
Sourcepub async fn get_section(&self, section_id: u64) -> Result<Section>
pub async fn get_section(&self, section_id: u64) -> Result<Section>
Sourcepub async fn get_folder(&self, folder_id: u64) -> Result<Folder>
pub async fn get_folder(&self, folder_id: u64) -> Result<Folder>
Sourcepub async fn get_progress(&self, progress_id: u64) -> Result<Progress>
pub async fn get_progress(&self, progress_id: u64) -> Result<Progress>
Sourcepub async fn get_conversation(
&self,
conversation_id: u64,
) -> Result<Conversation>
pub async fn get_conversation( &self, conversation_id: u64, ) -> Result<Conversation>
Sourcepub fn get_conversations(&self) -> PageStream<Conversation>
pub fn get_conversations(&self) -> PageStream<Conversation>
Sourcepub async fn create_conversation(
&self,
recipients: &[&str],
body: &str,
params: ConversationParams,
) -> Result<Conversation>
pub async fn create_conversation( &self, recipients: &[&str], body: &str, params: ConversationParams, ) -> Result<Conversation>
Sourcepub async fn get_calendar_event(&self, event_id: u64) -> Result<CalendarEvent>
pub async fn get_calendar_event(&self, event_id: u64) -> Result<CalendarEvent>
Sourcepub fn get_calendar_events(&self) -> PageStream<CalendarEvent>
pub fn get_calendar_events(&self) -> PageStream<CalendarEvent>
Stream all calendar events visible to the authenticated user.
§Canvas API
GET /api/v1/calendar_events
Sourcepub async fn create_calendar_event(
&self,
context_code: &str,
params: CalendarEventParams,
) -> Result<CalendarEvent>
pub async fn create_calendar_event( &self, context_code: &str, params: CalendarEventParams, ) -> Result<CalendarEvent>
Sourcepub async fn get_planner_note(&self, note_id: u64) -> Result<PlannerNote>
pub async fn get_planner_note(&self, note_id: u64) -> Result<PlannerNote>
Sourcepub fn get_planner_notes(&self) -> PageStream<PlannerNote>
pub fn get_planner_notes(&self) -> PageStream<PlannerNote>
Sourcepub async fn create_planner_note(
&self,
params: PlannerNoteParams,
) -> Result<PlannerNote>
pub async fn create_planner_note( &self, params: PlannerNoteParams, ) -> Result<PlannerNote>
Sourcepub async fn get_planner_override(
&self,
override_id: u64,
) -> Result<PlannerOverride>
pub async fn get_planner_override( &self, override_id: u64, ) -> Result<PlannerOverride>
Sourcepub fn get_planner_overrides(&self) -> PageStream<PlannerOverride>
pub fn get_planner_overrides(&self) -> PageStream<PlannerOverride>
Sourcepub async fn create_planner_override(
&self,
plannable_type: &str,
plannable_id: u64,
) -> Result<PlannerOverride>
pub async fn create_planner_override( &self, plannable_type: &str, plannable_id: u64, ) -> Result<PlannerOverride>
Sourcepub async fn get_eportfolio(&self, eportfolio_id: u64) -> Result<EPortfolio>
pub async fn get_eportfolio(&self, eportfolio_id: u64) -> Result<EPortfolio>
Sourcepub async fn get_appointment_group(
&self,
group_id: u64,
) -> Result<AppointmentGroup>
pub async fn get_appointment_group( &self, group_id: u64, ) -> Result<AppointmentGroup>
Sourcepub fn get_appointment_groups(&self) -> PageStream<AppointmentGroup>
pub fn get_appointment_groups(&self) -> PageStream<AppointmentGroup>
Stream all appointment groups visible to the authenticated user.
§Canvas API
GET /api/v1/appointment_groups
Sourcepub async fn create_appointment_group(
&self,
params: AppointmentGroupParams,
) -> Result<AppointmentGroup>
pub async fn create_appointment_group( &self, params: AppointmentGroupParams, ) -> Result<AppointmentGroup>
Sourcepub fn get_polls(&self) -> PageStream<Poll>
pub fn get_polls(&self) -> PageStream<Poll>
Sourcepub async fn create_poll(&self, params: CreatePollParams) -> Result<Poll>
pub async fn create_poll(&self, params: CreatePollParams) -> Result<Poll>
Sourcepub async fn create_jwt(&self) -> Result<CanvasJwt>
pub async fn create_jwt(&self) -> Result<CanvasJwt>
Auto Trait Implementations§
impl Freeze for Canvas
impl !RefUnwindSafe for Canvas
impl Send for Canvas
impl Sync for Canvas
impl Unpin for Canvas
impl UnsafeUnpin for Canvas
impl !UnwindSafe for Canvas
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more