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
use crate::models::AssignmentId;
use crate::{models, Octocrab};
#[derive(serde::Serialize)]
pub struct AssignmentsHandler<'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> AssignmentsHandler<'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
}
/// ### Gets a GitHub Classroom assignment.
///
/// Assignment will only be returned if the current user is an administrator of the GitHub Classroom for the assignment.
/// 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.
///
/// ```no_run
/// # use octocrab::models::AssignmentId;
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let assignment_id: AssignmentId = 42.into();
/// let result = octocrab
/// .assignments()
/// .get(assignment_id.into())
/// .await;
/// # Ok(())
/// # }
/// ```
pub async fn get(
&self,
assignment_id: AssignmentId,
) -> crate::Result<models::classroom::Assignment> {
let route = format!("/assignments/{}", assignment_id);
self.crab.get(route, Some(&self)).await
}
/// ### 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.
///
/// Fine-grained access tokens for "List accepted assignments for an assignment"
///
/// 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::AssignmentId;
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let accepted = octocrab
/// .assignments()
/// .list_accepted(AssignmentId(42))
/// .await?;
/// # Ok(())
/// # }
/// ```
pub async fn list_accepted(
&self,
assignment_id: AssignmentId,
) -> crate::Result<Vec<models::classroom::AcceptedAssignment>> {
let route = format!("/assignments/{assignment_id}/accepted_assignments");
self.crab.get(route, Some(&self)).await
}
/// ### 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.
///
/// Fine-grained access tokens for "Get assignment grades"
///
/// 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::AssignmentId;
/// # async fn run(octocrab: &octocrab::Octocrab) -> octocrab::Result<()> {
/// let grades = octocrab
/// .assignments()
/// .get_grades(AssignmentId(42))
/// .await?;
/// # Ok(())
/// # }
/// ```
pub async fn get_grades(
&self,
assignment_id: AssignmentId,
) -> crate::Result<Vec<models::classroom::AssignmentGrade>> {
let route = format!("/assignments/{assignment_id}/grades");
self.crab.get(route, Some(&self)).await
}
}