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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
use octocrate_core::*;
#[allow(unused_imports)]
use octocrate_types::*;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[allow(unused_imports)]
use typed_builder::TypedBuilder;
pub mod get_an_assignment {
#[allow(unused_imports)]
use super::*;
pub type Response = ClassroomAssignment;
}
pub mod list_accepted_assigments_for_an_assignment {
#[allow(unused_imports)]
use super::*;
pub type Response = Vec<ClassroomAcceptedAssignment>;
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
#[builder(field_defaults(setter(into)))]
pub struct Query {
/// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub page: Option<i64>,
/// The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub per_page: Option<i64>,
}
}
pub mod get_assignment_grades {
#[allow(unused_imports)]
use super::*;
pub type Response = Vec<ClassroomAssignmentGrade>;
}
pub mod list_classrooms {
#[allow(unused_imports)]
use super::*;
pub type Response = Vec<SimpleClassroom>;
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
#[builder(field_defaults(setter(into)))]
pub struct Query {
/// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub page: Option<i64>,
/// The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub per_page: Option<i64>,
}
}
pub mod get_a_classroom {
#[allow(unused_imports)]
use super::*;
pub type Response = Classroom;
}
pub mod list_assignments_for_a_classroom {
#[allow(unused_imports)]
use super::*;
pub type Response = Vec<SimpleClassroomAssignment>;
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
#[builder(field_defaults(setter(into)))]
pub struct Query {
/// The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub page: Option<i64>,
/// The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub per_page: Option<i64>,
}
}
/// Interact with GitHub Classroom.
pub struct GitHubClassroomAPI {
config: SharedAPIConfig,
}
impl GitHubClassroomAPI {
pub fn new(config: &SharedAPIConfig) -> Self {
Self {
config: config.clone(),
}
}
/// **Get an assignment**
///
/// Gets a GitHub Classroom assignment. Assignment will only be returned if the current user is an administrator of the GitHub Classroom for the assignment.
///
/// *Documentation*: [https://docs.github.com/rest/classroom/classroom#get-an-assignment](https://docs.github.com/rest/classroom/classroom#get-an-assignment)
pub fn get_an_assignment(
&self,
assignment_id: impl Into<i64>,
) -> Request<(), (), get_an_assignment::Response> {
let assignment_id = assignment_id.into();
let url = format!("/assignments/{assignment_id}");
Request::<(), (), get_an_assignment::Response>::builder(&self.config)
.get(url)
.build()
}
/// **List accepted assignments for an assignment**
///
/// Lists any assignment repositories that have been created by students accepting a GitHub Classroom assignment. Accepted assignments will only be returned if the current user is an administrator of the GitHub Classroom for the assignment.
///
/// *Documentation*: [https://docs.github.com/rest/classroom/classroom#list-accepted-assignments-for-an-assignment](https://docs.github.com/rest/classroom/classroom#list-accepted-assignments-for-an-assignment)
pub fn list_accepted_assigments_for_an_assignment(
&self,
assignment_id: impl Into<i64>,
) -> Request<
(),
list_accepted_assigments_for_an_assignment::Query,
list_accepted_assigments_for_an_assignment::Response,
> {
let assignment_id = assignment_id.into();
let url = format!("/assignments/{assignment_id}/accepted_assignments");
Request::<
(),
list_accepted_assigments_for_an_assignment::Query,
list_accepted_assigments_for_an_assignment::Response,
>::builder(&self.config)
.get(url)
.build()
}
/// **Get assignment grades**
///
/// Gets grades for a GitHub Classroom assignment. Grades will only be returned if the current user is an administrator of the GitHub Classroom for the assignment.
///
/// *Documentation*: [https://docs.github.com/rest/classroom/classroom#get-assignment-grades](https://docs.github.com/rest/classroom/classroom#get-assignment-grades)
pub fn get_assignment_grades(
&self,
assignment_id: impl Into<i64>,
) -> Request<(), (), get_assignment_grades::Response> {
let assignment_id = assignment_id.into();
let url = format!("/assignments/{assignment_id}/grades");
Request::<(), (), get_assignment_grades::Response>::builder(&self.config)
.get(url)
.build()
}
/// **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.
///
/// *Documentation*: [https://docs.github.com/rest/classroom/classroom#list-classrooms](https://docs.github.com/rest/classroom/classroom#list-classrooms)
pub fn list_classrooms(&self) -> Request<(), list_classrooms::Query, list_classrooms::Response> {
let url = format!("/classrooms");
Request::<(), list_classrooms::Query, list_classrooms::Response>::builder(&self.config)
.get(url)
.build()
}
/// **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.
///
/// *Documentation*: [https://docs.github.com/rest/classroom/classroom#get-a-classroom](https://docs.github.com/rest/classroom/classroom#get-a-classroom)
pub fn get_a_classroom(
&self,
classroom_id: impl Into<i64>,
) -> Request<(), (), get_a_classroom::Response> {
let classroom_id = classroom_id.into();
let url = format!("/classrooms/{classroom_id}");
Request::<(), (), get_a_classroom::Response>::builder(&self.config)
.get(url)
.build()
}
/// **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.
///
/// *Documentation*: [https://docs.github.com/rest/classroom/classroom#list-assignments-for-a-classroom](https://docs.github.com/rest/classroom/classroom#list-assignments-for-a-classroom)
pub fn list_assignments_for_a_classroom(
&self,
classroom_id: impl Into<i64>,
) -> Request<
(),
list_assignments_for_a_classroom::Query,
list_assignments_for_a_classroom::Response,
> {
let classroom_id = classroom_id.into();
let url = format!("/classrooms/{classroom_id}/assignments");
Request::<(), list_assignments_for_a_classroom::Query, list_assignments_for_a_classroom::Response>::builder(&self.config)
.get(url)
.build()
}
}