1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use crate::models::ClassroomId;
use crate::Octocrab;
#[derive(serde::Serialize)]
pub struct ClassroomHandler<'octo> {
#[serde(skip)]
crab: &'octo Octocrab,
#[serde(skip_serializing_if = "Option::is_none")]
per_page: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none")]
page: Option<u32>,
}
impl<'octo> ClassroomHandler<'octo> {
pub fn new(crab: &'octo Octocrab) -> Self {
Self {
crab,
per_page: None,
page: None,
}
}
/// Results per page (max 100).
pub fn per_page(mut self, per_page: impl Into<u8>) -> Self {
self.per_page = Some(per_page.into());
self
}
/// Page number of the results to fetch.
pub fn page(mut self, page: impl Into<u32>) -> Self {
self.page = Some(page.into());
self
}
/// ### List classrooms
///
/// Lists GitHub Classroom classrooms for the current user. Classrooms will only be returned if the current user is an administrator of one or more GitHub Classrooms.
///
/// Fine-grained access tokens for "List classrooms"
///
/// This endpoint works with the following fine-grained token types:
///
/// - GitHub App user access tokens
/// - Fine-grained personal access tokens
///
/// The fine-grained token does not require any permissions.
///
/// This endpoint can be used without authentication if only public resources are requested.
///
/// # Examples
///
/// ```no_run
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let classrooms = octocrab.classrooms().list_classrooms().await?;
/// # Ok(())
/// # }
/// ```
pub async fn list_classrooms(&self) -> crate::Result<Vec<crate::models::classroom::Classroom>> {
let route = String::from("/classrooms");
self.crab.get(route, Some(&self)).await
}
/// ### Get a classroom
///
/// Gets a GitHub Classroom classroom for the current user. Classroom will only be returned if the current user is an administrator of the GitHub Classroom.
///
/// Fine-grained access tokens for "Get a classroom"
///
/// This endpoint works with the following fine-grained token types:
///
/// - GitHub App user access tokens
/// - Fine-grained personal access tokens
///
/// The fine-grained token does not require any permissions.
///
/// This endpoint can be used without authentication if only public resources are requested.
///
/// # Examples
///
/// ```no_run
/// # use octocrab::models::ClassroomId;
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let classroom = octocrab.classrooms().get_classroom(ClassroomId(1)).await?;
/// # Ok(())
/// # }
/// ```
pub async fn get_classroom(
&self,
classroom_id: ClassroomId,
) -> crate::Result<crate::models::classroom::Classroom> {
let route = format!("/classrooms/{}", classroom_id);
self.crab.get(route, Some(&self)).await
}
/// ### List assignments for a classroom
///
/// Lists GitHub Classroom assignments for a classroom. Assignments will only be returned if the current user is an administrator of the GitHub Classroom.
///
/// Fine-grained access tokens for "List assignments for a classroom"
///
/// This endpoint works with the following fine-grained token types:
///
/// - GitHub App user access tokens
/// - Fine-grained personal access tokens
///
/// The fine-grained token does not require any permissions.
///
/// This endpoint can be used without authentication if only public resources are requested.
///
/// # Examples
///
/// ```no_run
/// # use octocrab::models::ClassroomId;
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let assignments = octocrab.classrooms().list_assignments(ClassroomId(1)).await?;
/// # Ok(())
/// # }
/// ```
pub async fn list_assignments(
&self,
classroom_id: ClassroomId,
) -> crate::Result<Vec<crate::models::classroom::SimpleAssignment>> {
let route = format!("/classrooms/{}/assignments", classroom_id);
self.crab.get(route, Some(&self)).await
}
}