google_classroom1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See and update its own attachments to posts in Google Classroom
17 AddonStudent,
18
19 /// See, create, and update its own attachments to posts in classes you teach in Google Classroom
20 AddonTeacher,
21
22 /// View and manage announcements in Google Classroom
23 Announcement,
24
25 /// View announcements in Google Classroom
26 AnnouncementReadonly,
27
28 /// See, edit, create, and permanently delete your Google Classroom classes
29 Course,
30
31 /// View your Google Classroom classes
32 CourseReadonly,
33
34 /// See, create and edit coursework items including assignments, questions, and grades
35 CourseworkMe,
36
37 /// View your course work and grades in Google Classroom
38 CourseworkMeReadonly,
39
40 /// Manage course work and grades for students in the Google Classroom classes you teach and view the course work and grades for classes you administer
41 CourseworkStudent,
42
43 /// View course work and grades for students in the Google Classroom classes you teach or administer
44 CourseworkStudentReadonly,
45
46 /// See, edit, and create classwork materials in Google Classroom
47 Courseworkmaterial,
48
49 /// See all classwork materials for your Google Classroom classes
50 CourseworkmaterialReadonly,
51
52 /// View your Google Classroom guardians
53 GuardianlinkMeReadonly,
54
55 /// View and manage guardians for students in your Google Classroom classes
56 GuardianlinkStudent,
57
58 /// View guardians for students in your Google Classroom classes
59 GuardianlinkStudentReadonly,
60
61 /// View the email addresses of people in your classes
62 ProfileEmail,
63
64 /// View the profile photos of people in your classes
65 ProfilePhoto,
66
67 /// Receive notifications about your Google Classroom data
68 PushNotification,
69
70 /// Manage your Google Classroom class rosters
71 Roster,
72
73 /// View your Google Classroom class rosters
74 RosterReadonly,
75
76 /// View your course work and grades in Google Classroom
77 StudentSubmissionMeReadonly,
78
79 /// View course work and grades for students in the Google Classroom classes you teach or administer
80 StudentSubmissionStudentReadonly,
81
82 /// See, create, and edit topics in Google Classroom
83 Topic,
84
85 /// View topics in Google Classroom
86 TopicReadonly,
87}
88
89impl AsRef<str> for Scope {
90 fn as_ref(&self) -> &str {
91 match *self {
92 Scope::AddonStudent => "https://www.googleapis.com/auth/classroom.addons.student",
93 Scope::AddonTeacher => "https://www.googleapis.com/auth/classroom.addons.teacher",
94 Scope::Announcement => "https://www.googleapis.com/auth/classroom.announcements",
95 Scope::AnnouncementReadonly => {
96 "https://www.googleapis.com/auth/classroom.announcements.readonly"
97 }
98 Scope::Course => "https://www.googleapis.com/auth/classroom.courses",
99 Scope::CourseReadonly => "https://www.googleapis.com/auth/classroom.courses.readonly",
100 Scope::CourseworkMe => "https://www.googleapis.com/auth/classroom.coursework.me",
101 Scope::CourseworkMeReadonly => {
102 "https://www.googleapis.com/auth/classroom.coursework.me.readonly"
103 }
104 Scope::CourseworkStudent => {
105 "https://www.googleapis.com/auth/classroom.coursework.students"
106 }
107 Scope::CourseworkStudentReadonly => {
108 "https://www.googleapis.com/auth/classroom.coursework.students.readonly"
109 }
110 Scope::Courseworkmaterial => {
111 "https://www.googleapis.com/auth/classroom.courseworkmaterials"
112 }
113 Scope::CourseworkmaterialReadonly => {
114 "https://www.googleapis.com/auth/classroom.courseworkmaterials.readonly"
115 }
116 Scope::GuardianlinkMeReadonly => {
117 "https://www.googleapis.com/auth/classroom.guardianlinks.me.readonly"
118 }
119 Scope::GuardianlinkStudent => {
120 "https://www.googleapis.com/auth/classroom.guardianlinks.students"
121 }
122 Scope::GuardianlinkStudentReadonly => {
123 "https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly"
124 }
125 Scope::ProfileEmail => "https://www.googleapis.com/auth/classroom.profile.emails",
126 Scope::ProfilePhoto => "https://www.googleapis.com/auth/classroom.profile.photos",
127 Scope::PushNotification => {
128 "https://www.googleapis.com/auth/classroom.push-notifications"
129 }
130 Scope::Roster => "https://www.googleapis.com/auth/classroom.rosters",
131 Scope::RosterReadonly => "https://www.googleapis.com/auth/classroom.rosters.readonly",
132 Scope::StudentSubmissionMeReadonly => {
133 "https://www.googleapis.com/auth/classroom.student-submissions.me.readonly"
134 }
135 Scope::StudentSubmissionStudentReadonly => {
136 "https://www.googleapis.com/auth/classroom.student-submissions.students.readonly"
137 }
138 Scope::Topic => "https://www.googleapis.com/auth/classroom.topics",
139 Scope::TopicReadonly => "https://www.googleapis.com/auth/classroom.topics.readonly",
140 }
141 }
142}
143
144#[allow(clippy::derivable_impls)]
145impl Default for Scope {
146 fn default() -> Scope {
147 Scope::AnnouncementReadonly
148 }
149}
150
151// ########
152// HUB ###
153// ######
154
155/// Central instance to access all Classroom related resource activities
156///
157/// # Examples
158///
159/// Instantiate a new hub
160///
161/// ```test_harness,no_run
162/// extern crate hyper;
163/// extern crate hyper_rustls;
164/// extern crate google_classroom1 as classroom1;
165/// use classroom1::api::AddOnAttachmentStudentSubmission;
166/// use classroom1::{Result, Error};
167/// # async fn dox() {
168/// use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
169///
170/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
171/// // `client_secret`, among other things.
172/// let secret: yup_oauth2::ApplicationSecret = Default::default();
173/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
174/// // unless you replace `None` with the desired Flow.
175/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
176/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
177/// // retrieve them from storage.
178/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
179/// .with_native_roots()
180/// .unwrap()
181/// .https_only()
182/// .enable_http2()
183/// .build();
184///
185/// let executor = hyper_util::rt::TokioExecutor::new();
186/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
187/// secret,
188/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
189/// yup_oauth2::client::CustomHyperClientBuilder::from(
190/// hyper_util::client::legacy::Client::builder(executor).build(connector),
191/// ),
192/// ).build().await.unwrap();
193///
194/// let client = hyper_util::client::legacy::Client::builder(
195/// hyper_util::rt::TokioExecutor::new()
196/// )
197/// .build(
198/// hyper_rustls::HttpsConnectorBuilder::new()
199/// .with_native_roots()
200/// .unwrap()
201/// .https_or_http()
202/// .enable_http2()
203/// .build()
204/// );
205/// let mut hub = Classroom::new(client, auth);
206/// // As the method needs a request, you would usually fill it with the desired information
207/// // into the respective structure. Some of the parts shown here might not be applicable !
208/// // Values shown here are possibly random and not representative !
209/// let mut req = AddOnAttachmentStudentSubmission::default();
210///
211/// // You can configure optional parameters by calling the respective setters at will, and
212/// // execute the final call using `doit()`.
213/// // Values shown here are possibly random and not representative !
214/// let result = hub.courses().course_work_add_on_attachments_student_submissions_patch(req, "courseId", "itemId", "attachmentId", "submissionId")
215/// .update_mask(FieldMask::new::<&str>(&[]))
216/// .post_id("Lorem")
217/// .doit().await;
218///
219/// match result {
220/// Err(e) => match e {
221/// // The Error enum provides details about what exactly happened.
222/// // You can also just use its `Debug`, `Display` or `Error` traits
223/// Error::HttpError(_)
224/// |Error::Io(_)
225/// |Error::MissingAPIKey
226/// |Error::MissingToken(_)
227/// |Error::Cancelled
228/// |Error::UploadSizeLimitExceeded(_, _)
229/// |Error::Failure(_)
230/// |Error::BadRequest(_)
231/// |Error::FieldClash(_)
232/// |Error::JsonDecodeError(_, _) => println!("{}", e),
233/// },
234/// Ok(res) => println!("Success: {:?}", res),
235/// }
236/// # }
237/// ```
238#[derive(Clone)]
239pub struct Classroom<C> {
240 pub client: common::Client<C>,
241 pub auth: Box<dyn common::GetToken>,
242 _user_agent: String,
243 _base_url: String,
244 _root_url: String,
245}
246
247impl<C> common::Hub for Classroom<C> {}
248
249impl<'a, C> Classroom<C> {
250 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Classroom<C> {
251 Classroom {
252 client,
253 auth: Box::new(auth),
254 _user_agent: "google-api-rust-client/7.0.0".to_string(),
255 _base_url: "https://classroom.googleapis.com/".to_string(),
256 _root_url: "https://classroom.googleapis.com/".to_string(),
257 }
258 }
259
260 pub fn courses(&'a self) -> CourseMethods<'a, C> {
261 CourseMethods { hub: self }
262 }
263 pub fn invitations(&'a self) -> InvitationMethods<'a, C> {
264 InvitationMethods { hub: self }
265 }
266 pub fn registrations(&'a self) -> RegistrationMethods<'a, C> {
267 RegistrationMethods { hub: self }
268 }
269 pub fn user_profiles(&'a self) -> UserProfileMethods<'a, C> {
270 UserProfileMethods { hub: self }
271 }
272
273 /// Set the user-agent header field to use in all requests to the server.
274 /// It defaults to `google-api-rust-client/7.0.0`.
275 ///
276 /// Returns the previously set user-agent.
277 pub fn user_agent(&mut self, agent_name: String) -> String {
278 std::mem::replace(&mut self._user_agent, agent_name)
279 }
280
281 /// Set the base url to use in all requests to the server.
282 /// It defaults to `https://classroom.googleapis.com/`.
283 ///
284 /// Returns the previously set base url.
285 pub fn base_url(&mut self, new_base_url: String) -> String {
286 std::mem::replace(&mut self._base_url, new_base_url)
287 }
288
289 /// Set the root url to use in all requests to the server.
290 /// It defaults to `https://classroom.googleapis.com/`.
291 ///
292 /// Returns the previously set root url.
293 pub fn root_url(&mut self, new_root_url: String) -> String {
294 std::mem::replace(&mut self._root_url, new_root_url)
295 }
296}
297
298// ############
299// SCHEMAS ###
300// ##########
301/// An add-on attachment on a post.
302///
303/// # Activities
304///
305/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
306/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
307///
308/// * [announcements add on attachments create courses](CourseAnnouncementAddOnAttachmentCreateCall) (request|response)
309/// * [announcements add on attachments get courses](CourseAnnouncementAddOnAttachmentGetCall) (response)
310/// * [announcements add on attachments patch courses](CourseAnnouncementAddOnAttachmentPatchCall) (request|response)
311/// * [course work add on attachments create courses](CourseCourseWorkAddOnAttachmentCreateCall) (request|response)
312/// * [course work add on attachments get courses](CourseCourseWorkAddOnAttachmentGetCall) (response)
313/// * [course work add on attachments patch courses](CourseCourseWorkAddOnAttachmentPatchCall) (request|response)
314/// * [course work materials add on attachments create courses](CourseCourseWorkMaterialAddOnAttachmentCreateCall) (request|response)
315/// * [course work materials add on attachments get courses](CourseCourseWorkMaterialAddOnAttachmentGetCall) (response)
316/// * [course work materials add on attachments patch courses](CourseCourseWorkMaterialAddOnAttachmentPatchCall) (request|response)
317/// * [posts add on attachments create courses](CoursePostAddOnAttachmentCreateCall) (request|response)
318/// * [posts add on attachments get courses](CoursePostAddOnAttachmentGetCall) (response)
319/// * [posts add on attachments patch courses](CoursePostAddOnAttachmentPatchCall) (request|response)
320#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
321#[serde_with::serde_as]
322#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
323pub struct AddOnAttachment {
324 /// Output only. Identifiers of attachments that were previous copies of this attachment. If the attachment was previously copied by virtue of its parent post being copied, this enumerates the identifiers of attachments that were its previous copies in ascending chronological order of copy.
325 #[serde(rename = "copyHistory")]
326 pub copy_history: Option<Vec<CopyHistory>>,
327 /// Immutable. Identifier of the course.
328 #[serde(rename = "courseId")]
329 pub course_id: Option<String>,
330 /// Date, in UTC, that work on this attachment is due. This must be specified if `due_time` is specified.
331 #[serde(rename = "dueDate")]
332 pub due_date: Option<Date>,
333 /// Time of day, in UTC, that work on this attachment is due. This must be specified if `due_date` is specified.
334 #[serde(rename = "dueTime")]
335 pub due_time: Option<TimeOfDay>,
336 /// Immutable. Classroom-assigned identifier for this attachment, unique per post.
337 pub id: Option<String>,
338 /// Immutable. Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. Unique per course.
339 #[serde(rename = "itemId")]
340 pub item_id: Option<String>,
341 /// Maximum grade for this attachment. Can only be set if `studentWorkReviewUri` is set. Set to a non-zero value to indicate that the attachment supports grade passback. If set, this must be a non-negative integer value. When set to zero, the attachment will not support grade passback.
342 #[serde(rename = "maxPoints")]
343 pub max_points: Option<f64>,
344 /// Immutable. Deprecated, use `item_id` instead.
345 #[serde(rename = "postId")]
346 pub post_id: Option<String>,
347 /// Required. URI to show the student view of the attachment. The URI will be opened in an iframe with the `courseId`, `itemId`, `itemType`, and `attachmentId` query parameters set.
348 #[serde(rename = "studentViewUri")]
349 pub student_view_uri: Option<EmbedUri>,
350 /// URI for the teacher to see student work on the attachment, if applicable. The URI will be opened in an iframe with the `courseId`, `itemId`, `itemType`, `attachmentId`, and `submissionId` query parameters set. This is the same `submissionId` returned in the [`AddOnContext.studentContext`](https://developers.google.com//devsite.google.com/classroom/reference/rest/v1/AddOnContext#StudentContext) field when a student views the attachment. If the URI is omitted or removed, `max_points` will also be discarded.
351 #[serde(rename = "studentWorkReviewUri")]
352 pub student_work_review_uri: Option<EmbedUri>,
353 /// Required. URI to show the teacher view of the attachment. The URI will be opened in an iframe with the `courseId`, `itemId`, `itemType`, and `attachmentId` query parameters set.
354 #[serde(rename = "teacherViewUri")]
355 pub teacher_view_uri: Option<EmbedUri>,
356 /// Required. Title of this attachment. The title must be between 1 and 1000 characters.
357 pub title: Option<String>,
358}
359
360impl common::RequestValue for AddOnAttachment {}
361impl common::ResponseResult for AddOnAttachment {}
362
363/// Payload for grade update requests.
364///
365/// # Activities
366///
367/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
368/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
369///
370/// * [course work add on attachments student submissions get courses](CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall) (response)
371/// * [course work add on attachments student submissions patch courses](CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall) (request|response)
372/// * [posts add on attachments student submissions get courses](CoursePostAddOnAttachmentStudentSubmissionGetCall) (response)
373/// * [posts add on attachments student submissions patch courses](CoursePostAddOnAttachmentStudentSubmissionPatchCall) (request|response)
374#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
375#[serde_with::serde_as]
376#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
377pub struct AddOnAttachmentStudentSubmission {
378 /// Student grade on this attachment. If unset, no grade was set.
379 #[serde(rename = "pointsEarned")]
380 pub points_earned: Option<f64>,
381 /// Submission state of add-on attachment's parent post (i.e. assignment).
382 #[serde(rename = "postSubmissionState")]
383 pub post_submission_state: Option<String>,
384}
385
386impl common::RequestValue for AddOnAttachmentStudentSubmission {}
387impl common::ResponseResult for AddOnAttachmentStudentSubmission {}
388
389/// Attachment-relevant metadata for Classroom add-ons in the context of a specific post.
390///
391/// # Activities
392///
393/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
394/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
395///
396/// * [announcements get add on context courses](CourseAnnouncementGetAddOnContextCall) (response)
397/// * [course work get add on context courses](CourseCourseWorkGetAddOnContextCall) (response)
398/// * [course work materials get add on context courses](CourseCourseWorkMaterialGetAddOnContextCall) (response)
399/// * [posts get add on context courses](CoursePostGetAddOnContextCall) (response)
400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
401#[serde_with::serde_as]
402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
403pub struct AddOnContext {
404 /// Immutable. Identifier of the course.
405 #[serde(rename = "courseId")]
406 pub course_id: Option<String>,
407 /// Immutable. Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached.
408 #[serde(rename = "itemId")]
409 pub item_id: Option<String>,
410 /// Immutable. Deprecated, use `item_id` instead.
411 #[serde(rename = "postId")]
412 pub post_id: Option<String>,
413 /// Add-on context corresponding to the requesting user's role as a student. Its presence implies that the requesting user is a student in the course.
414 #[serde(rename = "studentContext")]
415 pub student_context: Option<StudentContext>,
416 /// Optional. Whether the post allows the teacher to see student work and passback grades.
417 #[serde(rename = "supportsStudentWork")]
418 pub supports_student_work: Option<bool>,
419 /// Add-on context corresponding to the requesting user's role as a teacher. Its presence implies that the requesting user is a teacher in the course.
420 #[serde(rename = "teacherContext")]
421 pub teacher_context: Option<TeacherContext>,
422}
423
424impl common::ResponseResult for AddOnContext {}
425
426/// Announcement created by a teacher for students of the course
427///
428/// # Activities
429///
430/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
431/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
432///
433/// * [announcements create courses](CourseAnnouncementCreateCall) (request|response)
434/// * [announcements get courses](CourseAnnouncementGetCall) (response)
435/// * [announcements modify assignees courses](CourseAnnouncementModifyAssigneeCall) (response)
436/// * [announcements patch courses](CourseAnnouncementPatchCall) (request|response)
437#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
438#[serde_with::serde_as]
439#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
440pub struct Announcement {
441 /// Absolute link to this announcement in the Classroom web UI. This is only populated if `state` is `PUBLISHED`. Read-only.
442 #[serde(rename = "alternateLink")]
443 pub alternate_link: Option<String>,
444 /// Assignee mode of the announcement. If unspecified, the default value is `ALL_STUDENTS`.
445 #[serde(rename = "assigneeMode")]
446 pub assignee_mode: Option<String>,
447 /// Identifier of the course. Read-only.
448 #[serde(rename = "courseId")]
449 pub course_id: Option<String>,
450 /// Timestamp when this announcement was created. Read-only.
451 #[serde(rename = "creationTime")]
452 pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
453 /// Identifier for the user that created the announcement. Read-only.
454 #[serde(rename = "creatorUserId")]
455 pub creator_user_id: Option<String>,
456 /// Classroom-assigned identifier of this announcement, unique per course. Read-only.
457 pub id: Option<String>,
458 /// Identifiers of students with access to the announcement. This field is set only if `assigneeMode` is `INDIVIDUAL_STUDENTS`. If the `assigneeMode` is `INDIVIDUAL_STUDENTS`, then only students specified in this field can see the announcement.
459 #[serde(rename = "individualStudentsOptions")]
460 pub individual_students_options: Option<IndividualStudentsOptions>,
461 /// Additional materials. Announcements must have no more than 20 material items.
462 pub materials: Option<Vec<Material>>,
463 /// Optional timestamp when this announcement is scheduled to be published.
464 #[serde(rename = "scheduledTime")]
465 pub scheduled_time: Option<chrono::DateTime<chrono::offset::Utc>>,
466 /// Status of this announcement. If unspecified, the default state is `DRAFT`.
467 pub state: Option<String>,
468 /// Description of this announcement. The text must be a valid UTF-8 string containing no more than 30,000 characters.
469 pub text: Option<String>,
470 /// Timestamp of the most recent change to this announcement. Read-only.
471 #[serde(rename = "updateTime")]
472 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
473}
474
475impl common::RequestValue for Announcement {}
476impl common::ResponseResult for Announcement {}
477
478/// Additional details for assignments.
479///
480/// This type is not used in any activity, and only used as *part* of another schema.
481///
482#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
483#[serde_with::serde_as]
484#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
485pub struct Assignment {
486 /// Drive folder where attachments from student submissions are placed. This is only populated for course teachers and administrators.
487 #[serde(rename = "studentWorkFolder")]
488 pub student_work_folder: Option<DriveFolder>,
489}
490
491impl common::Part for Assignment {}
492
493/// Student work for an assignment.
494///
495/// This type is not used in any activity, and only used as *part* of another schema.
496///
497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
498#[serde_with::serde_as]
499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
500pub struct AssignmentSubmission {
501 /// Attachments added by the student. Drive files that correspond to materials with a share mode of STUDENT_COPY may not exist yet if the student has not accessed the assignment in Classroom. Some attachment metadata is only populated if the requesting user has permission to access it. Identifier and alternate_link fields are always available, but others (for example, title) may not be.
502 pub attachments: Option<Vec<Attachment>>,
503}
504
505impl common::Part for AssignmentSubmission {}
506
507/// Attachment added to student assignment work. When creating attachments, setting the `form` field is not supported.
508///
509/// This type is not used in any activity, and only used as *part* of another schema.
510///
511#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
512#[serde_with::serde_as]
513#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
514pub struct Attachment {
515 /// Google Drive file attachment.
516 #[serde(rename = "driveFile")]
517 pub drive_file: Option<DriveFile>,
518 /// Google Forms attachment.
519 pub form: Option<Form>,
520 /// Link attachment.
521 pub link: Option<Link>,
522 /// Youtube video attachment.
523 #[serde(rename = "youTubeVideo")]
524 pub you_tube_video: Option<YouTubeVideo>,
525}
526
527impl common::Part for Attachment {}
528
529/// A reference to a Cloud Pub/Sub topic. To register for notifications, the owner of the topic must grant `classroom-notifications@system.gserviceaccount.com` the `projects.topics.publish` permission.
530///
531/// This type is not used in any activity, and only used as *part* of another schema.
532///
533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
534#[serde_with::serde_as]
535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
536pub struct CloudPubsubTopic {
537 /// The `name` field of a Cloud Pub/Sub [Topic](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics#Topic).
538 #[serde(rename = "topicName")]
539 pub topic_name: Option<String>,
540}
541
542impl common::Part for CloudPubsubTopic {}
543
544/// Identifier of a previous copy of a given attachment.
545///
546/// This type is not used in any activity, and only used as *part* of another schema.
547///
548#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
549#[serde_with::serde_as]
550#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
551pub struct CopyHistory {
552 /// Immutable. Identifier of the attachment.
553 #[serde(rename = "attachmentId")]
554 pub attachment_id: Option<String>,
555 /// Immutable. Identifier of the course.
556 #[serde(rename = "courseId")]
557 pub course_id: Option<String>,
558 /// Immutable. Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached.
559 #[serde(rename = "itemId")]
560 pub item_id: Option<String>,
561 /// Immutable. Deprecated, use `item_id` instead.
562 #[serde(rename = "postId")]
563 pub post_id: Option<String>,
564}
565
566impl common::Part for CopyHistory {}
567
568/// A Course in Classroom.
569///
570/// # Activities
571///
572/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
573/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
574///
575/// * [aliases create courses](CourseAliasCreateCall) (none)
576/// * [aliases delete courses](CourseAliasDeleteCall) (none)
577/// * [aliases list courses](CourseAliasListCall) (none)
578/// * [announcements add on attachments create courses](CourseAnnouncementAddOnAttachmentCreateCall) (none)
579/// * [announcements add on attachments delete courses](CourseAnnouncementAddOnAttachmentDeleteCall) (none)
580/// * [announcements add on attachments get courses](CourseAnnouncementAddOnAttachmentGetCall) (none)
581/// * [announcements add on attachments list courses](CourseAnnouncementAddOnAttachmentListCall) (none)
582/// * [announcements add on attachments patch courses](CourseAnnouncementAddOnAttachmentPatchCall) (none)
583/// * [announcements create courses](CourseAnnouncementCreateCall) (none)
584/// * [announcements delete courses](CourseAnnouncementDeleteCall) (none)
585/// * [announcements get courses](CourseAnnouncementGetCall) (none)
586/// * [announcements get add on context courses](CourseAnnouncementGetAddOnContextCall) (none)
587/// * [announcements list courses](CourseAnnouncementListCall) (none)
588/// * [announcements modify assignees courses](CourseAnnouncementModifyAssigneeCall) (none)
589/// * [announcements patch courses](CourseAnnouncementPatchCall) (none)
590/// * [course work add on attachments student submissions get courses](CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall) (none)
591/// * [course work add on attachments student submissions patch courses](CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall) (none)
592/// * [course work add on attachments create courses](CourseCourseWorkAddOnAttachmentCreateCall) (none)
593/// * [course work add on attachments delete courses](CourseCourseWorkAddOnAttachmentDeleteCall) (none)
594/// * [course work add on attachments get courses](CourseCourseWorkAddOnAttachmentGetCall) (none)
595/// * [course work add on attachments list courses](CourseCourseWorkAddOnAttachmentListCall) (none)
596/// * [course work add on attachments patch courses](CourseCourseWorkAddOnAttachmentPatchCall) (none)
597/// * [course work rubrics create courses](CourseCourseWorkRubricCreateCall) (none)
598/// * [course work rubrics delete courses](CourseCourseWorkRubricDeleteCall) (none)
599/// * [course work rubrics get courses](CourseCourseWorkRubricGetCall) (none)
600/// * [course work rubrics list courses](CourseCourseWorkRubricListCall) (none)
601/// * [course work rubrics patch courses](CourseCourseWorkRubricPatchCall) (none)
602/// * [course work student submissions get courses](CourseCourseWorkStudentSubmissionGetCall) (none)
603/// * [course work student submissions list courses](CourseCourseWorkStudentSubmissionListCall) (none)
604/// * [course work student submissions modify attachments courses](CourseCourseWorkStudentSubmissionModifyAttachmentCall) (none)
605/// * [course work student submissions patch courses](CourseCourseWorkStudentSubmissionPatchCall) (none)
606/// * [course work student submissions reclaim courses](CourseCourseWorkStudentSubmissionReclaimCall) (none)
607/// * [course work student submissions return courses](CourseCourseWorkStudentSubmissionReturnCall) (none)
608/// * [course work student submissions turn in courses](CourseCourseWorkStudentSubmissionTurnInCall) (none)
609/// * [course work create courses](CourseCourseWorkCreateCall) (none)
610/// * [course work delete courses](CourseCourseWorkDeleteCall) (none)
611/// * [course work get courses](CourseCourseWorkGetCall) (none)
612/// * [course work get add on context courses](CourseCourseWorkGetAddOnContextCall) (none)
613/// * [course work list courses](CourseCourseWorkListCall) (none)
614/// * [course work modify assignees courses](CourseCourseWorkModifyAssigneeCall) (none)
615/// * [course work patch courses](CourseCourseWorkPatchCall) (none)
616/// * [course work update rubric courses](CourseCourseWorkUpdateRubricCall) (none)
617/// * [course work materials add on attachments create courses](CourseCourseWorkMaterialAddOnAttachmentCreateCall) (none)
618/// * [course work materials add on attachments delete courses](CourseCourseWorkMaterialAddOnAttachmentDeleteCall) (none)
619/// * [course work materials add on attachments get courses](CourseCourseWorkMaterialAddOnAttachmentGetCall) (none)
620/// * [course work materials add on attachments list courses](CourseCourseWorkMaterialAddOnAttachmentListCall) (none)
621/// * [course work materials add on attachments patch courses](CourseCourseWorkMaterialAddOnAttachmentPatchCall) (none)
622/// * [course work materials create courses](CourseCourseWorkMaterialCreateCall) (none)
623/// * [course work materials delete courses](CourseCourseWorkMaterialDeleteCall) (none)
624/// * [course work materials get courses](CourseCourseWorkMaterialGetCall) (none)
625/// * [course work materials get add on context courses](CourseCourseWorkMaterialGetAddOnContextCall) (none)
626/// * [course work materials list courses](CourseCourseWorkMaterialListCall) (none)
627/// * [course work materials patch courses](CourseCourseWorkMaterialPatchCall) (none)
628/// * [posts add on attachments student submissions get courses](CoursePostAddOnAttachmentStudentSubmissionGetCall) (none)
629/// * [posts add on attachments student submissions patch courses](CoursePostAddOnAttachmentStudentSubmissionPatchCall) (none)
630/// * [posts add on attachments create courses](CoursePostAddOnAttachmentCreateCall) (none)
631/// * [posts add on attachments delete courses](CoursePostAddOnAttachmentDeleteCall) (none)
632/// * [posts add on attachments get courses](CoursePostAddOnAttachmentGetCall) (none)
633/// * [posts add on attachments list courses](CoursePostAddOnAttachmentListCall) (none)
634/// * [posts add on attachments patch courses](CoursePostAddOnAttachmentPatchCall) (none)
635/// * [posts get add on context courses](CoursePostGetAddOnContextCall) (none)
636/// * [students create courses](CourseStudentCreateCall) (none)
637/// * [students delete courses](CourseStudentDeleteCall) (none)
638/// * [students get courses](CourseStudentGetCall) (none)
639/// * [students list courses](CourseStudentListCall) (none)
640/// * [teachers create courses](CourseTeacherCreateCall) (none)
641/// * [teachers delete courses](CourseTeacherDeleteCall) (none)
642/// * [teachers get courses](CourseTeacherGetCall) (none)
643/// * [teachers list courses](CourseTeacherListCall) (none)
644/// * [topics create courses](CourseTopicCreateCall) (none)
645/// * [topics delete courses](CourseTopicDeleteCall) (none)
646/// * [topics get courses](CourseTopicGetCall) (none)
647/// * [topics list courses](CourseTopicListCall) (none)
648/// * [topics patch courses](CourseTopicPatchCall) (none)
649/// * [create courses](CourseCreateCall) (request|response)
650/// * [delete courses](CourseDeleteCall) (none)
651/// * [get courses](CourseGetCall) (response)
652/// * [get grading period settings courses](CourseGetGradingPeriodSettingCall) (none)
653/// * [list courses](CourseListCall) (none)
654/// * [patch courses](CoursePatchCall) (request|response)
655/// * [update courses](CourseUpdateCall) (request|response)
656/// * [update grading period settings courses](CourseUpdateGradingPeriodSettingCall) (none)
657#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
658#[serde_with::serde_as]
659#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
660pub struct Course {
661 /// Absolute link to this course in the Classroom web UI. Read-only.
662 #[serde(rename = "alternateLink")]
663 pub alternate_link: Option<String>,
664 /// The Calendar ID for a calendar that all course members can see, to which Classroom adds events for course work and announcements in the course. The Calendar for a course is created asynchronously when the course is set to `CourseState.ACTIVE` for the first time (at creation time or when it is updated to `ACTIVE` through the UI or the API). The Calendar ID will not be populated until the creation process is completed. Read-only.
665 #[serde(rename = "calendarId")]
666 pub calendar_id: Option<String>,
667 /// The email address of a Google group containing all members of the course. This group does not accept email and can only be used for permissions. Read-only.
668 #[serde(rename = "courseGroupEmail")]
669 pub course_group_email: Option<String>,
670 /// Sets of materials that appear on the "about" page of this course. Read-only.
671 #[serde(rename = "courseMaterialSets")]
672 pub course_material_sets: Option<Vec<CourseMaterialSet>>,
673 /// State of the course. If unspecified, the default state is `PROVISIONED`.
674 #[serde(rename = "courseState")]
675 pub course_state: Option<String>,
676 /// Creation time of the course. Specifying this field in a course update mask results in an error. Read-only.
677 #[serde(rename = "creationTime")]
678 pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
679 /// Optional description. For example, "We'll be learning about the structure of living creatures from a combination of textbooks, guest lectures, and lab work. Expect to be excited!" If set, this field must be a valid UTF-8 string and no longer than 30,000 characters.
680 pub description: Option<String>,
681 /// Optional heading for the description. For example, "Welcome to 10th Grade Biology." If set, this field must be a valid UTF-8 string and no longer than 3600 characters.
682 #[serde(rename = "descriptionHeading")]
683 pub description_heading: Option<String>,
684 /// Enrollment code to use when joining this course. Specifying this field in a course update mask results in an error. Read-only.
685 #[serde(rename = "enrollmentCode")]
686 pub enrollment_code: Option<String>,
687 /// The gradebook settings that specify how a student's overall grade for the course will be calculated and who it will be displayed to. Read-only.
688 #[serde(rename = "gradebookSettings")]
689 pub gradebook_settings: Option<GradebookSettings>,
690 /// Whether or not guardian notifications are enabled for this course. Read-only.
691 #[serde(rename = "guardiansEnabled")]
692 pub guardians_enabled: Option<bool>,
693 /// Identifier for this course assigned by Classroom. When creating a course, you may optionally set this identifier to an alias string in the request to create a corresponding alias. The `id` is still assigned by Classroom and cannot be updated after the course is created. Specifying this field in a course update mask results in an error.
694 pub id: Option<String>,
695 /// Name of the course. For example, "10th Grade Biology". The name is required. It must be between 1 and 750 characters and a valid UTF-8 string.
696 pub name: Option<String>,
697 /// The identifier of the owner of a course. When specified as a parameter of a create course request, this field is required. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user This must be set in a create request. Admins can also specify this field in a patch course request to transfer ownership. In other contexts, it is read-only.
698 #[serde(rename = "ownerId")]
699 pub owner_id: Option<String>,
700 /// Optional room location. For example, "301". If set, this field must be a valid UTF-8 string and no longer than 650 characters.
701 pub room: Option<String>,
702 /// Section of the course. For example, "Period 2". If set, this field must be a valid UTF-8 string and no longer than 2800 characters.
703 pub section: Option<String>,
704 /// Information about a Drive Folder that is shared with all teachers of the course. This field will only be set for teachers of the course and domain administrators. Read-only.
705 #[serde(rename = "teacherFolder")]
706 pub teacher_folder: Option<DriveFolder>,
707 /// The email address of a Google group containing all teachers of the course. This group does not accept email and can only be used for permissions. Read-only.
708 #[serde(rename = "teacherGroupEmail")]
709 pub teacher_group_email: Option<String>,
710 /// Time of the most recent update to this course. Specifying this field in a course update mask results in an error. Read-only.
711 #[serde(rename = "updateTime")]
712 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
713}
714
715impl common::RequestValue for Course {}
716impl common::Resource for Course {}
717impl common::ResponseResult for Course {}
718
719/// Alternative identifier for a course. An alias uniquely identifies a course. It must be unique within one of the following scopes: * domain: A domain-scoped alias is visible to all users within the alias creator’s domain and can be created only by a domain admin. A domain-scoped alias is often used when a course has an identifier external to Classroom. * project: A project-scoped alias is visible to any request from an application using the Developer Console project ID that created the alias and can be created by any project. A project-scoped alias is often used when an application has alternative identifiers. A random value can also be used to avoid duplicate courses in the event of transmission failures, as retrying a request will return `ALREADY_EXISTS` if a previous one has succeeded.
720///
721/// # Activities
722///
723/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
724/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
725///
726/// * [aliases create courses](CourseAliasCreateCall) (request|response)
727#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
728#[serde_with::serde_as]
729#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
730pub struct CourseAlias {
731 /// Alias string. The format of the string indicates the desired alias scoping. * `d:` indicates a domain-scoped alias. Example: `d:math_101` * `p:` indicates a project-scoped alias. Example: `p:abc123` This field has a maximum length of 256 characters.
732 pub alias: Option<String>,
733}
734
735impl common::RequestValue for CourseAlias {}
736impl common::ResponseResult for CourseAlias {}
737
738/// A material attached to a course as part of a material set.
739///
740/// This type is not used in any activity, and only used as *part* of another schema.
741///
742#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
743#[serde_with::serde_as]
744#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
745pub struct CourseMaterial {
746 /// Google Drive file attachment.
747 #[serde(rename = "driveFile")]
748 pub drive_file: Option<DriveFile>,
749 /// Google Forms attachment.
750 pub form: Option<Form>,
751 /// Link atatchment.
752 pub link: Option<Link>,
753 /// Youtube video attachment.
754 #[serde(rename = "youTubeVideo")]
755 pub you_tube_video: Option<YouTubeVideo>,
756}
757
758impl common::Part for CourseMaterial {}
759
760/// A set of materials that appears on the "About" page of the course. These materials might include a syllabus, schedule, or other background information relating to the course as a whole.
761///
762/// This type is not used in any activity, and only used as *part* of another schema.
763///
764#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
765#[serde_with::serde_as]
766#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
767pub struct CourseMaterialSet {
768 /// Materials attached to this set.
769 pub materials: Option<Vec<CourseMaterial>>,
770 /// Title for this set.
771 pub title: Option<String>,
772}
773
774impl common::Part for CourseMaterialSet {}
775
776/// Information about a `Feed` with a `feed_type` of `COURSE_ROSTER_CHANGES`.
777///
778/// This type is not used in any activity, and only used as *part* of another schema.
779///
780#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
781#[serde_with::serde_as]
782#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
783pub struct CourseRosterChangesInfo {
784 /// The `course_id` of the course to subscribe to roster changes for.
785 #[serde(rename = "courseId")]
786 pub course_id: Option<String>,
787}
788
789impl common::Part for CourseRosterChangesInfo {}
790
791/// Course work created by a teacher for students of the course.
792///
793/// # Activities
794///
795/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
796/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
797///
798/// * [course work create courses](CourseCourseWorkCreateCall) (request|response)
799/// * [course work get courses](CourseCourseWorkGetCall) (response)
800/// * [course work modify assignees courses](CourseCourseWorkModifyAssigneeCall) (response)
801/// * [course work patch courses](CourseCourseWorkPatchCall) (request|response)
802#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
803#[serde_with::serde_as]
804#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
805pub struct CourseWork {
806 /// Absolute link to this course work in the Classroom web UI. This is only populated if `state` is `PUBLISHED`. Read-only.
807 #[serde(rename = "alternateLink")]
808 pub alternate_link: Option<String>,
809 /// Assignee mode of the coursework. If unspecified, the default value is `ALL_STUDENTS`.
810 #[serde(rename = "assigneeMode")]
811 pub assignee_mode: Option<String>,
812 /// Assignment details. This is populated only when `work_type` is `ASSIGNMENT`. Read-only.
813 pub assignment: Option<Assignment>,
814 /// Whether this course work item is associated with the Developer Console project making the request. See CreateCourseWork for more details. Read-only.
815 #[serde(rename = "associatedWithDeveloper")]
816 pub associated_with_developer: Option<bool>,
817 /// Identifier of the course. Read-only.
818 #[serde(rename = "courseId")]
819 pub course_id: Option<String>,
820 /// Timestamp when this course work was created. Read-only.
821 #[serde(rename = "creationTime")]
822 pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
823 /// Identifier for the user that created the coursework. Read-only.
824 #[serde(rename = "creatorUserId")]
825 pub creator_user_id: Option<String>,
826 /// Optional description of this course work. If set, the description must be a valid UTF-8 string containing no more than 30,000 characters.
827 pub description: Option<String>,
828 /// Optional date, in UTC, that submissions for this course work are due. This must be specified if `due_time` is specified.
829 #[serde(rename = "dueDate")]
830 pub due_date: Option<Date>,
831 /// Optional time of day, in UTC, that submissions for this course work are due. This must be specified if `due_date` is specified.
832 #[serde(rename = "dueTime")]
833 pub due_time: Option<TimeOfDay>,
834 /// The category that this coursework's grade contributes to. Present only when a category has been chosen for the coursework. May be used in calculating the overall grade. Read-only.
835 #[serde(rename = "gradeCategory")]
836 pub grade_category: Option<GradeCategory>,
837 /// Identifier of the grading period associated with the coursework. * At creation, if unspecified, the grading period ID will be set based on the `dueDate` (or `scheduledTime` if no `dueDate` is set). * To indicate no association to any grading period, set this field to an empty string (""). * If specified, it must match an existing grading period ID in the course.
838 #[serde(rename = "gradingPeriodId")]
839 pub grading_period_id: Option<String>,
840 /// Classroom-assigned identifier of this course work, unique per course. Read-only.
841 pub id: Option<String>,
842 /// Identifiers of students with access to the coursework. This field is set only if `assigneeMode` is `INDIVIDUAL_STUDENTS`. If the `assigneeMode` is `INDIVIDUAL_STUDENTS`, then only students specified in this field are assigned the coursework.
843 #[serde(rename = "individualStudentsOptions")]
844 pub individual_students_options: Option<IndividualStudentsOptions>,
845 /// Additional materials. CourseWork must have no more than 20 material items.
846 pub materials: Option<Vec<Material>>,
847 /// Maximum grade for this course work. If zero or unspecified, this assignment is considered ungraded. This must be a non-negative integer value.
848 #[serde(rename = "maxPoints")]
849 pub max_points: Option<f64>,
850 /// Multiple choice question details. For read operations, this field is populated only when `work_type` is `MULTIPLE_CHOICE_QUESTION`. For write operations, this field must be specified when creating course work with a `work_type` of `MULTIPLE_CHOICE_QUESTION`, and it must not be set otherwise.
851 #[serde(rename = "multipleChoiceQuestion")]
852 pub multiple_choice_question: Option<MultipleChoiceQuestion>,
853 /// Optional timestamp when this course work is scheduled to be published.
854 #[serde(rename = "scheduledTime")]
855 pub scheduled_time: Option<chrono::DateTime<chrono::offset::Utc>>,
856 /// Status of this course work. If unspecified, the default state is `DRAFT`.
857 pub state: Option<String>,
858 /// Setting to determine when students are allowed to modify submissions. If unspecified, the default value is `MODIFIABLE_UNTIL_TURNED_IN`.
859 #[serde(rename = "submissionModificationMode")]
860 pub submission_modification_mode: Option<String>,
861 /// Title of this course work. The title must be a valid UTF-8 string containing between 1 and 3000 characters.
862 pub title: Option<String>,
863 /// Identifier for the topic that this coursework is associated with. Must match an existing topic in the course.
864 #[serde(rename = "topicId")]
865 pub topic_id: Option<String>,
866 /// Timestamp of the most recent change to this course work. Read-only.
867 #[serde(rename = "updateTime")]
868 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
869 /// Type of this course work. The type is set when the course work is created and cannot be changed.
870 #[serde(rename = "workType")]
871 pub work_type: Option<String>,
872}
873
874impl common::RequestValue for CourseWork {}
875impl common::ResponseResult for CourseWork {}
876
877/// Information about a `Feed` with a `feed_type` of `COURSE_WORK_CHANGES`.
878///
879/// This type is not used in any activity, and only used as *part* of another schema.
880///
881#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
882#[serde_with::serde_as]
883#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
884pub struct CourseWorkChangesInfo {
885 /// The `course_id` of the course to subscribe to work changes for.
886 #[serde(rename = "courseId")]
887 pub course_id: Option<String>,
888}
889
890impl common::Part for CourseWorkChangesInfo {}
891
892/// Course work material created by a teacher for students of the course
893///
894/// # Activities
895///
896/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
897/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
898///
899/// * [course work materials create courses](CourseCourseWorkMaterialCreateCall) (request|response)
900/// * [course work materials get courses](CourseCourseWorkMaterialGetCall) (response)
901/// * [course work materials patch courses](CourseCourseWorkMaterialPatchCall) (request|response)
902#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
903#[serde_with::serde_as]
904#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
905pub struct CourseWorkMaterial {
906 /// Absolute link to this course work material in the Classroom web UI. This is only populated if `state` is `PUBLISHED`. Read-only.
907 #[serde(rename = "alternateLink")]
908 pub alternate_link: Option<String>,
909 /// Assignee mode of the course work material. If unspecified, the default value is `ALL_STUDENTS`.
910 #[serde(rename = "assigneeMode")]
911 pub assignee_mode: Option<String>,
912 /// Identifier of the course. Read-only.
913 #[serde(rename = "courseId")]
914 pub course_id: Option<String>,
915 /// Timestamp when this course work material was created. Read-only.
916 #[serde(rename = "creationTime")]
917 pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
918 /// Identifier for the user that created the course work material. Read-only.
919 #[serde(rename = "creatorUserId")]
920 pub creator_user_id: Option<String>,
921 /// Optional description of this course work material. The text must be a valid UTF-8 string containing no more than 30,000 characters.
922 pub description: Option<String>,
923 /// Classroom-assigned identifier of this course work material, unique per course. Read-only.
924 pub id: Option<String>,
925 /// Identifiers of students with access to the course work material. This field is set only if `assigneeMode` is `INDIVIDUAL_STUDENTS`. If the `assigneeMode` is `INDIVIDUAL_STUDENTS`, then only students specified in this field can see the course work material.
926 #[serde(rename = "individualStudentsOptions")]
927 pub individual_students_options: Option<IndividualStudentsOptions>,
928 /// Additional materials. A course work material must have no more than 20 material items.
929 pub materials: Option<Vec<Material>>,
930 /// Optional timestamp when this course work material is scheduled to be published.
931 #[serde(rename = "scheduledTime")]
932 pub scheduled_time: Option<chrono::DateTime<chrono::offset::Utc>>,
933 /// Status of this course work material. If unspecified, the default state is `DRAFT`.
934 pub state: Option<String>,
935 /// Title of this course work material. The title must be a valid UTF-8 string containing between 1 and 3000 characters.
936 pub title: Option<String>,
937 /// Identifier for the topic that this course work material is associated with. Must match an existing topic in the course.
938 #[serde(rename = "topicId")]
939 pub topic_id: Option<String>,
940 /// Timestamp of the most recent change to this course work material. Read-only.
941 #[serde(rename = "updateTime")]
942 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
943}
944
945impl common::RequestValue for CourseWorkMaterial {}
946impl common::ResponseResult for CourseWorkMaterial {}
947
948/// A rubric criterion. Each criterion is a dimension on which performance is rated.
949///
950/// This type is not used in any activity, and only used as *part* of another schema.
951///
952#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
953#[serde_with::serde_as]
954#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
955pub struct Criterion {
956 /// The description of the criterion.
957 pub description: Option<String>,
958 /// The criterion ID. On creation, an ID is assigned.
959 pub id: Option<String>,
960 /// The list of levels within this criterion.
961 pub levels: Option<Vec<Level>>,
962 /// The title of the criterion.
963 pub title: Option<String>,
964}
965
966impl common::Part for Criterion {}
967
968/// Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp
969///
970/// This type is not used in any activity, and only used as *part* of another schema.
971///
972#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
973#[serde_with::serde_as]
974#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
975pub struct Date {
976 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
977 pub day: Option<i32>,
978 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
979 pub month: Option<i32>,
980 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
981 pub year: Option<i32>,
982}
983
984impl common::Part for Date {}
985
986/// Representation of a Google Drive file.
987///
988/// This type is not used in any activity, and only used as *part* of another schema.
989///
990#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
991#[serde_with::serde_as]
992#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
993pub struct DriveFile {
994 /// URL that can be used to access the Drive item. Read-only.
995 #[serde(rename = "alternateLink")]
996 pub alternate_link: Option<String>,
997 /// Drive API resource ID.
998 pub id: Option<String>,
999 /// URL of a thumbnail image of the Drive item. Read-only.
1000 #[serde(rename = "thumbnailUrl")]
1001 pub thumbnail_url: Option<String>,
1002 /// Title of the Drive item. Read-only.
1003 pub title: Option<String>,
1004}
1005
1006impl common::Part for DriveFile {}
1007
1008/// Representation of a Google Drive folder.
1009///
1010/// This type is not used in any activity, and only used as *part* of another schema.
1011///
1012#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1013#[serde_with::serde_as]
1014#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1015pub struct DriveFolder {
1016 /// URL that can be used to access the Drive folder. Read-only.
1017 #[serde(rename = "alternateLink")]
1018 pub alternate_link: Option<String>,
1019 /// Drive API resource ID.
1020 pub id: Option<String>,
1021 /// Title of the Drive folder. Read-only.
1022 pub title: Option<String>,
1023}
1024
1025impl common::Part for DriveFolder {}
1026
1027/// URI to be iframed after being populated with query parameters.
1028///
1029/// This type is not used in any activity, and only used as *part* of another schema.
1030///
1031#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1032#[serde_with::serde_as]
1033#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1034pub struct EmbedUri {
1035 /// Required. URI to be iframed after being populated with query parameters. This must be a valid UTF-8 string containing between 1 and 1800 characters.
1036 pub uri: Option<String>,
1037}
1038
1039impl common::Part for EmbedUri {}
1040
1041/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
1042///
1043/// # Activities
1044///
1045/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1046/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1047///
1048/// * [aliases delete courses](CourseAliasDeleteCall) (response)
1049/// * [announcements add on attachments delete courses](CourseAnnouncementAddOnAttachmentDeleteCall) (response)
1050/// * [announcements delete courses](CourseAnnouncementDeleteCall) (response)
1051/// * [course work add on attachments delete courses](CourseCourseWorkAddOnAttachmentDeleteCall) (response)
1052/// * [course work rubrics delete courses](CourseCourseWorkRubricDeleteCall) (response)
1053/// * [course work student submissions reclaim courses](CourseCourseWorkStudentSubmissionReclaimCall) (response)
1054/// * [course work student submissions return courses](CourseCourseWorkStudentSubmissionReturnCall) (response)
1055/// * [course work student submissions turn in courses](CourseCourseWorkStudentSubmissionTurnInCall) (response)
1056/// * [course work delete courses](CourseCourseWorkDeleteCall) (response)
1057/// * [course work materials add on attachments delete courses](CourseCourseWorkMaterialAddOnAttachmentDeleteCall) (response)
1058/// * [course work materials delete courses](CourseCourseWorkMaterialDeleteCall) (response)
1059/// * [posts add on attachments delete courses](CoursePostAddOnAttachmentDeleteCall) (response)
1060/// * [students delete courses](CourseStudentDeleteCall) (response)
1061/// * [teachers delete courses](CourseTeacherDeleteCall) (response)
1062/// * [topics delete courses](CourseTopicDeleteCall) (response)
1063/// * [delete courses](CourseDeleteCall) (response)
1064/// * [accept invitations](InvitationAcceptCall) (response)
1065/// * [delete invitations](InvitationDeleteCall) (response)
1066/// * [delete registrations](RegistrationDeleteCall) (response)
1067/// * [guardians delete user profiles](UserProfileGuardianDeleteCall) (response)
1068#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1069#[serde_with::serde_as]
1070#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1071pub struct Empty {
1072 _never_set: Option<bool>,
1073}
1074
1075impl common::ResponseResult for Empty {}
1076
1077/// A class of notifications that an application can register to receive. For example: "all roster changes for a domain".
1078///
1079/// This type is not used in any activity, and only used as *part* of another schema.
1080///
1081#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1082#[serde_with::serde_as]
1083#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1084pub struct Feed {
1085 /// Information about a `Feed` with a `feed_type` of `COURSE_ROSTER_CHANGES`. This field must be specified if `feed_type` is `COURSE_ROSTER_CHANGES`.
1086 #[serde(rename = "courseRosterChangesInfo")]
1087 pub course_roster_changes_info: Option<CourseRosterChangesInfo>,
1088 /// Information about a `Feed` with a `feed_type` of `COURSE_WORK_CHANGES`. This field must be specified if `feed_type` is `COURSE_WORK_CHANGES`.
1089 #[serde(rename = "courseWorkChangesInfo")]
1090 pub course_work_changes_info: Option<CourseWorkChangesInfo>,
1091 /// The type of feed.
1092 #[serde(rename = "feedType")]
1093 pub feed_type: Option<String>,
1094}
1095
1096impl common::Part for Feed {}
1097
1098/// Google Forms item.
1099///
1100/// This type is not used in any activity, and only used as *part* of another schema.
1101///
1102#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1103#[serde_with::serde_as]
1104#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1105pub struct Form {
1106 /// URL of the form.
1107 #[serde(rename = "formUrl")]
1108 pub form_url: Option<String>,
1109 /// URL of the form responses document. Only set if responses have been recorded and only when the requesting user is an editor of the form. Read-only.
1110 #[serde(rename = "responseUrl")]
1111 pub response_url: Option<String>,
1112 /// URL of a thumbnail image of the Form. Read-only.
1113 #[serde(rename = "thumbnailUrl")]
1114 pub thumbnail_url: Option<String>,
1115 /// Title of the Form. Read-only.
1116 pub title: Option<String>,
1117}
1118
1119impl common::Part for Form {}
1120
1121/// Gemini Gem link.
1122///
1123/// This type is not used in any activity, and only used as *part* of another schema.
1124///
1125#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1126#[serde_with::serde_as]
1127#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1128pub struct GeminiGem {
1129 /// Gems resource id.
1130 pub id: Option<String>,
1131 /// Title of the Gem.
1132 pub title: Option<String>,
1133 /// URL that can be used to access the Gem.
1134 pub url: Option<String>,
1135}
1136
1137impl common::Part for GeminiGem {}
1138
1139/// Global user permission description.
1140///
1141/// This type is not used in any activity, and only used as *part* of another schema.
1142///
1143#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1144#[serde_with::serde_as]
1145#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1146pub struct GlobalPermission {
1147 /// Permission value.
1148 pub permission: Option<String>,
1149}
1150
1151impl common::Part for GlobalPermission {}
1152
1153/// Details for a grade category in a course. Coursework may have zero or one grade category, and the category may be used in computing the overall grade. See the [help center article](https://support.google.com/edu/classroom/answer/9184995) for details.
1154///
1155/// This type is not used in any activity, and only used as *part* of another schema.
1156///
1157#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1158#[serde_with::serde_as]
1159#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1160pub struct GradeCategory {
1161 /// Default value of denominator. Only applicable when grade calculation type is TOTAL_POINTS.
1162 #[serde(rename = "defaultGradeDenominator")]
1163 pub default_grade_denominator: Option<i32>,
1164 /// ID of the grade category.
1165 pub id: Option<String>,
1166 /// Name of the grade category.
1167 pub name: Option<String>,
1168 /// The weight of the category average as part of overall average. A weight of 12.34% is represented as 123400 (100% is 1,000,000). The last two digits should always be zero since we use two decimal precision. Only applicable when grade calculation type is WEIGHTED_CATEGORIES.
1169 pub weight: Option<i32>,
1170}
1171
1172impl common::Part for GradeCategory {}
1173
1174/// The history of each grade on this submission.
1175///
1176/// This type is not used in any activity, and only used as *part* of another schema.
1177///
1178#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1179#[serde_with::serde_as]
1180#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1181pub struct GradeHistory {
1182 /// The teacher who made the grade change.
1183 #[serde(rename = "actorUserId")]
1184 pub actor_user_id: Option<String>,
1185 /// The type of grade change at this time in the submission grade history.
1186 #[serde(rename = "gradeChangeType")]
1187 pub grade_change_type: Option<String>,
1188 /// When the grade of the submission was changed.
1189 #[serde(rename = "gradeTimestamp")]
1190 pub grade_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
1191 /// The denominator of the grade at this time in the submission grade history.
1192 #[serde(rename = "maxPoints")]
1193 pub max_points: Option<f64>,
1194 /// The numerator of the grade at this time in the submission grade history.
1195 #[serde(rename = "pointsEarned")]
1196 pub points_earned: Option<f64>,
1197}
1198
1199impl common::Part for GradeHistory {}
1200
1201/// The gradebook settings for a course. See the [help center article](https://support.google.com/edu/classroom/answer/9184995) for details.
1202///
1203/// This type is not used in any activity, and only used as *part* of another schema.
1204///
1205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1206#[serde_with::serde_as]
1207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1208pub struct GradebookSettings {
1209 /// Indicates how the overall grade is calculated.
1210 #[serde(rename = "calculationType")]
1211 pub calculation_type: Option<String>,
1212 /// Indicates who can see the overall grade..
1213 #[serde(rename = "displaySetting")]
1214 pub display_setting: Option<String>,
1215 /// Grade categories that are available for coursework in the course.
1216 #[serde(rename = "gradeCategories")]
1217 pub grade_categories: Option<Vec<GradeCategory>>,
1218}
1219
1220impl common::Part for GradebookSettings {}
1221
1222/// An individual grading period. Grading periods must not have overlapping date ranges and must be listed in chronological order. For example, if the end_date of a grading period is 2024-01-25, then the start_date of the next grading period must be 2024-01-26 or later. Each grading period must have a unique title within a course.
1223///
1224/// This type is not used in any activity, and only used as *part* of another schema.
1225///
1226#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1227#[serde_with::serde_as]
1228#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1229pub struct GradingPeriod {
1230 /// Required. End date, in UTC, of the grading period. Inclusive.
1231 #[serde(rename = "endDate")]
1232 pub end_date: Option<Date>,
1233 /// Output only. System generated grading period ID. Read-only.
1234 pub id: Option<String>,
1235 /// Required. Start date, in UTC, of the grading period. Inclusive.
1236 #[serde(rename = "startDate")]
1237 pub start_date: Option<Date>,
1238 /// Required. Title of the grading period. For example, “Semester 1”.
1239 pub title: Option<String>,
1240}
1241
1242impl common::Part for GradingPeriod {}
1243
1244/// Grading period settings that include all the individual grading periods in a course.
1245///
1246/// # Activities
1247///
1248/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1249/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1250///
1251/// * [get grading period settings courses](CourseGetGradingPeriodSettingCall) (response)
1252/// * [update grading period settings courses](CourseUpdateGradingPeriodSettingCall) (request|response)
1253#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1254#[serde_with::serde_as]
1255#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1256pub struct GradingPeriodSettings {
1257 /// Supports toggling the application of grading periods on existing stream items. Once set, this value is persisted meaning that it does not need to be set in every request to update `GradingPeriodSettings`. If not previously set, the default is False.
1258 #[serde(rename = "applyToExistingCoursework")]
1259 pub apply_to_existing_coursework: Option<bool>,
1260 /// The list of grading periods in a specific course. Grading periods must not have overlapping date ranges and must be listed in chronological order. Each grading period must have a unique title within a course.
1261 #[serde(rename = "gradingPeriods")]
1262 pub grading_periods: Option<Vec<GradingPeriod>>,
1263}
1264
1265impl common::RequestValue for GradingPeriodSettings {}
1266impl common::ResponseResult for GradingPeriodSettings {}
1267
1268/// Association between a student and a guardian of that student. The guardian may receive information about the student’s course work.
1269///
1270/// # Activities
1271///
1272/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1273/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1274///
1275/// * [guardians get user profiles](UserProfileGuardianGetCall) (response)
1276#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1277#[serde_with::serde_as]
1278#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1279pub struct Guardian {
1280 /// Identifier for the guardian.
1281 #[serde(rename = "guardianId")]
1282 pub guardian_id: Option<String>,
1283 /// User profile for the guardian.
1284 #[serde(rename = "guardianProfile")]
1285 pub guardian_profile: Option<UserProfile>,
1286 /// The email address to which the initial guardian invitation was sent. This field is only visible to domain administrators.
1287 #[serde(rename = "invitedEmailAddress")]
1288 pub invited_email_address: Option<String>,
1289 /// Identifier for the student to whom the guardian relationship applies.
1290 #[serde(rename = "studentId")]
1291 pub student_id: Option<String>,
1292}
1293
1294impl common::ResponseResult for Guardian {}
1295
1296/// An invitation to become the guardian of a specified user, sent to a specified email address.
1297///
1298/// # Activities
1299///
1300/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1301/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1302///
1303/// * [guardian invitations create user profiles](UserProfileGuardianInvitationCreateCall) (request|response)
1304/// * [guardian invitations get user profiles](UserProfileGuardianInvitationGetCall) (response)
1305/// * [guardian invitations patch user profiles](UserProfileGuardianInvitationPatchCall) (request|response)
1306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1307#[serde_with::serde_as]
1308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1309pub struct GuardianInvitation {
1310 /// The time that this invitation was created. Read-only.
1311 #[serde(rename = "creationTime")]
1312 pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1313 /// Unique identifier for this invitation. Read-only.
1314 #[serde(rename = "invitationId")]
1315 pub invitation_id: Option<String>,
1316 /// Email address that the invitation was sent to. This field is only visible to domain administrators.
1317 #[serde(rename = "invitedEmailAddress")]
1318 pub invited_email_address: Option<String>,
1319 /// The state that this invitation is in.
1320 pub state: Option<String>,
1321 /// ID of the student (in standard format)
1322 #[serde(rename = "studentId")]
1323 pub student_id: Option<String>,
1324}
1325
1326impl common::RequestValue for GuardianInvitation {}
1327impl common::ResponseResult for GuardianInvitation {}
1328
1329/// Assignee details about a coursework/announcement. This field is set if and only if `assigneeMode` is `INDIVIDUAL_STUDENTS`.
1330///
1331/// This type is not used in any activity, and only used as *part* of another schema.
1332///
1333#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1334#[serde_with::serde_as]
1335#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1336pub struct IndividualStudentsOptions {
1337 /// Identifiers for the students that have access to the coursework/announcement.
1338 #[serde(rename = "studentIds")]
1339 pub student_ids: Option<Vec<String>>,
1340}
1341
1342impl common::Part for IndividualStudentsOptions {}
1343
1344/// An invitation to join a course.
1345///
1346/// # Activities
1347///
1348/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1349/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1350///
1351/// * [accept invitations](InvitationAcceptCall) (none)
1352/// * [create invitations](InvitationCreateCall) (request|response)
1353/// * [delete invitations](InvitationDeleteCall) (none)
1354/// * [get invitations](InvitationGetCall) (response)
1355/// * [list invitations](InvitationListCall) (none)
1356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1357#[serde_with::serde_as]
1358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1359pub struct Invitation {
1360 /// Identifier of the course to invite the user to.
1361 #[serde(rename = "courseId")]
1362 pub course_id: Option<String>,
1363 /// Identifier assigned by Classroom. Read-only.
1364 pub id: Option<String>,
1365 /// Role to invite the user to have. Must not be `COURSE_ROLE_UNSPECIFIED`.
1366 pub role: Option<String>,
1367 /// Identifier of the invited user. When specified as a parameter of a request, this identifier can be set to one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
1368 #[serde(rename = "userId")]
1369 pub user_id: Option<String>,
1370}
1371
1372impl common::RequestValue for Invitation {}
1373impl common::Resource for Invitation {}
1374impl common::ResponseResult for Invitation {}
1375
1376/// A level of the criterion.
1377///
1378/// This type is not used in any activity, and only used as *part* of another schema.
1379///
1380#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1381#[serde_with::serde_as]
1382#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1383pub struct Level {
1384 /// The description of the level.
1385 pub description: Option<String>,
1386 /// The level ID. On creation, an ID is assigned.
1387 pub id: Option<String>,
1388 /// Optional points associated with this level. If set, all levels within the rubric must specify points and the value must be distinct across all levels within a single criterion. 0 is distinct from no points.
1389 pub points: Option<f64>,
1390 /// The title of the level. If the level has no points set, title must be set.
1391 pub title: Option<String>,
1392}
1393
1394impl common::Part for Level {}
1395
1396/// URL item.
1397///
1398/// This type is not used in any activity, and only used as *part* of another schema.
1399///
1400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1401#[serde_with::serde_as]
1402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1403pub struct Link {
1404 /// URL of a thumbnail image of the target URL. Read-only.
1405 #[serde(rename = "thumbnailUrl")]
1406 pub thumbnail_url: Option<String>,
1407 /// Title of the target of the URL. Read-only.
1408 pub title: Option<String>,
1409 /// URL to link to. This must be a valid UTF-8 string containing between 1 and 2024 characters.
1410 pub url: Option<String>,
1411}
1412
1413impl common::Part for Link {}
1414
1415/// Response when listing add-on attachments.
1416///
1417/// # Activities
1418///
1419/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1420/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1421///
1422/// * [announcements add on attachments list courses](CourseAnnouncementAddOnAttachmentListCall) (response)
1423/// * [course work add on attachments list courses](CourseCourseWorkAddOnAttachmentListCall) (response)
1424/// * [course work materials add on attachments list courses](CourseCourseWorkMaterialAddOnAttachmentListCall) (response)
1425/// * [posts add on attachments list courses](CoursePostAddOnAttachmentListCall) (response)
1426#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1427#[serde_with::serde_as]
1428#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1429pub struct ListAddOnAttachmentsResponse {
1430 /// Attachments under the given post.
1431 #[serde(rename = "addOnAttachments")]
1432 pub add_on_attachments: Option<Vec<AddOnAttachment>>,
1433 /// A token, which can be sent as `pageToken` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1434 #[serde(rename = "nextPageToken")]
1435 pub next_page_token: Option<String>,
1436}
1437
1438impl common::ResponseResult for ListAddOnAttachmentsResponse {}
1439
1440/// Response when listing course work.
1441///
1442/// # Activities
1443///
1444/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1445/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1446///
1447/// * [announcements list courses](CourseAnnouncementListCall) (response)
1448#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1449#[serde_with::serde_as]
1450#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1451pub struct ListAnnouncementsResponse {
1452 /// Announcement items that match the request.
1453 pub announcements: Option<Vec<Announcement>>,
1454 /// Token identifying the next page of results to return. If empty, no further results are available.
1455 #[serde(rename = "nextPageToken")]
1456 pub next_page_token: Option<String>,
1457}
1458
1459impl common::ResponseResult for ListAnnouncementsResponse {}
1460
1461/// Response when listing course aliases.
1462///
1463/// # Activities
1464///
1465/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1466/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1467///
1468/// * [aliases list courses](CourseAliasListCall) (response)
1469#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1470#[serde_with::serde_as]
1471#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1472pub struct ListCourseAliasesResponse {
1473 /// The course aliases.
1474 pub aliases: Option<Vec<CourseAlias>>,
1475 /// Token identifying the next page of results to return. If empty, no further results are available.
1476 #[serde(rename = "nextPageToken")]
1477 pub next_page_token: Option<String>,
1478}
1479
1480impl common::ResponseResult for ListCourseAliasesResponse {}
1481
1482/// Response when listing course work material.
1483///
1484/// # Activities
1485///
1486/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1487/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1488///
1489/// * [course work materials list courses](CourseCourseWorkMaterialListCall) (response)
1490#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1491#[serde_with::serde_as]
1492#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1493pub struct ListCourseWorkMaterialResponse {
1494 /// Course work material items that match the request.
1495 #[serde(rename = "courseWorkMaterial")]
1496 pub course_work_material: Option<Vec<CourseWorkMaterial>>,
1497 /// Token identifying the next page of results to return. If empty, no further results are available.
1498 #[serde(rename = "nextPageToken")]
1499 pub next_page_token: Option<String>,
1500}
1501
1502impl common::ResponseResult for ListCourseWorkMaterialResponse {}
1503
1504/// Response when listing course work.
1505///
1506/// # Activities
1507///
1508/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1509/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1510///
1511/// * [course work list courses](CourseCourseWorkListCall) (response)
1512#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1513#[serde_with::serde_as]
1514#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1515pub struct ListCourseWorkResponse {
1516 /// Course work items that match the request.
1517 #[serde(rename = "courseWork")]
1518 pub course_work: Option<Vec<CourseWork>>,
1519 /// Token identifying the next page of results to return. If empty, no further results are available.
1520 #[serde(rename = "nextPageToken")]
1521 pub next_page_token: Option<String>,
1522}
1523
1524impl common::ResponseResult for ListCourseWorkResponse {}
1525
1526/// Response when listing courses.
1527///
1528/// # Activities
1529///
1530/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1531/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1532///
1533/// * [list courses](CourseListCall) (response)
1534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1535#[serde_with::serde_as]
1536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1537pub struct ListCoursesResponse {
1538 /// Courses that match the list request.
1539 pub courses: Option<Vec<Course>>,
1540 /// Token identifying the next page of results to return. If empty, no further results are available.
1541 #[serde(rename = "nextPageToken")]
1542 pub next_page_token: Option<String>,
1543}
1544
1545impl common::ResponseResult for ListCoursesResponse {}
1546
1547/// Response when listing guardian invitations.
1548///
1549/// # Activities
1550///
1551/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1552/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1553///
1554/// * [guardian invitations list user profiles](UserProfileGuardianInvitationListCall) (response)
1555#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1556#[serde_with::serde_as]
1557#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1558pub struct ListGuardianInvitationsResponse {
1559 /// Guardian invitations that matched the list request.
1560 #[serde(rename = "guardianInvitations")]
1561 pub guardian_invitations: Option<Vec<GuardianInvitation>>,
1562 /// Token identifying the next page of results to return. If empty, no further results are available.
1563 #[serde(rename = "nextPageToken")]
1564 pub next_page_token: Option<String>,
1565}
1566
1567impl common::ResponseResult for ListGuardianInvitationsResponse {}
1568
1569/// Response when listing guardians.
1570///
1571/// # Activities
1572///
1573/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1574/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1575///
1576/// * [guardians list user profiles](UserProfileGuardianListCall) (response)
1577#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1578#[serde_with::serde_as]
1579#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1580pub struct ListGuardiansResponse {
1581 /// Guardians on this page of results that met the criteria specified in the request.
1582 pub guardians: Option<Vec<Guardian>>,
1583 /// Token identifying the next page of results to return. If empty, no further results are available.
1584 #[serde(rename = "nextPageToken")]
1585 pub next_page_token: Option<String>,
1586}
1587
1588impl common::ResponseResult for ListGuardiansResponse {}
1589
1590/// Response when listing invitations.
1591///
1592/// # Activities
1593///
1594/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1595/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1596///
1597/// * [list invitations](InvitationListCall) (response)
1598#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1599#[serde_with::serde_as]
1600#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1601pub struct ListInvitationsResponse {
1602 /// Invitations that match the list request.
1603 pub invitations: Option<Vec<Invitation>>,
1604 /// Token identifying the next page of results to return. If empty, no further results are available.
1605 #[serde(rename = "nextPageToken")]
1606 pub next_page_token: Option<String>,
1607}
1608
1609impl common::ResponseResult for ListInvitationsResponse {}
1610
1611/// Response when listing rubrics.
1612///
1613/// # Activities
1614///
1615/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1616/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1617///
1618/// * [course work rubrics list courses](CourseCourseWorkRubricListCall) (response)
1619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1620#[serde_with::serde_as]
1621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1622pub struct ListRubricsResponse {
1623 /// Token identifying the next page of results to return. If empty, no further results are available.
1624 #[serde(rename = "nextPageToken")]
1625 pub next_page_token: Option<String>,
1626 /// Rubrics that match the request.
1627 pub rubrics: Option<Vec<Rubric>>,
1628}
1629
1630impl common::ResponseResult for ListRubricsResponse {}
1631
1632/// Response when listing student submissions.
1633///
1634/// # Activities
1635///
1636/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1637/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1638///
1639/// * [course work student submissions list courses](CourseCourseWorkStudentSubmissionListCall) (response)
1640#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1641#[serde_with::serde_as]
1642#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1643pub struct ListStudentSubmissionsResponse {
1644 /// Token identifying the next page of results to return. If empty, no further results are available.
1645 #[serde(rename = "nextPageToken")]
1646 pub next_page_token: Option<String>,
1647 /// Student work that matches the request.
1648 #[serde(rename = "studentSubmissions")]
1649 pub student_submissions: Option<Vec<StudentSubmission>>,
1650}
1651
1652impl common::ResponseResult for ListStudentSubmissionsResponse {}
1653
1654/// Response when listing students.
1655///
1656/// # Activities
1657///
1658/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1659/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1660///
1661/// * [students list courses](CourseStudentListCall) (response)
1662#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1663#[serde_with::serde_as]
1664#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1665pub struct ListStudentsResponse {
1666 /// Token identifying the next page of results to return. If empty, no further results are available.
1667 #[serde(rename = "nextPageToken")]
1668 pub next_page_token: Option<String>,
1669 /// Students who match the list request.
1670 pub students: Option<Vec<Student>>,
1671}
1672
1673impl common::ResponseResult for ListStudentsResponse {}
1674
1675/// Response when listing teachers.
1676///
1677/// # Activities
1678///
1679/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1680/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1681///
1682/// * [teachers list courses](CourseTeacherListCall) (response)
1683#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1684#[serde_with::serde_as]
1685#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1686pub struct ListTeachersResponse {
1687 /// Token identifying the next page of results to return. If empty, no further results are available.
1688 #[serde(rename = "nextPageToken")]
1689 pub next_page_token: Option<String>,
1690 /// Teachers who match the list request.
1691 pub teachers: Option<Vec<Teacher>>,
1692}
1693
1694impl common::ResponseResult for ListTeachersResponse {}
1695
1696/// Response when listing topics.
1697///
1698/// # Activities
1699///
1700/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1701/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1702///
1703/// * [topics list courses](CourseTopicListCall) (response)
1704#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1705#[serde_with::serde_as]
1706#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1707pub struct ListTopicResponse {
1708 /// Token identifying the next page of results to return. If empty, no further results are available.
1709 #[serde(rename = "nextPageToken")]
1710 pub next_page_token: Option<String>,
1711 /// Topic items that match the request.
1712 pub topic: Option<Vec<Topic>>,
1713}
1714
1715impl common::ResponseResult for ListTopicResponse {}
1716
1717/// Material attached to course work. When creating attachments, setting the `form`, `gem`, or `notebook` field is not supported.
1718///
1719/// This type is not used in any activity, and only used as *part* of another schema.
1720///
1721#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1722#[serde_with::serde_as]
1723#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1724pub struct Material {
1725 /// Google Drive file material.
1726 #[serde(rename = "driveFile")]
1727 pub drive_file: Option<SharedDriveFile>,
1728 /// Google Forms material. Read-only.
1729 pub form: Option<Form>,
1730 /// Gemini Gem material. Read-only.
1731 pub gem: Option<GeminiGem>,
1732 /// Link material. On creation, this is upgraded to a more appropriate type if possible, and this is reflected in the response.
1733 pub link: Option<Link>,
1734 /// NotebookLM Notebook material. Read-only.
1735 pub notebook: Option<NotebookLmNotebook>,
1736 /// YouTube video material.
1737 #[serde(rename = "youtubeVideo")]
1738 pub youtube_video: Option<YouTubeVideo>,
1739}
1740
1741impl common::Part for Material {}
1742
1743/// Request to modify assignee mode and options of an announcement.
1744///
1745/// # Activities
1746///
1747/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1748/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1749///
1750/// * [announcements modify assignees courses](CourseAnnouncementModifyAssigneeCall) (request)
1751#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1752#[serde_with::serde_as]
1753#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1754pub struct ModifyAnnouncementAssigneesRequest {
1755 /// Mode of the announcement describing whether it is accessible by all students or specified individual students.
1756 #[serde(rename = "assigneeMode")]
1757 pub assignee_mode: Option<String>,
1758 /// Set which students can view or cannot view the announcement. Must be specified only when `assigneeMode` is `INDIVIDUAL_STUDENTS`.
1759 #[serde(rename = "modifyIndividualStudentsOptions")]
1760 pub modify_individual_students_options: Option<ModifyIndividualStudentsOptions>,
1761}
1762
1763impl common::RequestValue for ModifyAnnouncementAssigneesRequest {}
1764
1765/// Request to modify the attachments of a student submission.
1766///
1767/// # Activities
1768///
1769/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1770/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1771///
1772/// * [course work student submissions modify attachments courses](CourseCourseWorkStudentSubmissionModifyAttachmentCall) (request)
1773#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1774#[serde_with::serde_as]
1775#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1776pub struct ModifyAttachmentsRequest {
1777 /// Attachments to add. A student submission may not have more than 20 attachments. Form attachments are not supported.
1778 #[serde(rename = "addAttachments")]
1779 pub add_attachments: Option<Vec<Attachment>>,
1780}
1781
1782impl common::RequestValue for ModifyAttachmentsRequest {}
1783
1784/// Request to modify assignee mode and options of a coursework.
1785///
1786/// # Activities
1787///
1788/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1789/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1790///
1791/// * [course work modify assignees courses](CourseCourseWorkModifyAssigneeCall) (request)
1792#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1793#[serde_with::serde_as]
1794#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1795pub struct ModifyCourseWorkAssigneesRequest {
1796 /// Mode of the coursework describing whether it will be assigned to all students or specified individual students.
1797 #[serde(rename = "assigneeMode")]
1798 pub assignee_mode: Option<String>,
1799 /// Set which students are assigned or not assigned to the coursework. Must be specified only when `assigneeMode` is `INDIVIDUAL_STUDENTS`.
1800 #[serde(rename = "modifyIndividualStudentsOptions")]
1801 pub modify_individual_students_options: Option<ModifyIndividualStudentsOptions>,
1802}
1803
1804impl common::RequestValue for ModifyCourseWorkAssigneesRequest {}
1805
1806/// Contains fields to add or remove students from a course work or announcement where the `assigneeMode` is set to `INDIVIDUAL_STUDENTS`.
1807///
1808/// This type is not used in any activity, and only used as *part* of another schema.
1809///
1810#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1811#[serde_with::serde_as]
1812#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1813pub struct ModifyIndividualStudentsOptions {
1814 /// IDs of students to be added as having access to this coursework/announcement.
1815 #[serde(rename = "addStudentIds")]
1816 pub add_student_ids: Option<Vec<String>>,
1817 /// IDs of students to be removed from having access to this coursework/announcement.
1818 #[serde(rename = "removeStudentIds")]
1819 pub remove_student_ids: Option<Vec<String>>,
1820}
1821
1822impl common::Part for ModifyIndividualStudentsOptions {}
1823
1824/// Additional details for multiple-choice questions.
1825///
1826/// This type is not used in any activity, and only used as *part* of another schema.
1827///
1828#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1829#[serde_with::serde_as]
1830#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1831pub struct MultipleChoiceQuestion {
1832 /// Possible choices.
1833 pub choices: Option<Vec<String>>,
1834}
1835
1836impl common::Part for MultipleChoiceQuestion {}
1837
1838/// Student work for a multiple-choice question.
1839///
1840/// This type is not used in any activity, and only used as *part* of another schema.
1841///
1842#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1843#[serde_with::serde_as]
1844#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1845pub struct MultipleChoiceSubmission {
1846 /// Student's select choice.
1847 pub answer: Option<String>,
1848}
1849
1850impl common::Part for MultipleChoiceSubmission {}
1851
1852/// Details of the user's name.
1853///
1854/// This type is not used in any activity, and only used as *part* of another schema.
1855///
1856#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1857#[serde_with::serde_as]
1858#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1859pub struct Name {
1860 /// The user's last name. Read-only.
1861 #[serde(rename = "familyName")]
1862 pub family_name: Option<String>,
1863 /// The user's full name formed by concatenating the first and last name values. Read-only.
1864 #[serde(rename = "fullName")]
1865 pub full_name: Option<String>,
1866 /// The user's first name. Read-only.
1867 #[serde(rename = "givenName")]
1868 pub given_name: Option<String>,
1869}
1870
1871impl common::Part for Name {}
1872
1873/// NotebookLM Notebook link.
1874///
1875/// This type is not used in any activity, and only used as *part* of another schema.
1876///
1877#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1878#[serde_with::serde_as]
1879#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1880pub struct NotebookLmNotebook {
1881 /// Notebook resource id.
1882 pub id: Option<String>,
1883 /// Title of the Notebook.
1884 pub title: Option<String>,
1885 /// URL that can be used to access the Notebook.
1886 pub url: Option<String>,
1887}
1888
1889impl common::Part for NotebookLmNotebook {}
1890
1891/// Request to reclaim a student submission.
1892///
1893/// # Activities
1894///
1895/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1896/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1897///
1898/// * [course work student submissions reclaim courses](CourseCourseWorkStudentSubmissionReclaimCall) (request)
1899#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1900#[serde_with::serde_as]
1901#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1902pub struct ReclaimStudentSubmissionRequest {
1903 _never_set: Option<bool>,
1904}
1905
1906impl common::RequestValue for ReclaimStudentSubmissionRequest {}
1907
1908/// An instruction to Classroom to send notifications from the `feed` to the provided destination.
1909///
1910/// # Activities
1911///
1912/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1913/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1914///
1915/// * [create registrations](RegistrationCreateCall) (request|response)
1916/// * [delete registrations](RegistrationDeleteCall) (none)
1917#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1918#[serde_with::serde_as]
1919#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1920pub struct Registration {
1921 /// The Cloud Pub/Sub topic that notifications are to be sent to.
1922 #[serde(rename = "cloudPubsubTopic")]
1923 pub cloud_pubsub_topic: Option<CloudPubsubTopic>,
1924 /// The time until which the `Registration` is effective. This is a read-only field assigned by the server.
1925 #[serde(rename = "expiryTime")]
1926 pub expiry_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1927 /// Specification for the class of notifications that Classroom should deliver to the destination.
1928 pub feed: Option<Feed>,
1929 /// A server-generated unique identifier for this `Registration`. Read-only.
1930 #[serde(rename = "registrationId")]
1931 pub registration_id: Option<String>,
1932}
1933
1934impl common::RequestValue for Registration {}
1935impl common::Resource for Registration {}
1936impl common::ResponseResult for Registration {}
1937
1938/// Request to return a student submission.
1939///
1940/// # Activities
1941///
1942/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1943/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1944///
1945/// * [course work student submissions return courses](CourseCourseWorkStudentSubmissionReturnCall) (request)
1946#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1947#[serde_with::serde_as]
1948#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1949pub struct ReturnStudentSubmissionRequest {
1950 _never_set: Option<bool>,
1951}
1952
1953impl common::RequestValue for ReturnStudentSubmissionRequest {}
1954
1955/// The rubric of the course work. A rubric is a scoring guide used to evaluate student work and give feedback. For further details, see [Rubrics structure and known limitations](https://developers.google.com/classroom/rubrics/limitations).
1956///
1957/// # Activities
1958///
1959/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1960/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1961///
1962/// * [course work rubrics create courses](CourseCourseWorkRubricCreateCall) (request|response)
1963/// * [course work rubrics get courses](CourseCourseWorkRubricGetCall) (response)
1964/// * [course work rubrics patch courses](CourseCourseWorkRubricPatchCall) (request|response)
1965/// * [course work update rubric courses](CourseCourseWorkUpdateRubricCall) (request|response)
1966#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1967#[serde_with::serde_as]
1968#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1969pub struct Rubric {
1970 /// Identifier of the course. Read-only.
1971 #[serde(rename = "courseId")]
1972 pub course_id: Option<String>,
1973 /// Identifier for the course work this corresponds to. Read-only.
1974 #[serde(rename = "courseWorkId")]
1975 pub course_work_id: Option<String>,
1976 /// Output only. Timestamp when this rubric was created. Read-only.
1977 #[serde(rename = "creationTime")]
1978 pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1979 /// List of criteria. Each criterion is a dimension on which performance is rated.
1980 pub criteria: Option<Vec<Criterion>>,
1981 /// Classroom-assigned identifier for the rubric. This is unique among rubrics for the relevant course work. Read-only.
1982 pub id: Option<String>,
1983 /// Input only. Immutable. Google Sheets ID of the spreadsheet. This spreadsheet must contain formatted rubric settings. See [Create or reuse a rubric for an assignment](https://support.google.com/edu/classroom/answer/9335069). Use of this field requires the `https://www.googleapis.com/auth/spreadsheets.readonly` or `https://www.googleapis.com/auth/spreadsheets` scope.
1984 #[serde(rename = "sourceSpreadsheetId")]
1985 pub source_spreadsheet_id: Option<String>,
1986 /// Output only. Timestamp of the most recent change to this rubric. Read-only.
1987 #[serde(rename = "updateTime")]
1988 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1989}
1990
1991impl common::RequestValue for Rubric {}
1992impl common::ResponseResult for Rubric {}
1993
1994/// A rubric grade set for the student submission. There is at most one entry per rubric criterion.
1995///
1996/// This type is not used in any activity, and only used as *part* of another schema.
1997///
1998#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1999#[serde_with::serde_as]
2000#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2001pub struct RubricGrade {
2002 /// Optional. Criterion ID.
2003 #[serde(rename = "criterionId")]
2004 pub criterion_id: Option<String>,
2005 /// Optional. Optional level ID of the selected level. If empty, no level was selected.
2006 #[serde(rename = "levelId")]
2007 pub level_id: Option<String>,
2008 /// Optional. Optional points assigned for this criterion, typically based on the level. Levels might or might not have points. If unset, no points were set for this criterion.
2009 pub points: Option<f64>,
2010}
2011
2012impl common::Part for RubricGrade {}
2013
2014/// Drive file that is used as material for course work.
2015///
2016/// This type is not used in any activity, and only used as *part* of another schema.
2017///
2018#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2019#[serde_with::serde_as]
2020#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2021pub struct SharedDriveFile {
2022 /// Drive file details.
2023 #[serde(rename = "driveFile")]
2024 pub drive_file: Option<DriveFile>,
2025 /// Mechanism by which students access the Drive item.
2026 #[serde(rename = "shareMode")]
2027 pub share_mode: Option<String>,
2028}
2029
2030impl common::Part for SharedDriveFile {}
2031
2032/// Student work for a short answer question.
2033///
2034/// This type is not used in any activity, and only used as *part* of another schema.
2035///
2036#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2037#[serde_with::serde_as]
2038#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2039pub struct ShortAnswerSubmission {
2040 /// Student response to a short-answer question.
2041 pub answer: Option<String>,
2042}
2043
2044impl common::Part for ShortAnswerSubmission {}
2045
2046/// The history of each state this submission has been in.
2047///
2048/// This type is not used in any activity, and only used as *part* of another schema.
2049///
2050#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2051#[serde_with::serde_as]
2052#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2053pub struct StateHistory {
2054 /// The teacher or student who made the change.
2055 #[serde(rename = "actorUserId")]
2056 pub actor_user_id: Option<String>,
2057 /// The workflow pipeline stage.
2058 pub state: Option<String>,
2059 /// When the submission entered this state.
2060 #[serde(rename = "stateTimestamp")]
2061 pub state_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
2062}
2063
2064impl common::Part for StateHistory {}
2065
2066/// Student in a course.
2067///
2068/// # Activities
2069///
2070/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2071/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2072///
2073/// * [students create courses](CourseStudentCreateCall) (request|response)
2074/// * [students get courses](CourseStudentGetCall) (response)
2075#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2076#[serde_with::serde_as]
2077#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2078pub struct Student {
2079 /// Identifier of the course. Read-only.
2080 #[serde(rename = "courseId")]
2081 pub course_id: Option<String>,
2082 /// Global user information for the student. Read-only.
2083 pub profile: Option<UserProfile>,
2084 /// Information about a Drive Folder for this student's work in this course. Only visible to the student and domain administrators. Read-only.
2085 #[serde(rename = "studentWorkFolder")]
2086 pub student_work_folder: Option<DriveFolder>,
2087 /// Identifier of the user. When specified as a parameter of a request, this identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
2088 #[serde(rename = "userId")]
2089 pub user_id: Option<String>,
2090}
2091
2092impl common::RequestValue for Student {}
2093impl common::ResponseResult for Student {}
2094
2095/// Role-specific context if the requesting user is a student.
2096///
2097/// This type is not used in any activity, and only used as *part* of another schema.
2098///
2099#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2100#[serde_with::serde_as]
2101#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2102pub struct StudentContext {
2103 /// Requesting user's submission id to be used for grade passback and to identify the student when showing student work to the teacher. This is set exactly when `supportsStudentWork` is `true`.
2104 #[serde(rename = "submissionId")]
2105 pub submission_id: Option<String>,
2106}
2107
2108impl common::Part for StudentContext {}
2109
2110/// Student submission for course work. `StudentSubmission` items are generated when a `CourseWork` item is created. Student submissions that have never been accessed (i.e. with `state` = NEW) may not have a creation time or update time.
2111///
2112/// # Activities
2113///
2114/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2115/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2116///
2117/// * [course work student submissions get courses](CourseCourseWorkStudentSubmissionGetCall) (response)
2118/// * [course work student submissions modify attachments courses](CourseCourseWorkStudentSubmissionModifyAttachmentCall) (response)
2119/// * [course work student submissions patch courses](CourseCourseWorkStudentSubmissionPatchCall) (request|response)
2120#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2121#[serde_with::serde_as]
2122#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2123pub struct StudentSubmission {
2124 /// Absolute link to the submission in the Classroom web UI. Read-only.
2125 #[serde(rename = "alternateLink")]
2126 pub alternate_link: Option<String>,
2127 /// Optional grade. If unset, no grade was set. This value must be non-negative. Decimal (that is, non-integer) values are allowed, but are rounded to two decimal places. This may be modified only by course teachers.
2128 #[serde(rename = "assignedGrade")]
2129 pub assigned_grade: Option<f64>,
2130 /// Assigned rubric grades based on the rubric's Criteria. This map is empty if there is no rubric attached to this course work or if a rubric is attached, but no grades have been set on any Criteria. Entries are only populated for grades that have been set. Key: The rubric's criterion ID. Read-only.
2131 #[serde(rename = "assignedRubricGrades")]
2132 pub assigned_rubric_grades: Option<HashMap<String, RubricGrade>>,
2133 /// Submission content when course_work_type is ASSIGNMENT. Students can modify this content using ModifyAttachments.
2134 #[serde(rename = "assignmentSubmission")]
2135 pub assignment_submission: Option<AssignmentSubmission>,
2136 /// Whether this student submission is associated with the Developer Console project making the request. See CreateCourseWork for more details. Read-only.
2137 #[serde(rename = "associatedWithDeveloper")]
2138 pub associated_with_developer: Option<bool>,
2139 /// Identifier of the course. Read-only.
2140 #[serde(rename = "courseId")]
2141 pub course_id: Option<String>,
2142 /// Identifier for the course work this corresponds to. Read-only.
2143 #[serde(rename = "courseWorkId")]
2144 pub course_work_id: Option<String>,
2145 /// Type of course work this submission is for. Read-only.
2146 #[serde(rename = "courseWorkType")]
2147 pub course_work_type: Option<String>,
2148 /// Creation time of this submission. This may be unset if the student has not accessed this item. Read-only.
2149 #[serde(rename = "creationTime")]
2150 pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2151 /// Optional pending grade. If unset, no grade was set. This value must be non-negative. Decimal (that is, non-integer) values are allowed, but are rounded to two decimal places. This is only visible to and modifiable by course teachers.
2152 #[serde(rename = "draftGrade")]
2153 pub draft_grade: Option<f64>,
2154 /// Pending rubric grades based on the rubric's criteria. This map is empty if there is no rubric attached to this course work or if a rubric is attached, but no grades have been set on any criteria. Entries are only populated for grades that have been set. Key: The rubric's criterion ID. Read-only.
2155 #[serde(rename = "draftRubricGrades")]
2156 pub draft_rubric_grades: Option<HashMap<String, RubricGrade>>,
2157 /// Classroom-assigned Identifier for the student submission. This is unique among submissions for the relevant course work. Read-only.
2158 pub id: Option<String>,
2159 /// Whether this submission is late. Read-only.
2160 pub late: Option<bool>,
2161 /// Submission content when course_work_type is MULTIPLE_CHOICE_QUESTION.
2162 #[serde(rename = "multipleChoiceSubmission")]
2163 pub multiple_choice_submission: Option<MultipleChoiceSubmission>,
2164 /// Submission content when course_work_type is SHORT_ANSWER_QUESTION.
2165 #[serde(rename = "shortAnswerSubmission")]
2166 pub short_answer_submission: Option<ShortAnswerSubmission>,
2167 /// State of this submission. Read-only.
2168 pub state: Option<String>,
2169 /// The history of the submission (includes state and grade histories). Read-only.
2170 #[serde(rename = "submissionHistory")]
2171 pub submission_history: Option<Vec<SubmissionHistory>>,
2172 /// Last update time of this submission. This may be unset if the student has not accessed this item. Read-only.
2173 #[serde(rename = "updateTime")]
2174 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2175 /// Identifier for the student that owns this submission. Read-only.
2176 #[serde(rename = "userId")]
2177 pub user_id: Option<String>,
2178}
2179
2180impl common::RequestValue for StudentSubmission {}
2181impl common::ResponseResult for StudentSubmission {}
2182
2183/// The history of the submission. This currently includes state and grade histories.
2184///
2185/// This type is not used in any activity, and only used as *part* of another schema.
2186///
2187#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2188#[serde_with::serde_as]
2189#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2190pub struct SubmissionHistory {
2191 /// The grade history information of the submission, if present.
2192 #[serde(rename = "gradeHistory")]
2193 pub grade_history: Option<GradeHistory>,
2194 /// The state history information of the submission, if present.
2195 #[serde(rename = "stateHistory")]
2196 pub state_history: Option<StateHistory>,
2197}
2198
2199impl common::Part for SubmissionHistory {}
2200
2201/// Teacher of a course.
2202///
2203/// # Activities
2204///
2205/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2206/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2207///
2208/// * [teachers create courses](CourseTeacherCreateCall) (request|response)
2209/// * [teachers get courses](CourseTeacherGetCall) (response)
2210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2211#[serde_with::serde_as]
2212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2213pub struct Teacher {
2214 /// Identifier of the course. Read-only.
2215 #[serde(rename = "courseId")]
2216 pub course_id: Option<String>,
2217 /// Global user information for the teacher. Read-only.
2218 pub profile: Option<UserProfile>,
2219 /// Identifier of the user. When specified as a parameter of a request, this identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
2220 #[serde(rename = "userId")]
2221 pub user_id: Option<String>,
2222}
2223
2224impl common::RequestValue for Teacher {}
2225impl common::ResponseResult for Teacher {}
2226
2227/// Role-specific context if the requesting user is a teacher.
2228///
2229/// This type is not used in any activity, and only used as *part* of another schema.
2230///
2231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2232#[serde_with::serde_as]
2233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2234pub struct TeacherContext {
2235 _never_set: Option<bool>,
2236}
2237
2238impl common::Part for TeacherContext {}
2239
2240/// Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`.
2241///
2242/// This type is not used in any activity, and only used as *part* of another schema.
2243///
2244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2245#[serde_with::serde_as]
2246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2247pub struct TimeOfDay {
2248 /// Hours of a day in 24 hour format. Must be greater than or equal to 0 and typically must be less than or equal to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
2249 pub hours: Option<i32>,
2250 /// Minutes of an hour. Must be greater than or equal to 0 and less than or equal to 59.
2251 pub minutes: Option<i32>,
2252 /// Fractions of seconds, in nanoseconds. Must be greater than or equal to 0 and less than or equal to 999,999,999.
2253 pub nanos: Option<i32>,
2254 /// Seconds of a minute. Must be greater than or equal to 0 and typically must be less than or equal to 59. An API may allow the value 60 if it allows leap-seconds.
2255 pub seconds: Option<i32>,
2256}
2257
2258impl common::Part for TimeOfDay {}
2259
2260/// Topic created by a teacher for the course
2261///
2262/// # Activities
2263///
2264/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2265/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2266///
2267/// * [topics create courses](CourseTopicCreateCall) (request|response)
2268/// * [topics get courses](CourseTopicGetCall) (response)
2269/// * [topics patch courses](CourseTopicPatchCall) (request|response)
2270#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2271#[serde_with::serde_as]
2272#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2273pub struct Topic {
2274 /// Identifier of the course. Read-only.
2275 #[serde(rename = "courseId")]
2276 pub course_id: Option<String>,
2277 /// The name of the topic, generated by the user. Leading and trailing whitespaces, if any, are trimmed. Also, multiple consecutive whitespaces are collapsed into one inside the name. The result must be a non-empty string. Topic names are case sensitive, and must be no longer than 100 characters.
2278 pub name: Option<String>,
2279 /// Unique identifier for the topic. Read-only.
2280 #[serde(rename = "topicId")]
2281 pub topic_id: Option<String>,
2282 /// The time the topic was last updated by the system. Read-only.
2283 #[serde(rename = "updateTime")]
2284 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2285}
2286
2287impl common::RequestValue for Topic {}
2288impl common::ResponseResult for Topic {}
2289
2290/// Request to turn in a student submission.
2291///
2292/// # Activities
2293///
2294/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2295/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2296///
2297/// * [course work student submissions turn in courses](CourseCourseWorkStudentSubmissionTurnInCall) (request)
2298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2299#[serde_with::serde_as]
2300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2301pub struct TurnInStudentSubmissionRequest {
2302 _never_set: Option<bool>,
2303}
2304
2305impl common::RequestValue for TurnInStudentSubmissionRequest {}
2306
2307/// Global information for a user.
2308///
2309/// # Activities
2310///
2311/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2312/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2313///
2314/// * [guardian invitations create user profiles](UserProfileGuardianInvitationCreateCall) (none)
2315/// * [guardian invitations get user profiles](UserProfileGuardianInvitationGetCall) (none)
2316/// * [guardian invitations list user profiles](UserProfileGuardianInvitationListCall) (none)
2317/// * [guardian invitations patch user profiles](UserProfileGuardianInvitationPatchCall) (none)
2318/// * [guardians delete user profiles](UserProfileGuardianDeleteCall) (none)
2319/// * [guardians get user profiles](UserProfileGuardianGetCall) (none)
2320/// * [guardians list user profiles](UserProfileGuardianListCall) (none)
2321/// * [get user profiles](UserProfileGetCall) (response)
2322#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2323#[serde_with::serde_as]
2324#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2325pub struct UserProfile {
2326 /// Email address of the user. Must request `https://www.googleapis.com/auth/classroom.profile.emails` scope for this field to be populated in a response body. Read-only.
2327 #[serde(rename = "emailAddress")]
2328 pub email_address: Option<String>,
2329 /// Identifier of the user. Read-only.
2330 pub id: Option<String>,
2331 /// Name of the user. Read-only.
2332 pub name: Option<Name>,
2333 /// Global permissions of the user. Read-only.
2334 pub permissions: Option<Vec<GlobalPermission>>,
2335 /// URL of user's profile photo. Must request `https://www.googleapis.com/auth/classroom.profile.photos` scope for this field to be populated in a response body. Read-only.
2336 #[serde(rename = "photoUrl")]
2337 pub photo_url: Option<String>,
2338 /// Represents whether a Google Workspace for Education user's domain administrator has explicitly verified them as being a teacher. This field is always false if the user is not a member of a Google Workspace for Education domain. Read-only
2339 #[serde(rename = "verifiedTeacher")]
2340 pub verified_teacher: Option<bool>,
2341}
2342
2343impl common::Resource for UserProfile {}
2344impl common::ResponseResult for UserProfile {}
2345
2346/// YouTube video item.
2347///
2348/// This type is not used in any activity, and only used as *part* of another schema.
2349///
2350#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2351#[serde_with::serde_as]
2352#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2353pub struct YouTubeVideo {
2354 /// URL that can be used to view the YouTube video. Read-only.
2355 #[serde(rename = "alternateLink")]
2356 pub alternate_link: Option<String>,
2357 /// YouTube API resource ID.
2358 pub id: Option<String>,
2359 /// URL of a thumbnail image of the YouTube video. Read-only.
2360 #[serde(rename = "thumbnailUrl")]
2361 pub thumbnail_url: Option<String>,
2362 /// Title of the YouTube video. Read-only.
2363 pub title: Option<String>,
2364}
2365
2366impl common::Part for YouTubeVideo {}
2367
2368// ###################
2369// MethodBuilders ###
2370// #################
2371
2372/// A builder providing access to all methods supported on *course* resources.
2373/// It is not used directly, but through the [`Classroom`] hub.
2374///
2375/// # Example
2376///
2377/// Instantiate a resource builder
2378///
2379/// ```test_harness,no_run
2380/// extern crate hyper;
2381/// extern crate hyper_rustls;
2382/// extern crate google_classroom1 as classroom1;
2383///
2384/// # async fn dox() {
2385/// use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2386///
2387/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2388/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2389/// .with_native_roots()
2390/// .unwrap()
2391/// .https_only()
2392/// .enable_http2()
2393/// .build();
2394///
2395/// let executor = hyper_util::rt::TokioExecutor::new();
2396/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2397/// secret,
2398/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2399/// yup_oauth2::client::CustomHyperClientBuilder::from(
2400/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2401/// ),
2402/// ).build().await.unwrap();
2403///
2404/// let client = hyper_util::client::legacy::Client::builder(
2405/// hyper_util::rt::TokioExecutor::new()
2406/// )
2407/// .build(
2408/// hyper_rustls::HttpsConnectorBuilder::new()
2409/// .with_native_roots()
2410/// .unwrap()
2411/// .https_or_http()
2412/// .enable_http2()
2413/// .build()
2414/// );
2415/// let mut hub = Classroom::new(client, auth);
2416/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2417/// // like `aliases_create(...)`, `aliases_delete(...)`, `aliases_list(...)`, `announcements_add_on_attachments_create(...)`, `announcements_add_on_attachments_delete(...)`, `announcements_add_on_attachments_get(...)`, `announcements_add_on_attachments_list(...)`, `announcements_add_on_attachments_patch(...)`, `announcements_create(...)`, `announcements_delete(...)`, `announcements_get(...)`, `announcements_get_add_on_context(...)`, `announcements_list(...)`, `announcements_modify_assignees(...)`, `announcements_patch(...)`, `course_work_add_on_attachments_create(...)`, `course_work_add_on_attachments_delete(...)`, `course_work_add_on_attachments_get(...)`, `course_work_add_on_attachments_list(...)`, `course_work_add_on_attachments_patch(...)`, `course_work_add_on_attachments_student_submissions_get(...)`, `course_work_add_on_attachments_student_submissions_patch(...)`, `course_work_create(...)`, `course_work_delete(...)`, `course_work_get(...)`, `course_work_get_add_on_context(...)`, `course_work_list(...)`, `course_work_materials_add_on_attachments_create(...)`, `course_work_materials_add_on_attachments_delete(...)`, `course_work_materials_add_on_attachments_get(...)`, `course_work_materials_add_on_attachments_list(...)`, `course_work_materials_add_on_attachments_patch(...)`, `course_work_materials_create(...)`, `course_work_materials_delete(...)`, `course_work_materials_get(...)`, `course_work_materials_get_add_on_context(...)`, `course_work_materials_list(...)`, `course_work_materials_patch(...)`, `course_work_modify_assignees(...)`, `course_work_patch(...)`, `course_work_rubrics_create(...)`, `course_work_rubrics_delete(...)`, `course_work_rubrics_get(...)`, `course_work_rubrics_list(...)`, `course_work_rubrics_patch(...)`, `course_work_student_submissions_get(...)`, `course_work_student_submissions_list(...)`, `course_work_student_submissions_modify_attachments(...)`, `course_work_student_submissions_patch(...)`, `course_work_student_submissions_reclaim(...)`, `course_work_student_submissions_return(...)`, `course_work_student_submissions_turn_in(...)`, `course_work_update_rubric(...)`, `create(...)`, `delete(...)`, `get(...)`, `get_grading_period_settings(...)`, `list(...)`, `patch(...)`, `posts_add_on_attachments_create(...)`, `posts_add_on_attachments_delete(...)`, `posts_add_on_attachments_get(...)`, `posts_add_on_attachments_list(...)`, `posts_add_on_attachments_patch(...)`, `posts_add_on_attachments_student_submissions_get(...)`, `posts_add_on_attachments_student_submissions_patch(...)`, `posts_get_add_on_context(...)`, `students_create(...)`, `students_delete(...)`, `students_get(...)`, `students_list(...)`, `teachers_create(...)`, `teachers_delete(...)`, `teachers_get(...)`, `teachers_list(...)`, `topics_create(...)`, `topics_delete(...)`, `topics_get(...)`, `topics_list(...)`, `topics_patch(...)`, `update(...)` and `update_grading_period_settings(...)`
2418/// // to build up your call.
2419/// let rb = hub.courses();
2420/// # }
2421/// ```
2422pub struct CourseMethods<'a, C>
2423where
2424 C: 'a,
2425{
2426 hub: &'a Classroom<C>,
2427}
2428
2429impl<'a, C> common::MethodsBuilder for CourseMethods<'a, C> {}
2430
2431impl<'a, C> CourseMethods<'a, C> {
2432 /// Create a builder to help you perform the following task:
2433 ///
2434 /// Creates an alias for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create the alias or for access errors. * `NOT_FOUND` if the course does not exist. * `ALREADY_EXISTS` if the alias already exists. * `FAILED_PRECONDITION` if the alias requested does not make sense for the requesting user or course (for example, if a user not in a domain attempts to access a domain-scoped alias).
2435 ///
2436 /// # Arguments
2437 ///
2438 /// * `request` - No description provided.
2439 /// * `courseId` - Identifier of the course to alias. This identifier can be either the Classroom-assigned identifier or an alias.
2440 pub fn aliases_create(
2441 &self,
2442 request: CourseAlias,
2443 course_id: &str,
2444 ) -> CourseAliasCreateCall<'a, C> {
2445 CourseAliasCreateCall {
2446 hub: self.hub,
2447 _request: request,
2448 _course_id: course_id.to_string(),
2449 _delegate: Default::default(),
2450 _additional_params: Default::default(),
2451 _scopes: Default::default(),
2452 }
2453 }
2454
2455 /// Create a builder to help you perform the following task:
2456 ///
2457 /// Deletes an alias of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to remove the alias or for access errors. * `NOT_FOUND` if the alias does not exist. * `FAILED_PRECONDITION` if the alias requested does not make sense for the requesting user or course (for example, if a user not in a domain attempts to delete a domain-scoped alias).
2458 ///
2459 /// # Arguments
2460 ///
2461 /// * `courseId` - Identifier of the course whose alias should be deleted. This identifier can be either the Classroom-assigned identifier or an alias.
2462 /// * `alias` - Alias to delete. This may not be the Classroom-assigned identifier.
2463 pub fn aliases_delete(&self, course_id: &str, alias: &str) -> CourseAliasDeleteCall<'a, C> {
2464 CourseAliasDeleteCall {
2465 hub: self.hub,
2466 _course_id: course_id.to_string(),
2467 _alias: alias.to_string(),
2468 _delegate: Default::default(),
2469 _additional_params: Default::default(),
2470 _scopes: Default::default(),
2471 }
2472 }
2473
2474 /// Create a builder to help you perform the following task:
2475 ///
2476 /// Returns a list of aliases for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the course or for access errors. * `NOT_FOUND` if the course does not exist.
2477 ///
2478 /// # Arguments
2479 ///
2480 /// * `courseId` - The identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
2481 pub fn aliases_list(&self, course_id: &str) -> CourseAliasListCall<'a, C> {
2482 CourseAliasListCall {
2483 hub: self.hub,
2484 _course_id: course_id.to_string(),
2485 _page_token: Default::default(),
2486 _page_size: Default::default(),
2487 _delegate: Default::default(),
2488 _additional_params: Default::default(),
2489 _scopes: Default::default(),
2490 }
2491 }
2492
2493 /// Create a builder to help you perform the following task:
2494 ///
2495 /// Creates an add-on attachment under a post. Requires the add-on to have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2496 ///
2497 /// # Arguments
2498 ///
2499 /// * `request` - No description provided.
2500 /// * `courseId` - Required. Identifier of the course.
2501 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which to create the attachment. This field is required, but is not marked as such while we are migrating from post_id.
2502 pub fn announcements_add_on_attachments_create(
2503 &self,
2504 request: AddOnAttachment,
2505 course_id: &str,
2506 item_id: &str,
2507 ) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C> {
2508 CourseAnnouncementAddOnAttachmentCreateCall {
2509 hub: self.hub,
2510 _request: request,
2511 _course_id: course_id.to_string(),
2512 _item_id: item_id.to_string(),
2513 _post_id: Default::default(),
2514 _add_on_token: Default::default(),
2515 _delegate: Default::default(),
2516 _additional_params: Default::default(),
2517 _scopes: Default::default(),
2518 }
2519 }
2520
2521 /// Create a builder to help you perform the following task:
2522 ///
2523 /// Deletes an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2524 ///
2525 /// # Arguments
2526 ///
2527 /// * `courseId` - Required. Identifier of the course.
2528 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
2529 /// * `attachmentId` - Required. Identifier of the attachment.
2530 pub fn announcements_add_on_attachments_delete(
2531 &self,
2532 course_id: &str,
2533 item_id: &str,
2534 attachment_id: &str,
2535 ) -> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C> {
2536 CourseAnnouncementAddOnAttachmentDeleteCall {
2537 hub: self.hub,
2538 _course_id: course_id.to_string(),
2539 _item_id: item_id.to_string(),
2540 _attachment_id: attachment_id.to_string(),
2541 _post_id: Default::default(),
2542 _delegate: Default::default(),
2543 _additional_params: Default::default(),
2544 _scopes: Default::default(),
2545 }
2546 }
2547
2548 /// Create a builder to help you perform the following task:
2549 ///
2550 /// Returns an add-on attachment. Requires the add-on requesting the attachment to be the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2551 ///
2552 /// # Arguments
2553 ///
2554 /// * `courseId` - Required. Identifier of the course.
2555 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
2556 /// * `attachmentId` - Required. Identifier of the attachment.
2557 pub fn announcements_add_on_attachments_get(
2558 &self,
2559 course_id: &str,
2560 item_id: &str,
2561 attachment_id: &str,
2562 ) -> CourseAnnouncementAddOnAttachmentGetCall<'a, C> {
2563 CourseAnnouncementAddOnAttachmentGetCall {
2564 hub: self.hub,
2565 _course_id: course_id.to_string(),
2566 _item_id: item_id.to_string(),
2567 _attachment_id: attachment_id.to_string(),
2568 _post_id: Default::default(),
2569 _delegate: Default::default(),
2570 _additional_params: Default::default(),
2571 _scopes: Default::default(),
2572 }
2573 }
2574
2575 /// Create a builder to help you perform the following task:
2576 ///
2577 /// Returns all attachments created by an add-on under the post. Requires the add-on to have active attachments on the post or have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2578 ///
2579 /// # Arguments
2580 ///
2581 /// * `courseId` - Required. Identifier of the course.
2582 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` whose attachments should be enumerated. This field is required, but is not marked as such while we are migrating from post_id.
2583 pub fn announcements_add_on_attachments_list(
2584 &self,
2585 course_id: &str,
2586 item_id: &str,
2587 ) -> CourseAnnouncementAddOnAttachmentListCall<'a, C> {
2588 CourseAnnouncementAddOnAttachmentListCall {
2589 hub: self.hub,
2590 _course_id: course_id.to_string(),
2591 _item_id: item_id.to_string(),
2592 _post_id: Default::default(),
2593 _page_token: Default::default(),
2594 _page_size: Default::default(),
2595 _delegate: Default::default(),
2596 _additional_params: Default::default(),
2597 _scopes: Default::default(),
2598 }
2599 }
2600
2601 /// Create a builder to help you perform the following task:
2602 ///
2603 /// Updates an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2604 ///
2605 /// # Arguments
2606 ///
2607 /// * `request` - No description provided.
2608 /// * `courseId` - Required. Identifier of the course.
2609 /// * `itemId` - Identifier of the post under which the attachment is attached.
2610 /// * `attachmentId` - Required. Identifier of the attachment.
2611 pub fn announcements_add_on_attachments_patch(
2612 &self,
2613 request: AddOnAttachment,
2614 course_id: &str,
2615 item_id: &str,
2616 attachment_id: &str,
2617 ) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C> {
2618 CourseAnnouncementAddOnAttachmentPatchCall {
2619 hub: self.hub,
2620 _request: request,
2621 _course_id: course_id.to_string(),
2622 _item_id: item_id.to_string(),
2623 _attachment_id: attachment_id.to_string(),
2624 _update_mask: Default::default(),
2625 _post_id: Default::default(),
2626 _delegate: Default::default(),
2627 _additional_params: Default::default(),
2628 _scopes: Default::default(),
2629 }
2630 }
2631
2632 /// Create a builder to help you perform the following task:
2633 ///
2634 /// Creates an announcement. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create announcements in the requested course, share a Drive attachment, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist. * `FAILED_PRECONDITION` for the following request error: * AttachmentNotVisible
2635 ///
2636 /// # Arguments
2637 ///
2638 /// * `request` - No description provided.
2639 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
2640 pub fn announcements_create(
2641 &self,
2642 request: Announcement,
2643 course_id: &str,
2644 ) -> CourseAnnouncementCreateCall<'a, C> {
2645 CourseAnnouncementCreateCall {
2646 hub: self.hub,
2647 _request: request,
2648 _course_id: course_id.to_string(),
2649 _delegate: Default::default(),
2650 _additional_params: Default::default(),
2651 _scopes: Default::default(),
2652 }
2653 }
2654
2655 /// Create a builder to help you perform the following task:
2656 ///
2657 /// Deletes an announcement. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding announcement item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding announcement, if the requesting user is not permitted to delete the requested course or for access errors. * `FAILED_PRECONDITION` if the requested announcement has already been deleted. * `NOT_FOUND` if no course exists with the requested ID.
2658 ///
2659 /// # Arguments
2660 ///
2661 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
2662 /// * `id` - Identifier of the announcement to delete. This identifier is a Classroom-assigned identifier.
2663 pub fn announcements_delete(
2664 &self,
2665 course_id: &str,
2666 id: &str,
2667 ) -> CourseAnnouncementDeleteCall<'a, C> {
2668 CourseAnnouncementDeleteCall {
2669 hub: self.hub,
2670 _course_id: course_id.to_string(),
2671 _id: id.to_string(),
2672 _delegate: Default::default(),
2673 _additional_params: Default::default(),
2674 _scopes: Default::default(),
2675 }
2676 }
2677
2678 /// Create a builder to help you perform the following task:
2679 ///
2680 /// Returns an announcement. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or announcement, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or announcement does not exist.
2681 ///
2682 /// # Arguments
2683 ///
2684 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
2685 /// * `id` - Identifier of the announcement.
2686 pub fn announcements_get(&self, course_id: &str, id: &str) -> CourseAnnouncementGetCall<'a, C> {
2687 CourseAnnouncementGetCall {
2688 hub: self.hub,
2689 _course_id: course_id.to_string(),
2690 _id: id.to_string(),
2691 _delegate: Default::default(),
2692 _additional_params: Default::default(),
2693 _scopes: Default::default(),
2694 }
2695 }
2696
2697 /// Create a builder to help you perform the following task:
2698 ///
2699 /// Gets metadata for Classroom add-ons in the context of a specific post. To maintain the integrity of its own data and permissions model, an add-on should call this to validate query parameters and the requesting user's role whenever the add-on is opened in an [iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/iframes-overview). This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2700 ///
2701 /// # Arguments
2702 ///
2703 /// * `courseId` - Required. Identifier of the course.
2704 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
2705 pub fn announcements_get_add_on_context(
2706 &self,
2707 course_id: &str,
2708 item_id: &str,
2709 ) -> CourseAnnouncementGetAddOnContextCall<'a, C> {
2710 CourseAnnouncementGetAddOnContextCall {
2711 hub: self.hub,
2712 _course_id: course_id.to_string(),
2713 _item_id: item_id.to_string(),
2714 _post_id: Default::default(),
2715 _attachment_id: Default::default(),
2716 _add_on_token: Default::default(),
2717 _delegate: Default::default(),
2718 _additional_params: Default::default(),
2719 _scopes: Default::default(),
2720 }
2721 }
2722
2723 /// Create a builder to help you perform the following task:
2724 ///
2725 /// Returns a list of announcements that the requester is permitted to view. Course students may only view `PUBLISHED` announcements. Course teachers and domain administrators may view all announcements. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
2726 ///
2727 /// # Arguments
2728 ///
2729 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
2730 pub fn announcements_list(&self, course_id: &str) -> CourseAnnouncementListCall<'a, C> {
2731 CourseAnnouncementListCall {
2732 hub: self.hub,
2733 _course_id: course_id.to_string(),
2734 _page_token: Default::default(),
2735 _page_size: Default::default(),
2736 _order_by: Default::default(),
2737 _announcement_states: Default::default(),
2738 _delegate: Default::default(),
2739 _additional_params: Default::default(),
2740 _scopes: Default::default(),
2741 }
2742 }
2743
2744 /// Create a builder to help you perform the following task:
2745 ///
2746 /// Modifies assignee mode and options of an announcement. Only a teacher of the course that contains the announcement may call this method. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work does not exist. * `FAILED_PRECONDITION` for the following request error: * EmptyAssignees
2747 ///
2748 /// # Arguments
2749 ///
2750 /// * `request` - No description provided.
2751 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
2752 /// * `id` - Identifier of the announcement.
2753 pub fn announcements_modify_assignees(
2754 &self,
2755 request: ModifyAnnouncementAssigneesRequest,
2756 course_id: &str,
2757 id: &str,
2758 ) -> CourseAnnouncementModifyAssigneeCall<'a, C> {
2759 CourseAnnouncementModifyAssigneeCall {
2760 hub: self.hub,
2761 _request: request,
2762 _course_id: course_id.to_string(),
2763 _id: id.to_string(),
2764 _delegate: Default::default(),
2765 _additional_params: Default::default(),
2766 _scopes: Default::default(),
2767 }
2768 }
2769
2770 /// Create a builder to help you perform the following task:
2771 ///
2772 /// Updates one or more fields of an announcement. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding announcement or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if the requested announcement has already been deleted. * `NOT_FOUND` if the requested course or announcement does not exist
2773 ///
2774 /// # Arguments
2775 ///
2776 /// * `request` - No description provided.
2777 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
2778 /// * `id` - Identifier of the announcement.
2779 pub fn announcements_patch(
2780 &self,
2781 request: Announcement,
2782 course_id: &str,
2783 id: &str,
2784 ) -> CourseAnnouncementPatchCall<'a, C> {
2785 CourseAnnouncementPatchCall {
2786 hub: self.hub,
2787 _request: request,
2788 _course_id: course_id.to_string(),
2789 _id: id.to_string(),
2790 _update_mask: Default::default(),
2791 _delegate: Default::default(),
2792 _additional_params: Default::default(),
2793 _scopes: Default::default(),
2794 }
2795 }
2796
2797 /// Create a builder to help you perform the following task:
2798 ///
2799 /// Returns a student submission for an add-on attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2800 ///
2801 /// # Arguments
2802 ///
2803 /// * `courseId` - Required. Identifier of the course.
2804 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
2805 /// * `attachmentId` - Required. Identifier of the attachment.
2806 /// * `submissionId` - Required. Identifier of the student’s submission.
2807 pub fn course_work_add_on_attachments_student_submissions_get(
2808 &self,
2809 course_id: &str,
2810 item_id: &str,
2811 attachment_id: &str,
2812 submission_id: &str,
2813 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C> {
2814 CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall {
2815 hub: self.hub,
2816 _course_id: course_id.to_string(),
2817 _item_id: item_id.to_string(),
2818 _attachment_id: attachment_id.to_string(),
2819 _submission_id: submission_id.to_string(),
2820 _post_id: Default::default(),
2821 _delegate: Default::default(),
2822 _additional_params: Default::default(),
2823 _scopes: Default::default(),
2824 }
2825 }
2826
2827 /// Create a builder to help you perform the following task:
2828 ///
2829 /// Updates data associated with an add-on attachment submission. Requires the add-on to have been the original creator of the attachment and the attachment to have a positive `max_points` value set. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2830 ///
2831 /// # Arguments
2832 ///
2833 /// * `request` - No description provided.
2834 /// * `courseId` - Required. Identifier of the course.
2835 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
2836 /// * `attachmentId` - Required. Identifier of the attachment.
2837 /// * `submissionId` - Required. Identifier of the student's submission.
2838 pub fn course_work_add_on_attachments_student_submissions_patch(
2839 &self,
2840 request: AddOnAttachmentStudentSubmission,
2841 course_id: &str,
2842 item_id: &str,
2843 attachment_id: &str,
2844 submission_id: &str,
2845 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
2846 CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall {
2847 hub: self.hub,
2848 _request: request,
2849 _course_id: course_id.to_string(),
2850 _item_id: item_id.to_string(),
2851 _attachment_id: attachment_id.to_string(),
2852 _submission_id: submission_id.to_string(),
2853 _update_mask: Default::default(),
2854 _post_id: Default::default(),
2855 _delegate: Default::default(),
2856 _additional_params: Default::default(),
2857 _scopes: Default::default(),
2858 }
2859 }
2860
2861 /// Create a builder to help you perform the following task:
2862 ///
2863 /// Creates an add-on attachment under a post. Requires the add-on to have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2864 ///
2865 /// # Arguments
2866 ///
2867 /// * `request` - No description provided.
2868 /// * `courseId` - Required. Identifier of the course.
2869 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which to create the attachment. This field is required, but is not marked as such while we are migrating from post_id.
2870 pub fn course_work_add_on_attachments_create(
2871 &self,
2872 request: AddOnAttachment,
2873 course_id: &str,
2874 item_id: &str,
2875 ) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C> {
2876 CourseCourseWorkAddOnAttachmentCreateCall {
2877 hub: self.hub,
2878 _request: request,
2879 _course_id: course_id.to_string(),
2880 _item_id: item_id.to_string(),
2881 _post_id: Default::default(),
2882 _add_on_token: Default::default(),
2883 _delegate: Default::default(),
2884 _additional_params: Default::default(),
2885 _scopes: Default::default(),
2886 }
2887 }
2888
2889 /// Create a builder to help you perform the following task:
2890 ///
2891 /// Deletes an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2892 ///
2893 /// # Arguments
2894 ///
2895 /// * `courseId` - Required. Identifier of the course.
2896 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
2897 /// * `attachmentId` - Required. Identifier of the attachment.
2898 pub fn course_work_add_on_attachments_delete(
2899 &self,
2900 course_id: &str,
2901 item_id: &str,
2902 attachment_id: &str,
2903 ) -> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C> {
2904 CourseCourseWorkAddOnAttachmentDeleteCall {
2905 hub: self.hub,
2906 _course_id: course_id.to_string(),
2907 _item_id: item_id.to_string(),
2908 _attachment_id: attachment_id.to_string(),
2909 _post_id: Default::default(),
2910 _delegate: Default::default(),
2911 _additional_params: Default::default(),
2912 _scopes: Default::default(),
2913 }
2914 }
2915
2916 /// Create a builder to help you perform the following task:
2917 ///
2918 /// Returns an add-on attachment. Requires the add-on requesting the attachment to be the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2919 ///
2920 /// # Arguments
2921 ///
2922 /// * `courseId` - Required. Identifier of the course.
2923 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
2924 /// * `attachmentId` - Required. Identifier of the attachment.
2925 pub fn course_work_add_on_attachments_get(
2926 &self,
2927 course_id: &str,
2928 item_id: &str,
2929 attachment_id: &str,
2930 ) -> CourseCourseWorkAddOnAttachmentGetCall<'a, C> {
2931 CourseCourseWorkAddOnAttachmentGetCall {
2932 hub: self.hub,
2933 _course_id: course_id.to_string(),
2934 _item_id: item_id.to_string(),
2935 _attachment_id: attachment_id.to_string(),
2936 _post_id: Default::default(),
2937 _delegate: Default::default(),
2938 _additional_params: Default::default(),
2939 _scopes: Default::default(),
2940 }
2941 }
2942
2943 /// Create a builder to help you perform the following task:
2944 ///
2945 /// Returns all attachments created by an add-on under the post. Requires the add-on to have active attachments on the post or have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2946 ///
2947 /// # Arguments
2948 ///
2949 /// * `courseId` - Required. Identifier of the course.
2950 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` whose attachments should be enumerated. This field is required, but is not marked as such while we are migrating from post_id.
2951 pub fn course_work_add_on_attachments_list(
2952 &self,
2953 course_id: &str,
2954 item_id: &str,
2955 ) -> CourseCourseWorkAddOnAttachmentListCall<'a, C> {
2956 CourseCourseWorkAddOnAttachmentListCall {
2957 hub: self.hub,
2958 _course_id: course_id.to_string(),
2959 _item_id: item_id.to_string(),
2960 _post_id: Default::default(),
2961 _page_token: Default::default(),
2962 _page_size: Default::default(),
2963 _delegate: Default::default(),
2964 _additional_params: Default::default(),
2965 _scopes: Default::default(),
2966 }
2967 }
2968
2969 /// Create a builder to help you perform the following task:
2970 ///
2971 /// Updates an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
2972 ///
2973 /// # Arguments
2974 ///
2975 /// * `request` - No description provided.
2976 /// * `courseId` - Required. Identifier of the course.
2977 /// * `itemId` - Identifier of the post under which the attachment is attached.
2978 /// * `attachmentId` - Required. Identifier of the attachment.
2979 pub fn course_work_add_on_attachments_patch(
2980 &self,
2981 request: AddOnAttachment,
2982 course_id: &str,
2983 item_id: &str,
2984 attachment_id: &str,
2985 ) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C> {
2986 CourseCourseWorkAddOnAttachmentPatchCall {
2987 hub: self.hub,
2988 _request: request,
2989 _course_id: course_id.to_string(),
2990 _item_id: item_id.to_string(),
2991 _attachment_id: attachment_id.to_string(),
2992 _update_mask: Default::default(),
2993 _post_id: Default::default(),
2994 _delegate: Default::default(),
2995 _additional_params: Default::default(),
2996 _scopes: Default::default(),
2997 }
2998 }
2999
3000 /// Create a builder to help you perform the following task:
3001 ///
3002 /// Creates a rubric. The requesting user and course owner must have rubrics creation capabilities. For details, see [licensing requirements](https://developers.google.com/workspace/classroom/rubrics/limitations#license-requirements). For further details, see [Rubrics structure and known limitations](https://developers.google.com/classroom/rubrics/limitations). This request must be made by the Google Cloud console of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the parent course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user isn’t permitted to create rubrics for course work in the requested course. * `INTERNAL` if the request has insufficient OAuth scopes. * `INVALID_ARGUMENT` if the request is malformed and for the following request error: * `RubricCriteriaInvalidFormat` * `NOT_FOUND` if the requested course or course work don’t exist or the user doesn’t have access to the course or course work. * `FAILED_PRECONDITION` for the following request error: * `AttachmentNotVisible`
3003 ///
3004 /// # Arguments
3005 ///
3006 /// * `request` - No description provided.
3007 /// * `courseId` - Required. Identifier of the course.
3008 /// * `courseWorkId` - Required. Identifier of the course work.
3009 pub fn course_work_rubrics_create(
3010 &self,
3011 request: Rubric,
3012 course_id: &str,
3013 course_work_id: &str,
3014 ) -> CourseCourseWorkRubricCreateCall<'a, C> {
3015 CourseCourseWorkRubricCreateCall {
3016 hub: self.hub,
3017 _request: request,
3018 _course_id: course_id.to_string(),
3019 _course_work_id: course_work_id.to_string(),
3020 _delegate: Default::default(),
3021 _additional_params: Default::default(),
3022 _scopes: Default::default(),
3023 }
3024 }
3025
3026 /// Create a builder to help you perform the following task:
3027 ///
3028 /// Deletes a rubric. The requesting user and course owner must have rubrics creation capabilities. For details, see [licensing requirements](https://developers.google.com/workspace/classroom/rubrics/limitations#license-requirements). This request must be made by the Google Cloud console of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding rubric. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project didn't create the corresponding rubric, or if the requesting user isn't permitted to delete the requested rubric. * `NOT_FOUND` if no rubric exists with the requested ID or the user does not have access to the course, course work, or rubric. * `INVALID_ARGUMENT` if grading has already started on the rubric.
3029 ///
3030 /// # Arguments
3031 ///
3032 /// * `courseId` - Required. Identifier of the course.
3033 /// * `courseWorkId` - Required. Identifier of the course work.
3034 /// * `id` - Required. Identifier of the rubric.
3035 pub fn course_work_rubrics_delete(
3036 &self,
3037 course_id: &str,
3038 course_work_id: &str,
3039 id: &str,
3040 ) -> CourseCourseWorkRubricDeleteCall<'a, C> {
3041 CourseCourseWorkRubricDeleteCall {
3042 hub: self.hub,
3043 _course_id: course_id.to_string(),
3044 _course_work_id: course_work_id.to_string(),
3045 _id: id.to_string(),
3046 _delegate: Default::default(),
3047 _additional_params: Default::default(),
3048 _scopes: Default::default(),
3049 }
3050 }
3051
3052 /// Create a builder to help you perform the following task:
3053 ///
3054 /// Returns a rubric. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or rubric doesn't exist or if the user doesn't have access to the corresponding course work.
3055 ///
3056 /// # Arguments
3057 ///
3058 /// * `courseId` - Required. Identifier of the course.
3059 /// * `courseWorkId` - Required. Identifier of the course work.
3060 /// * `id` - Required. Identifier of the rubric.
3061 pub fn course_work_rubrics_get(
3062 &self,
3063 course_id: &str,
3064 course_work_id: &str,
3065 id: &str,
3066 ) -> CourseCourseWorkRubricGetCall<'a, C> {
3067 CourseCourseWorkRubricGetCall {
3068 hub: self.hub,
3069 _course_id: course_id.to_string(),
3070 _course_work_id: course_work_id.to_string(),
3071 _id: id.to_string(),
3072 _delegate: Default::default(),
3073 _additional_params: Default::default(),
3074 _scopes: Default::default(),
3075 }
3076 }
3077
3078 /// Create a builder to help you perform the following task:
3079 ///
3080 /// Returns a list of rubrics that the requester is permitted to view. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work doesn't exist or if the user doesn't have access to the corresponding course work.
3081 ///
3082 /// # Arguments
3083 ///
3084 /// * `courseId` - Required. Identifier of the course.
3085 /// * `courseWorkId` - Required. Identifier of the course work.
3086 pub fn course_work_rubrics_list(
3087 &self,
3088 course_id: &str,
3089 course_work_id: &str,
3090 ) -> CourseCourseWorkRubricListCall<'a, C> {
3091 CourseCourseWorkRubricListCall {
3092 hub: self.hub,
3093 _course_id: course_id.to_string(),
3094 _course_work_id: course_work_id.to_string(),
3095 _page_token: Default::default(),
3096 _page_size: Default::default(),
3097 _delegate: Default::default(),
3098 _additional_params: Default::default(),
3099 _scopes: Default::default(),
3100 }
3101 }
3102
3103 /// Create a builder to help you perform the following task:
3104 ///
3105 /// Updates a rubric. See google.classroom.v1.Rubric for details of which fields can be updated. Rubric update capabilities are [limited](https://developers.google.com/classroom/rubrics/limitations) once grading has started. The requesting user and course owner must have rubrics creation capabilities. For details, see [licensing requirements](https://developers.google.com/workspace/classroom/rubrics/limitations#license-requirements). This request must be made by the Google Cloud console of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the parent course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project didn’t create the corresponding course work, if the user isn’t permitted to make the requested modification to the rubric, or for access errors. This error code is also returned if grading has already started on the rubric. * `INVALID_ARGUMENT` if the request is malformed and for the following request error: * `RubricCriteriaInvalidFormat` * `NOT_FOUND` if the requested course, course work, or rubric doesn’t exist or if the user doesn’t have access to the corresponding course work. * `INTERNAL` if grading has already started on the rubric.
3106 ///
3107 /// # Arguments
3108 ///
3109 /// * `request` - No description provided.
3110 /// * `courseId` - Required. Identifier of the course.
3111 /// * `courseWorkId` - Required. Identifier of the course work.
3112 /// * `id` - Optional. Identifier of the rubric.
3113 pub fn course_work_rubrics_patch(
3114 &self,
3115 request: Rubric,
3116 course_id: &str,
3117 course_work_id: &str,
3118 id: &str,
3119 ) -> CourseCourseWorkRubricPatchCall<'a, C> {
3120 CourseCourseWorkRubricPatchCall {
3121 hub: self.hub,
3122 _request: request,
3123 _course_id: course_id.to_string(),
3124 _course_work_id: course_work_id.to_string(),
3125 _id: id.to_string(),
3126 _update_mask: Default::default(),
3127 _delegate: Default::default(),
3128 _additional_params: Default::default(),
3129 _scopes: Default::default(),
3130 }
3131 }
3132
3133 /// Create a builder to help you perform the following task:
3134 ///
3135 /// Returns a student submission. * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, course work, or student submission or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
3136 ///
3137 /// # Arguments
3138 ///
3139 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3140 /// * `courseWorkId` - Identifier of the course work.
3141 /// * `id` - Identifier of the student submission.
3142 pub fn course_work_student_submissions_get(
3143 &self,
3144 course_id: &str,
3145 course_work_id: &str,
3146 id: &str,
3147 ) -> CourseCourseWorkStudentSubmissionGetCall<'a, C> {
3148 CourseCourseWorkStudentSubmissionGetCall {
3149 hub: self.hub,
3150 _course_id: course_id.to_string(),
3151 _course_work_id: course_work_id.to_string(),
3152 _id: id.to_string(),
3153 _delegate: Default::default(),
3154 _additional_params: Default::default(),
3155 _scopes: Default::default(),
3156 }
3157 }
3158
3159 /// Create a builder to help you perform the following task:
3160 ///
3161 /// Returns a list of student submissions that the requester is permitted to view, factoring in the OAuth scopes of the request. `-` may be specified as the `course_work_id` to include student submissions for multiple course work items. Course students may only view their own work. Course teachers and domain administrators may view all student submissions. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
3162 ///
3163 /// # Arguments
3164 ///
3165 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3166 /// * `courseWorkId` - Identifier of the student work to request. This may be set to the string literal `"-"` to request student work for all course work in the specified course.
3167 pub fn course_work_student_submissions_list(
3168 &self,
3169 course_id: &str,
3170 course_work_id: &str,
3171 ) -> CourseCourseWorkStudentSubmissionListCall<'a, C> {
3172 CourseCourseWorkStudentSubmissionListCall {
3173 hub: self.hub,
3174 _course_id: course_id.to_string(),
3175 _course_work_id: course_work_id.to_string(),
3176 _user_id: Default::default(),
3177 _states: Default::default(),
3178 _page_token: Default::default(),
3179 _page_size: Default::default(),
3180 _late: Default::default(),
3181 _delegate: Default::default(),
3182 _additional_params: Default::default(),
3183 _scopes: Default::default(),
3184 }
3185 }
3186
3187 /// Create a builder to help you perform the following task:
3188 ///
3189 /// Modifies attachments of student submission. Attachments may only be added to student submissions belonging to course work objects with a `workType` of `ASSIGNMENT`. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, if the user is not permitted to modify attachments on the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
3190 ///
3191 /// # Arguments
3192 ///
3193 /// * `request` - No description provided.
3194 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3195 /// * `courseWorkId` - Identifier of the course work.
3196 /// * `id` - Identifier of the student submission.
3197 pub fn course_work_student_submissions_modify_attachments(
3198 &self,
3199 request: ModifyAttachmentsRequest,
3200 course_id: &str,
3201 course_work_id: &str,
3202 id: &str,
3203 ) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C> {
3204 CourseCourseWorkStudentSubmissionModifyAttachmentCall {
3205 hub: self.hub,
3206 _request: request,
3207 _course_id: course_id.to_string(),
3208 _course_work_id: course_work_id.to_string(),
3209 _id: id.to_string(),
3210 _delegate: Default::default(),
3211 _additional_params: Default::default(),
3212 _scopes: Default::default(),
3213 }
3214 }
3215
3216 /// Create a builder to help you perform the following task:
3217 ///
3218 /// Updates one or more fields of a student submission. See google.classroom.v1.StudentSubmission for details of which fields may be updated and who may change them. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work, if the user is not permitted to make the requested modification to the student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
3219 ///
3220 /// # Arguments
3221 ///
3222 /// * `request` - No description provided.
3223 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3224 /// * `courseWorkId` - Identifier of the course work.
3225 /// * `id` - Identifier of the student submission.
3226 pub fn course_work_student_submissions_patch(
3227 &self,
3228 request: StudentSubmission,
3229 course_id: &str,
3230 course_work_id: &str,
3231 id: &str,
3232 ) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C> {
3233 CourseCourseWorkStudentSubmissionPatchCall {
3234 hub: self.hub,
3235 _request: request,
3236 _course_id: course_id.to_string(),
3237 _course_work_id: course_work_id.to_string(),
3238 _id: id.to_string(),
3239 _update_mask: Default::default(),
3240 _delegate: Default::default(),
3241 _additional_params: Default::default(),
3242 _scopes: Default::default(),
3243 }
3244 }
3245
3246 /// Create a builder to help you perform the following task:
3247 ///
3248 /// Reclaims a student submission on behalf of the student that owns it. Reclaiming a student submission transfers ownership of attached Drive files to the student and updates the submission state. Only the student that owns the requested student submission may call this method, and only for a student submission that has been turned in. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, unsubmit the requested student submission, or for access errors. * `FAILED_PRECONDITION` if the student submission has not been turned in. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
3249 ///
3250 /// # Arguments
3251 ///
3252 /// * `request` - No description provided.
3253 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3254 /// * `courseWorkId` - Identifier of the course work.
3255 /// * `id` - Identifier of the student submission.
3256 pub fn course_work_student_submissions_reclaim(
3257 &self,
3258 request: ReclaimStudentSubmissionRequest,
3259 course_id: &str,
3260 course_work_id: &str,
3261 id: &str,
3262 ) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C> {
3263 CourseCourseWorkStudentSubmissionReclaimCall {
3264 hub: self.hub,
3265 _request: request,
3266 _course_id: course_id.to_string(),
3267 _course_work_id: course_work_id.to_string(),
3268 _id: id.to_string(),
3269 _delegate: Default::default(),
3270 _additional_params: Default::default(),
3271 _scopes: Default::default(),
3272 }
3273 }
3274
3275 /// Create a builder to help you perform the following task:
3276 ///
3277 /// Returns a student submission. Returning a student submission transfers ownership of attached Drive files to the student and may also update the submission state. Unlike the Classroom application, returning a student submission does not set assignedGrade to the draftGrade value. Only a teacher of the course that contains the requested student submission may call this method. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, return the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
3278 ///
3279 /// # Arguments
3280 ///
3281 /// * `request` - No description provided.
3282 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3283 /// * `courseWorkId` - Identifier of the course work.
3284 /// * `id` - Identifier of the student submission.
3285 pub fn course_work_student_submissions_return(
3286 &self,
3287 request: ReturnStudentSubmissionRequest,
3288 course_id: &str,
3289 course_work_id: &str,
3290 id: &str,
3291 ) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C> {
3292 CourseCourseWorkStudentSubmissionReturnCall {
3293 hub: self.hub,
3294 _request: request,
3295 _course_id: course_id.to_string(),
3296 _course_work_id: course_work_id.to_string(),
3297 _id: id.to_string(),
3298 _delegate: Default::default(),
3299 _additional_params: Default::default(),
3300 _scopes: Default::default(),
3301 }
3302 }
3303
3304 /// Create a builder to help you perform the following task:
3305 ///
3306 /// Turns in a student submission. Turning in a student submission transfers ownership of attached Drive files to the teacher and may also update the submission state. This may only be called by the student that owns the specified student submission. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, turn in the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
3307 ///
3308 /// # Arguments
3309 ///
3310 /// * `request` - No description provided.
3311 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3312 /// * `courseWorkId` - Identifier of the course work.
3313 /// * `id` - Identifier of the student submission.
3314 pub fn course_work_student_submissions_turn_in(
3315 &self,
3316 request: TurnInStudentSubmissionRequest,
3317 course_id: &str,
3318 course_work_id: &str,
3319 id: &str,
3320 ) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C> {
3321 CourseCourseWorkStudentSubmissionTurnInCall {
3322 hub: self.hub,
3323 _request: request,
3324 _course_id: course_id.to_string(),
3325 _course_work_id: course_work_id.to_string(),
3326 _id: id.to_string(),
3327 _delegate: Default::default(),
3328 _additional_params: Default::default(),
3329 _scopes: Default::default(),
3330 }
3331 }
3332
3333 /// Create a builder to help you perform the following task:
3334 ///
3335 /// Creates course work. The resulting course work (and corresponding student submissions) are associated with the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to make the request. Classroom API requests to modify course work and student submissions must be made with an OAuth client ID from the associated Developer Console project. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create course work in the requested course, share a Drive attachment, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist. * `FAILED_PRECONDITION` for the following request error: * AttachmentNotVisible
3336 ///
3337 /// # Arguments
3338 ///
3339 /// * `request` - No description provided.
3340 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3341 pub fn course_work_create(
3342 &self,
3343 request: CourseWork,
3344 course_id: &str,
3345 ) -> CourseCourseWorkCreateCall<'a, C> {
3346 CourseCourseWorkCreateCall {
3347 hub: self.hub,
3348 _request: request,
3349 _course_id: course_id.to_string(),
3350 _delegate: Default::default(),
3351 _additional_params: Default::default(),
3352 _scopes: Default::default(),
3353 }
3354 }
3355
3356 /// Create a builder to help you perform the following task:
3357 ///
3358 /// Deletes a course work. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work, if the requesting user is not permitted to delete the requested course or for access errors. * `FAILED_PRECONDITION` if the requested course work has already been deleted. * `NOT_FOUND` if no course exists with the requested ID.
3359 ///
3360 /// # Arguments
3361 ///
3362 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3363 /// * `id` - Identifier of the course work to delete. This identifier is a Classroom-assigned identifier.
3364 pub fn course_work_delete(
3365 &self,
3366 course_id: &str,
3367 id: &str,
3368 ) -> CourseCourseWorkDeleteCall<'a, C> {
3369 CourseCourseWorkDeleteCall {
3370 hub: self.hub,
3371 _course_id: course_id.to_string(),
3372 _id: id.to_string(),
3373 _delegate: Default::default(),
3374 _additional_params: Default::default(),
3375 _scopes: Default::default(),
3376 }
3377 }
3378
3379 /// Create a builder to help you perform the following task:
3380 ///
3381 /// Returns course work. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work does not exist.
3382 ///
3383 /// # Arguments
3384 ///
3385 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3386 /// * `id` - Identifier of the course work.
3387 pub fn course_work_get(&self, course_id: &str, id: &str) -> CourseCourseWorkGetCall<'a, C> {
3388 CourseCourseWorkGetCall {
3389 hub: self.hub,
3390 _course_id: course_id.to_string(),
3391 _id: id.to_string(),
3392 _delegate: Default::default(),
3393 _additional_params: Default::default(),
3394 _scopes: Default::default(),
3395 }
3396 }
3397
3398 /// Create a builder to help you perform the following task:
3399 ///
3400 /// Gets metadata for Classroom add-ons in the context of a specific post. To maintain the integrity of its own data and permissions model, an add-on should call this to validate query parameters and the requesting user's role whenever the add-on is opened in an [iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/iframes-overview). This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3401 ///
3402 /// # Arguments
3403 ///
3404 /// * `courseId` - Required. Identifier of the course.
3405 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
3406 pub fn course_work_get_add_on_context(
3407 &self,
3408 course_id: &str,
3409 item_id: &str,
3410 ) -> CourseCourseWorkGetAddOnContextCall<'a, C> {
3411 CourseCourseWorkGetAddOnContextCall {
3412 hub: self.hub,
3413 _course_id: course_id.to_string(),
3414 _item_id: item_id.to_string(),
3415 _post_id: Default::default(),
3416 _attachment_id: Default::default(),
3417 _add_on_token: Default::default(),
3418 _delegate: Default::default(),
3419 _additional_params: Default::default(),
3420 _scopes: Default::default(),
3421 }
3422 }
3423
3424 /// Create a builder to help you perform the following task:
3425 ///
3426 /// Returns a list of course work that the requester is permitted to view. Course students may only view `PUBLISHED` course work. Course teachers and domain administrators may view all course work. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
3427 ///
3428 /// # Arguments
3429 ///
3430 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3431 pub fn course_work_list(&self, course_id: &str) -> CourseCourseWorkListCall<'a, C> {
3432 CourseCourseWorkListCall {
3433 hub: self.hub,
3434 _course_id: course_id.to_string(),
3435 _page_token: Default::default(),
3436 _page_size: Default::default(),
3437 _order_by: Default::default(),
3438 _course_work_states: Default::default(),
3439 _delegate: Default::default(),
3440 _additional_params: Default::default(),
3441 _scopes: Default::default(),
3442 }
3443 }
3444
3445 /// Create a builder to help you perform the following task:
3446 ///
3447 /// Modifies assignee mode and options of a coursework. Only a teacher of the course that contains the coursework may call this method. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work does not exist. * `FAILED_PRECONDITION` for the following request error: * EmptyAssignees
3448 ///
3449 /// # Arguments
3450 ///
3451 /// * `request` - No description provided.
3452 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3453 /// * `id` - Identifier of the coursework.
3454 pub fn course_work_modify_assignees(
3455 &self,
3456 request: ModifyCourseWorkAssigneesRequest,
3457 course_id: &str,
3458 id: &str,
3459 ) -> CourseCourseWorkModifyAssigneeCall<'a, C> {
3460 CourseCourseWorkModifyAssigneeCall {
3461 hub: self.hub,
3462 _request: request,
3463 _course_id: course_id.to_string(),
3464 _id: id.to_string(),
3465 _delegate: Default::default(),
3466 _additional_params: Default::default(),
3467 _scopes: Default::default(),
3468 }
3469 }
3470
3471 /// Create a builder to help you perform the following task:
3472 ///
3473 /// Updates one or more fields of a course work. See google.classroom.v1.CourseWork for details of which fields may be updated and who may change them. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work, if the user is not permitted to make the requested modification to the student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if the requested course work has already been deleted. * `NOT_FOUND` if the requested course or course work does not exist.
3474 ///
3475 /// # Arguments
3476 ///
3477 /// * `request` - No description provided.
3478 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3479 /// * `id` - Identifier of the course work.
3480 pub fn course_work_patch(
3481 &self,
3482 request: CourseWork,
3483 course_id: &str,
3484 id: &str,
3485 ) -> CourseCourseWorkPatchCall<'a, C> {
3486 CourseCourseWorkPatchCall {
3487 hub: self.hub,
3488 _request: request,
3489 _course_id: course_id.to_string(),
3490 _id: id.to_string(),
3491 _update_mask: Default::default(),
3492 _delegate: Default::default(),
3493 _additional_params: Default::default(),
3494 _scopes: Default::default(),
3495 }
3496 }
3497
3498 /// Create a builder to help you perform the following task:
3499 ///
3500 /// Updates a rubric. See google.classroom.v1.Rubric for details of which fields can be updated. Rubric update capabilities are [limited](https://developers.google.com/classroom/rubrics/limitations) once grading has started. The requesting user and course owner must have rubrics creation capabilities. For details, see [licensing requirements](https://developers.google.com/workspace/classroom/rubrics/limitations#license-requirements). This request must be made by the Google Cloud console of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the parent course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project didn’t create the corresponding course work, if the user isn’t permitted to make the requested modification to the rubric, or for access errors. This error code is also returned if grading has already started on the rubric. * `INVALID_ARGUMENT` if the request is malformed and for the following request error: * `RubricCriteriaInvalidFormat` * `NOT_FOUND` if the requested course, course work, or rubric doesn’t exist or if the user doesn’t have access to the corresponding course work. * `INTERNAL` if grading has already started on the rubric.
3501 ///
3502 /// # Arguments
3503 ///
3504 /// * `request` - No description provided.
3505 /// * `courseId` - Required. Identifier of the course.
3506 /// * `courseWorkId` - Required. Identifier of the course work.
3507 pub fn course_work_update_rubric(
3508 &self,
3509 request: Rubric,
3510 course_id: &str,
3511 course_work_id: &str,
3512 ) -> CourseCourseWorkUpdateRubricCall<'a, C> {
3513 CourseCourseWorkUpdateRubricCall {
3514 hub: self.hub,
3515 _request: request,
3516 _course_id: course_id.to_string(),
3517 _course_work_id: course_work_id.to_string(),
3518 _update_mask: Default::default(),
3519 _id: Default::default(),
3520 _delegate: Default::default(),
3521 _additional_params: Default::default(),
3522 _scopes: Default::default(),
3523 }
3524 }
3525
3526 /// Create a builder to help you perform the following task:
3527 ///
3528 /// Creates an add-on attachment under a post. Requires the add-on to have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3529 ///
3530 /// # Arguments
3531 ///
3532 /// * `request` - No description provided.
3533 /// * `courseId` - Required. Identifier of the course.
3534 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which to create the attachment. This field is required, but is not marked as such while we are migrating from post_id.
3535 pub fn course_work_materials_add_on_attachments_create(
3536 &self,
3537 request: AddOnAttachment,
3538 course_id: &str,
3539 item_id: &str,
3540 ) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C> {
3541 CourseCourseWorkMaterialAddOnAttachmentCreateCall {
3542 hub: self.hub,
3543 _request: request,
3544 _course_id: course_id.to_string(),
3545 _item_id: item_id.to_string(),
3546 _post_id: Default::default(),
3547 _add_on_token: Default::default(),
3548 _delegate: Default::default(),
3549 _additional_params: Default::default(),
3550 _scopes: Default::default(),
3551 }
3552 }
3553
3554 /// Create a builder to help you perform the following task:
3555 ///
3556 /// Deletes an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3557 ///
3558 /// # Arguments
3559 ///
3560 /// * `courseId` - Required. Identifier of the course.
3561 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
3562 /// * `attachmentId` - Required. Identifier of the attachment.
3563 pub fn course_work_materials_add_on_attachments_delete(
3564 &self,
3565 course_id: &str,
3566 item_id: &str,
3567 attachment_id: &str,
3568 ) -> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C> {
3569 CourseCourseWorkMaterialAddOnAttachmentDeleteCall {
3570 hub: self.hub,
3571 _course_id: course_id.to_string(),
3572 _item_id: item_id.to_string(),
3573 _attachment_id: attachment_id.to_string(),
3574 _post_id: Default::default(),
3575 _delegate: Default::default(),
3576 _additional_params: Default::default(),
3577 _scopes: Default::default(),
3578 }
3579 }
3580
3581 /// Create a builder to help you perform the following task:
3582 ///
3583 /// Returns an add-on attachment. Requires the add-on requesting the attachment to be the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3584 ///
3585 /// # Arguments
3586 ///
3587 /// * `courseId` - Required. Identifier of the course.
3588 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
3589 /// * `attachmentId` - Required. Identifier of the attachment.
3590 pub fn course_work_materials_add_on_attachments_get(
3591 &self,
3592 course_id: &str,
3593 item_id: &str,
3594 attachment_id: &str,
3595 ) -> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C> {
3596 CourseCourseWorkMaterialAddOnAttachmentGetCall {
3597 hub: self.hub,
3598 _course_id: course_id.to_string(),
3599 _item_id: item_id.to_string(),
3600 _attachment_id: attachment_id.to_string(),
3601 _post_id: Default::default(),
3602 _delegate: Default::default(),
3603 _additional_params: Default::default(),
3604 _scopes: Default::default(),
3605 }
3606 }
3607
3608 /// Create a builder to help you perform the following task:
3609 ///
3610 /// Returns all attachments created by an add-on under the post. Requires the add-on to have active attachments on the post or have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3611 ///
3612 /// # Arguments
3613 ///
3614 /// * `courseId` - Required. Identifier of the course.
3615 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` whose attachments should be enumerated. This field is required, but is not marked as such while we are migrating from post_id.
3616 pub fn course_work_materials_add_on_attachments_list(
3617 &self,
3618 course_id: &str,
3619 item_id: &str,
3620 ) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C> {
3621 CourseCourseWorkMaterialAddOnAttachmentListCall {
3622 hub: self.hub,
3623 _course_id: course_id.to_string(),
3624 _item_id: item_id.to_string(),
3625 _post_id: Default::default(),
3626 _page_token: Default::default(),
3627 _page_size: Default::default(),
3628 _delegate: Default::default(),
3629 _additional_params: Default::default(),
3630 _scopes: Default::default(),
3631 }
3632 }
3633
3634 /// Create a builder to help you perform the following task:
3635 ///
3636 /// Updates an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3637 ///
3638 /// # Arguments
3639 ///
3640 /// * `request` - No description provided.
3641 /// * `courseId` - Required. Identifier of the course.
3642 /// * `itemId` - Identifier of the post under which the attachment is attached.
3643 /// * `attachmentId` - Required. Identifier of the attachment.
3644 pub fn course_work_materials_add_on_attachments_patch(
3645 &self,
3646 request: AddOnAttachment,
3647 course_id: &str,
3648 item_id: &str,
3649 attachment_id: &str,
3650 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C> {
3651 CourseCourseWorkMaterialAddOnAttachmentPatchCall {
3652 hub: self.hub,
3653 _request: request,
3654 _course_id: course_id.to_string(),
3655 _item_id: item_id.to_string(),
3656 _attachment_id: attachment_id.to_string(),
3657 _update_mask: Default::default(),
3658 _post_id: Default::default(),
3659 _delegate: Default::default(),
3660 _additional_params: Default::default(),
3661 _scopes: Default::default(),
3662 }
3663 }
3664
3665 /// Create a builder to help you perform the following task:
3666 ///
3667 /// Creates a course work material. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create course work material in the requested course, share a Drive attachment, or for access errors. * `INVALID_ARGUMENT` if the request is malformed or if more than 20 * materials are provided. * `NOT_FOUND` if the requested course does not exist. * `FAILED_PRECONDITION` for the following request error: * AttachmentNotVisible
3668 ///
3669 /// # Arguments
3670 ///
3671 /// * `request` - No description provided.
3672 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3673 pub fn course_work_materials_create(
3674 &self,
3675 request: CourseWorkMaterial,
3676 course_id: &str,
3677 ) -> CourseCourseWorkMaterialCreateCall<'a, C> {
3678 CourseCourseWorkMaterialCreateCall {
3679 hub: self.hub,
3680 _request: request,
3681 _course_id: course_id.to_string(),
3682 _delegate: Default::default(),
3683 _additional_params: Default::default(),
3684 _scopes: Default::default(),
3685 }
3686 }
3687
3688 /// Create a builder to help you perform the following task:
3689 ///
3690 /// Deletes a course work material. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work material item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work material, if the requesting user is not permitted to delete the requested course or for access errors. * `FAILED_PRECONDITION` if the requested course work material has already been deleted. * `NOT_FOUND` if no course exists with the requested ID.
3691 ///
3692 /// # Arguments
3693 ///
3694 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3695 /// * `id` - Identifier of the course work material to delete. This identifier is a Classroom-assigned identifier.
3696 pub fn course_work_materials_delete(
3697 &self,
3698 course_id: &str,
3699 id: &str,
3700 ) -> CourseCourseWorkMaterialDeleteCall<'a, C> {
3701 CourseCourseWorkMaterialDeleteCall {
3702 hub: self.hub,
3703 _course_id: course_id.to_string(),
3704 _id: id.to_string(),
3705 _delegate: Default::default(),
3706 _additional_params: Default::default(),
3707 _scopes: Default::default(),
3708 }
3709 }
3710
3711 /// Create a builder to help you perform the following task:
3712 ///
3713 /// Returns a course work material. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work material, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work material does not exist.
3714 ///
3715 /// # Arguments
3716 ///
3717 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3718 /// * `id` - Identifier of the course work material.
3719 pub fn course_work_materials_get(
3720 &self,
3721 course_id: &str,
3722 id: &str,
3723 ) -> CourseCourseWorkMaterialGetCall<'a, C> {
3724 CourseCourseWorkMaterialGetCall {
3725 hub: self.hub,
3726 _course_id: course_id.to_string(),
3727 _id: id.to_string(),
3728 _delegate: Default::default(),
3729 _additional_params: Default::default(),
3730 _scopes: Default::default(),
3731 }
3732 }
3733
3734 /// Create a builder to help you perform the following task:
3735 ///
3736 /// Gets metadata for Classroom add-ons in the context of a specific post. To maintain the integrity of its own data and permissions model, an add-on should call this to validate query parameters and the requesting user's role whenever the add-on is opened in an [iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/iframes-overview). This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3737 ///
3738 /// # Arguments
3739 ///
3740 /// * `courseId` - Required. Identifier of the course.
3741 /// * `itemId` - Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
3742 pub fn course_work_materials_get_add_on_context(
3743 &self,
3744 course_id: &str,
3745 item_id: &str,
3746 ) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C> {
3747 CourseCourseWorkMaterialGetAddOnContextCall {
3748 hub: self.hub,
3749 _course_id: course_id.to_string(),
3750 _item_id: item_id.to_string(),
3751 _post_id: Default::default(),
3752 _attachment_id: Default::default(),
3753 _add_on_token: Default::default(),
3754 _delegate: Default::default(),
3755 _additional_params: Default::default(),
3756 _scopes: Default::default(),
3757 }
3758 }
3759
3760 /// Create a builder to help you perform the following task:
3761 ///
3762 /// Returns a list of course work material that the requester is permitted to view. Course students may only view `PUBLISHED` course work material. Course teachers and domain administrators may view all course work material. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
3763 ///
3764 /// # Arguments
3765 ///
3766 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3767 pub fn course_work_materials_list(
3768 &self,
3769 course_id: &str,
3770 ) -> CourseCourseWorkMaterialListCall<'a, C> {
3771 CourseCourseWorkMaterialListCall {
3772 hub: self.hub,
3773 _course_id: course_id.to_string(),
3774 _page_token: Default::default(),
3775 _page_size: Default::default(),
3776 _order_by: Default::default(),
3777 _material_link: Default::default(),
3778 _material_drive_id: Default::default(),
3779 _course_work_material_states: Default::default(),
3780 _delegate: Default::default(),
3781 _additional_params: Default::default(),
3782 _scopes: Default::default(),
3783 }
3784 }
3785
3786 /// Create a builder to help you perform the following task:
3787 ///
3788 /// Updates one or more fields of a course work material. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if the requested course work material has already been deleted. * `NOT_FOUND` if the requested course or course work material does not exist
3789 ///
3790 /// # Arguments
3791 ///
3792 /// * `request` - No description provided.
3793 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
3794 /// * `id` - Identifier of the course work material.
3795 pub fn course_work_materials_patch(
3796 &self,
3797 request: CourseWorkMaterial,
3798 course_id: &str,
3799 id: &str,
3800 ) -> CourseCourseWorkMaterialPatchCall<'a, C> {
3801 CourseCourseWorkMaterialPatchCall {
3802 hub: self.hub,
3803 _request: request,
3804 _course_id: course_id.to_string(),
3805 _id: id.to_string(),
3806 _update_mask: Default::default(),
3807 _delegate: Default::default(),
3808 _additional_params: Default::default(),
3809 _scopes: Default::default(),
3810 }
3811 }
3812
3813 /// Create a builder to help you perform the following task:
3814 ///
3815 /// Returns a student submission for an add-on attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3816 ///
3817 /// # Arguments
3818 ///
3819 /// * `courseId` - Required. Identifier of the course.
3820 /// * `postId` - Optional. Deprecated, use `item_id` instead.
3821 /// * `attachmentId` - Required. Identifier of the attachment.
3822 /// * `submissionId` - Required. Identifier of the student’s submission.
3823 pub fn posts_add_on_attachments_student_submissions_get(
3824 &self,
3825 course_id: &str,
3826 post_id: &str,
3827 attachment_id: &str,
3828 submission_id: &str,
3829 ) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C> {
3830 CoursePostAddOnAttachmentStudentSubmissionGetCall {
3831 hub: self.hub,
3832 _course_id: course_id.to_string(),
3833 _post_id: post_id.to_string(),
3834 _attachment_id: attachment_id.to_string(),
3835 _submission_id: submission_id.to_string(),
3836 _item_id: Default::default(),
3837 _delegate: Default::default(),
3838 _additional_params: Default::default(),
3839 _scopes: Default::default(),
3840 }
3841 }
3842
3843 /// Create a builder to help you perform the following task:
3844 ///
3845 /// Updates data associated with an add-on attachment submission. Requires the add-on to have been the original creator of the attachment and the attachment to have a positive `max_points` value set. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3846 ///
3847 /// # Arguments
3848 ///
3849 /// * `request` - No description provided.
3850 /// * `courseId` - Required. Identifier of the course.
3851 /// * `postId` - Optional. Deprecated, use `item_id` instead.
3852 /// * `attachmentId` - Required. Identifier of the attachment.
3853 /// * `submissionId` - Required. Identifier of the student's submission.
3854 pub fn posts_add_on_attachments_student_submissions_patch(
3855 &self,
3856 request: AddOnAttachmentStudentSubmission,
3857 course_id: &str,
3858 post_id: &str,
3859 attachment_id: &str,
3860 submission_id: &str,
3861 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
3862 CoursePostAddOnAttachmentStudentSubmissionPatchCall {
3863 hub: self.hub,
3864 _request: request,
3865 _course_id: course_id.to_string(),
3866 _post_id: post_id.to_string(),
3867 _attachment_id: attachment_id.to_string(),
3868 _submission_id: submission_id.to_string(),
3869 _update_mask: Default::default(),
3870 _item_id: Default::default(),
3871 _delegate: Default::default(),
3872 _additional_params: Default::default(),
3873 _scopes: Default::default(),
3874 }
3875 }
3876
3877 /// Create a builder to help you perform the following task:
3878 ///
3879 /// Creates an add-on attachment under a post. Requires the add-on to have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3880 ///
3881 /// # Arguments
3882 ///
3883 /// * `request` - No description provided.
3884 /// * `courseId` - Required. Identifier of the course.
3885 /// * `postId` - Optional. Deprecated, use `item_id` instead.
3886 pub fn posts_add_on_attachments_create(
3887 &self,
3888 request: AddOnAttachment,
3889 course_id: &str,
3890 post_id: &str,
3891 ) -> CoursePostAddOnAttachmentCreateCall<'a, C> {
3892 CoursePostAddOnAttachmentCreateCall {
3893 hub: self.hub,
3894 _request: request,
3895 _course_id: course_id.to_string(),
3896 _post_id: post_id.to_string(),
3897 _item_id: Default::default(),
3898 _add_on_token: Default::default(),
3899 _delegate: Default::default(),
3900 _additional_params: Default::default(),
3901 _scopes: Default::default(),
3902 }
3903 }
3904
3905 /// Create a builder to help you perform the following task:
3906 ///
3907 /// Deletes an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3908 ///
3909 /// # Arguments
3910 ///
3911 /// * `courseId` - Required. Identifier of the course.
3912 /// * `postId` - Optional. Deprecated, use `item_id` instead.
3913 /// * `attachmentId` - Required. Identifier of the attachment.
3914 pub fn posts_add_on_attachments_delete(
3915 &self,
3916 course_id: &str,
3917 post_id: &str,
3918 attachment_id: &str,
3919 ) -> CoursePostAddOnAttachmentDeleteCall<'a, C> {
3920 CoursePostAddOnAttachmentDeleteCall {
3921 hub: self.hub,
3922 _course_id: course_id.to_string(),
3923 _post_id: post_id.to_string(),
3924 _attachment_id: attachment_id.to_string(),
3925 _item_id: Default::default(),
3926 _delegate: Default::default(),
3927 _additional_params: Default::default(),
3928 _scopes: Default::default(),
3929 }
3930 }
3931
3932 /// Create a builder to help you perform the following task:
3933 ///
3934 /// Returns an add-on attachment. Requires the add-on requesting the attachment to be the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3935 ///
3936 /// # Arguments
3937 ///
3938 /// * `courseId` - Required. Identifier of the course.
3939 /// * `postId` - Optional. Deprecated, use `item_id` instead.
3940 /// * `attachmentId` - Required. Identifier of the attachment.
3941 pub fn posts_add_on_attachments_get(
3942 &self,
3943 course_id: &str,
3944 post_id: &str,
3945 attachment_id: &str,
3946 ) -> CoursePostAddOnAttachmentGetCall<'a, C> {
3947 CoursePostAddOnAttachmentGetCall {
3948 hub: self.hub,
3949 _course_id: course_id.to_string(),
3950 _post_id: post_id.to_string(),
3951 _attachment_id: attachment_id.to_string(),
3952 _item_id: Default::default(),
3953 _delegate: Default::default(),
3954 _additional_params: Default::default(),
3955 _scopes: Default::default(),
3956 }
3957 }
3958
3959 /// Create a builder to help you perform the following task:
3960 ///
3961 /// Returns all attachments created by an add-on under the post. Requires the add-on to have active attachments on the post or have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3962 ///
3963 /// # Arguments
3964 ///
3965 /// * `courseId` - Required. Identifier of the course.
3966 /// * `postId` - Optional. Identifier of the post under the course whose attachments to enumerate. Deprecated, use `item_id` instead.
3967 pub fn posts_add_on_attachments_list(
3968 &self,
3969 course_id: &str,
3970 post_id: &str,
3971 ) -> CoursePostAddOnAttachmentListCall<'a, C> {
3972 CoursePostAddOnAttachmentListCall {
3973 hub: self.hub,
3974 _course_id: course_id.to_string(),
3975 _post_id: post_id.to_string(),
3976 _page_token: Default::default(),
3977 _page_size: Default::default(),
3978 _item_id: Default::default(),
3979 _delegate: Default::default(),
3980 _additional_params: Default::default(),
3981 _scopes: Default::default(),
3982 }
3983 }
3984
3985 /// Create a builder to help you perform the following task:
3986 ///
3987 /// Updates an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
3988 ///
3989 /// # Arguments
3990 ///
3991 /// * `request` - No description provided.
3992 /// * `courseId` - Required. Identifier of the course.
3993 /// * `postId` - Required. Identifier of the post under which the attachment is attached.
3994 /// * `attachmentId` - Required. Identifier of the attachment.
3995 pub fn posts_add_on_attachments_patch(
3996 &self,
3997 request: AddOnAttachment,
3998 course_id: &str,
3999 post_id: &str,
4000 attachment_id: &str,
4001 ) -> CoursePostAddOnAttachmentPatchCall<'a, C> {
4002 CoursePostAddOnAttachmentPatchCall {
4003 hub: self.hub,
4004 _request: request,
4005 _course_id: course_id.to_string(),
4006 _post_id: post_id.to_string(),
4007 _attachment_id: attachment_id.to_string(),
4008 _update_mask: Default::default(),
4009 _item_id: Default::default(),
4010 _delegate: Default::default(),
4011 _additional_params: Default::default(),
4012 _scopes: Default::default(),
4013 }
4014 }
4015
4016 /// Create a builder to help you perform the following task:
4017 ///
4018 /// Gets metadata for Classroom add-ons in the context of a specific post. To maintain the integrity of its own data and permissions model, an add-on should call this to validate query parameters and the requesting user's role whenever the add-on is opened in an [iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/iframes-overview). This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
4019 ///
4020 /// # Arguments
4021 ///
4022 /// * `courseId` - Required. Identifier of the course.
4023 /// * `postId` - Optional. Deprecated, use `item_id` instead.
4024 pub fn posts_get_add_on_context(
4025 &self,
4026 course_id: &str,
4027 post_id: &str,
4028 ) -> CoursePostGetAddOnContextCall<'a, C> {
4029 CoursePostGetAddOnContextCall {
4030 hub: self.hub,
4031 _course_id: course_id.to_string(),
4032 _post_id: post_id.to_string(),
4033 _item_id: Default::default(),
4034 _attachment_id: Default::default(),
4035 _add_on_token: Default::default(),
4036 _delegate: Default::default(),
4037 _additional_params: Default::default(),
4038 _scopes: Default::default(),
4039 }
4040 }
4041
4042 /// Create a builder to help you perform the following task:
4043 ///
4044 /// Adds a user as a student of a course. Domain administrators are permitted to [directly add](https://developers.google.com/workspace/classroom/guides/manage-users) users within their domain as students to courses within their domain. Students are permitted to add themselves to a course using an enrollment code. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create students in this course or for access errors. * `NOT_FOUND` if the requested course ID does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled, for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * UserGroupsMembershipLimitReached * InactiveCourseOwner * `ALREADY_EXISTS` if the user is already a student or teacher in the course.
4045 ///
4046 /// # Arguments
4047 ///
4048 /// * `request` - No description provided.
4049 /// * `courseId` - Identifier of the course to create the student in. This identifier can be either the Classroom-assigned identifier or an alias.
4050 pub fn students_create(
4051 &self,
4052 request: Student,
4053 course_id: &str,
4054 ) -> CourseStudentCreateCall<'a, C> {
4055 CourseStudentCreateCall {
4056 hub: self.hub,
4057 _request: request,
4058 _course_id: course_id.to_string(),
4059 _enrollment_code: Default::default(),
4060 _delegate: Default::default(),
4061 _additional_params: Default::default(),
4062 _scopes: Default::default(),
4063 }
4064 }
4065
4066 /// Create a builder to help you perform the following task:
4067 ///
4068 /// Deletes a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist.
4069 ///
4070 /// # Arguments
4071 ///
4072 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4073 /// * `userId` - Identifier of the student to delete. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
4074 pub fn students_delete(
4075 &self,
4076 course_id: &str,
4077 user_id: &str,
4078 ) -> CourseStudentDeleteCall<'a, C> {
4079 CourseStudentDeleteCall {
4080 hub: self.hub,
4081 _course_id: course_id.to_string(),
4082 _user_id: user_id.to_string(),
4083 _delegate: Default::default(),
4084 _additional_params: Default::default(),
4085 _scopes: Default::default(),
4086 }
4087 }
4088
4089 /// Create a builder to help you perform the following task:
4090 ///
4091 /// Returns a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist.
4092 ///
4093 /// # Arguments
4094 ///
4095 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4096 /// * `userId` - Identifier of the student to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
4097 pub fn students_get(&self, course_id: &str, user_id: &str) -> CourseStudentGetCall<'a, C> {
4098 CourseStudentGetCall {
4099 hub: self.hub,
4100 _course_id: course_id.to_string(),
4101 _user_id: user_id.to_string(),
4102 _delegate: Default::default(),
4103 _additional_params: Default::default(),
4104 _scopes: Default::default(),
4105 }
4106 }
4107
4108 /// Create a builder to help you perform the following task:
4109 ///
4110 /// Returns a list of students of this course that the requester is permitted to view. This method returns the following error codes: * `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for access errors.
4111 ///
4112 /// # Arguments
4113 ///
4114 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4115 pub fn students_list(&self, course_id: &str) -> CourseStudentListCall<'a, C> {
4116 CourseStudentListCall {
4117 hub: self.hub,
4118 _course_id: course_id.to_string(),
4119 _page_token: Default::default(),
4120 _page_size: Default::default(),
4121 _delegate: Default::default(),
4122 _additional_params: Default::default(),
4123 _scopes: Default::default(),
4124 }
4125 }
4126
4127 /// Create a builder to help you perform the following task:
4128 ///
4129 /// Creates a teacher of a course. Domain administrators are permitted to [directly add](https://developers.google.com/workspace/classroom/guides/manage-users) users within their domain as teachers to courses within their domain. Non-admin users should send an Invitation instead. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create teachers in this course or for access errors. * `NOT_FOUND` if the requested course ID does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled, for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * CourseTeacherLimitReached * UserGroupsMembershipLimitReached * InactiveCourseOwner * `ALREADY_EXISTS` if the user is already a teacher or student in the course.
4130 ///
4131 /// # Arguments
4132 ///
4133 /// * `request` - No description provided.
4134 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4135 pub fn teachers_create(
4136 &self,
4137 request: Teacher,
4138 course_id: &str,
4139 ) -> CourseTeacherCreateCall<'a, C> {
4140 CourseTeacherCreateCall {
4141 hub: self.hub,
4142 _request: request,
4143 _course_id: course_id.to_string(),
4144 _delegate: Default::default(),
4145 _additional_params: Default::default(),
4146 _scopes: Default::default(),
4147 }
4148 }
4149
4150 /// Create a builder to help you perform the following task:
4151 ///
4152 /// Removes the specified teacher from the specified course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete teachers of this course or for access errors. * `NOT_FOUND` if no teacher of this course has the requested ID or if the course does not exist. * `FAILED_PRECONDITION` if the requested ID belongs to the primary teacher of this course. * `FAILED_PRECONDITION` if the requested ID belongs to the owner of the course Drive folder. * `FAILED_PRECONDITION` if the course no longer has an active owner.
4153 ///
4154 /// # Arguments
4155 ///
4156 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4157 /// * `userId` - Identifier of the teacher to delete. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
4158 pub fn teachers_delete(
4159 &self,
4160 course_id: &str,
4161 user_id: &str,
4162 ) -> CourseTeacherDeleteCall<'a, C> {
4163 CourseTeacherDeleteCall {
4164 hub: self.hub,
4165 _course_id: course_id.to_string(),
4166 _user_id: user_id.to_string(),
4167 _delegate: Default::default(),
4168 _additional_params: Default::default(),
4169 _scopes: Default::default(),
4170 }
4171 }
4172
4173 /// Create a builder to help you perform the following task:
4174 ///
4175 /// Returns a teacher of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view teachers of this course or for access errors. * `NOT_FOUND` if no teacher of this course has the requested ID or if the course does not exist.
4176 ///
4177 /// # Arguments
4178 ///
4179 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4180 /// * `userId` - Identifier of the teacher to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
4181 pub fn teachers_get(&self, course_id: &str, user_id: &str) -> CourseTeacherGetCall<'a, C> {
4182 CourseTeacherGetCall {
4183 hub: self.hub,
4184 _course_id: course_id.to_string(),
4185 _user_id: user_id.to_string(),
4186 _delegate: Default::default(),
4187 _additional_params: Default::default(),
4188 _scopes: Default::default(),
4189 }
4190 }
4191
4192 /// Create a builder to help you perform the following task:
4193 ///
4194 /// Returns a list of teachers of this course that the requester is permitted to view. This method returns the following error codes: * `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for access errors.
4195 ///
4196 /// # Arguments
4197 ///
4198 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4199 pub fn teachers_list(&self, course_id: &str) -> CourseTeacherListCall<'a, C> {
4200 CourseTeacherListCall {
4201 hub: self.hub,
4202 _course_id: course_id.to_string(),
4203 _page_token: Default::default(),
4204 _page_size: Default::default(),
4205 _delegate: Default::default(),
4206 _additional_params: Default::default(),
4207 _scopes: Default::default(),
4208 }
4209 }
4210
4211 /// Create a builder to help you perform the following task:
4212 ///
4213 /// Creates a topic. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create a topic in the requested course, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `ALREADY_EXISTS` if there exists a topic in the course with the same name. * `FAILED_PRECONDITION` for the following request error: * CourseTopicLimitReached * `NOT_FOUND` if the requested course does not exist.
4214 ///
4215 /// # Arguments
4216 ///
4217 /// * `request` - No description provided.
4218 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4219 pub fn topics_create(&self, request: Topic, course_id: &str) -> CourseTopicCreateCall<'a, C> {
4220 CourseTopicCreateCall {
4221 hub: self.hub,
4222 _request: request,
4223 _course_id: course_id.to_string(),
4224 _delegate: Default::default(),
4225 _additional_params: Default::default(),
4226 _scopes: Default::default(),
4227 }
4228 }
4229
4230 /// Create a builder to help you perform the following task:
4231 ///
4232 /// Deletes a topic. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not allowed to delete the requested topic or for access errors. * `FAILED_PRECONDITION` if the requested topic has already been deleted. * `NOT_FOUND` if no course or topic exists with the requested ID.
4233 ///
4234 /// # Arguments
4235 ///
4236 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4237 /// * `id` - Identifier of the topic to delete.
4238 pub fn topics_delete(&self, course_id: &str, id: &str) -> CourseTopicDeleteCall<'a, C> {
4239 CourseTopicDeleteCall {
4240 hub: self.hub,
4241 _course_id: course_id.to_string(),
4242 _id: id.to_string(),
4243 _delegate: Default::default(),
4244 _additional_params: Default::default(),
4245 _scopes: Default::default(),
4246 }
4247 }
4248
4249 /// Create a builder to help you perform the following task:
4250 ///
4251 /// Returns a topic. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or topic, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or topic does not exist.
4252 ///
4253 /// # Arguments
4254 ///
4255 /// * `courseId` - Identifier of the course.
4256 /// * `id` - Identifier of the topic.
4257 pub fn topics_get(&self, course_id: &str, id: &str) -> CourseTopicGetCall<'a, C> {
4258 CourseTopicGetCall {
4259 hub: self.hub,
4260 _course_id: course_id.to_string(),
4261 _id: id.to_string(),
4262 _delegate: Default::default(),
4263 _additional_params: Default::default(),
4264 _scopes: Default::default(),
4265 }
4266 }
4267
4268 /// Create a builder to help you perform the following task:
4269 ///
4270 /// Returns the list of topics that the requester is permitted to view. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
4271 ///
4272 /// # Arguments
4273 ///
4274 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4275 pub fn topics_list(&self, course_id: &str) -> CourseTopicListCall<'a, C> {
4276 CourseTopicListCall {
4277 hub: self.hub,
4278 _course_id: course_id.to_string(),
4279 _page_token: Default::default(),
4280 _page_size: Default::default(),
4281 _delegate: Default::default(),
4282 _additional_params: Default::default(),
4283 _scopes: Default::default(),
4284 }
4285 }
4286
4287 /// Create a builder to help you perform the following task:
4288 ///
4289 /// Updates one or more fields of a topic. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding topic or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if there exists a topic in the course with the same name. * `NOT_FOUND` if the requested course or topic does not exist
4290 ///
4291 /// # Arguments
4292 ///
4293 /// * `request` - No description provided.
4294 /// * `courseId` - Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
4295 /// * `id` - Identifier of the topic.
4296 pub fn topics_patch(
4297 &self,
4298 request: Topic,
4299 course_id: &str,
4300 id: &str,
4301 ) -> CourseTopicPatchCall<'a, C> {
4302 CourseTopicPatchCall {
4303 hub: self.hub,
4304 _request: request,
4305 _course_id: course_id.to_string(),
4306 _id: id.to_string(),
4307 _update_mask: Default::default(),
4308 _delegate: Default::default(),
4309 _additional_params: Default::default(),
4310 _scopes: Default::default(),
4311 }
4312 }
4313
4314 /// Create a builder to help you perform the following task:
4315 ///
4316 /// Creates a course. The user specified in `ownerId` is the owner of the created course and added as a teacher. A non-admin requesting user can only create a course with themselves as the owner. Domain admins can create courses owned by any user within their domain. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create courses or for access errors. * `NOT_FOUND` if the primary teacher is not a valid user. * `FAILED_PRECONDITION` if the course owner's account is disabled or for the following request errors: * UserCannotOwnCourse * UserGroupsMembershipLimitReached * CourseTitleCannotContainUrl * `ALREADY_EXISTS` if an alias was specified in the `id` and already exists.
4317 ///
4318 /// # Arguments
4319 ///
4320 /// * `request` - No description provided.
4321 pub fn create(&self, request: Course) -> CourseCreateCall<'a, C> {
4322 CourseCreateCall {
4323 hub: self.hub,
4324 _request: request,
4325 _delegate: Default::default(),
4326 _additional_params: Default::default(),
4327 _scopes: Default::default(),
4328 }
4329 }
4330
4331 /// Create a builder to help you perform the following task:
4332 ///
4333 /// Deletes a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID.
4334 ///
4335 /// # Arguments
4336 ///
4337 /// * `id` - Identifier of the course to delete. This identifier can be either the Classroom-assigned identifier or an alias.
4338 pub fn delete(&self, id: &str) -> CourseDeleteCall<'a, C> {
4339 CourseDeleteCall {
4340 hub: self.hub,
4341 _id: id.to_string(),
4342 _delegate: Default::default(),
4343 _additional_params: Default::default(),
4344 _scopes: Default::default(),
4345 }
4346 }
4347
4348 /// Create a builder to help you perform the following task:
4349 ///
4350 /// Returns a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID.
4351 ///
4352 /// # Arguments
4353 ///
4354 /// * `id` - Identifier of the course to return. This identifier can be either the Classroom-assigned identifier or an alias.
4355 pub fn get(&self, id: &str) -> CourseGetCall<'a, C> {
4356 CourseGetCall {
4357 hub: self.hub,
4358 _id: id.to_string(),
4359 _delegate: Default::default(),
4360 _additional_params: Default::default(),
4361 _scopes: Default::default(),
4362 }
4363 }
4364
4365 /// Create a builder to help you perform the following task:
4366 ///
4367 /// Returns the grading period settings in a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user isn't permitted to access the grading period settings in the requested course or for access errors. * `NOT_FOUND` if the requested course does not exist.
4368 ///
4369 /// # Arguments
4370 ///
4371 /// * `courseId` - Required. The identifier of the course.
4372 pub fn get_grading_period_settings(
4373 &self,
4374 course_id: &str,
4375 ) -> CourseGetGradingPeriodSettingCall<'a, C> {
4376 CourseGetGradingPeriodSettingCall {
4377 hub: self.hub,
4378 _course_id: course_id.to_string(),
4379 _delegate: Default::default(),
4380 _additional_params: Default::default(),
4381 _scopes: Default::default(),
4382 }
4383 }
4384
4385 /// Create a builder to help you perform the following task:
4386 ///
4387 /// Returns a list of courses that the requesting user is permitted to view, restricted to those that match the request. Returned courses are ordered by creation time, with the most recently created coming first. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the query argument is malformed. * `NOT_FOUND` if any users specified in the query arguments do not exist.
4388 pub fn list(&self) -> CourseListCall<'a, C> {
4389 CourseListCall {
4390 hub: self.hub,
4391 _teacher_id: Default::default(),
4392 _student_id: Default::default(),
4393 _page_token: Default::default(),
4394 _page_size: Default::default(),
4395 _course_states: Default::default(),
4396 _delegate: Default::default(),
4397 _additional_params: Default::default(),
4398 _scopes: Default::default(),
4399 }
4400 }
4401
4402 /// Create a builder to help you perform the following task:
4403 ///
4404 /// Updates one or more fields in a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID. * `INVALID_ARGUMENT` if invalid fields are specified in the update mask or if no update mask is supplied. * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable * InactiveCourseOwner * IneligibleOwner * CourseTitleCannotContainUrl
4405 ///
4406 /// # Arguments
4407 ///
4408 /// * `request` - No description provided.
4409 /// * `id` - Identifier of the course to update. This identifier can be either the Classroom-assigned identifier or an alias.
4410 pub fn patch(&self, request: Course, id: &str) -> CoursePatchCall<'a, C> {
4411 CoursePatchCall {
4412 hub: self.hub,
4413 _request: request,
4414 _id: id.to_string(),
4415 _update_mask: Default::default(),
4416 _delegate: Default::default(),
4417 _additional_params: Default::default(),
4418 _scopes: Default::default(),
4419 }
4420 }
4421
4422 /// Create a builder to help you perform the following task:
4423 ///
4424 /// Updates a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID. * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable * CourseTitleCannotContainUrl
4425 ///
4426 /// # Arguments
4427 ///
4428 /// * `request` - No description provided.
4429 /// * `id` - Identifier of the course to update. This identifier can be either the Classroom-assigned identifier or an alias.
4430 pub fn update(&self, request: Course, id: &str) -> CourseUpdateCall<'a, C> {
4431 CourseUpdateCall {
4432 hub: self.hub,
4433 _request: request,
4434 _id: id.to_string(),
4435 _delegate: Default::default(),
4436 _additional_params: Default::default(),
4437 _scopes: Default::default(),
4438 }
4439 }
4440
4441 /// Create a builder to help you perform the following task:
4442 ///
4443 /// Updates grading period settings of a course. Individual grading periods can be added, removed, or modified using this method. The requesting user and course owner must be eligible to modify Grading Periods. For details, see [licensing requirements](https://developers.google.com/workspace/classroom/grading-periods/manage-grading-periods#licensing_requirements). This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the grading period settings in a course or for access errors: * UserIneligibleToUpdateGradingPeriodSettings * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
4444 ///
4445 /// # Arguments
4446 ///
4447 /// * `request` - No description provided.
4448 /// * `courseId` - Required. The identifier of the course.
4449 pub fn update_grading_period_settings(
4450 &self,
4451 request: GradingPeriodSettings,
4452 course_id: &str,
4453 ) -> CourseUpdateGradingPeriodSettingCall<'a, C> {
4454 CourseUpdateGradingPeriodSettingCall {
4455 hub: self.hub,
4456 _request: request,
4457 _course_id: course_id.to_string(),
4458 _update_mask: Default::default(),
4459 _delegate: Default::default(),
4460 _additional_params: Default::default(),
4461 _scopes: Default::default(),
4462 }
4463 }
4464}
4465
4466/// A builder providing access to all methods supported on *invitation* resources.
4467/// It is not used directly, but through the [`Classroom`] hub.
4468///
4469/// # Example
4470///
4471/// Instantiate a resource builder
4472///
4473/// ```test_harness,no_run
4474/// extern crate hyper;
4475/// extern crate hyper_rustls;
4476/// extern crate google_classroom1 as classroom1;
4477///
4478/// # async fn dox() {
4479/// use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4480///
4481/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4482/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4483/// .with_native_roots()
4484/// .unwrap()
4485/// .https_only()
4486/// .enable_http2()
4487/// .build();
4488///
4489/// let executor = hyper_util::rt::TokioExecutor::new();
4490/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4491/// secret,
4492/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4493/// yup_oauth2::client::CustomHyperClientBuilder::from(
4494/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4495/// ),
4496/// ).build().await.unwrap();
4497///
4498/// let client = hyper_util::client::legacy::Client::builder(
4499/// hyper_util::rt::TokioExecutor::new()
4500/// )
4501/// .build(
4502/// hyper_rustls::HttpsConnectorBuilder::new()
4503/// .with_native_roots()
4504/// .unwrap()
4505/// .https_or_http()
4506/// .enable_http2()
4507/// .build()
4508/// );
4509/// let mut hub = Classroom::new(client, auth);
4510/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4511/// // like `accept(...)`, `create(...)`, `delete(...)`, `get(...)` and `list(...)`
4512/// // to build up your call.
4513/// let rb = hub.invitations();
4514/// # }
4515/// ```
4516pub struct InvitationMethods<'a, C>
4517where
4518 C: 'a,
4519{
4520 hub: &'a Classroom<C>,
4521}
4522
4523impl<'a, C> common::MethodsBuilder for InvitationMethods<'a, C> {}
4524
4525impl<'a, C> InvitationMethods<'a, C> {
4526 /// Create a builder to help you perform the following task:
4527 ///
4528 /// Accepts an invitation, removing it and adding the invited user to the teachers or students (as appropriate) of the specified course. Only the invited user may accept an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to accept the requested invitation or for access errors. * `FAILED_PRECONDITION` for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * CourseTeacherLimitReached * UserGroupsMembershipLimitReached * `NOT_FOUND` if no invitation exists with the requested ID.
4529 ///
4530 /// # Arguments
4531 ///
4532 /// * `id` - Identifier of the invitation to accept.
4533 pub fn accept(&self, id: &str) -> InvitationAcceptCall<'a, C> {
4534 InvitationAcceptCall {
4535 hub: self.hub,
4536 _id: id.to_string(),
4537 _delegate: Default::default(),
4538 _additional_params: Default::default(),
4539 _scopes: Default::default(),
4540 }
4541 }
4542
4543 /// Create a builder to help you perform the following task:
4544 ///
4545 /// Creates an invitation. Only one invitation for a user and course may exist at a time. Delete and re-create an invitation to make changes. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create invitations for this course or for access errors. * `NOT_FOUND` if the course or the user does not exist. * `FAILED_PRECONDITION`: * if the requested user's account is disabled. * if the user already has this role or a role with greater permissions. * for the following request errors: * IneligibleOwner * `ALREADY_EXISTS` if an invitation for the specified user and course already exists.
4546 ///
4547 /// # Arguments
4548 ///
4549 /// * `request` - No description provided.
4550 pub fn create(&self, request: Invitation) -> InvitationCreateCall<'a, C> {
4551 InvitationCreateCall {
4552 hub: self.hub,
4553 _request: request,
4554 _delegate: Default::default(),
4555 _additional_params: Default::default(),
4556 _scopes: Default::default(),
4557 }
4558 }
4559
4560 /// Create a builder to help you perform the following task:
4561 ///
4562 /// Deletes an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete the requested invitation or for access errors. * `NOT_FOUND` if no invitation exists with the requested ID.
4563 ///
4564 /// # Arguments
4565 ///
4566 /// * `id` - Identifier of the invitation to delete.
4567 pub fn delete(&self, id: &str) -> InvitationDeleteCall<'a, C> {
4568 InvitationDeleteCall {
4569 hub: self.hub,
4570 _id: id.to_string(),
4571 _delegate: Default::default(),
4572 _additional_params: Default::default(),
4573 _scopes: Default::default(),
4574 }
4575 }
4576
4577 /// Create a builder to help you perform the following task:
4578 ///
4579 /// Returns an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view the requested invitation or for access errors. * `NOT_FOUND` if no invitation exists with the requested ID.
4580 ///
4581 /// # Arguments
4582 ///
4583 /// * `id` - Identifier of the invitation to return.
4584 pub fn get(&self, id: &str) -> InvitationGetCall<'a, C> {
4585 InvitationGetCall {
4586 hub: self.hub,
4587 _id: id.to_string(),
4588 _delegate: Default::default(),
4589 _additional_params: Default::default(),
4590 _scopes: Default::default(),
4591 }
4592 }
4593
4594 /// Create a builder to help you perform the following task:
4595 ///
4596 /// Returns a list of invitations that the requesting user is permitted to view, restricted to those that match the list request. *Note:* At least one of `user_id` or `course_id` must be supplied. Both fields can be supplied. This method returns the following error codes: * `PERMISSION_DENIED` for access errors.
4597 pub fn list(&self) -> InvitationListCall<'a, C> {
4598 InvitationListCall {
4599 hub: self.hub,
4600 _user_id: Default::default(),
4601 _page_token: Default::default(),
4602 _page_size: Default::default(),
4603 _course_id: Default::default(),
4604 _delegate: Default::default(),
4605 _additional_params: Default::default(),
4606 _scopes: Default::default(),
4607 }
4608 }
4609}
4610
4611/// A builder providing access to all methods supported on *registration* resources.
4612/// It is not used directly, but through the [`Classroom`] hub.
4613///
4614/// # Example
4615///
4616/// Instantiate a resource builder
4617///
4618/// ```test_harness,no_run
4619/// extern crate hyper;
4620/// extern crate hyper_rustls;
4621/// extern crate google_classroom1 as classroom1;
4622///
4623/// # async fn dox() {
4624/// use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4625///
4626/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4627/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4628/// .with_native_roots()
4629/// .unwrap()
4630/// .https_only()
4631/// .enable_http2()
4632/// .build();
4633///
4634/// let executor = hyper_util::rt::TokioExecutor::new();
4635/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4636/// secret,
4637/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4638/// yup_oauth2::client::CustomHyperClientBuilder::from(
4639/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4640/// ),
4641/// ).build().await.unwrap();
4642///
4643/// let client = hyper_util::client::legacy::Client::builder(
4644/// hyper_util::rt::TokioExecutor::new()
4645/// )
4646/// .build(
4647/// hyper_rustls::HttpsConnectorBuilder::new()
4648/// .with_native_roots()
4649/// .unwrap()
4650/// .https_or_http()
4651/// .enable_http2()
4652/// .build()
4653/// );
4654/// let mut hub = Classroom::new(client, auth);
4655/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4656/// // like `create(...)` and `delete(...)`
4657/// // to build up your call.
4658/// let rb = hub.registrations();
4659/// # }
4660/// ```
4661pub struct RegistrationMethods<'a, C>
4662where
4663 C: 'a,
4664{
4665 hub: &'a Classroom<C>,
4666}
4667
4668impl<'a, C> common::MethodsBuilder for RegistrationMethods<'a, C> {}
4669
4670impl<'a, C> RegistrationMethods<'a, C> {
4671 /// Create a builder to help you perform the following task:
4672 ///
4673 /// Creates a `Registration`, causing Classroom to start sending notifications from the provided `feed` to the destination provided in `cloudPubSubTopic`. Returns the created `Registration`. Currently, this will be the same as the argument, but with server-assigned fields such as `expiry_time` and `id` filled in. Note that any value specified for the `expiry_time` or `id` fields will be ignored. While Classroom may validate the `cloudPubSubTopic` and return errors on a best effort basis, it is the caller's responsibility to ensure that it exists and that Classroom has permission to publish to it. This method may return the following error codes: * `PERMISSION_DENIED` if: * the authenticated user does not have permission to receive notifications from the requested field; or * the current user has not granted access to the current Cloud project with the appropriate scope for the requested feed. Note that domain-wide delegation of authority is not currently supported for this purpose. If the request has the appropriate scope, but no grant exists, a Request Errors is returned. * another access error is encountered. * `INVALID_ARGUMENT` if: * no `cloudPubsubTopic` is specified, or the specified `cloudPubsubTopic` is not valid; or * no `feed` is specified, or the specified `feed` is not valid. * `NOT_FOUND` if: * the specified `feed` cannot be located, or the requesting user does not have permission to determine whether or not it exists; or * the specified `cloudPubsubTopic` cannot be located, or Classroom has not been granted permission to publish to it.
4674 ///
4675 /// # Arguments
4676 ///
4677 /// * `request` - No description provided.
4678 pub fn create(&self, request: Registration) -> RegistrationCreateCall<'a, C> {
4679 RegistrationCreateCall {
4680 hub: self.hub,
4681 _request: request,
4682 _delegate: Default::default(),
4683 _additional_params: Default::default(),
4684 _scopes: Default::default(),
4685 }
4686 }
4687
4688 /// Create a builder to help you perform the following task:
4689 ///
4690 /// Deletes a `Registration`, causing Classroom to stop sending notifications for that `Registration`.
4691 ///
4692 /// # Arguments
4693 ///
4694 /// * `registrationId` - The `registration_id` of the `Registration` to be deleted.
4695 pub fn delete(&self, registration_id: &str) -> RegistrationDeleteCall<'a, C> {
4696 RegistrationDeleteCall {
4697 hub: self.hub,
4698 _registration_id: registration_id.to_string(),
4699 _delegate: Default::default(),
4700 _additional_params: Default::default(),
4701 _scopes: Default::default(),
4702 }
4703 }
4704}
4705
4706/// A builder providing access to all methods supported on *userProfile* resources.
4707/// It is not used directly, but through the [`Classroom`] hub.
4708///
4709/// # Example
4710///
4711/// Instantiate a resource builder
4712///
4713/// ```test_harness,no_run
4714/// extern crate hyper;
4715/// extern crate hyper_rustls;
4716/// extern crate google_classroom1 as classroom1;
4717///
4718/// # async fn dox() {
4719/// use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4720///
4721/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4722/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4723/// .with_native_roots()
4724/// .unwrap()
4725/// .https_only()
4726/// .enable_http2()
4727/// .build();
4728///
4729/// let executor = hyper_util::rt::TokioExecutor::new();
4730/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4731/// secret,
4732/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4733/// yup_oauth2::client::CustomHyperClientBuilder::from(
4734/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4735/// ),
4736/// ).build().await.unwrap();
4737///
4738/// let client = hyper_util::client::legacy::Client::builder(
4739/// hyper_util::rt::TokioExecutor::new()
4740/// )
4741/// .build(
4742/// hyper_rustls::HttpsConnectorBuilder::new()
4743/// .with_native_roots()
4744/// .unwrap()
4745/// .https_or_http()
4746/// .enable_http2()
4747/// .build()
4748/// );
4749/// let mut hub = Classroom::new(client, auth);
4750/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4751/// // like `get(...)`, `guardian_invitations_create(...)`, `guardian_invitations_get(...)`, `guardian_invitations_list(...)`, `guardian_invitations_patch(...)`, `guardians_delete(...)`, `guardians_get(...)` and `guardians_list(...)`
4752/// // to build up your call.
4753/// let rb = hub.user_profiles();
4754/// # }
4755/// ```
4756pub struct UserProfileMethods<'a, C>
4757where
4758 C: 'a,
4759{
4760 hub: &'a Classroom<C>,
4761}
4762
4763impl<'a, C> common::MethodsBuilder for UserProfileMethods<'a, C> {}
4764
4765impl<'a, C> UserProfileMethods<'a, C> {
4766 /// Create a builder to help you perform the following task:
4767 ///
4768 /// Creates a guardian invitation, and sends an email to the guardian asking them to confirm that they are the student's guardian. Once the guardian accepts the invitation, their `state` will change to `COMPLETED` and they will start receiving guardian notifications. A `Guardian` resource will also be created to represent the active guardian. The request object must have the `student_id` and `invited_email_address` fields set. Failing to set these fields, or setting any other fields in the request, will result in an error. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if the guardian in question has already rejected too many requests for that student, if guardians are not enabled for the domain in question, or for other access errors. * `RESOURCE_EXHAUSTED` if the student or guardian has exceeded the guardian link limit. * `INVALID_ARGUMENT` if the guardian email address is not valid (for example, if it is too long), or if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API). This error will also be returned if read-only fields are set, or if the `state` field is set to to a value other than `PENDING`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student. * `ALREADY_EXISTS` if there is already a pending guardian invitation for the student and `invited_email_address` provided, or if the provided `invited_email_address` matches the Google account of an existing `Guardian` for this user.
4769 ///
4770 /// # Arguments
4771 ///
4772 /// * `request` - No description provided.
4773 /// * `studentId` - ID of the student (in standard format)
4774 pub fn guardian_invitations_create(
4775 &self,
4776 request: GuardianInvitation,
4777 student_id: &str,
4778 ) -> UserProfileGuardianInvitationCreateCall<'a, C> {
4779 UserProfileGuardianInvitationCreateCall {
4780 hub: self.hub,
4781 _request: request,
4782 _student_id: student_id.to_string(),
4783 _delegate: Default::default(),
4784 _additional_params: Default::default(),
4785 _scopes: Default::default(),
4786 }
4787 }
4788
4789 /// Create a builder to help you perform the following task:
4790 ///
4791 /// Returns a specific guardian invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view guardian invitations for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). * `NOT_FOUND` if Classroom cannot find any record of the given student or `invitation_id`. May also be returned if the student exists, but the requesting user does not have access to see that student.
4792 ///
4793 /// # Arguments
4794 ///
4795 /// * `studentId` - The ID of the student whose guardian invitation is being requested.
4796 /// * `invitationId` - The `id` field of the `GuardianInvitation` being requested.
4797 pub fn guardian_invitations_get(
4798 &self,
4799 student_id: &str,
4800 invitation_id: &str,
4801 ) -> UserProfileGuardianInvitationGetCall<'a, C> {
4802 UserProfileGuardianInvitationGetCall {
4803 hub: self.hub,
4804 _student_id: student_id.to_string(),
4805 _invitation_id: invitation_id.to_string(),
4806 _delegate: Default::default(),
4807 _additional_params: Default::default(),
4808 _scopes: Default::default(),
4809 }
4810 }
4811
4812 /// Create a builder to help you perform the following task:
4813 ///
4814 /// Returns a list of guardian invitations that the requesting user is permitted to view, filtered by the parameters provided. This method returns the following error codes: * `PERMISSION_DENIED` if a `student_id` is specified, and the requesting user is not permitted to view guardian invitations for that student, if `"-"` is specified as the `student_id` and the user is not a domain administrator, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). May also be returned if an invalid `page_token` or `state` is provided. * `NOT_FOUND` if a `student_id` is specified, and its format can be recognized, but Classroom has no record of that student.
4815 ///
4816 /// # Arguments
4817 ///
4818 /// * `studentId` - The ID of the student whose guardian invitations are to be returned. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user * the string literal `"-"`, indicating that results should be returned for all students that the requesting user is permitted to view guardian invitations.
4819 pub fn guardian_invitations_list(
4820 &self,
4821 student_id: &str,
4822 ) -> UserProfileGuardianInvitationListCall<'a, C> {
4823 UserProfileGuardianInvitationListCall {
4824 hub: self.hub,
4825 _student_id: student_id.to_string(),
4826 _states: Default::default(),
4827 _page_token: Default::default(),
4828 _page_size: Default::default(),
4829 _invited_email_address: Default::default(),
4830 _delegate: Default::default(),
4831 _additional_params: Default::default(),
4832 _scopes: Default::default(),
4833 }
4834 }
4835
4836 /// Create a builder to help you perform the following task:
4837 ///
4838 /// Modifies a guardian invitation. Currently, the only valid modification is to change the `state` from `PENDING` to `COMPLETE`. This has the effect of withdrawing the invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if guardians are not enabled for the domain in question or for other access errors. * `FAILED_PRECONDITION` if the guardian link is not in the `PENDING` state. * `INVALID_ARGUMENT` if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API), or if the passed `GuardianInvitation` has a `state` other than `COMPLETE`, or if it modifies fields other than `state`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student, or if the `id` field does not refer to a guardian invitation known to Classroom.
4839 ///
4840 /// # Arguments
4841 ///
4842 /// * `request` - No description provided.
4843 /// * `studentId` - The ID of the student whose guardian invitation is to be modified.
4844 /// * `invitationId` - The `id` field of the `GuardianInvitation` to be modified.
4845 pub fn guardian_invitations_patch(
4846 &self,
4847 request: GuardianInvitation,
4848 student_id: &str,
4849 invitation_id: &str,
4850 ) -> UserProfileGuardianInvitationPatchCall<'a, C> {
4851 UserProfileGuardianInvitationPatchCall {
4852 hub: self.hub,
4853 _request: request,
4854 _student_id: student_id.to_string(),
4855 _invitation_id: invitation_id.to_string(),
4856 _update_mask: Default::default(),
4857 _delegate: Default::default(),
4858 _additional_params: Default::default(),
4859 _scopes: Default::default(),
4860 }
4861 }
4862
4863 /// Create a builder to help you perform the following task:
4864 ///
4865 /// Deletes a guardian. The guardian will no longer receive guardian notifications and the guardian will no longer be accessible via the API. This method returns the following error codes: * `PERMISSION_DENIED` if no user that matches the provided `student_id` is visible to the requesting user, if the requesting user is not permitted to manage guardians for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API). * `NOT_FOUND` if the requesting user is permitted to modify guardians for the requested `student_id`, but no `Guardian` record exists for that student with the provided `guardian_id`.
4866 ///
4867 /// # Arguments
4868 ///
4869 /// * `studentId` - The student whose guardian is to be deleted. One of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
4870 /// * `guardianId` - The `id` field from a `Guardian`.
4871 pub fn guardians_delete(
4872 &self,
4873 student_id: &str,
4874 guardian_id: &str,
4875 ) -> UserProfileGuardianDeleteCall<'a, C> {
4876 UserProfileGuardianDeleteCall {
4877 hub: self.hub,
4878 _student_id: student_id.to_string(),
4879 _guardian_id: guardian_id.to_string(),
4880 _delegate: Default::default(),
4881 _additional_params: Default::default(),
4882 _scopes: Default::default(),
4883 }
4884 }
4885
4886 /// Create a builder to help you perform the following task:
4887 ///
4888 /// Returns a specific guardian. This method returns the following error codes: * `PERMISSION_DENIED` if no user that matches the provided `student_id` is visible to the requesting user, if the requesting user is not permitted to view guardian information for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). * `NOT_FOUND` if the requesting user is permitted to view guardians for the requested `student_id`, but no `Guardian` record exists for that student that matches the provided `guardian_id`.
4889 ///
4890 /// # Arguments
4891 ///
4892 /// * `studentId` - The student whose guardian is being requested. One of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
4893 /// * `guardianId` - The `id` field from a `Guardian`.
4894 pub fn guardians_get(
4895 &self,
4896 student_id: &str,
4897 guardian_id: &str,
4898 ) -> UserProfileGuardianGetCall<'a, C> {
4899 UserProfileGuardianGetCall {
4900 hub: self.hub,
4901 _student_id: student_id.to_string(),
4902 _guardian_id: guardian_id.to_string(),
4903 _delegate: Default::default(),
4904 _additional_params: Default::default(),
4905 _scopes: Default::default(),
4906 }
4907 }
4908
4909 /// Create a builder to help you perform the following task:
4910 ///
4911 /// Returns a list of guardians that the requesting user is permitted to view, restricted to those that match the request. To list guardians for any student that the requesting user may view guardians for, use the literal character `-` for the student ID. This method returns the following error codes: * `PERMISSION_DENIED` if a `student_id` is specified, and the requesting user is not permitted to view guardian information for that student, if `"-"` is specified as the `student_id` and the user is not a domain administrator, if guardians are not enabled for the domain in question, if the `invited_email_address` filter is set by a user who is not a domain administrator, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). May also be returned if an invalid `page_token` is provided. * `NOT_FOUND` if a `student_id` is specified, and its format can be recognized, but Classroom has no record of that student.
4912 ///
4913 /// # Arguments
4914 ///
4915 /// * `studentId` - Filter results by the student who the guardian is linked to. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user * the string literal `"-"`, indicating that results should be returned for all students that the requesting user has access to view.
4916 pub fn guardians_list(&self, student_id: &str) -> UserProfileGuardianListCall<'a, C> {
4917 UserProfileGuardianListCall {
4918 hub: self.hub,
4919 _student_id: student_id.to_string(),
4920 _page_token: Default::default(),
4921 _page_size: Default::default(),
4922 _invited_email_address: Default::default(),
4923 _delegate: Default::default(),
4924 _additional_params: Default::default(),
4925 _scopes: Default::default(),
4926 }
4927 }
4928
4929 /// Create a builder to help you perform the following task:
4930 ///
4931 /// Returns a user profile. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access this user profile, if no profile exists with the requested ID, or for access errors.
4932 ///
4933 /// # Arguments
4934 ///
4935 /// * `userId` - Identifier of the profile to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
4936 pub fn get(&self, user_id: &str) -> UserProfileGetCall<'a, C> {
4937 UserProfileGetCall {
4938 hub: self.hub,
4939 _user_id: user_id.to_string(),
4940 _delegate: Default::default(),
4941 _additional_params: Default::default(),
4942 _scopes: Default::default(),
4943 }
4944 }
4945}
4946
4947// ###################
4948// CallBuilders ###
4949// #################
4950
4951/// Creates an alias for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create the alias or for access errors. * `NOT_FOUND` if the course does not exist. * `ALREADY_EXISTS` if the alias already exists. * `FAILED_PRECONDITION` if the alias requested does not make sense for the requesting user or course (for example, if a user not in a domain attempts to access a domain-scoped alias).
4952///
4953/// A builder for the *aliases.create* method supported by a *course* resource.
4954/// It is not used directly, but through a [`CourseMethods`] instance.
4955///
4956/// # Example
4957///
4958/// Instantiate a resource method builder
4959///
4960/// ```test_harness,no_run
4961/// # extern crate hyper;
4962/// # extern crate hyper_rustls;
4963/// # extern crate google_classroom1 as classroom1;
4964/// use classroom1::api::CourseAlias;
4965/// # async fn dox() {
4966/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4967///
4968/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4969/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4970/// # .with_native_roots()
4971/// # .unwrap()
4972/// # .https_only()
4973/// # .enable_http2()
4974/// # .build();
4975///
4976/// # let executor = hyper_util::rt::TokioExecutor::new();
4977/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4978/// # secret,
4979/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4980/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4981/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4982/// # ),
4983/// # ).build().await.unwrap();
4984///
4985/// # let client = hyper_util::client::legacy::Client::builder(
4986/// # hyper_util::rt::TokioExecutor::new()
4987/// # )
4988/// # .build(
4989/// # hyper_rustls::HttpsConnectorBuilder::new()
4990/// # .with_native_roots()
4991/// # .unwrap()
4992/// # .https_or_http()
4993/// # .enable_http2()
4994/// # .build()
4995/// # );
4996/// # let mut hub = Classroom::new(client, auth);
4997/// // As the method needs a request, you would usually fill it with the desired information
4998/// // into the respective structure. Some of the parts shown here might not be applicable !
4999/// // Values shown here are possibly random and not representative !
5000/// let mut req = CourseAlias::default();
5001///
5002/// // You can configure optional parameters by calling the respective setters at will, and
5003/// // execute the final call using `doit()`.
5004/// // Values shown here are possibly random and not representative !
5005/// let result = hub.courses().aliases_create(req, "courseId")
5006/// .doit().await;
5007/// # }
5008/// ```
5009pub struct CourseAliasCreateCall<'a, C>
5010where
5011 C: 'a,
5012{
5013 hub: &'a Classroom<C>,
5014 _request: CourseAlias,
5015 _course_id: String,
5016 _delegate: Option<&'a mut dyn common::Delegate>,
5017 _additional_params: HashMap<String, String>,
5018 _scopes: BTreeSet<String>,
5019}
5020
5021impl<'a, C> common::CallBuilder for CourseAliasCreateCall<'a, C> {}
5022
5023impl<'a, C> CourseAliasCreateCall<'a, C>
5024where
5025 C: common::Connector,
5026{
5027 /// Perform the operation you have build so far.
5028 pub async fn doit(mut self) -> common::Result<(common::Response, CourseAlias)> {
5029 use std::borrow::Cow;
5030 use std::io::{Read, Seek};
5031
5032 use common::{url::Params, ToParts};
5033 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5034
5035 let mut dd = common::DefaultDelegate;
5036 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5037 dlg.begin(common::MethodInfo {
5038 id: "classroom.courses.aliases.create",
5039 http_method: hyper::Method::POST,
5040 });
5041
5042 for &field in ["alt", "courseId"].iter() {
5043 if self._additional_params.contains_key(field) {
5044 dlg.finished(false);
5045 return Err(common::Error::FieldClash(field));
5046 }
5047 }
5048
5049 let mut params = Params::with_capacity(4 + self._additional_params.len());
5050 params.push("courseId", self._course_id);
5051
5052 params.extend(self._additional_params.iter());
5053
5054 params.push("alt", "json");
5055 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/aliases";
5056 if self._scopes.is_empty() {
5057 self._scopes.insert(Scope::Course.as_ref().to_string());
5058 }
5059
5060 #[allow(clippy::single_element_loop)]
5061 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
5062 url = params.uri_replacement(url, param_name, find_this, false);
5063 }
5064 {
5065 let to_remove = ["courseId"];
5066 params.remove_params(&to_remove);
5067 }
5068
5069 let url = params.parse_with_url(&url);
5070
5071 let mut json_mime_type = mime::APPLICATION_JSON;
5072 let mut request_value_reader = {
5073 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5074 common::remove_json_null_values(&mut value);
5075 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5076 serde_json::to_writer(&mut dst, &value).unwrap();
5077 dst
5078 };
5079 let request_size = request_value_reader
5080 .seek(std::io::SeekFrom::End(0))
5081 .unwrap();
5082 request_value_reader
5083 .seek(std::io::SeekFrom::Start(0))
5084 .unwrap();
5085
5086 loop {
5087 let token = match self
5088 .hub
5089 .auth
5090 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5091 .await
5092 {
5093 Ok(token) => token,
5094 Err(e) => match dlg.token(e) {
5095 Ok(token) => token,
5096 Err(e) => {
5097 dlg.finished(false);
5098 return Err(common::Error::MissingToken(e));
5099 }
5100 },
5101 };
5102 request_value_reader
5103 .seek(std::io::SeekFrom::Start(0))
5104 .unwrap();
5105 let mut req_result = {
5106 let client = &self.hub.client;
5107 dlg.pre_request();
5108 let mut req_builder = hyper::Request::builder()
5109 .method(hyper::Method::POST)
5110 .uri(url.as_str())
5111 .header(USER_AGENT, self.hub._user_agent.clone());
5112
5113 if let Some(token) = token.as_ref() {
5114 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5115 }
5116
5117 let request = req_builder
5118 .header(CONTENT_TYPE, json_mime_type.to_string())
5119 .header(CONTENT_LENGTH, request_size as u64)
5120 .body(common::to_body(
5121 request_value_reader.get_ref().clone().into(),
5122 ));
5123
5124 client.request(request.unwrap()).await
5125 };
5126
5127 match req_result {
5128 Err(err) => {
5129 if let common::Retry::After(d) = dlg.http_error(&err) {
5130 sleep(d).await;
5131 continue;
5132 }
5133 dlg.finished(false);
5134 return Err(common::Error::HttpError(err));
5135 }
5136 Ok(res) => {
5137 let (mut parts, body) = res.into_parts();
5138 let mut body = common::Body::new(body);
5139 if !parts.status.is_success() {
5140 let bytes = common::to_bytes(body).await.unwrap_or_default();
5141 let error = serde_json::from_str(&common::to_string(&bytes));
5142 let response = common::to_response(parts, bytes.into());
5143
5144 if let common::Retry::After(d) =
5145 dlg.http_failure(&response, error.as_ref().ok())
5146 {
5147 sleep(d).await;
5148 continue;
5149 }
5150
5151 dlg.finished(false);
5152
5153 return Err(match error {
5154 Ok(value) => common::Error::BadRequest(value),
5155 _ => common::Error::Failure(response),
5156 });
5157 }
5158 let response = {
5159 let bytes = common::to_bytes(body).await.unwrap_or_default();
5160 let encoded = common::to_string(&bytes);
5161 match serde_json::from_str(&encoded) {
5162 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5163 Err(error) => {
5164 dlg.response_json_decode_error(&encoded, &error);
5165 return Err(common::Error::JsonDecodeError(
5166 encoded.to_string(),
5167 error,
5168 ));
5169 }
5170 }
5171 };
5172
5173 dlg.finished(true);
5174 return Ok(response);
5175 }
5176 }
5177 }
5178 }
5179
5180 ///
5181 /// Sets the *request* property to the given value.
5182 ///
5183 /// Even though the property as already been set when instantiating this call,
5184 /// we provide this method for API completeness.
5185 pub fn request(mut self, new_value: CourseAlias) -> CourseAliasCreateCall<'a, C> {
5186 self._request = new_value;
5187 self
5188 }
5189 /// Identifier of the course to alias. This identifier can be either the Classroom-assigned identifier or an alias.
5190 ///
5191 /// Sets the *course id* path property to the given value.
5192 ///
5193 /// Even though the property as already been set when instantiating this call,
5194 /// we provide this method for API completeness.
5195 pub fn course_id(mut self, new_value: &str) -> CourseAliasCreateCall<'a, C> {
5196 self._course_id = new_value.to_string();
5197 self
5198 }
5199 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5200 /// while executing the actual API request.
5201 ///
5202 /// ````text
5203 /// It should be used to handle progress information, and to implement a certain level of resilience.
5204 /// ````
5205 ///
5206 /// Sets the *delegate* property to the given value.
5207 pub fn delegate(
5208 mut self,
5209 new_value: &'a mut dyn common::Delegate,
5210 ) -> CourseAliasCreateCall<'a, C> {
5211 self._delegate = Some(new_value);
5212 self
5213 }
5214
5215 /// Set any additional parameter of the query string used in the request.
5216 /// It should be used to set parameters which are not yet available through their own
5217 /// setters.
5218 ///
5219 /// Please note that this method must not be used to set any of the known parameters
5220 /// which have their own setter method. If done anyway, the request will fail.
5221 ///
5222 /// # Additional Parameters
5223 ///
5224 /// * *$.xgafv* (query-string) - V1 error format.
5225 /// * *access_token* (query-string) - OAuth access token.
5226 /// * *alt* (query-string) - Data format for response.
5227 /// * *callback* (query-string) - JSONP
5228 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5229 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5230 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5231 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5232 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5233 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5234 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5235 pub fn param<T>(mut self, name: T, value: T) -> CourseAliasCreateCall<'a, C>
5236 where
5237 T: AsRef<str>,
5238 {
5239 self._additional_params
5240 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5241 self
5242 }
5243
5244 /// Identifies the authorization scope for the method you are building.
5245 ///
5246 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5247 /// [`Scope::Course`].
5248 ///
5249 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5250 /// tokens for more than one scope.
5251 ///
5252 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5253 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5254 /// sufficient, a read-write scope will do as well.
5255 pub fn add_scope<St>(mut self, scope: St) -> CourseAliasCreateCall<'a, C>
5256 where
5257 St: AsRef<str>,
5258 {
5259 self._scopes.insert(String::from(scope.as_ref()));
5260 self
5261 }
5262 /// Identifies the authorization scope(s) for the method you are building.
5263 ///
5264 /// See [`Self::add_scope()`] for details.
5265 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAliasCreateCall<'a, C>
5266 where
5267 I: IntoIterator<Item = St>,
5268 St: AsRef<str>,
5269 {
5270 self._scopes
5271 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5272 self
5273 }
5274
5275 /// Removes all scopes, and no default scope will be used either.
5276 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5277 /// for details).
5278 pub fn clear_scopes(mut self) -> CourseAliasCreateCall<'a, C> {
5279 self._scopes.clear();
5280 self
5281 }
5282}
5283
5284/// Deletes an alias of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to remove the alias or for access errors. * `NOT_FOUND` if the alias does not exist. * `FAILED_PRECONDITION` if the alias requested does not make sense for the requesting user or course (for example, if a user not in a domain attempts to delete a domain-scoped alias).
5285///
5286/// A builder for the *aliases.delete* method supported by a *course* resource.
5287/// It is not used directly, but through a [`CourseMethods`] instance.
5288///
5289/// # Example
5290///
5291/// Instantiate a resource method builder
5292///
5293/// ```test_harness,no_run
5294/// # extern crate hyper;
5295/// # extern crate hyper_rustls;
5296/// # extern crate google_classroom1 as classroom1;
5297/// # async fn dox() {
5298/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5299///
5300/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5301/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5302/// # .with_native_roots()
5303/// # .unwrap()
5304/// # .https_only()
5305/// # .enable_http2()
5306/// # .build();
5307///
5308/// # let executor = hyper_util::rt::TokioExecutor::new();
5309/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5310/// # secret,
5311/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5312/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5313/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5314/// # ),
5315/// # ).build().await.unwrap();
5316///
5317/// # let client = hyper_util::client::legacy::Client::builder(
5318/// # hyper_util::rt::TokioExecutor::new()
5319/// # )
5320/// # .build(
5321/// # hyper_rustls::HttpsConnectorBuilder::new()
5322/// # .with_native_roots()
5323/// # .unwrap()
5324/// # .https_or_http()
5325/// # .enable_http2()
5326/// # .build()
5327/// # );
5328/// # let mut hub = Classroom::new(client, auth);
5329/// // You can configure optional parameters by calling the respective setters at will, and
5330/// // execute the final call using `doit()`.
5331/// // Values shown here are possibly random and not representative !
5332/// let result = hub.courses().aliases_delete("courseId", "alias")
5333/// .doit().await;
5334/// # }
5335/// ```
5336pub struct CourseAliasDeleteCall<'a, C>
5337where
5338 C: 'a,
5339{
5340 hub: &'a Classroom<C>,
5341 _course_id: String,
5342 _alias: String,
5343 _delegate: Option<&'a mut dyn common::Delegate>,
5344 _additional_params: HashMap<String, String>,
5345 _scopes: BTreeSet<String>,
5346}
5347
5348impl<'a, C> common::CallBuilder for CourseAliasDeleteCall<'a, C> {}
5349
5350impl<'a, C> CourseAliasDeleteCall<'a, C>
5351where
5352 C: common::Connector,
5353{
5354 /// Perform the operation you have build so far.
5355 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5356 use std::borrow::Cow;
5357 use std::io::{Read, Seek};
5358
5359 use common::{url::Params, ToParts};
5360 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5361
5362 let mut dd = common::DefaultDelegate;
5363 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5364 dlg.begin(common::MethodInfo {
5365 id: "classroom.courses.aliases.delete",
5366 http_method: hyper::Method::DELETE,
5367 });
5368
5369 for &field in ["alt", "courseId", "alias"].iter() {
5370 if self._additional_params.contains_key(field) {
5371 dlg.finished(false);
5372 return Err(common::Error::FieldClash(field));
5373 }
5374 }
5375
5376 let mut params = Params::with_capacity(4 + self._additional_params.len());
5377 params.push("courseId", self._course_id);
5378 params.push("alias", self._alias);
5379
5380 params.extend(self._additional_params.iter());
5381
5382 params.push("alt", "json");
5383 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/aliases/{alias}";
5384 if self._scopes.is_empty() {
5385 self._scopes.insert(Scope::Course.as_ref().to_string());
5386 }
5387
5388 #[allow(clippy::single_element_loop)]
5389 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{alias}", "alias")].iter() {
5390 url = params.uri_replacement(url, param_name, find_this, false);
5391 }
5392 {
5393 let to_remove = ["alias", "courseId"];
5394 params.remove_params(&to_remove);
5395 }
5396
5397 let url = params.parse_with_url(&url);
5398
5399 loop {
5400 let token = match self
5401 .hub
5402 .auth
5403 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5404 .await
5405 {
5406 Ok(token) => token,
5407 Err(e) => match dlg.token(e) {
5408 Ok(token) => token,
5409 Err(e) => {
5410 dlg.finished(false);
5411 return Err(common::Error::MissingToken(e));
5412 }
5413 },
5414 };
5415 let mut req_result = {
5416 let client = &self.hub.client;
5417 dlg.pre_request();
5418 let mut req_builder = hyper::Request::builder()
5419 .method(hyper::Method::DELETE)
5420 .uri(url.as_str())
5421 .header(USER_AGENT, self.hub._user_agent.clone());
5422
5423 if let Some(token) = token.as_ref() {
5424 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5425 }
5426
5427 let request = req_builder
5428 .header(CONTENT_LENGTH, 0_u64)
5429 .body(common::to_body::<String>(None));
5430
5431 client.request(request.unwrap()).await
5432 };
5433
5434 match req_result {
5435 Err(err) => {
5436 if let common::Retry::After(d) = dlg.http_error(&err) {
5437 sleep(d).await;
5438 continue;
5439 }
5440 dlg.finished(false);
5441 return Err(common::Error::HttpError(err));
5442 }
5443 Ok(res) => {
5444 let (mut parts, body) = res.into_parts();
5445 let mut body = common::Body::new(body);
5446 if !parts.status.is_success() {
5447 let bytes = common::to_bytes(body).await.unwrap_or_default();
5448 let error = serde_json::from_str(&common::to_string(&bytes));
5449 let response = common::to_response(parts, bytes.into());
5450
5451 if let common::Retry::After(d) =
5452 dlg.http_failure(&response, error.as_ref().ok())
5453 {
5454 sleep(d).await;
5455 continue;
5456 }
5457
5458 dlg.finished(false);
5459
5460 return Err(match error {
5461 Ok(value) => common::Error::BadRequest(value),
5462 _ => common::Error::Failure(response),
5463 });
5464 }
5465 let response = {
5466 let bytes = common::to_bytes(body).await.unwrap_or_default();
5467 let encoded = common::to_string(&bytes);
5468 match serde_json::from_str(&encoded) {
5469 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5470 Err(error) => {
5471 dlg.response_json_decode_error(&encoded, &error);
5472 return Err(common::Error::JsonDecodeError(
5473 encoded.to_string(),
5474 error,
5475 ));
5476 }
5477 }
5478 };
5479
5480 dlg.finished(true);
5481 return Ok(response);
5482 }
5483 }
5484 }
5485 }
5486
5487 /// Identifier of the course whose alias should be deleted. This identifier can be either the Classroom-assigned identifier or an alias.
5488 ///
5489 /// Sets the *course id* path property to the given value.
5490 ///
5491 /// Even though the property as already been set when instantiating this call,
5492 /// we provide this method for API completeness.
5493 pub fn course_id(mut self, new_value: &str) -> CourseAliasDeleteCall<'a, C> {
5494 self._course_id = new_value.to_string();
5495 self
5496 }
5497 /// Alias to delete. This may not be the Classroom-assigned identifier.
5498 ///
5499 /// Sets the *alias* path property to the given value.
5500 ///
5501 /// Even though the property as already been set when instantiating this call,
5502 /// we provide this method for API completeness.
5503 pub fn alias(mut self, new_value: &str) -> CourseAliasDeleteCall<'a, C> {
5504 self._alias = new_value.to_string();
5505 self
5506 }
5507 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5508 /// while executing the actual API request.
5509 ///
5510 /// ````text
5511 /// It should be used to handle progress information, and to implement a certain level of resilience.
5512 /// ````
5513 ///
5514 /// Sets the *delegate* property to the given value.
5515 pub fn delegate(
5516 mut self,
5517 new_value: &'a mut dyn common::Delegate,
5518 ) -> CourseAliasDeleteCall<'a, C> {
5519 self._delegate = Some(new_value);
5520 self
5521 }
5522
5523 /// Set any additional parameter of the query string used in the request.
5524 /// It should be used to set parameters which are not yet available through their own
5525 /// setters.
5526 ///
5527 /// Please note that this method must not be used to set any of the known parameters
5528 /// which have their own setter method. If done anyway, the request will fail.
5529 ///
5530 /// # Additional Parameters
5531 ///
5532 /// * *$.xgafv* (query-string) - V1 error format.
5533 /// * *access_token* (query-string) - OAuth access token.
5534 /// * *alt* (query-string) - Data format for response.
5535 /// * *callback* (query-string) - JSONP
5536 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5537 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5538 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5539 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5540 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5541 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5542 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5543 pub fn param<T>(mut self, name: T, value: T) -> CourseAliasDeleteCall<'a, C>
5544 where
5545 T: AsRef<str>,
5546 {
5547 self._additional_params
5548 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5549 self
5550 }
5551
5552 /// Identifies the authorization scope for the method you are building.
5553 ///
5554 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5555 /// [`Scope::Course`].
5556 ///
5557 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5558 /// tokens for more than one scope.
5559 ///
5560 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5561 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5562 /// sufficient, a read-write scope will do as well.
5563 pub fn add_scope<St>(mut self, scope: St) -> CourseAliasDeleteCall<'a, C>
5564 where
5565 St: AsRef<str>,
5566 {
5567 self._scopes.insert(String::from(scope.as_ref()));
5568 self
5569 }
5570 /// Identifies the authorization scope(s) for the method you are building.
5571 ///
5572 /// See [`Self::add_scope()`] for details.
5573 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAliasDeleteCall<'a, C>
5574 where
5575 I: IntoIterator<Item = St>,
5576 St: AsRef<str>,
5577 {
5578 self._scopes
5579 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5580 self
5581 }
5582
5583 /// Removes all scopes, and no default scope will be used either.
5584 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5585 /// for details).
5586 pub fn clear_scopes(mut self) -> CourseAliasDeleteCall<'a, C> {
5587 self._scopes.clear();
5588 self
5589 }
5590}
5591
5592/// Returns a list of aliases for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the course or for access errors. * `NOT_FOUND` if the course does not exist.
5593///
5594/// A builder for the *aliases.list* method supported by a *course* resource.
5595/// It is not used directly, but through a [`CourseMethods`] instance.
5596///
5597/// # Example
5598///
5599/// Instantiate a resource method builder
5600///
5601/// ```test_harness,no_run
5602/// # extern crate hyper;
5603/// # extern crate hyper_rustls;
5604/// # extern crate google_classroom1 as classroom1;
5605/// # async fn dox() {
5606/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5607///
5608/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5609/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5610/// # .with_native_roots()
5611/// # .unwrap()
5612/// # .https_only()
5613/// # .enable_http2()
5614/// # .build();
5615///
5616/// # let executor = hyper_util::rt::TokioExecutor::new();
5617/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5618/// # secret,
5619/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5620/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5621/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5622/// # ),
5623/// # ).build().await.unwrap();
5624///
5625/// # let client = hyper_util::client::legacy::Client::builder(
5626/// # hyper_util::rt::TokioExecutor::new()
5627/// # )
5628/// # .build(
5629/// # hyper_rustls::HttpsConnectorBuilder::new()
5630/// # .with_native_roots()
5631/// # .unwrap()
5632/// # .https_or_http()
5633/// # .enable_http2()
5634/// # .build()
5635/// # );
5636/// # let mut hub = Classroom::new(client, auth);
5637/// // You can configure optional parameters by calling the respective setters at will, and
5638/// // execute the final call using `doit()`.
5639/// // Values shown here are possibly random and not representative !
5640/// let result = hub.courses().aliases_list("courseId")
5641/// .page_token("ipsum")
5642/// .page_size(-88)
5643/// .doit().await;
5644/// # }
5645/// ```
5646pub struct CourseAliasListCall<'a, C>
5647where
5648 C: 'a,
5649{
5650 hub: &'a Classroom<C>,
5651 _course_id: String,
5652 _page_token: Option<String>,
5653 _page_size: Option<i32>,
5654 _delegate: Option<&'a mut dyn common::Delegate>,
5655 _additional_params: HashMap<String, String>,
5656 _scopes: BTreeSet<String>,
5657}
5658
5659impl<'a, C> common::CallBuilder for CourseAliasListCall<'a, C> {}
5660
5661impl<'a, C> CourseAliasListCall<'a, C>
5662where
5663 C: common::Connector,
5664{
5665 /// Perform the operation you have build so far.
5666 pub async fn doit(mut self) -> common::Result<(common::Response, ListCourseAliasesResponse)> {
5667 use std::borrow::Cow;
5668 use std::io::{Read, Seek};
5669
5670 use common::{url::Params, ToParts};
5671 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5672
5673 let mut dd = common::DefaultDelegate;
5674 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5675 dlg.begin(common::MethodInfo {
5676 id: "classroom.courses.aliases.list",
5677 http_method: hyper::Method::GET,
5678 });
5679
5680 for &field in ["alt", "courseId", "pageToken", "pageSize"].iter() {
5681 if self._additional_params.contains_key(field) {
5682 dlg.finished(false);
5683 return Err(common::Error::FieldClash(field));
5684 }
5685 }
5686
5687 let mut params = Params::with_capacity(5 + self._additional_params.len());
5688 params.push("courseId", self._course_id);
5689 if let Some(value) = self._page_token.as_ref() {
5690 params.push("pageToken", value);
5691 }
5692 if let Some(value) = self._page_size.as_ref() {
5693 params.push("pageSize", value.to_string());
5694 }
5695
5696 params.extend(self._additional_params.iter());
5697
5698 params.push("alt", "json");
5699 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/aliases";
5700 if self._scopes.is_empty() {
5701 self._scopes
5702 .insert(Scope::CourseReadonly.as_ref().to_string());
5703 }
5704
5705 #[allow(clippy::single_element_loop)]
5706 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
5707 url = params.uri_replacement(url, param_name, find_this, false);
5708 }
5709 {
5710 let to_remove = ["courseId"];
5711 params.remove_params(&to_remove);
5712 }
5713
5714 let url = params.parse_with_url(&url);
5715
5716 loop {
5717 let token = match self
5718 .hub
5719 .auth
5720 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5721 .await
5722 {
5723 Ok(token) => token,
5724 Err(e) => match dlg.token(e) {
5725 Ok(token) => token,
5726 Err(e) => {
5727 dlg.finished(false);
5728 return Err(common::Error::MissingToken(e));
5729 }
5730 },
5731 };
5732 let mut req_result = {
5733 let client = &self.hub.client;
5734 dlg.pre_request();
5735 let mut req_builder = hyper::Request::builder()
5736 .method(hyper::Method::GET)
5737 .uri(url.as_str())
5738 .header(USER_AGENT, self.hub._user_agent.clone());
5739
5740 if let Some(token) = token.as_ref() {
5741 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5742 }
5743
5744 let request = req_builder
5745 .header(CONTENT_LENGTH, 0_u64)
5746 .body(common::to_body::<String>(None));
5747
5748 client.request(request.unwrap()).await
5749 };
5750
5751 match req_result {
5752 Err(err) => {
5753 if let common::Retry::After(d) = dlg.http_error(&err) {
5754 sleep(d).await;
5755 continue;
5756 }
5757 dlg.finished(false);
5758 return Err(common::Error::HttpError(err));
5759 }
5760 Ok(res) => {
5761 let (mut parts, body) = res.into_parts();
5762 let mut body = common::Body::new(body);
5763 if !parts.status.is_success() {
5764 let bytes = common::to_bytes(body).await.unwrap_or_default();
5765 let error = serde_json::from_str(&common::to_string(&bytes));
5766 let response = common::to_response(parts, bytes.into());
5767
5768 if let common::Retry::After(d) =
5769 dlg.http_failure(&response, error.as_ref().ok())
5770 {
5771 sleep(d).await;
5772 continue;
5773 }
5774
5775 dlg.finished(false);
5776
5777 return Err(match error {
5778 Ok(value) => common::Error::BadRequest(value),
5779 _ => common::Error::Failure(response),
5780 });
5781 }
5782 let response = {
5783 let bytes = common::to_bytes(body).await.unwrap_or_default();
5784 let encoded = common::to_string(&bytes);
5785 match serde_json::from_str(&encoded) {
5786 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5787 Err(error) => {
5788 dlg.response_json_decode_error(&encoded, &error);
5789 return Err(common::Error::JsonDecodeError(
5790 encoded.to_string(),
5791 error,
5792 ));
5793 }
5794 }
5795 };
5796
5797 dlg.finished(true);
5798 return Ok(response);
5799 }
5800 }
5801 }
5802 }
5803
5804 /// The identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
5805 ///
5806 /// Sets the *course id* path property to the given value.
5807 ///
5808 /// Even though the property as already been set when instantiating this call,
5809 /// we provide this method for API completeness.
5810 pub fn course_id(mut self, new_value: &str) -> CourseAliasListCall<'a, C> {
5811 self._course_id = new_value.to_string();
5812 self
5813 }
5814 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
5815 ///
5816 /// Sets the *page token* query property to the given value.
5817 pub fn page_token(mut self, new_value: &str) -> CourseAliasListCall<'a, C> {
5818 self._page_token = Some(new_value.to_string());
5819 self
5820 }
5821 /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.
5822 ///
5823 /// Sets the *page size* query property to the given value.
5824 pub fn page_size(mut self, new_value: i32) -> CourseAliasListCall<'a, C> {
5825 self._page_size = Some(new_value);
5826 self
5827 }
5828 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5829 /// while executing the actual API request.
5830 ///
5831 /// ````text
5832 /// It should be used to handle progress information, and to implement a certain level of resilience.
5833 /// ````
5834 ///
5835 /// Sets the *delegate* property to the given value.
5836 pub fn delegate(
5837 mut self,
5838 new_value: &'a mut dyn common::Delegate,
5839 ) -> CourseAliasListCall<'a, C> {
5840 self._delegate = Some(new_value);
5841 self
5842 }
5843
5844 /// Set any additional parameter of the query string used in the request.
5845 /// It should be used to set parameters which are not yet available through their own
5846 /// setters.
5847 ///
5848 /// Please note that this method must not be used to set any of the known parameters
5849 /// which have their own setter method. If done anyway, the request will fail.
5850 ///
5851 /// # Additional Parameters
5852 ///
5853 /// * *$.xgafv* (query-string) - V1 error format.
5854 /// * *access_token* (query-string) - OAuth access token.
5855 /// * *alt* (query-string) - Data format for response.
5856 /// * *callback* (query-string) - JSONP
5857 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5858 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5859 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5860 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5861 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5862 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5863 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5864 pub fn param<T>(mut self, name: T, value: T) -> CourseAliasListCall<'a, C>
5865 where
5866 T: AsRef<str>,
5867 {
5868 self._additional_params
5869 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5870 self
5871 }
5872
5873 /// Identifies the authorization scope for the method you are building.
5874 ///
5875 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5876 /// [`Scope::CourseReadonly`].
5877 ///
5878 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5879 /// tokens for more than one scope.
5880 ///
5881 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5882 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5883 /// sufficient, a read-write scope will do as well.
5884 pub fn add_scope<St>(mut self, scope: St) -> CourseAliasListCall<'a, C>
5885 where
5886 St: AsRef<str>,
5887 {
5888 self._scopes.insert(String::from(scope.as_ref()));
5889 self
5890 }
5891 /// Identifies the authorization scope(s) for the method you are building.
5892 ///
5893 /// See [`Self::add_scope()`] for details.
5894 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAliasListCall<'a, C>
5895 where
5896 I: IntoIterator<Item = St>,
5897 St: AsRef<str>,
5898 {
5899 self._scopes
5900 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5901 self
5902 }
5903
5904 /// Removes all scopes, and no default scope will be used either.
5905 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5906 /// for details).
5907 pub fn clear_scopes(mut self) -> CourseAliasListCall<'a, C> {
5908 self._scopes.clear();
5909 self
5910 }
5911}
5912
5913/// Creates an add-on attachment under a post. Requires the add-on to have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
5914///
5915/// A builder for the *announcements.addOnAttachments.create* method supported by a *course* resource.
5916/// It is not used directly, but through a [`CourseMethods`] instance.
5917///
5918/// # Example
5919///
5920/// Instantiate a resource method builder
5921///
5922/// ```test_harness,no_run
5923/// # extern crate hyper;
5924/// # extern crate hyper_rustls;
5925/// # extern crate google_classroom1 as classroom1;
5926/// use classroom1::api::AddOnAttachment;
5927/// # async fn dox() {
5928/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5929///
5930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5931/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5932/// # .with_native_roots()
5933/// # .unwrap()
5934/// # .https_only()
5935/// # .enable_http2()
5936/// # .build();
5937///
5938/// # let executor = hyper_util::rt::TokioExecutor::new();
5939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5940/// # secret,
5941/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5942/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5943/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5944/// # ),
5945/// # ).build().await.unwrap();
5946///
5947/// # let client = hyper_util::client::legacy::Client::builder(
5948/// # hyper_util::rt::TokioExecutor::new()
5949/// # )
5950/// # .build(
5951/// # hyper_rustls::HttpsConnectorBuilder::new()
5952/// # .with_native_roots()
5953/// # .unwrap()
5954/// # .https_or_http()
5955/// # .enable_http2()
5956/// # .build()
5957/// # );
5958/// # let mut hub = Classroom::new(client, auth);
5959/// // As the method needs a request, you would usually fill it with the desired information
5960/// // into the respective structure. Some of the parts shown here might not be applicable !
5961/// // Values shown here are possibly random and not representative !
5962/// let mut req = AddOnAttachment::default();
5963///
5964/// // You can configure optional parameters by calling the respective setters at will, and
5965/// // execute the final call using `doit()`.
5966/// // Values shown here are possibly random and not representative !
5967/// let result = hub.courses().announcements_add_on_attachments_create(req, "courseId", "itemId")
5968/// .post_id("ipsum")
5969/// .add_on_token("sed")
5970/// .doit().await;
5971/// # }
5972/// ```
5973pub struct CourseAnnouncementAddOnAttachmentCreateCall<'a, C>
5974where
5975 C: 'a,
5976{
5977 hub: &'a Classroom<C>,
5978 _request: AddOnAttachment,
5979 _course_id: String,
5980 _item_id: String,
5981 _post_id: Option<String>,
5982 _add_on_token: Option<String>,
5983 _delegate: Option<&'a mut dyn common::Delegate>,
5984 _additional_params: HashMap<String, String>,
5985 _scopes: BTreeSet<String>,
5986}
5987
5988impl<'a, C> common::CallBuilder for CourseAnnouncementAddOnAttachmentCreateCall<'a, C> {}
5989
5990impl<'a, C> CourseAnnouncementAddOnAttachmentCreateCall<'a, C>
5991where
5992 C: common::Connector,
5993{
5994 /// Perform the operation you have build so far.
5995 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
5996 use std::borrow::Cow;
5997 use std::io::{Read, Seek};
5998
5999 use common::{url::Params, ToParts};
6000 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6001
6002 let mut dd = common::DefaultDelegate;
6003 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6004 dlg.begin(common::MethodInfo {
6005 id: "classroom.courses.announcements.addOnAttachments.create",
6006 http_method: hyper::Method::POST,
6007 });
6008
6009 for &field in ["alt", "courseId", "itemId", "postId", "addOnToken"].iter() {
6010 if self._additional_params.contains_key(field) {
6011 dlg.finished(false);
6012 return Err(common::Error::FieldClash(field));
6013 }
6014 }
6015
6016 let mut params = Params::with_capacity(7 + self._additional_params.len());
6017 params.push("courseId", self._course_id);
6018 params.push("itemId", self._item_id);
6019 if let Some(value) = self._post_id.as_ref() {
6020 params.push("postId", value);
6021 }
6022 if let Some(value) = self._add_on_token.as_ref() {
6023 params.push("addOnToken", value);
6024 }
6025
6026 params.extend(self._additional_params.iter());
6027
6028 params.push("alt", "json");
6029 let mut url = self.hub._base_url.clone()
6030 + "v1/courses/{courseId}/announcements/{itemId}/addOnAttachments";
6031 if self._scopes.is_empty() {
6032 self._scopes
6033 .insert(Scope::AddonTeacher.as_ref().to_string());
6034 }
6035
6036 #[allow(clippy::single_element_loop)]
6037 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{itemId}", "itemId")].iter()
6038 {
6039 url = params.uri_replacement(url, param_name, find_this, false);
6040 }
6041 {
6042 let to_remove = ["itemId", "courseId"];
6043 params.remove_params(&to_remove);
6044 }
6045
6046 let url = params.parse_with_url(&url);
6047
6048 let mut json_mime_type = mime::APPLICATION_JSON;
6049 let mut request_value_reader = {
6050 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6051 common::remove_json_null_values(&mut value);
6052 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6053 serde_json::to_writer(&mut dst, &value).unwrap();
6054 dst
6055 };
6056 let request_size = request_value_reader
6057 .seek(std::io::SeekFrom::End(0))
6058 .unwrap();
6059 request_value_reader
6060 .seek(std::io::SeekFrom::Start(0))
6061 .unwrap();
6062
6063 loop {
6064 let token = match self
6065 .hub
6066 .auth
6067 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6068 .await
6069 {
6070 Ok(token) => token,
6071 Err(e) => match dlg.token(e) {
6072 Ok(token) => token,
6073 Err(e) => {
6074 dlg.finished(false);
6075 return Err(common::Error::MissingToken(e));
6076 }
6077 },
6078 };
6079 request_value_reader
6080 .seek(std::io::SeekFrom::Start(0))
6081 .unwrap();
6082 let mut req_result = {
6083 let client = &self.hub.client;
6084 dlg.pre_request();
6085 let mut req_builder = hyper::Request::builder()
6086 .method(hyper::Method::POST)
6087 .uri(url.as_str())
6088 .header(USER_AGENT, self.hub._user_agent.clone());
6089
6090 if let Some(token) = token.as_ref() {
6091 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6092 }
6093
6094 let request = req_builder
6095 .header(CONTENT_TYPE, json_mime_type.to_string())
6096 .header(CONTENT_LENGTH, request_size as u64)
6097 .body(common::to_body(
6098 request_value_reader.get_ref().clone().into(),
6099 ));
6100
6101 client.request(request.unwrap()).await
6102 };
6103
6104 match req_result {
6105 Err(err) => {
6106 if let common::Retry::After(d) = dlg.http_error(&err) {
6107 sleep(d).await;
6108 continue;
6109 }
6110 dlg.finished(false);
6111 return Err(common::Error::HttpError(err));
6112 }
6113 Ok(res) => {
6114 let (mut parts, body) = res.into_parts();
6115 let mut body = common::Body::new(body);
6116 if !parts.status.is_success() {
6117 let bytes = common::to_bytes(body).await.unwrap_or_default();
6118 let error = serde_json::from_str(&common::to_string(&bytes));
6119 let response = common::to_response(parts, bytes.into());
6120
6121 if let common::Retry::After(d) =
6122 dlg.http_failure(&response, error.as_ref().ok())
6123 {
6124 sleep(d).await;
6125 continue;
6126 }
6127
6128 dlg.finished(false);
6129
6130 return Err(match error {
6131 Ok(value) => common::Error::BadRequest(value),
6132 _ => common::Error::Failure(response),
6133 });
6134 }
6135 let response = {
6136 let bytes = common::to_bytes(body).await.unwrap_or_default();
6137 let encoded = common::to_string(&bytes);
6138 match serde_json::from_str(&encoded) {
6139 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6140 Err(error) => {
6141 dlg.response_json_decode_error(&encoded, &error);
6142 return Err(common::Error::JsonDecodeError(
6143 encoded.to_string(),
6144 error,
6145 ));
6146 }
6147 }
6148 };
6149
6150 dlg.finished(true);
6151 return Ok(response);
6152 }
6153 }
6154 }
6155 }
6156
6157 ///
6158 /// Sets the *request* property to the given value.
6159 ///
6160 /// Even though the property as already been set when instantiating this call,
6161 /// we provide this method for API completeness.
6162 pub fn request(
6163 mut self,
6164 new_value: AddOnAttachment,
6165 ) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C> {
6166 self._request = new_value;
6167 self
6168 }
6169 /// Required. Identifier of the course.
6170 ///
6171 /// Sets the *course id* path property to the given value.
6172 ///
6173 /// Even though the property as already been set when instantiating this call,
6174 /// we provide this method for API completeness.
6175 pub fn course_id(
6176 mut self,
6177 new_value: &str,
6178 ) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C> {
6179 self._course_id = new_value.to_string();
6180 self
6181 }
6182 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which to create the attachment. This field is required, but is not marked as such while we are migrating from post_id.
6183 ///
6184 /// Sets the *item id* path property to the given value.
6185 ///
6186 /// Even though the property as already been set when instantiating this call,
6187 /// we provide this method for API completeness.
6188 pub fn item_id(
6189 mut self,
6190 new_value: &str,
6191 ) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C> {
6192 self._item_id = new_value.to_string();
6193 self
6194 }
6195 /// Optional. Deprecated, use `item_id` instead.
6196 ///
6197 /// Sets the *post id* query property to the given value.
6198 pub fn post_id(
6199 mut self,
6200 new_value: &str,
6201 ) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C> {
6202 self._post_id = Some(new_value.to_string());
6203 self
6204 }
6205 /// Optional. Token that authorizes the request. The token is passed as a query parameter when the user is redirected from Classroom to the add-on's URL. This authorization token is required for in-Classroom attachment creation but optional for partner-first attachment creation. Returns an error if not provided for partner-first attachment creation and the developer projects that created the attachment and its parent stream item do not match.
6206 ///
6207 /// Sets the *add on token* query property to the given value.
6208 pub fn add_on_token(
6209 mut self,
6210 new_value: &str,
6211 ) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C> {
6212 self._add_on_token = Some(new_value.to_string());
6213 self
6214 }
6215 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6216 /// while executing the actual API request.
6217 ///
6218 /// ````text
6219 /// It should be used to handle progress information, and to implement a certain level of resilience.
6220 /// ````
6221 ///
6222 /// Sets the *delegate* property to the given value.
6223 pub fn delegate(
6224 mut self,
6225 new_value: &'a mut dyn common::Delegate,
6226 ) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C> {
6227 self._delegate = Some(new_value);
6228 self
6229 }
6230
6231 /// Set any additional parameter of the query string used in the request.
6232 /// It should be used to set parameters which are not yet available through their own
6233 /// setters.
6234 ///
6235 /// Please note that this method must not be used to set any of the known parameters
6236 /// which have their own setter method. If done anyway, the request will fail.
6237 ///
6238 /// # Additional Parameters
6239 ///
6240 /// * *$.xgafv* (query-string) - V1 error format.
6241 /// * *access_token* (query-string) - OAuth access token.
6242 /// * *alt* (query-string) - Data format for response.
6243 /// * *callback* (query-string) - JSONP
6244 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6245 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6246 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6247 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6248 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6249 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6250 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6251 pub fn param<T>(
6252 mut self,
6253 name: T,
6254 value: T,
6255 ) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C>
6256 where
6257 T: AsRef<str>,
6258 {
6259 self._additional_params
6260 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6261 self
6262 }
6263
6264 /// Identifies the authorization scope for the method you are building.
6265 ///
6266 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6267 /// [`Scope::AddonTeacher`].
6268 ///
6269 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6270 /// tokens for more than one scope.
6271 ///
6272 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6273 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6274 /// sufficient, a read-write scope will do as well.
6275 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C>
6276 where
6277 St: AsRef<str>,
6278 {
6279 self._scopes.insert(String::from(scope.as_ref()));
6280 self
6281 }
6282 /// Identifies the authorization scope(s) for the method you are building.
6283 ///
6284 /// See [`Self::add_scope()`] for details.
6285 pub fn add_scopes<I, St>(
6286 mut self,
6287 scopes: I,
6288 ) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C>
6289 where
6290 I: IntoIterator<Item = St>,
6291 St: AsRef<str>,
6292 {
6293 self._scopes
6294 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6295 self
6296 }
6297
6298 /// Removes all scopes, and no default scope will be used either.
6299 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6300 /// for details).
6301 pub fn clear_scopes(mut self) -> CourseAnnouncementAddOnAttachmentCreateCall<'a, C> {
6302 self._scopes.clear();
6303 self
6304 }
6305}
6306
6307/// Deletes an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
6308///
6309/// A builder for the *announcements.addOnAttachments.delete* method supported by a *course* resource.
6310/// It is not used directly, but through a [`CourseMethods`] instance.
6311///
6312/// # Example
6313///
6314/// Instantiate a resource method builder
6315///
6316/// ```test_harness,no_run
6317/// # extern crate hyper;
6318/// # extern crate hyper_rustls;
6319/// # extern crate google_classroom1 as classroom1;
6320/// # async fn dox() {
6321/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6322///
6323/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6324/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6325/// # .with_native_roots()
6326/// # .unwrap()
6327/// # .https_only()
6328/// # .enable_http2()
6329/// # .build();
6330///
6331/// # let executor = hyper_util::rt::TokioExecutor::new();
6332/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6333/// # secret,
6334/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6335/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6336/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6337/// # ),
6338/// # ).build().await.unwrap();
6339///
6340/// # let client = hyper_util::client::legacy::Client::builder(
6341/// # hyper_util::rt::TokioExecutor::new()
6342/// # )
6343/// # .build(
6344/// # hyper_rustls::HttpsConnectorBuilder::new()
6345/// # .with_native_roots()
6346/// # .unwrap()
6347/// # .https_or_http()
6348/// # .enable_http2()
6349/// # .build()
6350/// # );
6351/// # let mut hub = Classroom::new(client, auth);
6352/// // You can configure optional parameters by calling the respective setters at will, and
6353/// // execute the final call using `doit()`.
6354/// // Values shown here are possibly random and not representative !
6355/// let result = hub.courses().announcements_add_on_attachments_delete("courseId", "itemId", "attachmentId")
6356/// .post_id("est")
6357/// .doit().await;
6358/// # }
6359/// ```
6360pub struct CourseAnnouncementAddOnAttachmentDeleteCall<'a, C>
6361where
6362 C: 'a,
6363{
6364 hub: &'a Classroom<C>,
6365 _course_id: String,
6366 _item_id: String,
6367 _attachment_id: String,
6368 _post_id: Option<String>,
6369 _delegate: Option<&'a mut dyn common::Delegate>,
6370 _additional_params: HashMap<String, String>,
6371 _scopes: BTreeSet<String>,
6372}
6373
6374impl<'a, C> common::CallBuilder for CourseAnnouncementAddOnAttachmentDeleteCall<'a, C> {}
6375
6376impl<'a, C> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C>
6377where
6378 C: common::Connector,
6379{
6380 /// Perform the operation you have build so far.
6381 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
6382 use std::borrow::Cow;
6383 use std::io::{Read, Seek};
6384
6385 use common::{url::Params, ToParts};
6386 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6387
6388 let mut dd = common::DefaultDelegate;
6389 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6390 dlg.begin(common::MethodInfo {
6391 id: "classroom.courses.announcements.addOnAttachments.delete",
6392 http_method: hyper::Method::DELETE,
6393 });
6394
6395 for &field in ["alt", "courseId", "itemId", "attachmentId", "postId"].iter() {
6396 if self._additional_params.contains_key(field) {
6397 dlg.finished(false);
6398 return Err(common::Error::FieldClash(field));
6399 }
6400 }
6401
6402 let mut params = Params::with_capacity(6 + self._additional_params.len());
6403 params.push("courseId", self._course_id);
6404 params.push("itemId", self._item_id);
6405 params.push("attachmentId", self._attachment_id);
6406 if let Some(value) = self._post_id.as_ref() {
6407 params.push("postId", value);
6408 }
6409
6410 params.extend(self._additional_params.iter());
6411
6412 params.push("alt", "json");
6413 let mut url = self.hub._base_url.clone()
6414 + "v1/courses/{courseId}/announcements/{itemId}/addOnAttachments/{attachmentId}";
6415 if self._scopes.is_empty() {
6416 self._scopes
6417 .insert(Scope::AddonTeacher.as_ref().to_string());
6418 }
6419
6420 #[allow(clippy::single_element_loop)]
6421 for &(find_this, param_name) in [
6422 ("{courseId}", "courseId"),
6423 ("{itemId}", "itemId"),
6424 ("{attachmentId}", "attachmentId"),
6425 ]
6426 .iter()
6427 {
6428 url = params.uri_replacement(url, param_name, find_this, false);
6429 }
6430 {
6431 let to_remove = ["attachmentId", "itemId", "courseId"];
6432 params.remove_params(&to_remove);
6433 }
6434
6435 let url = params.parse_with_url(&url);
6436
6437 loop {
6438 let token = match self
6439 .hub
6440 .auth
6441 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6442 .await
6443 {
6444 Ok(token) => token,
6445 Err(e) => match dlg.token(e) {
6446 Ok(token) => token,
6447 Err(e) => {
6448 dlg.finished(false);
6449 return Err(common::Error::MissingToken(e));
6450 }
6451 },
6452 };
6453 let mut req_result = {
6454 let client = &self.hub.client;
6455 dlg.pre_request();
6456 let mut req_builder = hyper::Request::builder()
6457 .method(hyper::Method::DELETE)
6458 .uri(url.as_str())
6459 .header(USER_AGENT, self.hub._user_agent.clone());
6460
6461 if let Some(token) = token.as_ref() {
6462 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6463 }
6464
6465 let request = req_builder
6466 .header(CONTENT_LENGTH, 0_u64)
6467 .body(common::to_body::<String>(None));
6468
6469 client.request(request.unwrap()).await
6470 };
6471
6472 match req_result {
6473 Err(err) => {
6474 if let common::Retry::After(d) = dlg.http_error(&err) {
6475 sleep(d).await;
6476 continue;
6477 }
6478 dlg.finished(false);
6479 return Err(common::Error::HttpError(err));
6480 }
6481 Ok(res) => {
6482 let (mut parts, body) = res.into_parts();
6483 let mut body = common::Body::new(body);
6484 if !parts.status.is_success() {
6485 let bytes = common::to_bytes(body).await.unwrap_or_default();
6486 let error = serde_json::from_str(&common::to_string(&bytes));
6487 let response = common::to_response(parts, bytes.into());
6488
6489 if let common::Retry::After(d) =
6490 dlg.http_failure(&response, error.as_ref().ok())
6491 {
6492 sleep(d).await;
6493 continue;
6494 }
6495
6496 dlg.finished(false);
6497
6498 return Err(match error {
6499 Ok(value) => common::Error::BadRequest(value),
6500 _ => common::Error::Failure(response),
6501 });
6502 }
6503 let response = {
6504 let bytes = common::to_bytes(body).await.unwrap_or_default();
6505 let encoded = common::to_string(&bytes);
6506 match serde_json::from_str(&encoded) {
6507 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6508 Err(error) => {
6509 dlg.response_json_decode_error(&encoded, &error);
6510 return Err(common::Error::JsonDecodeError(
6511 encoded.to_string(),
6512 error,
6513 ));
6514 }
6515 }
6516 };
6517
6518 dlg.finished(true);
6519 return Ok(response);
6520 }
6521 }
6522 }
6523 }
6524
6525 /// Required. Identifier of the course.
6526 ///
6527 /// Sets the *course id* path property to the given value.
6528 ///
6529 /// Even though the property as already been set when instantiating this call,
6530 /// we provide this method for API completeness.
6531 pub fn course_id(
6532 mut self,
6533 new_value: &str,
6534 ) -> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C> {
6535 self._course_id = new_value.to_string();
6536 self
6537 }
6538 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
6539 ///
6540 /// Sets the *item id* path property to the given value.
6541 ///
6542 /// Even though the property as already been set when instantiating this call,
6543 /// we provide this method for API completeness.
6544 pub fn item_id(
6545 mut self,
6546 new_value: &str,
6547 ) -> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C> {
6548 self._item_id = new_value.to_string();
6549 self
6550 }
6551 /// Required. Identifier of the attachment.
6552 ///
6553 /// Sets the *attachment id* path property to the given value.
6554 ///
6555 /// Even though the property as already been set when instantiating this call,
6556 /// we provide this method for API completeness.
6557 pub fn attachment_id(
6558 mut self,
6559 new_value: &str,
6560 ) -> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C> {
6561 self._attachment_id = new_value.to_string();
6562 self
6563 }
6564 /// Optional. Deprecated, use `item_id` instead.
6565 ///
6566 /// Sets the *post id* query property to the given value.
6567 pub fn post_id(
6568 mut self,
6569 new_value: &str,
6570 ) -> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C> {
6571 self._post_id = Some(new_value.to_string());
6572 self
6573 }
6574 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6575 /// while executing the actual API request.
6576 ///
6577 /// ````text
6578 /// It should be used to handle progress information, and to implement a certain level of resilience.
6579 /// ````
6580 ///
6581 /// Sets the *delegate* property to the given value.
6582 pub fn delegate(
6583 mut self,
6584 new_value: &'a mut dyn common::Delegate,
6585 ) -> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C> {
6586 self._delegate = Some(new_value);
6587 self
6588 }
6589
6590 /// Set any additional parameter of the query string used in the request.
6591 /// It should be used to set parameters which are not yet available through their own
6592 /// setters.
6593 ///
6594 /// Please note that this method must not be used to set any of the known parameters
6595 /// which have their own setter method. If done anyway, the request will fail.
6596 ///
6597 /// # Additional Parameters
6598 ///
6599 /// * *$.xgafv* (query-string) - V1 error format.
6600 /// * *access_token* (query-string) - OAuth access token.
6601 /// * *alt* (query-string) - Data format for response.
6602 /// * *callback* (query-string) - JSONP
6603 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6604 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6605 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6606 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6607 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6608 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6609 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6610 pub fn param<T>(
6611 mut self,
6612 name: T,
6613 value: T,
6614 ) -> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C>
6615 where
6616 T: AsRef<str>,
6617 {
6618 self._additional_params
6619 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6620 self
6621 }
6622
6623 /// Identifies the authorization scope for the method you are building.
6624 ///
6625 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6626 /// [`Scope::AddonTeacher`].
6627 ///
6628 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6629 /// tokens for more than one scope.
6630 ///
6631 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6632 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6633 /// sufficient, a read-write scope will do as well.
6634 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C>
6635 where
6636 St: AsRef<str>,
6637 {
6638 self._scopes.insert(String::from(scope.as_ref()));
6639 self
6640 }
6641 /// Identifies the authorization scope(s) for the method you are building.
6642 ///
6643 /// See [`Self::add_scope()`] for details.
6644 pub fn add_scopes<I, St>(
6645 mut self,
6646 scopes: I,
6647 ) -> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C>
6648 where
6649 I: IntoIterator<Item = St>,
6650 St: AsRef<str>,
6651 {
6652 self._scopes
6653 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6654 self
6655 }
6656
6657 /// Removes all scopes, and no default scope will be used either.
6658 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6659 /// for details).
6660 pub fn clear_scopes(mut self) -> CourseAnnouncementAddOnAttachmentDeleteCall<'a, C> {
6661 self._scopes.clear();
6662 self
6663 }
6664}
6665
6666/// Returns an add-on attachment. Requires the add-on requesting the attachment to be the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
6667///
6668/// A builder for the *announcements.addOnAttachments.get* method supported by a *course* resource.
6669/// It is not used directly, but through a [`CourseMethods`] instance.
6670///
6671/// # Example
6672///
6673/// Instantiate a resource method builder
6674///
6675/// ```test_harness,no_run
6676/// # extern crate hyper;
6677/// # extern crate hyper_rustls;
6678/// # extern crate google_classroom1 as classroom1;
6679/// # async fn dox() {
6680/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6681///
6682/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6683/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6684/// # .with_native_roots()
6685/// # .unwrap()
6686/// # .https_only()
6687/// # .enable_http2()
6688/// # .build();
6689///
6690/// # let executor = hyper_util::rt::TokioExecutor::new();
6691/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6692/// # secret,
6693/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6694/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6695/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6696/// # ),
6697/// # ).build().await.unwrap();
6698///
6699/// # let client = hyper_util::client::legacy::Client::builder(
6700/// # hyper_util::rt::TokioExecutor::new()
6701/// # )
6702/// # .build(
6703/// # hyper_rustls::HttpsConnectorBuilder::new()
6704/// # .with_native_roots()
6705/// # .unwrap()
6706/// # .https_or_http()
6707/// # .enable_http2()
6708/// # .build()
6709/// # );
6710/// # let mut hub = Classroom::new(client, auth);
6711/// // You can configure optional parameters by calling the respective setters at will, and
6712/// // execute the final call using `doit()`.
6713/// // Values shown here are possibly random and not representative !
6714/// let result = hub.courses().announcements_add_on_attachments_get("courseId", "itemId", "attachmentId")
6715/// .post_id("gubergren")
6716/// .doit().await;
6717/// # }
6718/// ```
6719pub struct CourseAnnouncementAddOnAttachmentGetCall<'a, C>
6720where
6721 C: 'a,
6722{
6723 hub: &'a Classroom<C>,
6724 _course_id: String,
6725 _item_id: String,
6726 _attachment_id: String,
6727 _post_id: Option<String>,
6728 _delegate: Option<&'a mut dyn common::Delegate>,
6729 _additional_params: HashMap<String, String>,
6730 _scopes: BTreeSet<String>,
6731}
6732
6733impl<'a, C> common::CallBuilder for CourseAnnouncementAddOnAttachmentGetCall<'a, C> {}
6734
6735impl<'a, C> CourseAnnouncementAddOnAttachmentGetCall<'a, C>
6736where
6737 C: common::Connector,
6738{
6739 /// Perform the operation you have build so far.
6740 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
6741 use std::borrow::Cow;
6742 use std::io::{Read, Seek};
6743
6744 use common::{url::Params, ToParts};
6745 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6746
6747 let mut dd = common::DefaultDelegate;
6748 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6749 dlg.begin(common::MethodInfo {
6750 id: "classroom.courses.announcements.addOnAttachments.get",
6751 http_method: hyper::Method::GET,
6752 });
6753
6754 for &field in ["alt", "courseId", "itemId", "attachmentId", "postId"].iter() {
6755 if self._additional_params.contains_key(field) {
6756 dlg.finished(false);
6757 return Err(common::Error::FieldClash(field));
6758 }
6759 }
6760
6761 let mut params = Params::with_capacity(6 + self._additional_params.len());
6762 params.push("courseId", self._course_id);
6763 params.push("itemId", self._item_id);
6764 params.push("attachmentId", self._attachment_id);
6765 if let Some(value) = self._post_id.as_ref() {
6766 params.push("postId", value);
6767 }
6768
6769 params.extend(self._additional_params.iter());
6770
6771 params.push("alt", "json");
6772 let mut url = self.hub._base_url.clone()
6773 + "v1/courses/{courseId}/announcements/{itemId}/addOnAttachments/{attachmentId}";
6774 if self._scopes.is_empty() {
6775 self._scopes
6776 .insert(Scope::AddonStudent.as_ref().to_string());
6777 }
6778
6779 #[allow(clippy::single_element_loop)]
6780 for &(find_this, param_name) in [
6781 ("{courseId}", "courseId"),
6782 ("{itemId}", "itemId"),
6783 ("{attachmentId}", "attachmentId"),
6784 ]
6785 .iter()
6786 {
6787 url = params.uri_replacement(url, param_name, find_this, false);
6788 }
6789 {
6790 let to_remove = ["attachmentId", "itemId", "courseId"];
6791 params.remove_params(&to_remove);
6792 }
6793
6794 let url = params.parse_with_url(&url);
6795
6796 loop {
6797 let token = match self
6798 .hub
6799 .auth
6800 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6801 .await
6802 {
6803 Ok(token) => token,
6804 Err(e) => match dlg.token(e) {
6805 Ok(token) => token,
6806 Err(e) => {
6807 dlg.finished(false);
6808 return Err(common::Error::MissingToken(e));
6809 }
6810 },
6811 };
6812 let mut req_result = {
6813 let client = &self.hub.client;
6814 dlg.pre_request();
6815 let mut req_builder = hyper::Request::builder()
6816 .method(hyper::Method::GET)
6817 .uri(url.as_str())
6818 .header(USER_AGENT, self.hub._user_agent.clone());
6819
6820 if let Some(token) = token.as_ref() {
6821 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6822 }
6823
6824 let request = req_builder
6825 .header(CONTENT_LENGTH, 0_u64)
6826 .body(common::to_body::<String>(None));
6827
6828 client.request(request.unwrap()).await
6829 };
6830
6831 match req_result {
6832 Err(err) => {
6833 if let common::Retry::After(d) = dlg.http_error(&err) {
6834 sleep(d).await;
6835 continue;
6836 }
6837 dlg.finished(false);
6838 return Err(common::Error::HttpError(err));
6839 }
6840 Ok(res) => {
6841 let (mut parts, body) = res.into_parts();
6842 let mut body = common::Body::new(body);
6843 if !parts.status.is_success() {
6844 let bytes = common::to_bytes(body).await.unwrap_or_default();
6845 let error = serde_json::from_str(&common::to_string(&bytes));
6846 let response = common::to_response(parts, bytes.into());
6847
6848 if let common::Retry::After(d) =
6849 dlg.http_failure(&response, error.as_ref().ok())
6850 {
6851 sleep(d).await;
6852 continue;
6853 }
6854
6855 dlg.finished(false);
6856
6857 return Err(match error {
6858 Ok(value) => common::Error::BadRequest(value),
6859 _ => common::Error::Failure(response),
6860 });
6861 }
6862 let response = {
6863 let bytes = common::to_bytes(body).await.unwrap_or_default();
6864 let encoded = common::to_string(&bytes);
6865 match serde_json::from_str(&encoded) {
6866 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6867 Err(error) => {
6868 dlg.response_json_decode_error(&encoded, &error);
6869 return Err(common::Error::JsonDecodeError(
6870 encoded.to_string(),
6871 error,
6872 ));
6873 }
6874 }
6875 };
6876
6877 dlg.finished(true);
6878 return Ok(response);
6879 }
6880 }
6881 }
6882 }
6883
6884 /// Required. Identifier of the course.
6885 ///
6886 /// Sets the *course id* path property to the given value.
6887 ///
6888 /// Even though the property as already been set when instantiating this call,
6889 /// we provide this method for API completeness.
6890 pub fn course_id(mut self, new_value: &str) -> CourseAnnouncementAddOnAttachmentGetCall<'a, C> {
6891 self._course_id = new_value.to_string();
6892 self
6893 }
6894 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
6895 ///
6896 /// Sets the *item id* path property to the given value.
6897 ///
6898 /// Even though the property as already been set when instantiating this call,
6899 /// we provide this method for API completeness.
6900 pub fn item_id(mut self, new_value: &str) -> CourseAnnouncementAddOnAttachmentGetCall<'a, C> {
6901 self._item_id = new_value.to_string();
6902 self
6903 }
6904 /// Required. Identifier of the attachment.
6905 ///
6906 /// Sets the *attachment id* path property to the given value.
6907 ///
6908 /// Even though the property as already been set when instantiating this call,
6909 /// we provide this method for API completeness.
6910 pub fn attachment_id(
6911 mut self,
6912 new_value: &str,
6913 ) -> CourseAnnouncementAddOnAttachmentGetCall<'a, C> {
6914 self._attachment_id = new_value.to_string();
6915 self
6916 }
6917 /// Optional. Deprecated, use `item_id` instead.
6918 ///
6919 /// Sets the *post id* query property to the given value.
6920 pub fn post_id(mut self, new_value: &str) -> CourseAnnouncementAddOnAttachmentGetCall<'a, C> {
6921 self._post_id = Some(new_value.to_string());
6922 self
6923 }
6924 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6925 /// while executing the actual API request.
6926 ///
6927 /// ````text
6928 /// It should be used to handle progress information, and to implement a certain level of resilience.
6929 /// ````
6930 ///
6931 /// Sets the *delegate* property to the given value.
6932 pub fn delegate(
6933 mut self,
6934 new_value: &'a mut dyn common::Delegate,
6935 ) -> CourseAnnouncementAddOnAttachmentGetCall<'a, C> {
6936 self._delegate = Some(new_value);
6937 self
6938 }
6939
6940 /// Set any additional parameter of the query string used in the request.
6941 /// It should be used to set parameters which are not yet available through their own
6942 /// setters.
6943 ///
6944 /// Please note that this method must not be used to set any of the known parameters
6945 /// which have their own setter method. If done anyway, the request will fail.
6946 ///
6947 /// # Additional Parameters
6948 ///
6949 /// * *$.xgafv* (query-string) - V1 error format.
6950 /// * *access_token* (query-string) - OAuth access token.
6951 /// * *alt* (query-string) - Data format for response.
6952 /// * *callback* (query-string) - JSONP
6953 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6954 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6955 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6956 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6957 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6958 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6959 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6960 pub fn param<T>(mut self, name: T, value: T) -> CourseAnnouncementAddOnAttachmentGetCall<'a, C>
6961 where
6962 T: AsRef<str>,
6963 {
6964 self._additional_params
6965 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6966 self
6967 }
6968
6969 /// Identifies the authorization scope for the method you are building.
6970 ///
6971 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6972 /// [`Scope::AddonStudent`].
6973 ///
6974 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6975 /// tokens for more than one scope.
6976 ///
6977 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6978 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6979 /// sufficient, a read-write scope will do as well.
6980 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementAddOnAttachmentGetCall<'a, C>
6981 where
6982 St: AsRef<str>,
6983 {
6984 self._scopes.insert(String::from(scope.as_ref()));
6985 self
6986 }
6987 /// Identifies the authorization scope(s) for the method you are building.
6988 ///
6989 /// See [`Self::add_scope()`] for details.
6990 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAnnouncementAddOnAttachmentGetCall<'a, C>
6991 where
6992 I: IntoIterator<Item = St>,
6993 St: AsRef<str>,
6994 {
6995 self._scopes
6996 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6997 self
6998 }
6999
7000 /// Removes all scopes, and no default scope will be used either.
7001 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7002 /// for details).
7003 pub fn clear_scopes(mut self) -> CourseAnnouncementAddOnAttachmentGetCall<'a, C> {
7004 self._scopes.clear();
7005 self
7006 }
7007}
7008
7009/// Returns all attachments created by an add-on under the post. Requires the add-on to have active attachments on the post or have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
7010///
7011/// A builder for the *announcements.addOnAttachments.list* method supported by a *course* resource.
7012/// It is not used directly, but through a [`CourseMethods`] instance.
7013///
7014/// # Example
7015///
7016/// Instantiate a resource method builder
7017///
7018/// ```test_harness,no_run
7019/// # extern crate hyper;
7020/// # extern crate hyper_rustls;
7021/// # extern crate google_classroom1 as classroom1;
7022/// # async fn dox() {
7023/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7024///
7025/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7026/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7027/// # .with_native_roots()
7028/// # .unwrap()
7029/// # .https_only()
7030/// # .enable_http2()
7031/// # .build();
7032///
7033/// # let executor = hyper_util::rt::TokioExecutor::new();
7034/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7035/// # secret,
7036/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7037/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7038/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7039/// # ),
7040/// # ).build().await.unwrap();
7041///
7042/// # let client = hyper_util::client::legacy::Client::builder(
7043/// # hyper_util::rt::TokioExecutor::new()
7044/// # )
7045/// # .build(
7046/// # hyper_rustls::HttpsConnectorBuilder::new()
7047/// # .with_native_roots()
7048/// # .unwrap()
7049/// # .https_or_http()
7050/// # .enable_http2()
7051/// # .build()
7052/// # );
7053/// # let mut hub = Classroom::new(client, auth);
7054/// // You can configure optional parameters by calling the respective setters at will, and
7055/// // execute the final call using `doit()`.
7056/// // Values shown here are possibly random and not representative !
7057/// let result = hub.courses().announcements_add_on_attachments_list("courseId", "itemId")
7058/// .post_id("Lorem")
7059/// .page_token("eos")
7060/// .page_size(-86)
7061/// .doit().await;
7062/// # }
7063/// ```
7064pub struct CourseAnnouncementAddOnAttachmentListCall<'a, C>
7065where
7066 C: 'a,
7067{
7068 hub: &'a Classroom<C>,
7069 _course_id: String,
7070 _item_id: String,
7071 _post_id: Option<String>,
7072 _page_token: Option<String>,
7073 _page_size: Option<i32>,
7074 _delegate: Option<&'a mut dyn common::Delegate>,
7075 _additional_params: HashMap<String, String>,
7076 _scopes: BTreeSet<String>,
7077}
7078
7079impl<'a, C> common::CallBuilder for CourseAnnouncementAddOnAttachmentListCall<'a, C> {}
7080
7081impl<'a, C> CourseAnnouncementAddOnAttachmentListCall<'a, C>
7082where
7083 C: common::Connector,
7084{
7085 /// Perform the operation you have build so far.
7086 pub async fn doit(
7087 mut self,
7088 ) -> common::Result<(common::Response, ListAddOnAttachmentsResponse)> {
7089 use std::borrow::Cow;
7090 use std::io::{Read, Seek};
7091
7092 use common::{url::Params, ToParts};
7093 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7094
7095 let mut dd = common::DefaultDelegate;
7096 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7097 dlg.begin(common::MethodInfo {
7098 id: "classroom.courses.announcements.addOnAttachments.list",
7099 http_method: hyper::Method::GET,
7100 });
7101
7102 for &field in [
7103 "alt",
7104 "courseId",
7105 "itemId",
7106 "postId",
7107 "pageToken",
7108 "pageSize",
7109 ]
7110 .iter()
7111 {
7112 if self._additional_params.contains_key(field) {
7113 dlg.finished(false);
7114 return Err(common::Error::FieldClash(field));
7115 }
7116 }
7117
7118 let mut params = Params::with_capacity(7 + self._additional_params.len());
7119 params.push("courseId", self._course_id);
7120 params.push("itemId", self._item_id);
7121 if let Some(value) = self._post_id.as_ref() {
7122 params.push("postId", value);
7123 }
7124 if let Some(value) = self._page_token.as_ref() {
7125 params.push("pageToken", value);
7126 }
7127 if let Some(value) = self._page_size.as_ref() {
7128 params.push("pageSize", value.to_string());
7129 }
7130
7131 params.extend(self._additional_params.iter());
7132
7133 params.push("alt", "json");
7134 let mut url = self.hub._base_url.clone()
7135 + "v1/courses/{courseId}/announcements/{itemId}/addOnAttachments";
7136 if self._scopes.is_empty() {
7137 self._scopes
7138 .insert(Scope::AddonStudent.as_ref().to_string());
7139 }
7140
7141 #[allow(clippy::single_element_loop)]
7142 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{itemId}", "itemId")].iter()
7143 {
7144 url = params.uri_replacement(url, param_name, find_this, false);
7145 }
7146 {
7147 let to_remove = ["itemId", "courseId"];
7148 params.remove_params(&to_remove);
7149 }
7150
7151 let url = params.parse_with_url(&url);
7152
7153 loop {
7154 let token = match self
7155 .hub
7156 .auth
7157 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7158 .await
7159 {
7160 Ok(token) => token,
7161 Err(e) => match dlg.token(e) {
7162 Ok(token) => token,
7163 Err(e) => {
7164 dlg.finished(false);
7165 return Err(common::Error::MissingToken(e));
7166 }
7167 },
7168 };
7169 let mut req_result = {
7170 let client = &self.hub.client;
7171 dlg.pre_request();
7172 let mut req_builder = hyper::Request::builder()
7173 .method(hyper::Method::GET)
7174 .uri(url.as_str())
7175 .header(USER_AGENT, self.hub._user_agent.clone());
7176
7177 if let Some(token) = token.as_ref() {
7178 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7179 }
7180
7181 let request = req_builder
7182 .header(CONTENT_LENGTH, 0_u64)
7183 .body(common::to_body::<String>(None));
7184
7185 client.request(request.unwrap()).await
7186 };
7187
7188 match req_result {
7189 Err(err) => {
7190 if let common::Retry::After(d) = dlg.http_error(&err) {
7191 sleep(d).await;
7192 continue;
7193 }
7194 dlg.finished(false);
7195 return Err(common::Error::HttpError(err));
7196 }
7197 Ok(res) => {
7198 let (mut parts, body) = res.into_parts();
7199 let mut body = common::Body::new(body);
7200 if !parts.status.is_success() {
7201 let bytes = common::to_bytes(body).await.unwrap_or_default();
7202 let error = serde_json::from_str(&common::to_string(&bytes));
7203 let response = common::to_response(parts, bytes.into());
7204
7205 if let common::Retry::After(d) =
7206 dlg.http_failure(&response, error.as_ref().ok())
7207 {
7208 sleep(d).await;
7209 continue;
7210 }
7211
7212 dlg.finished(false);
7213
7214 return Err(match error {
7215 Ok(value) => common::Error::BadRequest(value),
7216 _ => common::Error::Failure(response),
7217 });
7218 }
7219 let response = {
7220 let bytes = common::to_bytes(body).await.unwrap_or_default();
7221 let encoded = common::to_string(&bytes);
7222 match serde_json::from_str(&encoded) {
7223 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7224 Err(error) => {
7225 dlg.response_json_decode_error(&encoded, &error);
7226 return Err(common::Error::JsonDecodeError(
7227 encoded.to_string(),
7228 error,
7229 ));
7230 }
7231 }
7232 };
7233
7234 dlg.finished(true);
7235 return Ok(response);
7236 }
7237 }
7238 }
7239 }
7240
7241 /// Required. Identifier of the course.
7242 ///
7243 /// Sets the *course id* path property to the given value.
7244 ///
7245 /// Even though the property as already been set when instantiating this call,
7246 /// we provide this method for API completeness.
7247 pub fn course_id(
7248 mut self,
7249 new_value: &str,
7250 ) -> CourseAnnouncementAddOnAttachmentListCall<'a, C> {
7251 self._course_id = new_value.to_string();
7252 self
7253 }
7254 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` whose attachments should be enumerated. This field is required, but is not marked as such while we are migrating from post_id.
7255 ///
7256 /// Sets the *item id* path property to the given value.
7257 ///
7258 /// Even though the property as already been set when instantiating this call,
7259 /// we provide this method for API completeness.
7260 pub fn item_id(mut self, new_value: &str) -> CourseAnnouncementAddOnAttachmentListCall<'a, C> {
7261 self._item_id = new_value.to_string();
7262 self
7263 }
7264 /// Optional. Identifier of the post under the course whose attachments to enumerate. Deprecated, use `item_id` instead.
7265 ///
7266 /// Sets the *post id* query property to the given value.
7267 pub fn post_id(mut self, new_value: &str) -> CourseAnnouncementAddOnAttachmentListCall<'a, C> {
7268 self._post_id = Some(new_value.to_string());
7269 self
7270 }
7271 /// A page token, received from a previous `ListAddOnAttachments` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAddOnAttachments` must match the call that provided the page token.
7272 ///
7273 /// Sets the *page token* query property to the given value.
7274 pub fn page_token(
7275 mut self,
7276 new_value: &str,
7277 ) -> CourseAnnouncementAddOnAttachmentListCall<'a, C> {
7278 self._page_token = Some(new_value.to_string());
7279 self
7280 }
7281 /// The maximum number of attachments to return. The service may return fewer than this value. If unspecified, at most 20 attachments will be returned. The maximum value is 20; values above 20 will be coerced to 20.
7282 ///
7283 /// Sets the *page size* query property to the given value.
7284 pub fn page_size(mut self, new_value: i32) -> CourseAnnouncementAddOnAttachmentListCall<'a, C> {
7285 self._page_size = Some(new_value);
7286 self
7287 }
7288 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7289 /// while executing the actual API request.
7290 ///
7291 /// ````text
7292 /// It should be used to handle progress information, and to implement a certain level of resilience.
7293 /// ````
7294 ///
7295 /// Sets the *delegate* property to the given value.
7296 pub fn delegate(
7297 mut self,
7298 new_value: &'a mut dyn common::Delegate,
7299 ) -> CourseAnnouncementAddOnAttachmentListCall<'a, C> {
7300 self._delegate = Some(new_value);
7301 self
7302 }
7303
7304 /// Set any additional parameter of the query string used in the request.
7305 /// It should be used to set parameters which are not yet available through their own
7306 /// setters.
7307 ///
7308 /// Please note that this method must not be used to set any of the known parameters
7309 /// which have their own setter method. If done anyway, the request will fail.
7310 ///
7311 /// # Additional Parameters
7312 ///
7313 /// * *$.xgafv* (query-string) - V1 error format.
7314 /// * *access_token* (query-string) - OAuth access token.
7315 /// * *alt* (query-string) - Data format for response.
7316 /// * *callback* (query-string) - JSONP
7317 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7318 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7319 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7320 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7321 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7322 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7323 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7324 pub fn param<T>(mut self, name: T, value: T) -> CourseAnnouncementAddOnAttachmentListCall<'a, C>
7325 where
7326 T: AsRef<str>,
7327 {
7328 self._additional_params
7329 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7330 self
7331 }
7332
7333 /// Identifies the authorization scope for the method you are building.
7334 ///
7335 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7336 /// [`Scope::AddonStudent`].
7337 ///
7338 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7339 /// tokens for more than one scope.
7340 ///
7341 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7342 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7343 /// sufficient, a read-write scope will do as well.
7344 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementAddOnAttachmentListCall<'a, C>
7345 where
7346 St: AsRef<str>,
7347 {
7348 self._scopes.insert(String::from(scope.as_ref()));
7349 self
7350 }
7351 /// Identifies the authorization scope(s) for the method you are building.
7352 ///
7353 /// See [`Self::add_scope()`] for details.
7354 pub fn add_scopes<I, St>(
7355 mut self,
7356 scopes: I,
7357 ) -> CourseAnnouncementAddOnAttachmentListCall<'a, C>
7358 where
7359 I: IntoIterator<Item = St>,
7360 St: AsRef<str>,
7361 {
7362 self._scopes
7363 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7364 self
7365 }
7366
7367 /// Removes all scopes, and no default scope will be used either.
7368 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7369 /// for details).
7370 pub fn clear_scopes(mut self) -> CourseAnnouncementAddOnAttachmentListCall<'a, C> {
7371 self._scopes.clear();
7372 self
7373 }
7374}
7375
7376/// Updates an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
7377///
7378/// A builder for the *announcements.addOnAttachments.patch* method supported by a *course* resource.
7379/// It is not used directly, but through a [`CourseMethods`] instance.
7380///
7381/// # Example
7382///
7383/// Instantiate a resource method builder
7384///
7385/// ```test_harness,no_run
7386/// # extern crate hyper;
7387/// # extern crate hyper_rustls;
7388/// # extern crate google_classroom1 as classroom1;
7389/// use classroom1::api::AddOnAttachment;
7390/// # async fn dox() {
7391/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7392///
7393/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7394/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7395/// # .with_native_roots()
7396/// # .unwrap()
7397/// # .https_only()
7398/// # .enable_http2()
7399/// # .build();
7400///
7401/// # let executor = hyper_util::rt::TokioExecutor::new();
7402/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7403/// # secret,
7404/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7405/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7406/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7407/// # ),
7408/// # ).build().await.unwrap();
7409///
7410/// # let client = hyper_util::client::legacy::Client::builder(
7411/// # hyper_util::rt::TokioExecutor::new()
7412/// # )
7413/// # .build(
7414/// # hyper_rustls::HttpsConnectorBuilder::new()
7415/// # .with_native_roots()
7416/// # .unwrap()
7417/// # .https_or_http()
7418/// # .enable_http2()
7419/// # .build()
7420/// # );
7421/// # let mut hub = Classroom::new(client, auth);
7422/// // As the method needs a request, you would usually fill it with the desired information
7423/// // into the respective structure. Some of the parts shown here might not be applicable !
7424/// // Values shown here are possibly random and not representative !
7425/// let mut req = AddOnAttachment::default();
7426///
7427/// // You can configure optional parameters by calling the respective setters at will, and
7428/// // execute the final call using `doit()`.
7429/// // Values shown here are possibly random and not representative !
7430/// let result = hub.courses().announcements_add_on_attachments_patch(req, "courseId", "itemId", "attachmentId")
7431/// .update_mask(FieldMask::new::<&str>(&[]))
7432/// .post_id("no")
7433/// .doit().await;
7434/// # }
7435/// ```
7436pub struct CourseAnnouncementAddOnAttachmentPatchCall<'a, C>
7437where
7438 C: 'a,
7439{
7440 hub: &'a Classroom<C>,
7441 _request: AddOnAttachment,
7442 _course_id: String,
7443 _item_id: String,
7444 _attachment_id: String,
7445 _update_mask: Option<common::FieldMask>,
7446 _post_id: Option<String>,
7447 _delegate: Option<&'a mut dyn common::Delegate>,
7448 _additional_params: HashMap<String, String>,
7449 _scopes: BTreeSet<String>,
7450}
7451
7452impl<'a, C> common::CallBuilder for CourseAnnouncementAddOnAttachmentPatchCall<'a, C> {}
7453
7454impl<'a, C> CourseAnnouncementAddOnAttachmentPatchCall<'a, C>
7455where
7456 C: common::Connector,
7457{
7458 /// Perform the operation you have build so far.
7459 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
7460 use std::borrow::Cow;
7461 use std::io::{Read, Seek};
7462
7463 use common::{url::Params, ToParts};
7464 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7465
7466 let mut dd = common::DefaultDelegate;
7467 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7468 dlg.begin(common::MethodInfo {
7469 id: "classroom.courses.announcements.addOnAttachments.patch",
7470 http_method: hyper::Method::PATCH,
7471 });
7472
7473 for &field in [
7474 "alt",
7475 "courseId",
7476 "itemId",
7477 "attachmentId",
7478 "updateMask",
7479 "postId",
7480 ]
7481 .iter()
7482 {
7483 if self._additional_params.contains_key(field) {
7484 dlg.finished(false);
7485 return Err(common::Error::FieldClash(field));
7486 }
7487 }
7488
7489 let mut params = Params::with_capacity(8 + self._additional_params.len());
7490 params.push("courseId", self._course_id);
7491 params.push("itemId", self._item_id);
7492 params.push("attachmentId", self._attachment_id);
7493 if let Some(value) = self._update_mask.as_ref() {
7494 params.push("updateMask", value.to_string());
7495 }
7496 if let Some(value) = self._post_id.as_ref() {
7497 params.push("postId", value);
7498 }
7499
7500 params.extend(self._additional_params.iter());
7501
7502 params.push("alt", "json");
7503 let mut url = self.hub._base_url.clone()
7504 + "v1/courses/{courseId}/announcements/{itemId}/addOnAttachments/{attachmentId}";
7505 if self._scopes.is_empty() {
7506 self._scopes
7507 .insert(Scope::AddonTeacher.as_ref().to_string());
7508 }
7509
7510 #[allow(clippy::single_element_loop)]
7511 for &(find_this, param_name) in [
7512 ("{courseId}", "courseId"),
7513 ("{itemId}", "itemId"),
7514 ("{attachmentId}", "attachmentId"),
7515 ]
7516 .iter()
7517 {
7518 url = params.uri_replacement(url, param_name, find_this, false);
7519 }
7520 {
7521 let to_remove = ["attachmentId", "itemId", "courseId"];
7522 params.remove_params(&to_remove);
7523 }
7524
7525 let url = params.parse_with_url(&url);
7526
7527 let mut json_mime_type = mime::APPLICATION_JSON;
7528 let mut request_value_reader = {
7529 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7530 common::remove_json_null_values(&mut value);
7531 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7532 serde_json::to_writer(&mut dst, &value).unwrap();
7533 dst
7534 };
7535 let request_size = request_value_reader
7536 .seek(std::io::SeekFrom::End(0))
7537 .unwrap();
7538 request_value_reader
7539 .seek(std::io::SeekFrom::Start(0))
7540 .unwrap();
7541
7542 loop {
7543 let token = match self
7544 .hub
7545 .auth
7546 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7547 .await
7548 {
7549 Ok(token) => token,
7550 Err(e) => match dlg.token(e) {
7551 Ok(token) => token,
7552 Err(e) => {
7553 dlg.finished(false);
7554 return Err(common::Error::MissingToken(e));
7555 }
7556 },
7557 };
7558 request_value_reader
7559 .seek(std::io::SeekFrom::Start(0))
7560 .unwrap();
7561 let mut req_result = {
7562 let client = &self.hub.client;
7563 dlg.pre_request();
7564 let mut req_builder = hyper::Request::builder()
7565 .method(hyper::Method::PATCH)
7566 .uri(url.as_str())
7567 .header(USER_AGENT, self.hub._user_agent.clone());
7568
7569 if let Some(token) = token.as_ref() {
7570 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7571 }
7572
7573 let request = req_builder
7574 .header(CONTENT_TYPE, json_mime_type.to_string())
7575 .header(CONTENT_LENGTH, request_size as u64)
7576 .body(common::to_body(
7577 request_value_reader.get_ref().clone().into(),
7578 ));
7579
7580 client.request(request.unwrap()).await
7581 };
7582
7583 match req_result {
7584 Err(err) => {
7585 if let common::Retry::After(d) = dlg.http_error(&err) {
7586 sleep(d).await;
7587 continue;
7588 }
7589 dlg.finished(false);
7590 return Err(common::Error::HttpError(err));
7591 }
7592 Ok(res) => {
7593 let (mut parts, body) = res.into_parts();
7594 let mut body = common::Body::new(body);
7595 if !parts.status.is_success() {
7596 let bytes = common::to_bytes(body).await.unwrap_or_default();
7597 let error = serde_json::from_str(&common::to_string(&bytes));
7598 let response = common::to_response(parts, bytes.into());
7599
7600 if let common::Retry::After(d) =
7601 dlg.http_failure(&response, error.as_ref().ok())
7602 {
7603 sleep(d).await;
7604 continue;
7605 }
7606
7607 dlg.finished(false);
7608
7609 return Err(match error {
7610 Ok(value) => common::Error::BadRequest(value),
7611 _ => common::Error::Failure(response),
7612 });
7613 }
7614 let response = {
7615 let bytes = common::to_bytes(body).await.unwrap_or_default();
7616 let encoded = common::to_string(&bytes);
7617 match serde_json::from_str(&encoded) {
7618 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7619 Err(error) => {
7620 dlg.response_json_decode_error(&encoded, &error);
7621 return Err(common::Error::JsonDecodeError(
7622 encoded.to_string(),
7623 error,
7624 ));
7625 }
7626 }
7627 };
7628
7629 dlg.finished(true);
7630 return Ok(response);
7631 }
7632 }
7633 }
7634 }
7635
7636 ///
7637 /// Sets the *request* property to the given value.
7638 ///
7639 /// Even though the property as already been set when instantiating this call,
7640 /// we provide this method for API completeness.
7641 pub fn request(
7642 mut self,
7643 new_value: AddOnAttachment,
7644 ) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C> {
7645 self._request = new_value;
7646 self
7647 }
7648 /// Required. Identifier of the course.
7649 ///
7650 /// Sets the *course id* path property to the given value.
7651 ///
7652 /// Even though the property as already been set when instantiating this call,
7653 /// we provide this method for API completeness.
7654 pub fn course_id(
7655 mut self,
7656 new_value: &str,
7657 ) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C> {
7658 self._course_id = new_value.to_string();
7659 self
7660 }
7661 /// Identifier of the post under which the attachment is attached.
7662 ///
7663 /// Sets the *item id* path property to the given value.
7664 ///
7665 /// Even though the property as already been set when instantiating this call,
7666 /// we provide this method for API completeness.
7667 pub fn item_id(mut self, new_value: &str) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C> {
7668 self._item_id = new_value.to_string();
7669 self
7670 }
7671 /// Required. Identifier of the attachment.
7672 ///
7673 /// Sets the *attachment id* path property to the given value.
7674 ///
7675 /// Even though the property as already been set when instantiating this call,
7676 /// we provide this method for API completeness.
7677 pub fn attachment_id(
7678 mut self,
7679 new_value: &str,
7680 ) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C> {
7681 self._attachment_id = new_value.to_string();
7682 self
7683 }
7684 /// Required. Mask that identifies which fields on the attachment to update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the `AddOnAttachment` object. If a field that does not support empty values is included in the update mask and not set in the `AddOnAttachment` object, an `INVALID_ARGUMENT` error is returned. The following fields may be specified by teachers: * `title` * `teacher_view_uri` * `student_view_uri` * `student_work_review_uri` * `due_date` * `due_time` * `max_points`
7685 ///
7686 /// Sets the *update mask* query property to the given value.
7687 pub fn update_mask(
7688 mut self,
7689 new_value: common::FieldMask,
7690 ) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C> {
7691 self._update_mask = Some(new_value);
7692 self
7693 }
7694 /// Required. Identifier of the post under which the attachment is attached.
7695 ///
7696 /// Sets the *post id* query property to the given value.
7697 pub fn post_id(mut self, new_value: &str) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C> {
7698 self._post_id = Some(new_value.to_string());
7699 self
7700 }
7701 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7702 /// while executing the actual API request.
7703 ///
7704 /// ````text
7705 /// It should be used to handle progress information, and to implement a certain level of resilience.
7706 /// ````
7707 ///
7708 /// Sets the *delegate* property to the given value.
7709 pub fn delegate(
7710 mut self,
7711 new_value: &'a mut dyn common::Delegate,
7712 ) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C> {
7713 self._delegate = Some(new_value);
7714 self
7715 }
7716
7717 /// Set any additional parameter of the query string used in the request.
7718 /// It should be used to set parameters which are not yet available through their own
7719 /// setters.
7720 ///
7721 /// Please note that this method must not be used to set any of the known parameters
7722 /// which have their own setter method. If done anyway, the request will fail.
7723 ///
7724 /// # Additional Parameters
7725 ///
7726 /// * *$.xgafv* (query-string) - V1 error format.
7727 /// * *access_token* (query-string) - OAuth access token.
7728 /// * *alt* (query-string) - Data format for response.
7729 /// * *callback* (query-string) - JSONP
7730 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7731 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7732 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7733 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7734 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7735 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7736 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7737 pub fn param<T>(
7738 mut self,
7739 name: T,
7740 value: T,
7741 ) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C>
7742 where
7743 T: AsRef<str>,
7744 {
7745 self._additional_params
7746 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7747 self
7748 }
7749
7750 /// Identifies the authorization scope for the method you are building.
7751 ///
7752 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7753 /// [`Scope::AddonTeacher`].
7754 ///
7755 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7756 /// tokens for more than one scope.
7757 ///
7758 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7759 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7760 /// sufficient, a read-write scope will do as well.
7761 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C>
7762 where
7763 St: AsRef<str>,
7764 {
7765 self._scopes.insert(String::from(scope.as_ref()));
7766 self
7767 }
7768 /// Identifies the authorization scope(s) for the method you are building.
7769 ///
7770 /// See [`Self::add_scope()`] for details.
7771 pub fn add_scopes<I, St>(
7772 mut self,
7773 scopes: I,
7774 ) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C>
7775 where
7776 I: IntoIterator<Item = St>,
7777 St: AsRef<str>,
7778 {
7779 self._scopes
7780 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7781 self
7782 }
7783
7784 /// Removes all scopes, and no default scope will be used either.
7785 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7786 /// for details).
7787 pub fn clear_scopes(mut self) -> CourseAnnouncementAddOnAttachmentPatchCall<'a, C> {
7788 self._scopes.clear();
7789 self
7790 }
7791}
7792
7793/// Creates an announcement. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create announcements in the requested course, share a Drive attachment, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist. * `FAILED_PRECONDITION` for the following request error: * AttachmentNotVisible
7794///
7795/// A builder for the *announcements.create* method supported by a *course* resource.
7796/// It is not used directly, but through a [`CourseMethods`] instance.
7797///
7798/// # Example
7799///
7800/// Instantiate a resource method builder
7801///
7802/// ```test_harness,no_run
7803/// # extern crate hyper;
7804/// # extern crate hyper_rustls;
7805/// # extern crate google_classroom1 as classroom1;
7806/// use classroom1::api::Announcement;
7807/// # async fn dox() {
7808/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7809///
7810/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7811/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7812/// # .with_native_roots()
7813/// # .unwrap()
7814/// # .https_only()
7815/// # .enable_http2()
7816/// # .build();
7817///
7818/// # let executor = hyper_util::rt::TokioExecutor::new();
7819/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7820/// # secret,
7821/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7822/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7823/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7824/// # ),
7825/// # ).build().await.unwrap();
7826///
7827/// # let client = hyper_util::client::legacy::Client::builder(
7828/// # hyper_util::rt::TokioExecutor::new()
7829/// # )
7830/// # .build(
7831/// # hyper_rustls::HttpsConnectorBuilder::new()
7832/// # .with_native_roots()
7833/// # .unwrap()
7834/// # .https_or_http()
7835/// # .enable_http2()
7836/// # .build()
7837/// # );
7838/// # let mut hub = Classroom::new(client, auth);
7839/// // As the method needs a request, you would usually fill it with the desired information
7840/// // into the respective structure. Some of the parts shown here might not be applicable !
7841/// // Values shown here are possibly random and not representative !
7842/// let mut req = Announcement::default();
7843///
7844/// // You can configure optional parameters by calling the respective setters at will, and
7845/// // execute the final call using `doit()`.
7846/// // Values shown here are possibly random and not representative !
7847/// let result = hub.courses().announcements_create(req, "courseId")
7848/// .doit().await;
7849/// # }
7850/// ```
7851pub struct CourseAnnouncementCreateCall<'a, C>
7852where
7853 C: 'a,
7854{
7855 hub: &'a Classroom<C>,
7856 _request: Announcement,
7857 _course_id: String,
7858 _delegate: Option<&'a mut dyn common::Delegate>,
7859 _additional_params: HashMap<String, String>,
7860 _scopes: BTreeSet<String>,
7861}
7862
7863impl<'a, C> common::CallBuilder for CourseAnnouncementCreateCall<'a, C> {}
7864
7865impl<'a, C> CourseAnnouncementCreateCall<'a, C>
7866where
7867 C: common::Connector,
7868{
7869 /// Perform the operation you have build so far.
7870 pub async fn doit(mut self) -> common::Result<(common::Response, Announcement)> {
7871 use std::borrow::Cow;
7872 use std::io::{Read, Seek};
7873
7874 use common::{url::Params, ToParts};
7875 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7876
7877 let mut dd = common::DefaultDelegate;
7878 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7879 dlg.begin(common::MethodInfo {
7880 id: "classroom.courses.announcements.create",
7881 http_method: hyper::Method::POST,
7882 });
7883
7884 for &field in ["alt", "courseId"].iter() {
7885 if self._additional_params.contains_key(field) {
7886 dlg.finished(false);
7887 return Err(common::Error::FieldClash(field));
7888 }
7889 }
7890
7891 let mut params = Params::with_capacity(4 + self._additional_params.len());
7892 params.push("courseId", self._course_id);
7893
7894 params.extend(self._additional_params.iter());
7895
7896 params.push("alt", "json");
7897 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/announcements";
7898 if self._scopes.is_empty() {
7899 self._scopes
7900 .insert(Scope::Announcement.as_ref().to_string());
7901 }
7902
7903 #[allow(clippy::single_element_loop)]
7904 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
7905 url = params.uri_replacement(url, param_name, find_this, false);
7906 }
7907 {
7908 let to_remove = ["courseId"];
7909 params.remove_params(&to_remove);
7910 }
7911
7912 let url = params.parse_with_url(&url);
7913
7914 let mut json_mime_type = mime::APPLICATION_JSON;
7915 let mut request_value_reader = {
7916 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7917 common::remove_json_null_values(&mut value);
7918 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7919 serde_json::to_writer(&mut dst, &value).unwrap();
7920 dst
7921 };
7922 let request_size = request_value_reader
7923 .seek(std::io::SeekFrom::End(0))
7924 .unwrap();
7925 request_value_reader
7926 .seek(std::io::SeekFrom::Start(0))
7927 .unwrap();
7928
7929 loop {
7930 let token = match self
7931 .hub
7932 .auth
7933 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7934 .await
7935 {
7936 Ok(token) => token,
7937 Err(e) => match dlg.token(e) {
7938 Ok(token) => token,
7939 Err(e) => {
7940 dlg.finished(false);
7941 return Err(common::Error::MissingToken(e));
7942 }
7943 },
7944 };
7945 request_value_reader
7946 .seek(std::io::SeekFrom::Start(0))
7947 .unwrap();
7948 let mut req_result = {
7949 let client = &self.hub.client;
7950 dlg.pre_request();
7951 let mut req_builder = hyper::Request::builder()
7952 .method(hyper::Method::POST)
7953 .uri(url.as_str())
7954 .header(USER_AGENT, self.hub._user_agent.clone());
7955
7956 if let Some(token) = token.as_ref() {
7957 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7958 }
7959
7960 let request = req_builder
7961 .header(CONTENT_TYPE, json_mime_type.to_string())
7962 .header(CONTENT_LENGTH, request_size as u64)
7963 .body(common::to_body(
7964 request_value_reader.get_ref().clone().into(),
7965 ));
7966
7967 client.request(request.unwrap()).await
7968 };
7969
7970 match req_result {
7971 Err(err) => {
7972 if let common::Retry::After(d) = dlg.http_error(&err) {
7973 sleep(d).await;
7974 continue;
7975 }
7976 dlg.finished(false);
7977 return Err(common::Error::HttpError(err));
7978 }
7979 Ok(res) => {
7980 let (mut parts, body) = res.into_parts();
7981 let mut body = common::Body::new(body);
7982 if !parts.status.is_success() {
7983 let bytes = common::to_bytes(body).await.unwrap_or_default();
7984 let error = serde_json::from_str(&common::to_string(&bytes));
7985 let response = common::to_response(parts, bytes.into());
7986
7987 if let common::Retry::After(d) =
7988 dlg.http_failure(&response, error.as_ref().ok())
7989 {
7990 sleep(d).await;
7991 continue;
7992 }
7993
7994 dlg.finished(false);
7995
7996 return Err(match error {
7997 Ok(value) => common::Error::BadRequest(value),
7998 _ => common::Error::Failure(response),
7999 });
8000 }
8001 let response = {
8002 let bytes = common::to_bytes(body).await.unwrap_or_default();
8003 let encoded = common::to_string(&bytes);
8004 match serde_json::from_str(&encoded) {
8005 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8006 Err(error) => {
8007 dlg.response_json_decode_error(&encoded, &error);
8008 return Err(common::Error::JsonDecodeError(
8009 encoded.to_string(),
8010 error,
8011 ));
8012 }
8013 }
8014 };
8015
8016 dlg.finished(true);
8017 return Ok(response);
8018 }
8019 }
8020 }
8021 }
8022
8023 ///
8024 /// Sets the *request* property to the given value.
8025 ///
8026 /// Even though the property as already been set when instantiating this call,
8027 /// we provide this method for API completeness.
8028 pub fn request(mut self, new_value: Announcement) -> CourseAnnouncementCreateCall<'a, C> {
8029 self._request = new_value;
8030 self
8031 }
8032 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
8033 ///
8034 /// Sets the *course id* path property to the given value.
8035 ///
8036 /// Even though the property as already been set when instantiating this call,
8037 /// we provide this method for API completeness.
8038 pub fn course_id(mut self, new_value: &str) -> CourseAnnouncementCreateCall<'a, C> {
8039 self._course_id = new_value.to_string();
8040 self
8041 }
8042 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8043 /// while executing the actual API request.
8044 ///
8045 /// ````text
8046 /// It should be used to handle progress information, and to implement a certain level of resilience.
8047 /// ````
8048 ///
8049 /// Sets the *delegate* property to the given value.
8050 pub fn delegate(
8051 mut self,
8052 new_value: &'a mut dyn common::Delegate,
8053 ) -> CourseAnnouncementCreateCall<'a, C> {
8054 self._delegate = Some(new_value);
8055 self
8056 }
8057
8058 /// Set any additional parameter of the query string used in the request.
8059 /// It should be used to set parameters which are not yet available through their own
8060 /// setters.
8061 ///
8062 /// Please note that this method must not be used to set any of the known parameters
8063 /// which have their own setter method. If done anyway, the request will fail.
8064 ///
8065 /// # Additional Parameters
8066 ///
8067 /// * *$.xgafv* (query-string) - V1 error format.
8068 /// * *access_token* (query-string) - OAuth access token.
8069 /// * *alt* (query-string) - Data format for response.
8070 /// * *callback* (query-string) - JSONP
8071 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8072 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8073 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8074 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8075 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8076 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8077 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8078 pub fn param<T>(mut self, name: T, value: T) -> CourseAnnouncementCreateCall<'a, C>
8079 where
8080 T: AsRef<str>,
8081 {
8082 self._additional_params
8083 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8084 self
8085 }
8086
8087 /// Identifies the authorization scope for the method you are building.
8088 ///
8089 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8090 /// [`Scope::Announcement`].
8091 ///
8092 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8093 /// tokens for more than one scope.
8094 ///
8095 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8096 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8097 /// sufficient, a read-write scope will do as well.
8098 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementCreateCall<'a, C>
8099 where
8100 St: AsRef<str>,
8101 {
8102 self._scopes.insert(String::from(scope.as_ref()));
8103 self
8104 }
8105 /// Identifies the authorization scope(s) for the method you are building.
8106 ///
8107 /// See [`Self::add_scope()`] for details.
8108 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAnnouncementCreateCall<'a, C>
8109 where
8110 I: IntoIterator<Item = St>,
8111 St: AsRef<str>,
8112 {
8113 self._scopes
8114 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8115 self
8116 }
8117
8118 /// Removes all scopes, and no default scope will be used either.
8119 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8120 /// for details).
8121 pub fn clear_scopes(mut self) -> CourseAnnouncementCreateCall<'a, C> {
8122 self._scopes.clear();
8123 self
8124 }
8125}
8126
8127/// Deletes an announcement. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding announcement item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding announcement, if the requesting user is not permitted to delete the requested course or for access errors. * `FAILED_PRECONDITION` if the requested announcement has already been deleted. * `NOT_FOUND` if no course exists with the requested ID.
8128///
8129/// A builder for the *announcements.delete* method supported by a *course* resource.
8130/// It is not used directly, but through a [`CourseMethods`] instance.
8131///
8132/// # Example
8133///
8134/// Instantiate a resource method builder
8135///
8136/// ```test_harness,no_run
8137/// # extern crate hyper;
8138/// # extern crate hyper_rustls;
8139/// # extern crate google_classroom1 as classroom1;
8140/// # async fn dox() {
8141/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8142///
8143/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8144/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8145/// # .with_native_roots()
8146/// # .unwrap()
8147/// # .https_only()
8148/// # .enable_http2()
8149/// # .build();
8150///
8151/// # let executor = hyper_util::rt::TokioExecutor::new();
8152/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8153/// # secret,
8154/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8155/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8156/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8157/// # ),
8158/// # ).build().await.unwrap();
8159///
8160/// # let client = hyper_util::client::legacy::Client::builder(
8161/// # hyper_util::rt::TokioExecutor::new()
8162/// # )
8163/// # .build(
8164/// # hyper_rustls::HttpsConnectorBuilder::new()
8165/// # .with_native_roots()
8166/// # .unwrap()
8167/// # .https_or_http()
8168/// # .enable_http2()
8169/// # .build()
8170/// # );
8171/// # let mut hub = Classroom::new(client, auth);
8172/// // You can configure optional parameters by calling the respective setters at will, and
8173/// // execute the final call using `doit()`.
8174/// // Values shown here are possibly random and not representative !
8175/// let result = hub.courses().announcements_delete("courseId", "id")
8176/// .doit().await;
8177/// # }
8178/// ```
8179pub struct CourseAnnouncementDeleteCall<'a, C>
8180where
8181 C: 'a,
8182{
8183 hub: &'a Classroom<C>,
8184 _course_id: String,
8185 _id: String,
8186 _delegate: Option<&'a mut dyn common::Delegate>,
8187 _additional_params: HashMap<String, String>,
8188 _scopes: BTreeSet<String>,
8189}
8190
8191impl<'a, C> common::CallBuilder for CourseAnnouncementDeleteCall<'a, C> {}
8192
8193impl<'a, C> CourseAnnouncementDeleteCall<'a, C>
8194where
8195 C: common::Connector,
8196{
8197 /// Perform the operation you have build so far.
8198 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8199 use std::borrow::Cow;
8200 use std::io::{Read, Seek};
8201
8202 use common::{url::Params, ToParts};
8203 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8204
8205 let mut dd = common::DefaultDelegate;
8206 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8207 dlg.begin(common::MethodInfo {
8208 id: "classroom.courses.announcements.delete",
8209 http_method: hyper::Method::DELETE,
8210 });
8211
8212 for &field in ["alt", "courseId", "id"].iter() {
8213 if self._additional_params.contains_key(field) {
8214 dlg.finished(false);
8215 return Err(common::Error::FieldClash(field));
8216 }
8217 }
8218
8219 let mut params = Params::with_capacity(4 + self._additional_params.len());
8220 params.push("courseId", self._course_id);
8221 params.push("id", self._id);
8222
8223 params.extend(self._additional_params.iter());
8224
8225 params.push("alt", "json");
8226 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/announcements/{id}";
8227 if self._scopes.is_empty() {
8228 self._scopes
8229 .insert(Scope::Announcement.as_ref().to_string());
8230 }
8231
8232 #[allow(clippy::single_element_loop)]
8233 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
8234 url = params.uri_replacement(url, param_name, find_this, false);
8235 }
8236 {
8237 let to_remove = ["id", "courseId"];
8238 params.remove_params(&to_remove);
8239 }
8240
8241 let url = params.parse_with_url(&url);
8242
8243 loop {
8244 let token = match self
8245 .hub
8246 .auth
8247 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8248 .await
8249 {
8250 Ok(token) => token,
8251 Err(e) => match dlg.token(e) {
8252 Ok(token) => token,
8253 Err(e) => {
8254 dlg.finished(false);
8255 return Err(common::Error::MissingToken(e));
8256 }
8257 },
8258 };
8259 let mut req_result = {
8260 let client = &self.hub.client;
8261 dlg.pre_request();
8262 let mut req_builder = hyper::Request::builder()
8263 .method(hyper::Method::DELETE)
8264 .uri(url.as_str())
8265 .header(USER_AGENT, self.hub._user_agent.clone());
8266
8267 if let Some(token) = token.as_ref() {
8268 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8269 }
8270
8271 let request = req_builder
8272 .header(CONTENT_LENGTH, 0_u64)
8273 .body(common::to_body::<String>(None));
8274
8275 client.request(request.unwrap()).await
8276 };
8277
8278 match req_result {
8279 Err(err) => {
8280 if let common::Retry::After(d) = dlg.http_error(&err) {
8281 sleep(d).await;
8282 continue;
8283 }
8284 dlg.finished(false);
8285 return Err(common::Error::HttpError(err));
8286 }
8287 Ok(res) => {
8288 let (mut parts, body) = res.into_parts();
8289 let mut body = common::Body::new(body);
8290 if !parts.status.is_success() {
8291 let bytes = common::to_bytes(body).await.unwrap_or_default();
8292 let error = serde_json::from_str(&common::to_string(&bytes));
8293 let response = common::to_response(parts, bytes.into());
8294
8295 if let common::Retry::After(d) =
8296 dlg.http_failure(&response, error.as_ref().ok())
8297 {
8298 sleep(d).await;
8299 continue;
8300 }
8301
8302 dlg.finished(false);
8303
8304 return Err(match error {
8305 Ok(value) => common::Error::BadRequest(value),
8306 _ => common::Error::Failure(response),
8307 });
8308 }
8309 let response = {
8310 let bytes = common::to_bytes(body).await.unwrap_or_default();
8311 let encoded = common::to_string(&bytes);
8312 match serde_json::from_str(&encoded) {
8313 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8314 Err(error) => {
8315 dlg.response_json_decode_error(&encoded, &error);
8316 return Err(common::Error::JsonDecodeError(
8317 encoded.to_string(),
8318 error,
8319 ));
8320 }
8321 }
8322 };
8323
8324 dlg.finished(true);
8325 return Ok(response);
8326 }
8327 }
8328 }
8329 }
8330
8331 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
8332 ///
8333 /// Sets the *course id* path property to the given value.
8334 ///
8335 /// Even though the property as already been set when instantiating this call,
8336 /// we provide this method for API completeness.
8337 pub fn course_id(mut self, new_value: &str) -> CourseAnnouncementDeleteCall<'a, C> {
8338 self._course_id = new_value.to_string();
8339 self
8340 }
8341 /// Identifier of the announcement to delete. This identifier is a Classroom-assigned identifier.
8342 ///
8343 /// Sets the *id* path property to the given value.
8344 ///
8345 /// Even though the property as already been set when instantiating this call,
8346 /// we provide this method for API completeness.
8347 pub fn id(mut self, new_value: &str) -> CourseAnnouncementDeleteCall<'a, C> {
8348 self._id = new_value.to_string();
8349 self
8350 }
8351 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8352 /// while executing the actual API request.
8353 ///
8354 /// ````text
8355 /// It should be used to handle progress information, and to implement a certain level of resilience.
8356 /// ````
8357 ///
8358 /// Sets the *delegate* property to the given value.
8359 pub fn delegate(
8360 mut self,
8361 new_value: &'a mut dyn common::Delegate,
8362 ) -> CourseAnnouncementDeleteCall<'a, C> {
8363 self._delegate = Some(new_value);
8364 self
8365 }
8366
8367 /// Set any additional parameter of the query string used in the request.
8368 /// It should be used to set parameters which are not yet available through their own
8369 /// setters.
8370 ///
8371 /// Please note that this method must not be used to set any of the known parameters
8372 /// which have their own setter method. If done anyway, the request will fail.
8373 ///
8374 /// # Additional Parameters
8375 ///
8376 /// * *$.xgafv* (query-string) - V1 error format.
8377 /// * *access_token* (query-string) - OAuth access token.
8378 /// * *alt* (query-string) - Data format for response.
8379 /// * *callback* (query-string) - JSONP
8380 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8381 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8382 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8383 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8384 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8385 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8386 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8387 pub fn param<T>(mut self, name: T, value: T) -> CourseAnnouncementDeleteCall<'a, C>
8388 where
8389 T: AsRef<str>,
8390 {
8391 self._additional_params
8392 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8393 self
8394 }
8395
8396 /// Identifies the authorization scope for the method you are building.
8397 ///
8398 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8399 /// [`Scope::Announcement`].
8400 ///
8401 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8402 /// tokens for more than one scope.
8403 ///
8404 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8405 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8406 /// sufficient, a read-write scope will do as well.
8407 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementDeleteCall<'a, C>
8408 where
8409 St: AsRef<str>,
8410 {
8411 self._scopes.insert(String::from(scope.as_ref()));
8412 self
8413 }
8414 /// Identifies the authorization scope(s) for the method you are building.
8415 ///
8416 /// See [`Self::add_scope()`] for details.
8417 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAnnouncementDeleteCall<'a, C>
8418 where
8419 I: IntoIterator<Item = St>,
8420 St: AsRef<str>,
8421 {
8422 self._scopes
8423 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8424 self
8425 }
8426
8427 /// Removes all scopes, and no default scope will be used either.
8428 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8429 /// for details).
8430 pub fn clear_scopes(mut self) -> CourseAnnouncementDeleteCall<'a, C> {
8431 self._scopes.clear();
8432 self
8433 }
8434}
8435
8436/// Returns an announcement. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or announcement, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or announcement does not exist.
8437///
8438/// A builder for the *announcements.get* method supported by a *course* resource.
8439/// It is not used directly, but through a [`CourseMethods`] instance.
8440///
8441/// # Example
8442///
8443/// Instantiate a resource method builder
8444///
8445/// ```test_harness,no_run
8446/// # extern crate hyper;
8447/// # extern crate hyper_rustls;
8448/// # extern crate google_classroom1 as classroom1;
8449/// # async fn dox() {
8450/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8451///
8452/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8453/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8454/// # .with_native_roots()
8455/// # .unwrap()
8456/// # .https_only()
8457/// # .enable_http2()
8458/// # .build();
8459///
8460/// # let executor = hyper_util::rt::TokioExecutor::new();
8461/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8462/// # secret,
8463/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8464/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8465/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8466/// # ),
8467/// # ).build().await.unwrap();
8468///
8469/// # let client = hyper_util::client::legacy::Client::builder(
8470/// # hyper_util::rt::TokioExecutor::new()
8471/// # )
8472/// # .build(
8473/// # hyper_rustls::HttpsConnectorBuilder::new()
8474/// # .with_native_roots()
8475/// # .unwrap()
8476/// # .https_or_http()
8477/// # .enable_http2()
8478/// # .build()
8479/// # );
8480/// # let mut hub = Classroom::new(client, auth);
8481/// // You can configure optional parameters by calling the respective setters at will, and
8482/// // execute the final call using `doit()`.
8483/// // Values shown here are possibly random and not representative !
8484/// let result = hub.courses().announcements_get("courseId", "id")
8485/// .doit().await;
8486/// # }
8487/// ```
8488pub struct CourseAnnouncementGetCall<'a, C>
8489where
8490 C: 'a,
8491{
8492 hub: &'a Classroom<C>,
8493 _course_id: String,
8494 _id: String,
8495 _delegate: Option<&'a mut dyn common::Delegate>,
8496 _additional_params: HashMap<String, String>,
8497 _scopes: BTreeSet<String>,
8498}
8499
8500impl<'a, C> common::CallBuilder for CourseAnnouncementGetCall<'a, C> {}
8501
8502impl<'a, C> CourseAnnouncementGetCall<'a, C>
8503where
8504 C: common::Connector,
8505{
8506 /// Perform the operation you have build so far.
8507 pub async fn doit(mut self) -> common::Result<(common::Response, Announcement)> {
8508 use std::borrow::Cow;
8509 use std::io::{Read, Seek};
8510
8511 use common::{url::Params, ToParts};
8512 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8513
8514 let mut dd = common::DefaultDelegate;
8515 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8516 dlg.begin(common::MethodInfo {
8517 id: "classroom.courses.announcements.get",
8518 http_method: hyper::Method::GET,
8519 });
8520
8521 for &field in ["alt", "courseId", "id"].iter() {
8522 if self._additional_params.contains_key(field) {
8523 dlg.finished(false);
8524 return Err(common::Error::FieldClash(field));
8525 }
8526 }
8527
8528 let mut params = Params::with_capacity(4 + self._additional_params.len());
8529 params.push("courseId", self._course_id);
8530 params.push("id", self._id);
8531
8532 params.extend(self._additional_params.iter());
8533
8534 params.push("alt", "json");
8535 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/announcements/{id}";
8536 if self._scopes.is_empty() {
8537 self._scopes
8538 .insert(Scope::AnnouncementReadonly.as_ref().to_string());
8539 }
8540
8541 #[allow(clippy::single_element_loop)]
8542 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
8543 url = params.uri_replacement(url, param_name, find_this, false);
8544 }
8545 {
8546 let to_remove = ["id", "courseId"];
8547 params.remove_params(&to_remove);
8548 }
8549
8550 let url = params.parse_with_url(&url);
8551
8552 loop {
8553 let token = match self
8554 .hub
8555 .auth
8556 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8557 .await
8558 {
8559 Ok(token) => token,
8560 Err(e) => match dlg.token(e) {
8561 Ok(token) => token,
8562 Err(e) => {
8563 dlg.finished(false);
8564 return Err(common::Error::MissingToken(e));
8565 }
8566 },
8567 };
8568 let mut req_result = {
8569 let client = &self.hub.client;
8570 dlg.pre_request();
8571 let mut req_builder = hyper::Request::builder()
8572 .method(hyper::Method::GET)
8573 .uri(url.as_str())
8574 .header(USER_AGENT, self.hub._user_agent.clone());
8575
8576 if let Some(token) = token.as_ref() {
8577 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8578 }
8579
8580 let request = req_builder
8581 .header(CONTENT_LENGTH, 0_u64)
8582 .body(common::to_body::<String>(None));
8583
8584 client.request(request.unwrap()).await
8585 };
8586
8587 match req_result {
8588 Err(err) => {
8589 if let common::Retry::After(d) = dlg.http_error(&err) {
8590 sleep(d).await;
8591 continue;
8592 }
8593 dlg.finished(false);
8594 return Err(common::Error::HttpError(err));
8595 }
8596 Ok(res) => {
8597 let (mut parts, body) = res.into_parts();
8598 let mut body = common::Body::new(body);
8599 if !parts.status.is_success() {
8600 let bytes = common::to_bytes(body).await.unwrap_or_default();
8601 let error = serde_json::from_str(&common::to_string(&bytes));
8602 let response = common::to_response(parts, bytes.into());
8603
8604 if let common::Retry::After(d) =
8605 dlg.http_failure(&response, error.as_ref().ok())
8606 {
8607 sleep(d).await;
8608 continue;
8609 }
8610
8611 dlg.finished(false);
8612
8613 return Err(match error {
8614 Ok(value) => common::Error::BadRequest(value),
8615 _ => common::Error::Failure(response),
8616 });
8617 }
8618 let response = {
8619 let bytes = common::to_bytes(body).await.unwrap_or_default();
8620 let encoded = common::to_string(&bytes);
8621 match serde_json::from_str(&encoded) {
8622 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8623 Err(error) => {
8624 dlg.response_json_decode_error(&encoded, &error);
8625 return Err(common::Error::JsonDecodeError(
8626 encoded.to_string(),
8627 error,
8628 ));
8629 }
8630 }
8631 };
8632
8633 dlg.finished(true);
8634 return Ok(response);
8635 }
8636 }
8637 }
8638 }
8639
8640 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
8641 ///
8642 /// Sets the *course id* path property to the given value.
8643 ///
8644 /// Even though the property as already been set when instantiating this call,
8645 /// we provide this method for API completeness.
8646 pub fn course_id(mut self, new_value: &str) -> CourseAnnouncementGetCall<'a, C> {
8647 self._course_id = new_value.to_string();
8648 self
8649 }
8650 /// Identifier of the announcement.
8651 ///
8652 /// Sets the *id* path property to the given value.
8653 ///
8654 /// Even though the property as already been set when instantiating this call,
8655 /// we provide this method for API completeness.
8656 pub fn id(mut self, new_value: &str) -> CourseAnnouncementGetCall<'a, C> {
8657 self._id = new_value.to_string();
8658 self
8659 }
8660 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8661 /// while executing the actual API request.
8662 ///
8663 /// ````text
8664 /// It should be used to handle progress information, and to implement a certain level of resilience.
8665 /// ````
8666 ///
8667 /// Sets the *delegate* property to the given value.
8668 pub fn delegate(
8669 mut self,
8670 new_value: &'a mut dyn common::Delegate,
8671 ) -> CourseAnnouncementGetCall<'a, C> {
8672 self._delegate = Some(new_value);
8673 self
8674 }
8675
8676 /// Set any additional parameter of the query string used in the request.
8677 /// It should be used to set parameters which are not yet available through their own
8678 /// setters.
8679 ///
8680 /// Please note that this method must not be used to set any of the known parameters
8681 /// which have their own setter method. If done anyway, the request will fail.
8682 ///
8683 /// # Additional Parameters
8684 ///
8685 /// * *$.xgafv* (query-string) - V1 error format.
8686 /// * *access_token* (query-string) - OAuth access token.
8687 /// * *alt* (query-string) - Data format for response.
8688 /// * *callback* (query-string) - JSONP
8689 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8690 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8691 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8692 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8693 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8694 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8695 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8696 pub fn param<T>(mut self, name: T, value: T) -> CourseAnnouncementGetCall<'a, C>
8697 where
8698 T: AsRef<str>,
8699 {
8700 self._additional_params
8701 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8702 self
8703 }
8704
8705 /// Identifies the authorization scope for the method you are building.
8706 ///
8707 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8708 /// [`Scope::AnnouncementReadonly`].
8709 ///
8710 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8711 /// tokens for more than one scope.
8712 ///
8713 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8714 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8715 /// sufficient, a read-write scope will do as well.
8716 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementGetCall<'a, C>
8717 where
8718 St: AsRef<str>,
8719 {
8720 self._scopes.insert(String::from(scope.as_ref()));
8721 self
8722 }
8723 /// Identifies the authorization scope(s) for the method you are building.
8724 ///
8725 /// See [`Self::add_scope()`] for details.
8726 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAnnouncementGetCall<'a, C>
8727 where
8728 I: IntoIterator<Item = St>,
8729 St: AsRef<str>,
8730 {
8731 self._scopes
8732 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8733 self
8734 }
8735
8736 /// Removes all scopes, and no default scope will be used either.
8737 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8738 /// for details).
8739 pub fn clear_scopes(mut self) -> CourseAnnouncementGetCall<'a, C> {
8740 self._scopes.clear();
8741 self
8742 }
8743}
8744
8745/// Gets metadata for Classroom add-ons in the context of a specific post. To maintain the integrity of its own data and permissions model, an add-on should call this to validate query parameters and the requesting user's role whenever the add-on is opened in an [iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/iframes-overview). This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
8746///
8747/// A builder for the *announcements.getAddOnContext* method supported by a *course* resource.
8748/// It is not used directly, but through a [`CourseMethods`] instance.
8749///
8750/// # Example
8751///
8752/// Instantiate a resource method builder
8753///
8754/// ```test_harness,no_run
8755/// # extern crate hyper;
8756/// # extern crate hyper_rustls;
8757/// # extern crate google_classroom1 as classroom1;
8758/// # async fn dox() {
8759/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8760///
8761/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8762/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8763/// # .with_native_roots()
8764/// # .unwrap()
8765/// # .https_only()
8766/// # .enable_http2()
8767/// # .build();
8768///
8769/// # let executor = hyper_util::rt::TokioExecutor::new();
8770/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8771/// # secret,
8772/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8773/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8774/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8775/// # ),
8776/// # ).build().await.unwrap();
8777///
8778/// # let client = hyper_util::client::legacy::Client::builder(
8779/// # hyper_util::rt::TokioExecutor::new()
8780/// # )
8781/// # .build(
8782/// # hyper_rustls::HttpsConnectorBuilder::new()
8783/// # .with_native_roots()
8784/// # .unwrap()
8785/// # .https_or_http()
8786/// # .enable_http2()
8787/// # .build()
8788/// # );
8789/// # let mut hub = Classroom::new(client, auth);
8790/// // You can configure optional parameters by calling the respective setters at will, and
8791/// // execute the final call using `doit()`.
8792/// // Values shown here are possibly random and not representative !
8793/// let result = hub.courses().announcements_get_add_on_context("courseId", "itemId")
8794/// .post_id("erat")
8795/// .attachment_id("sed")
8796/// .add_on_token("duo")
8797/// .doit().await;
8798/// # }
8799/// ```
8800pub struct CourseAnnouncementGetAddOnContextCall<'a, C>
8801where
8802 C: 'a,
8803{
8804 hub: &'a Classroom<C>,
8805 _course_id: String,
8806 _item_id: String,
8807 _post_id: Option<String>,
8808 _attachment_id: Option<String>,
8809 _add_on_token: Option<String>,
8810 _delegate: Option<&'a mut dyn common::Delegate>,
8811 _additional_params: HashMap<String, String>,
8812 _scopes: BTreeSet<String>,
8813}
8814
8815impl<'a, C> common::CallBuilder for CourseAnnouncementGetAddOnContextCall<'a, C> {}
8816
8817impl<'a, C> CourseAnnouncementGetAddOnContextCall<'a, C>
8818where
8819 C: common::Connector,
8820{
8821 /// Perform the operation you have build so far.
8822 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnContext)> {
8823 use std::borrow::Cow;
8824 use std::io::{Read, Seek};
8825
8826 use common::{url::Params, ToParts};
8827 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8828
8829 let mut dd = common::DefaultDelegate;
8830 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8831 dlg.begin(common::MethodInfo {
8832 id: "classroom.courses.announcements.getAddOnContext",
8833 http_method: hyper::Method::GET,
8834 });
8835
8836 for &field in [
8837 "alt",
8838 "courseId",
8839 "itemId",
8840 "postId",
8841 "attachmentId",
8842 "addOnToken",
8843 ]
8844 .iter()
8845 {
8846 if self._additional_params.contains_key(field) {
8847 dlg.finished(false);
8848 return Err(common::Error::FieldClash(field));
8849 }
8850 }
8851
8852 let mut params = Params::with_capacity(7 + self._additional_params.len());
8853 params.push("courseId", self._course_id);
8854 params.push("itemId", self._item_id);
8855 if let Some(value) = self._post_id.as_ref() {
8856 params.push("postId", value);
8857 }
8858 if let Some(value) = self._attachment_id.as_ref() {
8859 params.push("attachmentId", value);
8860 }
8861 if let Some(value) = self._add_on_token.as_ref() {
8862 params.push("addOnToken", value);
8863 }
8864
8865 params.extend(self._additional_params.iter());
8866
8867 params.push("alt", "json");
8868 let mut url = self.hub._base_url.clone()
8869 + "v1/courses/{courseId}/announcements/{itemId}/addOnContext";
8870 if self._scopes.is_empty() {
8871 self._scopes
8872 .insert(Scope::AddonStudent.as_ref().to_string());
8873 }
8874
8875 #[allow(clippy::single_element_loop)]
8876 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{itemId}", "itemId")].iter()
8877 {
8878 url = params.uri_replacement(url, param_name, find_this, false);
8879 }
8880 {
8881 let to_remove = ["itemId", "courseId"];
8882 params.remove_params(&to_remove);
8883 }
8884
8885 let url = params.parse_with_url(&url);
8886
8887 loop {
8888 let token = match self
8889 .hub
8890 .auth
8891 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8892 .await
8893 {
8894 Ok(token) => token,
8895 Err(e) => match dlg.token(e) {
8896 Ok(token) => token,
8897 Err(e) => {
8898 dlg.finished(false);
8899 return Err(common::Error::MissingToken(e));
8900 }
8901 },
8902 };
8903 let mut req_result = {
8904 let client = &self.hub.client;
8905 dlg.pre_request();
8906 let mut req_builder = hyper::Request::builder()
8907 .method(hyper::Method::GET)
8908 .uri(url.as_str())
8909 .header(USER_AGENT, self.hub._user_agent.clone());
8910
8911 if let Some(token) = token.as_ref() {
8912 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8913 }
8914
8915 let request = req_builder
8916 .header(CONTENT_LENGTH, 0_u64)
8917 .body(common::to_body::<String>(None));
8918
8919 client.request(request.unwrap()).await
8920 };
8921
8922 match req_result {
8923 Err(err) => {
8924 if let common::Retry::After(d) = dlg.http_error(&err) {
8925 sleep(d).await;
8926 continue;
8927 }
8928 dlg.finished(false);
8929 return Err(common::Error::HttpError(err));
8930 }
8931 Ok(res) => {
8932 let (mut parts, body) = res.into_parts();
8933 let mut body = common::Body::new(body);
8934 if !parts.status.is_success() {
8935 let bytes = common::to_bytes(body).await.unwrap_or_default();
8936 let error = serde_json::from_str(&common::to_string(&bytes));
8937 let response = common::to_response(parts, bytes.into());
8938
8939 if let common::Retry::After(d) =
8940 dlg.http_failure(&response, error.as_ref().ok())
8941 {
8942 sleep(d).await;
8943 continue;
8944 }
8945
8946 dlg.finished(false);
8947
8948 return Err(match error {
8949 Ok(value) => common::Error::BadRequest(value),
8950 _ => common::Error::Failure(response),
8951 });
8952 }
8953 let response = {
8954 let bytes = common::to_bytes(body).await.unwrap_or_default();
8955 let encoded = common::to_string(&bytes);
8956 match serde_json::from_str(&encoded) {
8957 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8958 Err(error) => {
8959 dlg.response_json_decode_error(&encoded, &error);
8960 return Err(common::Error::JsonDecodeError(
8961 encoded.to_string(),
8962 error,
8963 ));
8964 }
8965 }
8966 };
8967
8968 dlg.finished(true);
8969 return Ok(response);
8970 }
8971 }
8972 }
8973 }
8974
8975 /// Required. Identifier of the course.
8976 ///
8977 /// Sets the *course id* path property to the given value.
8978 ///
8979 /// Even though the property as already been set when instantiating this call,
8980 /// we provide this method for API completeness.
8981 pub fn course_id(mut self, new_value: &str) -> CourseAnnouncementGetAddOnContextCall<'a, C> {
8982 self._course_id = new_value.to_string();
8983 self
8984 }
8985 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
8986 ///
8987 /// Sets the *item id* path property to the given value.
8988 ///
8989 /// Even though the property as already been set when instantiating this call,
8990 /// we provide this method for API completeness.
8991 pub fn item_id(mut self, new_value: &str) -> CourseAnnouncementGetAddOnContextCall<'a, C> {
8992 self._item_id = new_value.to_string();
8993 self
8994 }
8995 /// Optional. Deprecated, use `item_id` instead.
8996 ///
8997 /// Sets the *post id* query property to the given value.
8998 pub fn post_id(mut self, new_value: &str) -> CourseAnnouncementGetAddOnContextCall<'a, C> {
8999 self._post_id = Some(new_value.to_string());
9000 self
9001 }
9002 /// Optional. The identifier of the attachment. This field is required for all requests except when the user is in the [Attachment Discovery iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/attachment-discovery-iframe).
9003 ///
9004 /// Sets the *attachment id* query property to the given value.
9005 pub fn attachment_id(
9006 mut self,
9007 new_value: &str,
9008 ) -> CourseAnnouncementGetAddOnContextCall<'a, C> {
9009 self._attachment_id = Some(new_value.to_string());
9010 self
9011 }
9012 /// Optional. Token that authorizes the request. The token is passed as a query parameter when the user is redirected from Classroom to the add-on's URL. The authorization token is required when neither of the following is true: * The add-on has attachments on the post. * The developer project issuing the request is the same project that created the post.
9013 ///
9014 /// Sets the *add on token* query property to the given value.
9015 pub fn add_on_token(mut self, new_value: &str) -> CourseAnnouncementGetAddOnContextCall<'a, C> {
9016 self._add_on_token = Some(new_value.to_string());
9017 self
9018 }
9019 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9020 /// while executing the actual API request.
9021 ///
9022 /// ````text
9023 /// It should be used to handle progress information, and to implement a certain level of resilience.
9024 /// ````
9025 ///
9026 /// Sets the *delegate* property to the given value.
9027 pub fn delegate(
9028 mut self,
9029 new_value: &'a mut dyn common::Delegate,
9030 ) -> CourseAnnouncementGetAddOnContextCall<'a, C> {
9031 self._delegate = Some(new_value);
9032 self
9033 }
9034
9035 /// Set any additional parameter of the query string used in the request.
9036 /// It should be used to set parameters which are not yet available through their own
9037 /// setters.
9038 ///
9039 /// Please note that this method must not be used to set any of the known parameters
9040 /// which have their own setter method. If done anyway, the request will fail.
9041 ///
9042 /// # Additional Parameters
9043 ///
9044 /// * *$.xgafv* (query-string) - V1 error format.
9045 /// * *access_token* (query-string) - OAuth access token.
9046 /// * *alt* (query-string) - Data format for response.
9047 /// * *callback* (query-string) - JSONP
9048 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9049 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9050 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9051 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9052 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9053 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9054 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9055 pub fn param<T>(mut self, name: T, value: T) -> CourseAnnouncementGetAddOnContextCall<'a, C>
9056 where
9057 T: AsRef<str>,
9058 {
9059 self._additional_params
9060 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9061 self
9062 }
9063
9064 /// Identifies the authorization scope for the method you are building.
9065 ///
9066 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9067 /// [`Scope::AddonStudent`].
9068 ///
9069 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9070 /// tokens for more than one scope.
9071 ///
9072 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9073 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9074 /// sufficient, a read-write scope will do as well.
9075 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementGetAddOnContextCall<'a, C>
9076 where
9077 St: AsRef<str>,
9078 {
9079 self._scopes.insert(String::from(scope.as_ref()));
9080 self
9081 }
9082 /// Identifies the authorization scope(s) for the method you are building.
9083 ///
9084 /// See [`Self::add_scope()`] for details.
9085 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAnnouncementGetAddOnContextCall<'a, C>
9086 where
9087 I: IntoIterator<Item = St>,
9088 St: AsRef<str>,
9089 {
9090 self._scopes
9091 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9092 self
9093 }
9094
9095 /// Removes all scopes, and no default scope will be used either.
9096 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9097 /// for details).
9098 pub fn clear_scopes(mut self) -> CourseAnnouncementGetAddOnContextCall<'a, C> {
9099 self._scopes.clear();
9100 self
9101 }
9102}
9103
9104/// Returns a list of announcements that the requester is permitted to view. Course students may only view `PUBLISHED` announcements. Course teachers and domain administrators may view all announcements. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
9105///
9106/// A builder for the *announcements.list* method supported by a *course* resource.
9107/// It is not used directly, but through a [`CourseMethods`] instance.
9108///
9109/// # Example
9110///
9111/// Instantiate a resource method builder
9112///
9113/// ```test_harness,no_run
9114/// # extern crate hyper;
9115/// # extern crate hyper_rustls;
9116/// # extern crate google_classroom1 as classroom1;
9117/// # async fn dox() {
9118/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9119///
9120/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9121/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9122/// # .with_native_roots()
9123/// # .unwrap()
9124/// # .https_only()
9125/// # .enable_http2()
9126/// # .build();
9127///
9128/// # let executor = hyper_util::rt::TokioExecutor::new();
9129/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9130/// # secret,
9131/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9132/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9133/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9134/// # ),
9135/// # ).build().await.unwrap();
9136///
9137/// # let client = hyper_util::client::legacy::Client::builder(
9138/// # hyper_util::rt::TokioExecutor::new()
9139/// # )
9140/// # .build(
9141/// # hyper_rustls::HttpsConnectorBuilder::new()
9142/// # .with_native_roots()
9143/// # .unwrap()
9144/// # .https_or_http()
9145/// # .enable_http2()
9146/// # .build()
9147/// # );
9148/// # let mut hub = Classroom::new(client, auth);
9149/// // You can configure optional parameters by calling the respective setters at will, and
9150/// // execute the final call using `doit()`.
9151/// // Values shown here are possibly random and not representative !
9152/// let result = hub.courses().announcements_list("courseId")
9153/// .page_token("et")
9154/// .page_size(-28)
9155/// .order_by("amet.")
9156/// .add_announcement_states("consetetur")
9157/// .doit().await;
9158/// # }
9159/// ```
9160pub struct CourseAnnouncementListCall<'a, C>
9161where
9162 C: 'a,
9163{
9164 hub: &'a Classroom<C>,
9165 _course_id: String,
9166 _page_token: Option<String>,
9167 _page_size: Option<i32>,
9168 _order_by: Option<String>,
9169 _announcement_states: Vec<String>,
9170 _delegate: Option<&'a mut dyn common::Delegate>,
9171 _additional_params: HashMap<String, String>,
9172 _scopes: BTreeSet<String>,
9173}
9174
9175impl<'a, C> common::CallBuilder for CourseAnnouncementListCall<'a, C> {}
9176
9177impl<'a, C> CourseAnnouncementListCall<'a, C>
9178where
9179 C: common::Connector,
9180{
9181 /// Perform the operation you have build so far.
9182 pub async fn doit(mut self) -> common::Result<(common::Response, ListAnnouncementsResponse)> {
9183 use std::borrow::Cow;
9184 use std::io::{Read, Seek};
9185
9186 use common::{url::Params, ToParts};
9187 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9188
9189 let mut dd = common::DefaultDelegate;
9190 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9191 dlg.begin(common::MethodInfo {
9192 id: "classroom.courses.announcements.list",
9193 http_method: hyper::Method::GET,
9194 });
9195
9196 for &field in [
9197 "alt",
9198 "courseId",
9199 "pageToken",
9200 "pageSize",
9201 "orderBy",
9202 "announcementStates",
9203 ]
9204 .iter()
9205 {
9206 if self._additional_params.contains_key(field) {
9207 dlg.finished(false);
9208 return Err(common::Error::FieldClash(field));
9209 }
9210 }
9211
9212 let mut params = Params::with_capacity(7 + self._additional_params.len());
9213 params.push("courseId", self._course_id);
9214 if let Some(value) = self._page_token.as_ref() {
9215 params.push("pageToken", value);
9216 }
9217 if let Some(value) = self._page_size.as_ref() {
9218 params.push("pageSize", value.to_string());
9219 }
9220 if let Some(value) = self._order_by.as_ref() {
9221 params.push("orderBy", value);
9222 }
9223 if !self._announcement_states.is_empty() {
9224 for f in self._announcement_states.iter() {
9225 params.push("announcementStates", f);
9226 }
9227 }
9228
9229 params.extend(self._additional_params.iter());
9230
9231 params.push("alt", "json");
9232 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/announcements";
9233 if self._scopes.is_empty() {
9234 self._scopes
9235 .insert(Scope::AnnouncementReadonly.as_ref().to_string());
9236 }
9237
9238 #[allow(clippy::single_element_loop)]
9239 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
9240 url = params.uri_replacement(url, param_name, find_this, false);
9241 }
9242 {
9243 let to_remove = ["courseId"];
9244 params.remove_params(&to_remove);
9245 }
9246
9247 let url = params.parse_with_url(&url);
9248
9249 loop {
9250 let token = match self
9251 .hub
9252 .auth
9253 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9254 .await
9255 {
9256 Ok(token) => token,
9257 Err(e) => match dlg.token(e) {
9258 Ok(token) => token,
9259 Err(e) => {
9260 dlg.finished(false);
9261 return Err(common::Error::MissingToken(e));
9262 }
9263 },
9264 };
9265 let mut req_result = {
9266 let client = &self.hub.client;
9267 dlg.pre_request();
9268 let mut req_builder = hyper::Request::builder()
9269 .method(hyper::Method::GET)
9270 .uri(url.as_str())
9271 .header(USER_AGENT, self.hub._user_agent.clone());
9272
9273 if let Some(token) = token.as_ref() {
9274 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9275 }
9276
9277 let request = req_builder
9278 .header(CONTENT_LENGTH, 0_u64)
9279 .body(common::to_body::<String>(None));
9280
9281 client.request(request.unwrap()).await
9282 };
9283
9284 match req_result {
9285 Err(err) => {
9286 if let common::Retry::After(d) = dlg.http_error(&err) {
9287 sleep(d).await;
9288 continue;
9289 }
9290 dlg.finished(false);
9291 return Err(common::Error::HttpError(err));
9292 }
9293 Ok(res) => {
9294 let (mut parts, body) = res.into_parts();
9295 let mut body = common::Body::new(body);
9296 if !parts.status.is_success() {
9297 let bytes = common::to_bytes(body).await.unwrap_or_default();
9298 let error = serde_json::from_str(&common::to_string(&bytes));
9299 let response = common::to_response(parts, bytes.into());
9300
9301 if let common::Retry::After(d) =
9302 dlg.http_failure(&response, error.as_ref().ok())
9303 {
9304 sleep(d).await;
9305 continue;
9306 }
9307
9308 dlg.finished(false);
9309
9310 return Err(match error {
9311 Ok(value) => common::Error::BadRequest(value),
9312 _ => common::Error::Failure(response),
9313 });
9314 }
9315 let response = {
9316 let bytes = common::to_bytes(body).await.unwrap_or_default();
9317 let encoded = common::to_string(&bytes);
9318 match serde_json::from_str(&encoded) {
9319 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9320 Err(error) => {
9321 dlg.response_json_decode_error(&encoded, &error);
9322 return Err(common::Error::JsonDecodeError(
9323 encoded.to_string(),
9324 error,
9325 ));
9326 }
9327 }
9328 };
9329
9330 dlg.finished(true);
9331 return Ok(response);
9332 }
9333 }
9334 }
9335 }
9336
9337 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
9338 ///
9339 /// Sets the *course id* path property to the given value.
9340 ///
9341 /// Even though the property as already been set when instantiating this call,
9342 /// we provide this method for API completeness.
9343 pub fn course_id(mut self, new_value: &str) -> CourseAnnouncementListCall<'a, C> {
9344 self._course_id = new_value.to_string();
9345 self
9346 }
9347 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
9348 ///
9349 /// Sets the *page token* query property to the given value.
9350 pub fn page_token(mut self, new_value: &str) -> CourseAnnouncementListCall<'a, C> {
9351 self._page_token = Some(new_value.to_string());
9352 self
9353 }
9354 /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.
9355 ///
9356 /// Sets the *page size* query property to the given value.
9357 pub fn page_size(mut self, new_value: i32) -> CourseAnnouncementListCall<'a, C> {
9358 self._page_size = Some(new_value);
9359 self
9360 }
9361 /// Optional sort ordering for results. A comma-separated list of fields with an optional sort direction keyword. Supported field is `updateTime`. Supported direction keywords are `asc` and `desc`. If not specified, `updateTime desc` is the default behavior. Examples: `updateTime asc`, `updateTime`
9362 ///
9363 /// Sets the *order by* query property to the given value.
9364 pub fn order_by(mut self, new_value: &str) -> CourseAnnouncementListCall<'a, C> {
9365 self._order_by = Some(new_value.to_string());
9366 self
9367 }
9368 /// Restriction on the `state` of announcements returned. If this argument is left unspecified, the default value is `PUBLISHED`.
9369 ///
9370 /// Append the given value to the *announcement states* query property.
9371 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9372 pub fn add_announcement_states(mut self, new_value: &str) -> CourseAnnouncementListCall<'a, C> {
9373 self._announcement_states.push(new_value.to_string());
9374 self
9375 }
9376 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9377 /// while executing the actual API request.
9378 ///
9379 /// ````text
9380 /// It should be used to handle progress information, and to implement a certain level of resilience.
9381 /// ````
9382 ///
9383 /// Sets the *delegate* property to the given value.
9384 pub fn delegate(
9385 mut self,
9386 new_value: &'a mut dyn common::Delegate,
9387 ) -> CourseAnnouncementListCall<'a, C> {
9388 self._delegate = Some(new_value);
9389 self
9390 }
9391
9392 /// Set any additional parameter of the query string used in the request.
9393 /// It should be used to set parameters which are not yet available through their own
9394 /// setters.
9395 ///
9396 /// Please note that this method must not be used to set any of the known parameters
9397 /// which have their own setter method. If done anyway, the request will fail.
9398 ///
9399 /// # Additional Parameters
9400 ///
9401 /// * *$.xgafv* (query-string) - V1 error format.
9402 /// * *access_token* (query-string) - OAuth access token.
9403 /// * *alt* (query-string) - Data format for response.
9404 /// * *callback* (query-string) - JSONP
9405 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9406 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9407 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9408 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9409 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9410 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9411 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9412 pub fn param<T>(mut self, name: T, value: T) -> CourseAnnouncementListCall<'a, C>
9413 where
9414 T: AsRef<str>,
9415 {
9416 self._additional_params
9417 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9418 self
9419 }
9420
9421 /// Identifies the authorization scope for the method you are building.
9422 ///
9423 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9424 /// [`Scope::AnnouncementReadonly`].
9425 ///
9426 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9427 /// tokens for more than one scope.
9428 ///
9429 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9430 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9431 /// sufficient, a read-write scope will do as well.
9432 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementListCall<'a, C>
9433 where
9434 St: AsRef<str>,
9435 {
9436 self._scopes.insert(String::from(scope.as_ref()));
9437 self
9438 }
9439 /// Identifies the authorization scope(s) for the method you are building.
9440 ///
9441 /// See [`Self::add_scope()`] for details.
9442 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAnnouncementListCall<'a, C>
9443 where
9444 I: IntoIterator<Item = St>,
9445 St: AsRef<str>,
9446 {
9447 self._scopes
9448 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9449 self
9450 }
9451
9452 /// Removes all scopes, and no default scope will be used either.
9453 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9454 /// for details).
9455 pub fn clear_scopes(mut self) -> CourseAnnouncementListCall<'a, C> {
9456 self._scopes.clear();
9457 self
9458 }
9459}
9460
9461/// Modifies assignee mode and options of an announcement. Only a teacher of the course that contains the announcement may call this method. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work does not exist. * `FAILED_PRECONDITION` for the following request error: * EmptyAssignees
9462///
9463/// A builder for the *announcements.modifyAssignees* method supported by a *course* resource.
9464/// It is not used directly, but through a [`CourseMethods`] instance.
9465///
9466/// # Example
9467///
9468/// Instantiate a resource method builder
9469///
9470/// ```test_harness,no_run
9471/// # extern crate hyper;
9472/// # extern crate hyper_rustls;
9473/// # extern crate google_classroom1 as classroom1;
9474/// use classroom1::api::ModifyAnnouncementAssigneesRequest;
9475/// # async fn dox() {
9476/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9477///
9478/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9479/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9480/// # .with_native_roots()
9481/// # .unwrap()
9482/// # .https_only()
9483/// # .enable_http2()
9484/// # .build();
9485///
9486/// # let executor = hyper_util::rt::TokioExecutor::new();
9487/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9488/// # secret,
9489/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9490/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9491/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9492/// # ),
9493/// # ).build().await.unwrap();
9494///
9495/// # let client = hyper_util::client::legacy::Client::builder(
9496/// # hyper_util::rt::TokioExecutor::new()
9497/// # )
9498/// # .build(
9499/// # hyper_rustls::HttpsConnectorBuilder::new()
9500/// # .with_native_roots()
9501/// # .unwrap()
9502/// # .https_or_http()
9503/// # .enable_http2()
9504/// # .build()
9505/// # );
9506/// # let mut hub = Classroom::new(client, auth);
9507/// // As the method needs a request, you would usually fill it with the desired information
9508/// // into the respective structure. Some of the parts shown here might not be applicable !
9509/// // Values shown here are possibly random and not representative !
9510/// let mut req = ModifyAnnouncementAssigneesRequest::default();
9511///
9512/// // You can configure optional parameters by calling the respective setters at will, and
9513/// // execute the final call using `doit()`.
9514/// // Values shown here are possibly random and not representative !
9515/// let result = hub.courses().announcements_modify_assignees(req, "courseId", "id")
9516/// .doit().await;
9517/// # }
9518/// ```
9519pub struct CourseAnnouncementModifyAssigneeCall<'a, C>
9520where
9521 C: 'a,
9522{
9523 hub: &'a Classroom<C>,
9524 _request: ModifyAnnouncementAssigneesRequest,
9525 _course_id: String,
9526 _id: String,
9527 _delegate: Option<&'a mut dyn common::Delegate>,
9528 _additional_params: HashMap<String, String>,
9529 _scopes: BTreeSet<String>,
9530}
9531
9532impl<'a, C> common::CallBuilder for CourseAnnouncementModifyAssigneeCall<'a, C> {}
9533
9534impl<'a, C> CourseAnnouncementModifyAssigneeCall<'a, C>
9535where
9536 C: common::Connector,
9537{
9538 /// Perform the operation you have build so far.
9539 pub async fn doit(mut self) -> common::Result<(common::Response, Announcement)> {
9540 use std::borrow::Cow;
9541 use std::io::{Read, Seek};
9542
9543 use common::{url::Params, ToParts};
9544 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9545
9546 let mut dd = common::DefaultDelegate;
9547 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9548 dlg.begin(common::MethodInfo {
9549 id: "classroom.courses.announcements.modifyAssignees",
9550 http_method: hyper::Method::POST,
9551 });
9552
9553 for &field in ["alt", "courseId", "id"].iter() {
9554 if self._additional_params.contains_key(field) {
9555 dlg.finished(false);
9556 return Err(common::Error::FieldClash(field));
9557 }
9558 }
9559
9560 let mut params = Params::with_capacity(5 + self._additional_params.len());
9561 params.push("courseId", self._course_id);
9562 params.push("id", self._id);
9563
9564 params.extend(self._additional_params.iter());
9565
9566 params.push("alt", "json");
9567 let mut url =
9568 self.hub._base_url.clone() + "v1/courses/{courseId}/announcements/{id}:modifyAssignees";
9569 if self._scopes.is_empty() {
9570 self._scopes
9571 .insert(Scope::Announcement.as_ref().to_string());
9572 }
9573
9574 #[allow(clippy::single_element_loop)]
9575 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
9576 url = params.uri_replacement(url, param_name, find_this, false);
9577 }
9578 {
9579 let to_remove = ["id", "courseId"];
9580 params.remove_params(&to_remove);
9581 }
9582
9583 let url = params.parse_with_url(&url);
9584
9585 let mut json_mime_type = mime::APPLICATION_JSON;
9586 let mut request_value_reader = {
9587 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9588 common::remove_json_null_values(&mut value);
9589 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9590 serde_json::to_writer(&mut dst, &value).unwrap();
9591 dst
9592 };
9593 let request_size = request_value_reader
9594 .seek(std::io::SeekFrom::End(0))
9595 .unwrap();
9596 request_value_reader
9597 .seek(std::io::SeekFrom::Start(0))
9598 .unwrap();
9599
9600 loop {
9601 let token = match self
9602 .hub
9603 .auth
9604 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9605 .await
9606 {
9607 Ok(token) => token,
9608 Err(e) => match dlg.token(e) {
9609 Ok(token) => token,
9610 Err(e) => {
9611 dlg.finished(false);
9612 return Err(common::Error::MissingToken(e));
9613 }
9614 },
9615 };
9616 request_value_reader
9617 .seek(std::io::SeekFrom::Start(0))
9618 .unwrap();
9619 let mut req_result = {
9620 let client = &self.hub.client;
9621 dlg.pre_request();
9622 let mut req_builder = hyper::Request::builder()
9623 .method(hyper::Method::POST)
9624 .uri(url.as_str())
9625 .header(USER_AGENT, self.hub._user_agent.clone());
9626
9627 if let Some(token) = token.as_ref() {
9628 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9629 }
9630
9631 let request = req_builder
9632 .header(CONTENT_TYPE, json_mime_type.to_string())
9633 .header(CONTENT_LENGTH, request_size as u64)
9634 .body(common::to_body(
9635 request_value_reader.get_ref().clone().into(),
9636 ));
9637
9638 client.request(request.unwrap()).await
9639 };
9640
9641 match req_result {
9642 Err(err) => {
9643 if let common::Retry::After(d) = dlg.http_error(&err) {
9644 sleep(d).await;
9645 continue;
9646 }
9647 dlg.finished(false);
9648 return Err(common::Error::HttpError(err));
9649 }
9650 Ok(res) => {
9651 let (mut parts, body) = res.into_parts();
9652 let mut body = common::Body::new(body);
9653 if !parts.status.is_success() {
9654 let bytes = common::to_bytes(body).await.unwrap_or_default();
9655 let error = serde_json::from_str(&common::to_string(&bytes));
9656 let response = common::to_response(parts, bytes.into());
9657
9658 if let common::Retry::After(d) =
9659 dlg.http_failure(&response, error.as_ref().ok())
9660 {
9661 sleep(d).await;
9662 continue;
9663 }
9664
9665 dlg.finished(false);
9666
9667 return Err(match error {
9668 Ok(value) => common::Error::BadRequest(value),
9669 _ => common::Error::Failure(response),
9670 });
9671 }
9672 let response = {
9673 let bytes = common::to_bytes(body).await.unwrap_or_default();
9674 let encoded = common::to_string(&bytes);
9675 match serde_json::from_str(&encoded) {
9676 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9677 Err(error) => {
9678 dlg.response_json_decode_error(&encoded, &error);
9679 return Err(common::Error::JsonDecodeError(
9680 encoded.to_string(),
9681 error,
9682 ));
9683 }
9684 }
9685 };
9686
9687 dlg.finished(true);
9688 return Ok(response);
9689 }
9690 }
9691 }
9692 }
9693
9694 ///
9695 /// Sets the *request* property to the given value.
9696 ///
9697 /// Even though the property as already been set when instantiating this call,
9698 /// we provide this method for API completeness.
9699 pub fn request(
9700 mut self,
9701 new_value: ModifyAnnouncementAssigneesRequest,
9702 ) -> CourseAnnouncementModifyAssigneeCall<'a, C> {
9703 self._request = new_value;
9704 self
9705 }
9706 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
9707 ///
9708 /// Sets the *course id* path property to the given value.
9709 ///
9710 /// Even though the property as already been set when instantiating this call,
9711 /// we provide this method for API completeness.
9712 pub fn course_id(mut self, new_value: &str) -> CourseAnnouncementModifyAssigneeCall<'a, C> {
9713 self._course_id = new_value.to_string();
9714 self
9715 }
9716 /// Identifier of the announcement.
9717 ///
9718 /// Sets the *id* path property to the given value.
9719 ///
9720 /// Even though the property as already been set when instantiating this call,
9721 /// we provide this method for API completeness.
9722 pub fn id(mut self, new_value: &str) -> CourseAnnouncementModifyAssigneeCall<'a, C> {
9723 self._id = new_value.to_string();
9724 self
9725 }
9726 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9727 /// while executing the actual API request.
9728 ///
9729 /// ````text
9730 /// It should be used to handle progress information, and to implement a certain level of resilience.
9731 /// ````
9732 ///
9733 /// Sets the *delegate* property to the given value.
9734 pub fn delegate(
9735 mut self,
9736 new_value: &'a mut dyn common::Delegate,
9737 ) -> CourseAnnouncementModifyAssigneeCall<'a, C> {
9738 self._delegate = Some(new_value);
9739 self
9740 }
9741
9742 /// Set any additional parameter of the query string used in the request.
9743 /// It should be used to set parameters which are not yet available through their own
9744 /// setters.
9745 ///
9746 /// Please note that this method must not be used to set any of the known parameters
9747 /// which have their own setter method. If done anyway, the request will fail.
9748 ///
9749 /// # Additional Parameters
9750 ///
9751 /// * *$.xgafv* (query-string) - V1 error format.
9752 /// * *access_token* (query-string) - OAuth access token.
9753 /// * *alt* (query-string) - Data format for response.
9754 /// * *callback* (query-string) - JSONP
9755 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9756 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9757 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9758 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9759 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9760 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9761 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9762 pub fn param<T>(mut self, name: T, value: T) -> CourseAnnouncementModifyAssigneeCall<'a, C>
9763 where
9764 T: AsRef<str>,
9765 {
9766 self._additional_params
9767 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9768 self
9769 }
9770
9771 /// Identifies the authorization scope for the method you are building.
9772 ///
9773 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9774 /// [`Scope::Announcement`].
9775 ///
9776 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9777 /// tokens for more than one scope.
9778 ///
9779 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9780 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9781 /// sufficient, a read-write scope will do as well.
9782 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementModifyAssigneeCall<'a, C>
9783 where
9784 St: AsRef<str>,
9785 {
9786 self._scopes.insert(String::from(scope.as_ref()));
9787 self
9788 }
9789 /// Identifies the authorization scope(s) for the method you are building.
9790 ///
9791 /// See [`Self::add_scope()`] for details.
9792 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAnnouncementModifyAssigneeCall<'a, C>
9793 where
9794 I: IntoIterator<Item = St>,
9795 St: AsRef<str>,
9796 {
9797 self._scopes
9798 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9799 self
9800 }
9801
9802 /// Removes all scopes, and no default scope will be used either.
9803 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9804 /// for details).
9805 pub fn clear_scopes(mut self) -> CourseAnnouncementModifyAssigneeCall<'a, C> {
9806 self._scopes.clear();
9807 self
9808 }
9809}
9810
9811/// Updates one or more fields of an announcement. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding announcement or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if the requested announcement has already been deleted. * `NOT_FOUND` if the requested course or announcement does not exist
9812///
9813/// A builder for the *announcements.patch* method supported by a *course* resource.
9814/// It is not used directly, but through a [`CourseMethods`] instance.
9815///
9816/// # Example
9817///
9818/// Instantiate a resource method builder
9819///
9820/// ```test_harness,no_run
9821/// # extern crate hyper;
9822/// # extern crate hyper_rustls;
9823/// # extern crate google_classroom1 as classroom1;
9824/// use classroom1::api::Announcement;
9825/// # async fn dox() {
9826/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9827///
9828/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9829/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9830/// # .with_native_roots()
9831/// # .unwrap()
9832/// # .https_only()
9833/// # .enable_http2()
9834/// # .build();
9835///
9836/// # let executor = hyper_util::rt::TokioExecutor::new();
9837/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9838/// # secret,
9839/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9840/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9841/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9842/// # ),
9843/// # ).build().await.unwrap();
9844///
9845/// # let client = hyper_util::client::legacy::Client::builder(
9846/// # hyper_util::rt::TokioExecutor::new()
9847/// # )
9848/// # .build(
9849/// # hyper_rustls::HttpsConnectorBuilder::new()
9850/// # .with_native_roots()
9851/// # .unwrap()
9852/// # .https_or_http()
9853/// # .enable_http2()
9854/// # .build()
9855/// # );
9856/// # let mut hub = Classroom::new(client, auth);
9857/// // As the method needs a request, you would usually fill it with the desired information
9858/// // into the respective structure. Some of the parts shown here might not be applicable !
9859/// // Values shown here are possibly random and not representative !
9860/// let mut req = Announcement::default();
9861///
9862/// // You can configure optional parameters by calling the respective setters at will, and
9863/// // execute the final call using `doit()`.
9864/// // Values shown here are possibly random and not representative !
9865/// let result = hub.courses().announcements_patch(req, "courseId", "id")
9866/// .update_mask(FieldMask::new::<&str>(&[]))
9867/// .doit().await;
9868/// # }
9869/// ```
9870pub struct CourseAnnouncementPatchCall<'a, C>
9871where
9872 C: 'a,
9873{
9874 hub: &'a Classroom<C>,
9875 _request: Announcement,
9876 _course_id: String,
9877 _id: String,
9878 _update_mask: Option<common::FieldMask>,
9879 _delegate: Option<&'a mut dyn common::Delegate>,
9880 _additional_params: HashMap<String, String>,
9881 _scopes: BTreeSet<String>,
9882}
9883
9884impl<'a, C> common::CallBuilder for CourseAnnouncementPatchCall<'a, C> {}
9885
9886impl<'a, C> CourseAnnouncementPatchCall<'a, C>
9887where
9888 C: common::Connector,
9889{
9890 /// Perform the operation you have build so far.
9891 pub async fn doit(mut self) -> common::Result<(common::Response, Announcement)> {
9892 use std::borrow::Cow;
9893 use std::io::{Read, Seek};
9894
9895 use common::{url::Params, ToParts};
9896 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9897
9898 let mut dd = common::DefaultDelegate;
9899 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9900 dlg.begin(common::MethodInfo {
9901 id: "classroom.courses.announcements.patch",
9902 http_method: hyper::Method::PATCH,
9903 });
9904
9905 for &field in ["alt", "courseId", "id", "updateMask"].iter() {
9906 if self._additional_params.contains_key(field) {
9907 dlg.finished(false);
9908 return Err(common::Error::FieldClash(field));
9909 }
9910 }
9911
9912 let mut params = Params::with_capacity(6 + self._additional_params.len());
9913 params.push("courseId", self._course_id);
9914 params.push("id", self._id);
9915 if let Some(value) = self._update_mask.as_ref() {
9916 params.push("updateMask", value.to_string());
9917 }
9918
9919 params.extend(self._additional_params.iter());
9920
9921 params.push("alt", "json");
9922 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/announcements/{id}";
9923 if self._scopes.is_empty() {
9924 self._scopes
9925 .insert(Scope::Announcement.as_ref().to_string());
9926 }
9927
9928 #[allow(clippy::single_element_loop)]
9929 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
9930 url = params.uri_replacement(url, param_name, find_this, false);
9931 }
9932 {
9933 let to_remove = ["id", "courseId"];
9934 params.remove_params(&to_remove);
9935 }
9936
9937 let url = params.parse_with_url(&url);
9938
9939 let mut json_mime_type = mime::APPLICATION_JSON;
9940 let mut request_value_reader = {
9941 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9942 common::remove_json_null_values(&mut value);
9943 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9944 serde_json::to_writer(&mut dst, &value).unwrap();
9945 dst
9946 };
9947 let request_size = request_value_reader
9948 .seek(std::io::SeekFrom::End(0))
9949 .unwrap();
9950 request_value_reader
9951 .seek(std::io::SeekFrom::Start(0))
9952 .unwrap();
9953
9954 loop {
9955 let token = match self
9956 .hub
9957 .auth
9958 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9959 .await
9960 {
9961 Ok(token) => token,
9962 Err(e) => match dlg.token(e) {
9963 Ok(token) => token,
9964 Err(e) => {
9965 dlg.finished(false);
9966 return Err(common::Error::MissingToken(e));
9967 }
9968 },
9969 };
9970 request_value_reader
9971 .seek(std::io::SeekFrom::Start(0))
9972 .unwrap();
9973 let mut req_result = {
9974 let client = &self.hub.client;
9975 dlg.pre_request();
9976 let mut req_builder = hyper::Request::builder()
9977 .method(hyper::Method::PATCH)
9978 .uri(url.as_str())
9979 .header(USER_AGENT, self.hub._user_agent.clone());
9980
9981 if let Some(token) = token.as_ref() {
9982 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9983 }
9984
9985 let request = req_builder
9986 .header(CONTENT_TYPE, json_mime_type.to_string())
9987 .header(CONTENT_LENGTH, request_size as u64)
9988 .body(common::to_body(
9989 request_value_reader.get_ref().clone().into(),
9990 ));
9991
9992 client.request(request.unwrap()).await
9993 };
9994
9995 match req_result {
9996 Err(err) => {
9997 if let common::Retry::After(d) = dlg.http_error(&err) {
9998 sleep(d).await;
9999 continue;
10000 }
10001 dlg.finished(false);
10002 return Err(common::Error::HttpError(err));
10003 }
10004 Ok(res) => {
10005 let (mut parts, body) = res.into_parts();
10006 let mut body = common::Body::new(body);
10007 if !parts.status.is_success() {
10008 let bytes = common::to_bytes(body).await.unwrap_or_default();
10009 let error = serde_json::from_str(&common::to_string(&bytes));
10010 let response = common::to_response(parts, bytes.into());
10011
10012 if let common::Retry::After(d) =
10013 dlg.http_failure(&response, error.as_ref().ok())
10014 {
10015 sleep(d).await;
10016 continue;
10017 }
10018
10019 dlg.finished(false);
10020
10021 return Err(match error {
10022 Ok(value) => common::Error::BadRequest(value),
10023 _ => common::Error::Failure(response),
10024 });
10025 }
10026 let response = {
10027 let bytes = common::to_bytes(body).await.unwrap_or_default();
10028 let encoded = common::to_string(&bytes);
10029 match serde_json::from_str(&encoded) {
10030 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10031 Err(error) => {
10032 dlg.response_json_decode_error(&encoded, &error);
10033 return Err(common::Error::JsonDecodeError(
10034 encoded.to_string(),
10035 error,
10036 ));
10037 }
10038 }
10039 };
10040
10041 dlg.finished(true);
10042 return Ok(response);
10043 }
10044 }
10045 }
10046 }
10047
10048 ///
10049 /// Sets the *request* property to the given value.
10050 ///
10051 /// Even though the property as already been set when instantiating this call,
10052 /// we provide this method for API completeness.
10053 pub fn request(mut self, new_value: Announcement) -> CourseAnnouncementPatchCall<'a, C> {
10054 self._request = new_value;
10055 self
10056 }
10057 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
10058 ///
10059 /// Sets the *course id* path property to the given value.
10060 ///
10061 /// Even though the property as already been set when instantiating this call,
10062 /// we provide this method for API completeness.
10063 pub fn course_id(mut self, new_value: &str) -> CourseAnnouncementPatchCall<'a, C> {
10064 self._course_id = new_value.to_string();
10065 self
10066 }
10067 /// Identifier of the announcement.
10068 ///
10069 /// Sets the *id* path property to the given value.
10070 ///
10071 /// Even though the property as already been set when instantiating this call,
10072 /// we provide this method for API completeness.
10073 pub fn id(mut self, new_value: &str) -> CourseAnnouncementPatchCall<'a, C> {
10074 self._id = new_value.to_string();
10075 self
10076 }
10077 /// Mask that identifies which fields on the announcement to update. This field is required to do an update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the Announcement object. If a field that does not support empty values is included in the update mask and not set in the Announcement object, an `INVALID_ARGUMENT` error is returned. The following fields may be specified by teachers: * `text` * `state` * `scheduled_time`
10078 ///
10079 /// Sets the *update mask* query property to the given value.
10080 pub fn update_mask(
10081 mut self,
10082 new_value: common::FieldMask,
10083 ) -> CourseAnnouncementPatchCall<'a, C> {
10084 self._update_mask = Some(new_value);
10085 self
10086 }
10087 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10088 /// while executing the actual API request.
10089 ///
10090 /// ````text
10091 /// It should be used to handle progress information, and to implement a certain level of resilience.
10092 /// ````
10093 ///
10094 /// Sets the *delegate* property to the given value.
10095 pub fn delegate(
10096 mut self,
10097 new_value: &'a mut dyn common::Delegate,
10098 ) -> CourseAnnouncementPatchCall<'a, C> {
10099 self._delegate = Some(new_value);
10100 self
10101 }
10102
10103 /// Set any additional parameter of the query string used in the request.
10104 /// It should be used to set parameters which are not yet available through their own
10105 /// setters.
10106 ///
10107 /// Please note that this method must not be used to set any of the known parameters
10108 /// which have their own setter method. If done anyway, the request will fail.
10109 ///
10110 /// # Additional Parameters
10111 ///
10112 /// * *$.xgafv* (query-string) - V1 error format.
10113 /// * *access_token* (query-string) - OAuth access token.
10114 /// * *alt* (query-string) - Data format for response.
10115 /// * *callback* (query-string) - JSONP
10116 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10117 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10118 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10119 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10120 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10121 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10122 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10123 pub fn param<T>(mut self, name: T, value: T) -> CourseAnnouncementPatchCall<'a, C>
10124 where
10125 T: AsRef<str>,
10126 {
10127 self._additional_params
10128 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10129 self
10130 }
10131
10132 /// Identifies the authorization scope for the method you are building.
10133 ///
10134 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10135 /// [`Scope::Announcement`].
10136 ///
10137 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10138 /// tokens for more than one scope.
10139 ///
10140 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10141 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10142 /// sufficient, a read-write scope will do as well.
10143 pub fn add_scope<St>(mut self, scope: St) -> CourseAnnouncementPatchCall<'a, C>
10144 where
10145 St: AsRef<str>,
10146 {
10147 self._scopes.insert(String::from(scope.as_ref()));
10148 self
10149 }
10150 /// Identifies the authorization scope(s) for the method you are building.
10151 ///
10152 /// See [`Self::add_scope()`] for details.
10153 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseAnnouncementPatchCall<'a, C>
10154 where
10155 I: IntoIterator<Item = St>,
10156 St: AsRef<str>,
10157 {
10158 self._scopes
10159 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10160 self
10161 }
10162
10163 /// Removes all scopes, and no default scope will be used either.
10164 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10165 /// for details).
10166 pub fn clear_scopes(mut self) -> CourseAnnouncementPatchCall<'a, C> {
10167 self._scopes.clear();
10168 self
10169 }
10170}
10171
10172/// Returns a student submission for an add-on attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
10173///
10174/// A builder for the *courseWork.addOnAttachments.studentSubmissions.get* method supported by a *course* resource.
10175/// It is not used directly, but through a [`CourseMethods`] instance.
10176///
10177/// # Example
10178///
10179/// Instantiate a resource method builder
10180///
10181/// ```test_harness,no_run
10182/// # extern crate hyper;
10183/// # extern crate hyper_rustls;
10184/// # extern crate google_classroom1 as classroom1;
10185/// # async fn dox() {
10186/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10187///
10188/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10189/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10190/// # .with_native_roots()
10191/// # .unwrap()
10192/// # .https_only()
10193/// # .enable_http2()
10194/// # .build();
10195///
10196/// # let executor = hyper_util::rt::TokioExecutor::new();
10197/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10198/// # secret,
10199/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10200/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10201/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10202/// # ),
10203/// # ).build().await.unwrap();
10204///
10205/// # let client = hyper_util::client::legacy::Client::builder(
10206/// # hyper_util::rt::TokioExecutor::new()
10207/// # )
10208/// # .build(
10209/// # hyper_rustls::HttpsConnectorBuilder::new()
10210/// # .with_native_roots()
10211/// # .unwrap()
10212/// # .https_or_http()
10213/// # .enable_http2()
10214/// # .build()
10215/// # );
10216/// # let mut hub = Classroom::new(client, auth);
10217/// // You can configure optional parameters by calling the respective setters at will, and
10218/// // execute the final call using `doit()`.
10219/// // Values shown here are possibly random and not representative !
10220/// let result = hub.courses().course_work_add_on_attachments_student_submissions_get("courseId", "itemId", "attachmentId", "submissionId")
10221/// .post_id("vero")
10222/// .doit().await;
10223/// # }
10224/// ```
10225pub struct CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C>
10226where
10227 C: 'a,
10228{
10229 hub: &'a Classroom<C>,
10230 _course_id: String,
10231 _item_id: String,
10232 _attachment_id: String,
10233 _submission_id: String,
10234 _post_id: Option<String>,
10235 _delegate: Option<&'a mut dyn common::Delegate>,
10236 _additional_params: HashMap<String, String>,
10237 _scopes: BTreeSet<String>,
10238}
10239
10240impl<'a, C> common::CallBuilder for CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C> {}
10241
10242impl<'a, C> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C>
10243where
10244 C: common::Connector,
10245{
10246 /// Perform the operation you have build so far.
10247 pub async fn doit(
10248 mut self,
10249 ) -> common::Result<(common::Response, AddOnAttachmentStudentSubmission)> {
10250 use std::borrow::Cow;
10251 use std::io::{Read, Seek};
10252
10253 use common::{url::Params, ToParts};
10254 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10255
10256 let mut dd = common::DefaultDelegate;
10257 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10258 dlg.begin(common::MethodInfo {
10259 id: "classroom.courses.courseWork.addOnAttachments.studentSubmissions.get",
10260 http_method: hyper::Method::GET,
10261 });
10262
10263 for &field in [
10264 "alt",
10265 "courseId",
10266 "itemId",
10267 "attachmentId",
10268 "submissionId",
10269 "postId",
10270 ]
10271 .iter()
10272 {
10273 if self._additional_params.contains_key(field) {
10274 dlg.finished(false);
10275 return Err(common::Error::FieldClash(field));
10276 }
10277 }
10278
10279 let mut params = Params::with_capacity(7 + self._additional_params.len());
10280 params.push("courseId", self._course_id);
10281 params.push("itemId", self._item_id);
10282 params.push("attachmentId", self._attachment_id);
10283 params.push("submissionId", self._submission_id);
10284 if let Some(value) = self._post_id.as_ref() {
10285 params.push("postId", value);
10286 }
10287
10288 params.extend(self._additional_params.iter());
10289
10290 params.push("alt", "json");
10291 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{itemId}/addOnAttachments/{attachmentId}/studentSubmissions/{submissionId}";
10292 if self._scopes.is_empty() {
10293 self._scopes
10294 .insert(Scope::StudentSubmissionStudentReadonly.as_ref().to_string());
10295 }
10296
10297 #[allow(clippy::single_element_loop)]
10298 for &(find_this, param_name) in [
10299 ("{courseId}", "courseId"),
10300 ("{itemId}", "itemId"),
10301 ("{attachmentId}", "attachmentId"),
10302 ("{submissionId}", "submissionId"),
10303 ]
10304 .iter()
10305 {
10306 url = params.uri_replacement(url, param_name, find_this, false);
10307 }
10308 {
10309 let to_remove = ["submissionId", "attachmentId", "itemId", "courseId"];
10310 params.remove_params(&to_remove);
10311 }
10312
10313 let url = params.parse_with_url(&url);
10314
10315 loop {
10316 let token = match self
10317 .hub
10318 .auth
10319 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10320 .await
10321 {
10322 Ok(token) => token,
10323 Err(e) => match dlg.token(e) {
10324 Ok(token) => token,
10325 Err(e) => {
10326 dlg.finished(false);
10327 return Err(common::Error::MissingToken(e));
10328 }
10329 },
10330 };
10331 let mut req_result = {
10332 let client = &self.hub.client;
10333 dlg.pre_request();
10334 let mut req_builder = hyper::Request::builder()
10335 .method(hyper::Method::GET)
10336 .uri(url.as_str())
10337 .header(USER_AGENT, self.hub._user_agent.clone());
10338
10339 if let Some(token) = token.as_ref() {
10340 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10341 }
10342
10343 let request = req_builder
10344 .header(CONTENT_LENGTH, 0_u64)
10345 .body(common::to_body::<String>(None));
10346
10347 client.request(request.unwrap()).await
10348 };
10349
10350 match req_result {
10351 Err(err) => {
10352 if let common::Retry::After(d) = dlg.http_error(&err) {
10353 sleep(d).await;
10354 continue;
10355 }
10356 dlg.finished(false);
10357 return Err(common::Error::HttpError(err));
10358 }
10359 Ok(res) => {
10360 let (mut parts, body) = res.into_parts();
10361 let mut body = common::Body::new(body);
10362 if !parts.status.is_success() {
10363 let bytes = common::to_bytes(body).await.unwrap_or_default();
10364 let error = serde_json::from_str(&common::to_string(&bytes));
10365 let response = common::to_response(parts, bytes.into());
10366
10367 if let common::Retry::After(d) =
10368 dlg.http_failure(&response, error.as_ref().ok())
10369 {
10370 sleep(d).await;
10371 continue;
10372 }
10373
10374 dlg.finished(false);
10375
10376 return Err(match error {
10377 Ok(value) => common::Error::BadRequest(value),
10378 _ => common::Error::Failure(response),
10379 });
10380 }
10381 let response = {
10382 let bytes = common::to_bytes(body).await.unwrap_or_default();
10383 let encoded = common::to_string(&bytes);
10384 match serde_json::from_str(&encoded) {
10385 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10386 Err(error) => {
10387 dlg.response_json_decode_error(&encoded, &error);
10388 return Err(common::Error::JsonDecodeError(
10389 encoded.to_string(),
10390 error,
10391 ));
10392 }
10393 }
10394 };
10395
10396 dlg.finished(true);
10397 return Ok(response);
10398 }
10399 }
10400 }
10401 }
10402
10403 /// Required. Identifier of the course.
10404 ///
10405 /// Sets the *course id* path property to the given value.
10406 ///
10407 /// Even though the property as already been set when instantiating this call,
10408 /// we provide this method for API completeness.
10409 pub fn course_id(
10410 mut self,
10411 new_value: &str,
10412 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C> {
10413 self._course_id = new_value.to_string();
10414 self
10415 }
10416 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
10417 ///
10418 /// Sets the *item id* path property to the given value.
10419 ///
10420 /// Even though the property as already been set when instantiating this call,
10421 /// we provide this method for API completeness.
10422 pub fn item_id(
10423 mut self,
10424 new_value: &str,
10425 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C> {
10426 self._item_id = new_value.to_string();
10427 self
10428 }
10429 /// Required. Identifier of the attachment.
10430 ///
10431 /// Sets the *attachment id* path property to the given value.
10432 ///
10433 /// Even though the property as already been set when instantiating this call,
10434 /// we provide this method for API completeness.
10435 pub fn attachment_id(
10436 mut self,
10437 new_value: &str,
10438 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C> {
10439 self._attachment_id = new_value.to_string();
10440 self
10441 }
10442 /// Required. Identifier of the student’s submission.
10443 ///
10444 /// Sets the *submission id* path property to the given value.
10445 ///
10446 /// Even though the property as already been set when instantiating this call,
10447 /// we provide this method for API completeness.
10448 pub fn submission_id(
10449 mut self,
10450 new_value: &str,
10451 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C> {
10452 self._submission_id = new_value.to_string();
10453 self
10454 }
10455 /// Optional. Deprecated, use `item_id` instead.
10456 ///
10457 /// Sets the *post id* query property to the given value.
10458 pub fn post_id(
10459 mut self,
10460 new_value: &str,
10461 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C> {
10462 self._post_id = Some(new_value.to_string());
10463 self
10464 }
10465 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10466 /// while executing the actual API request.
10467 ///
10468 /// ````text
10469 /// It should be used to handle progress information, and to implement a certain level of resilience.
10470 /// ````
10471 ///
10472 /// Sets the *delegate* property to the given value.
10473 pub fn delegate(
10474 mut self,
10475 new_value: &'a mut dyn common::Delegate,
10476 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C> {
10477 self._delegate = Some(new_value);
10478 self
10479 }
10480
10481 /// Set any additional parameter of the query string used in the request.
10482 /// It should be used to set parameters which are not yet available through their own
10483 /// setters.
10484 ///
10485 /// Please note that this method must not be used to set any of the known parameters
10486 /// which have their own setter method. If done anyway, the request will fail.
10487 ///
10488 /// # Additional Parameters
10489 ///
10490 /// * *$.xgafv* (query-string) - V1 error format.
10491 /// * *access_token* (query-string) - OAuth access token.
10492 /// * *alt* (query-string) - Data format for response.
10493 /// * *callback* (query-string) - JSONP
10494 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10495 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10496 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10497 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10498 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10499 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10500 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10501 pub fn param<T>(
10502 mut self,
10503 name: T,
10504 value: T,
10505 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C>
10506 where
10507 T: AsRef<str>,
10508 {
10509 self._additional_params
10510 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10511 self
10512 }
10513
10514 /// Identifies the authorization scope for the method you are building.
10515 ///
10516 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10517 /// [`Scope::StudentSubmissionStudentReadonly`].
10518 ///
10519 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10520 /// tokens for more than one scope.
10521 ///
10522 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10523 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10524 /// sufficient, a read-write scope will do as well.
10525 pub fn add_scope<St>(
10526 mut self,
10527 scope: St,
10528 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C>
10529 where
10530 St: AsRef<str>,
10531 {
10532 self._scopes.insert(String::from(scope.as_ref()));
10533 self
10534 }
10535 /// Identifies the authorization scope(s) for the method you are building.
10536 ///
10537 /// See [`Self::add_scope()`] for details.
10538 pub fn add_scopes<I, St>(
10539 mut self,
10540 scopes: I,
10541 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C>
10542 where
10543 I: IntoIterator<Item = St>,
10544 St: AsRef<str>,
10545 {
10546 self._scopes
10547 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10548 self
10549 }
10550
10551 /// Removes all scopes, and no default scope will be used either.
10552 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10553 /// for details).
10554 pub fn clear_scopes(
10555 mut self,
10556 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionGetCall<'a, C> {
10557 self._scopes.clear();
10558 self
10559 }
10560}
10561
10562/// Updates data associated with an add-on attachment submission. Requires the add-on to have been the original creator of the attachment and the attachment to have a positive `max_points` value set. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
10563///
10564/// A builder for the *courseWork.addOnAttachments.studentSubmissions.patch* method supported by a *course* resource.
10565/// It is not used directly, but through a [`CourseMethods`] instance.
10566///
10567/// # Example
10568///
10569/// Instantiate a resource method builder
10570///
10571/// ```test_harness,no_run
10572/// # extern crate hyper;
10573/// # extern crate hyper_rustls;
10574/// # extern crate google_classroom1 as classroom1;
10575/// use classroom1::api::AddOnAttachmentStudentSubmission;
10576/// # async fn dox() {
10577/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10578///
10579/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10580/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10581/// # .with_native_roots()
10582/// # .unwrap()
10583/// # .https_only()
10584/// # .enable_http2()
10585/// # .build();
10586///
10587/// # let executor = hyper_util::rt::TokioExecutor::new();
10588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10589/// # secret,
10590/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10591/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10592/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10593/// # ),
10594/// # ).build().await.unwrap();
10595///
10596/// # let client = hyper_util::client::legacy::Client::builder(
10597/// # hyper_util::rt::TokioExecutor::new()
10598/// # )
10599/// # .build(
10600/// # hyper_rustls::HttpsConnectorBuilder::new()
10601/// # .with_native_roots()
10602/// # .unwrap()
10603/// # .https_or_http()
10604/// # .enable_http2()
10605/// # .build()
10606/// # );
10607/// # let mut hub = Classroom::new(client, auth);
10608/// // As the method needs a request, you would usually fill it with the desired information
10609/// // into the respective structure. Some of the parts shown here might not be applicable !
10610/// // Values shown here are possibly random and not representative !
10611/// let mut req = AddOnAttachmentStudentSubmission::default();
10612///
10613/// // You can configure optional parameters by calling the respective setters at will, and
10614/// // execute the final call using `doit()`.
10615/// // Values shown here are possibly random and not representative !
10616/// let result = hub.courses().course_work_add_on_attachments_student_submissions_patch(req, "courseId", "itemId", "attachmentId", "submissionId")
10617/// .update_mask(FieldMask::new::<&str>(&[]))
10618/// .post_id("elitr")
10619/// .doit().await;
10620/// # }
10621/// ```
10622pub struct CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C>
10623where
10624 C: 'a,
10625{
10626 hub: &'a Classroom<C>,
10627 _request: AddOnAttachmentStudentSubmission,
10628 _course_id: String,
10629 _item_id: String,
10630 _attachment_id: String,
10631 _submission_id: String,
10632 _update_mask: Option<common::FieldMask>,
10633 _post_id: Option<String>,
10634 _delegate: Option<&'a mut dyn common::Delegate>,
10635 _additional_params: HashMap<String, String>,
10636 _scopes: BTreeSet<String>,
10637}
10638
10639impl<'a, C> common::CallBuilder
10640 for CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C>
10641{
10642}
10643
10644impl<'a, C> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C>
10645where
10646 C: common::Connector,
10647{
10648 /// Perform the operation you have build so far.
10649 pub async fn doit(
10650 mut self,
10651 ) -> common::Result<(common::Response, AddOnAttachmentStudentSubmission)> {
10652 use std::borrow::Cow;
10653 use std::io::{Read, Seek};
10654
10655 use common::{url::Params, ToParts};
10656 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10657
10658 let mut dd = common::DefaultDelegate;
10659 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10660 dlg.begin(common::MethodInfo {
10661 id: "classroom.courses.courseWork.addOnAttachments.studentSubmissions.patch",
10662 http_method: hyper::Method::PATCH,
10663 });
10664
10665 for &field in [
10666 "alt",
10667 "courseId",
10668 "itemId",
10669 "attachmentId",
10670 "submissionId",
10671 "updateMask",
10672 "postId",
10673 ]
10674 .iter()
10675 {
10676 if self._additional_params.contains_key(field) {
10677 dlg.finished(false);
10678 return Err(common::Error::FieldClash(field));
10679 }
10680 }
10681
10682 let mut params = Params::with_capacity(9 + self._additional_params.len());
10683 params.push("courseId", self._course_id);
10684 params.push("itemId", self._item_id);
10685 params.push("attachmentId", self._attachment_id);
10686 params.push("submissionId", self._submission_id);
10687 if let Some(value) = self._update_mask.as_ref() {
10688 params.push("updateMask", value.to_string());
10689 }
10690 if let Some(value) = self._post_id.as_ref() {
10691 params.push("postId", value);
10692 }
10693
10694 params.extend(self._additional_params.iter());
10695
10696 params.push("alt", "json");
10697 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{itemId}/addOnAttachments/{attachmentId}/studentSubmissions/{submissionId}";
10698 if self._scopes.is_empty() {
10699 self._scopes
10700 .insert(Scope::AddonTeacher.as_ref().to_string());
10701 }
10702
10703 #[allow(clippy::single_element_loop)]
10704 for &(find_this, param_name) in [
10705 ("{courseId}", "courseId"),
10706 ("{itemId}", "itemId"),
10707 ("{attachmentId}", "attachmentId"),
10708 ("{submissionId}", "submissionId"),
10709 ]
10710 .iter()
10711 {
10712 url = params.uri_replacement(url, param_name, find_this, false);
10713 }
10714 {
10715 let to_remove = ["submissionId", "attachmentId", "itemId", "courseId"];
10716 params.remove_params(&to_remove);
10717 }
10718
10719 let url = params.parse_with_url(&url);
10720
10721 let mut json_mime_type = mime::APPLICATION_JSON;
10722 let mut request_value_reader = {
10723 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10724 common::remove_json_null_values(&mut value);
10725 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10726 serde_json::to_writer(&mut dst, &value).unwrap();
10727 dst
10728 };
10729 let request_size = request_value_reader
10730 .seek(std::io::SeekFrom::End(0))
10731 .unwrap();
10732 request_value_reader
10733 .seek(std::io::SeekFrom::Start(0))
10734 .unwrap();
10735
10736 loop {
10737 let token = match self
10738 .hub
10739 .auth
10740 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10741 .await
10742 {
10743 Ok(token) => token,
10744 Err(e) => match dlg.token(e) {
10745 Ok(token) => token,
10746 Err(e) => {
10747 dlg.finished(false);
10748 return Err(common::Error::MissingToken(e));
10749 }
10750 },
10751 };
10752 request_value_reader
10753 .seek(std::io::SeekFrom::Start(0))
10754 .unwrap();
10755 let mut req_result = {
10756 let client = &self.hub.client;
10757 dlg.pre_request();
10758 let mut req_builder = hyper::Request::builder()
10759 .method(hyper::Method::PATCH)
10760 .uri(url.as_str())
10761 .header(USER_AGENT, self.hub._user_agent.clone());
10762
10763 if let Some(token) = token.as_ref() {
10764 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10765 }
10766
10767 let request = req_builder
10768 .header(CONTENT_TYPE, json_mime_type.to_string())
10769 .header(CONTENT_LENGTH, request_size as u64)
10770 .body(common::to_body(
10771 request_value_reader.get_ref().clone().into(),
10772 ));
10773
10774 client.request(request.unwrap()).await
10775 };
10776
10777 match req_result {
10778 Err(err) => {
10779 if let common::Retry::After(d) = dlg.http_error(&err) {
10780 sleep(d).await;
10781 continue;
10782 }
10783 dlg.finished(false);
10784 return Err(common::Error::HttpError(err));
10785 }
10786 Ok(res) => {
10787 let (mut parts, body) = res.into_parts();
10788 let mut body = common::Body::new(body);
10789 if !parts.status.is_success() {
10790 let bytes = common::to_bytes(body).await.unwrap_or_default();
10791 let error = serde_json::from_str(&common::to_string(&bytes));
10792 let response = common::to_response(parts, bytes.into());
10793
10794 if let common::Retry::After(d) =
10795 dlg.http_failure(&response, error.as_ref().ok())
10796 {
10797 sleep(d).await;
10798 continue;
10799 }
10800
10801 dlg.finished(false);
10802
10803 return Err(match error {
10804 Ok(value) => common::Error::BadRequest(value),
10805 _ => common::Error::Failure(response),
10806 });
10807 }
10808 let response = {
10809 let bytes = common::to_bytes(body).await.unwrap_or_default();
10810 let encoded = common::to_string(&bytes);
10811 match serde_json::from_str(&encoded) {
10812 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10813 Err(error) => {
10814 dlg.response_json_decode_error(&encoded, &error);
10815 return Err(common::Error::JsonDecodeError(
10816 encoded.to_string(),
10817 error,
10818 ));
10819 }
10820 }
10821 };
10822
10823 dlg.finished(true);
10824 return Ok(response);
10825 }
10826 }
10827 }
10828 }
10829
10830 ///
10831 /// Sets the *request* property to the given value.
10832 ///
10833 /// Even though the property as already been set when instantiating this call,
10834 /// we provide this method for API completeness.
10835 pub fn request(
10836 mut self,
10837 new_value: AddOnAttachmentStudentSubmission,
10838 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
10839 self._request = new_value;
10840 self
10841 }
10842 /// Required. Identifier of the course.
10843 ///
10844 /// Sets the *course id* path property to the given value.
10845 ///
10846 /// Even though the property as already been set when instantiating this call,
10847 /// we provide this method for API completeness.
10848 pub fn course_id(
10849 mut self,
10850 new_value: &str,
10851 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
10852 self._course_id = new_value.to_string();
10853 self
10854 }
10855 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
10856 ///
10857 /// Sets the *item id* path property to the given value.
10858 ///
10859 /// Even though the property as already been set when instantiating this call,
10860 /// we provide this method for API completeness.
10861 pub fn item_id(
10862 mut self,
10863 new_value: &str,
10864 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
10865 self._item_id = new_value.to_string();
10866 self
10867 }
10868 /// Required. Identifier of the attachment.
10869 ///
10870 /// Sets the *attachment id* path property to the given value.
10871 ///
10872 /// Even though the property as already been set when instantiating this call,
10873 /// we provide this method for API completeness.
10874 pub fn attachment_id(
10875 mut self,
10876 new_value: &str,
10877 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
10878 self._attachment_id = new_value.to_string();
10879 self
10880 }
10881 /// Required. Identifier of the student's submission.
10882 ///
10883 /// Sets the *submission id* path property to the given value.
10884 ///
10885 /// Even though the property as already been set when instantiating this call,
10886 /// we provide this method for API completeness.
10887 pub fn submission_id(
10888 mut self,
10889 new_value: &str,
10890 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
10891 self._submission_id = new_value.to_string();
10892 self
10893 }
10894 /// Required. Mask that identifies which fields on the attachment to update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the `AddOnAttachmentStudentSubmission` object. The following fields may be specified by teachers: * `points_earned`
10895 ///
10896 /// Sets the *update mask* query property to the given value.
10897 pub fn update_mask(
10898 mut self,
10899 new_value: common::FieldMask,
10900 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
10901 self._update_mask = Some(new_value);
10902 self
10903 }
10904 /// Optional. Deprecated, use `item_id` instead.
10905 ///
10906 /// Sets the *post id* query property to the given value.
10907 pub fn post_id(
10908 mut self,
10909 new_value: &str,
10910 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
10911 self._post_id = Some(new_value.to_string());
10912 self
10913 }
10914 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10915 /// while executing the actual API request.
10916 ///
10917 /// ````text
10918 /// It should be used to handle progress information, and to implement a certain level of resilience.
10919 /// ````
10920 ///
10921 /// Sets the *delegate* property to the given value.
10922 pub fn delegate(
10923 mut self,
10924 new_value: &'a mut dyn common::Delegate,
10925 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
10926 self._delegate = Some(new_value);
10927 self
10928 }
10929
10930 /// Set any additional parameter of the query string used in the request.
10931 /// It should be used to set parameters which are not yet available through their own
10932 /// setters.
10933 ///
10934 /// Please note that this method must not be used to set any of the known parameters
10935 /// which have their own setter method. If done anyway, the request will fail.
10936 ///
10937 /// # Additional Parameters
10938 ///
10939 /// * *$.xgafv* (query-string) - V1 error format.
10940 /// * *access_token* (query-string) - OAuth access token.
10941 /// * *alt* (query-string) - Data format for response.
10942 /// * *callback* (query-string) - JSONP
10943 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10944 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10945 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10946 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10947 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10948 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10949 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10950 pub fn param<T>(
10951 mut self,
10952 name: T,
10953 value: T,
10954 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C>
10955 where
10956 T: AsRef<str>,
10957 {
10958 self._additional_params
10959 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10960 self
10961 }
10962
10963 /// Identifies the authorization scope for the method you are building.
10964 ///
10965 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10966 /// [`Scope::AddonTeacher`].
10967 ///
10968 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10969 /// tokens for more than one scope.
10970 ///
10971 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10972 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10973 /// sufficient, a read-write scope will do as well.
10974 pub fn add_scope<St>(
10975 mut self,
10976 scope: St,
10977 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C>
10978 where
10979 St: AsRef<str>,
10980 {
10981 self._scopes.insert(String::from(scope.as_ref()));
10982 self
10983 }
10984 /// Identifies the authorization scope(s) for the method you are building.
10985 ///
10986 /// See [`Self::add_scope()`] for details.
10987 pub fn add_scopes<I, St>(
10988 mut self,
10989 scopes: I,
10990 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C>
10991 where
10992 I: IntoIterator<Item = St>,
10993 St: AsRef<str>,
10994 {
10995 self._scopes
10996 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10997 self
10998 }
10999
11000 /// Removes all scopes, and no default scope will be used either.
11001 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11002 /// for details).
11003 pub fn clear_scopes(
11004 mut self,
11005 ) -> CourseCourseWorkAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
11006 self._scopes.clear();
11007 self
11008 }
11009}
11010
11011/// Creates an add-on attachment under a post. Requires the add-on to have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
11012///
11013/// A builder for the *courseWork.addOnAttachments.create* method supported by a *course* resource.
11014/// It is not used directly, but through a [`CourseMethods`] instance.
11015///
11016/// # Example
11017///
11018/// Instantiate a resource method builder
11019///
11020/// ```test_harness,no_run
11021/// # extern crate hyper;
11022/// # extern crate hyper_rustls;
11023/// # extern crate google_classroom1 as classroom1;
11024/// use classroom1::api::AddOnAttachment;
11025/// # async fn dox() {
11026/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11027///
11028/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11029/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11030/// # .with_native_roots()
11031/// # .unwrap()
11032/// # .https_only()
11033/// # .enable_http2()
11034/// # .build();
11035///
11036/// # let executor = hyper_util::rt::TokioExecutor::new();
11037/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11038/// # secret,
11039/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11040/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11041/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11042/// # ),
11043/// # ).build().await.unwrap();
11044///
11045/// # let client = hyper_util::client::legacy::Client::builder(
11046/// # hyper_util::rt::TokioExecutor::new()
11047/// # )
11048/// # .build(
11049/// # hyper_rustls::HttpsConnectorBuilder::new()
11050/// # .with_native_roots()
11051/// # .unwrap()
11052/// # .https_or_http()
11053/// # .enable_http2()
11054/// # .build()
11055/// # );
11056/// # let mut hub = Classroom::new(client, auth);
11057/// // As the method needs a request, you would usually fill it with the desired information
11058/// // into the respective structure. Some of the parts shown here might not be applicable !
11059/// // Values shown here are possibly random and not representative !
11060/// let mut req = AddOnAttachment::default();
11061///
11062/// // You can configure optional parameters by calling the respective setters at will, and
11063/// // execute the final call using `doit()`.
11064/// // Values shown here are possibly random and not representative !
11065/// let result = hub.courses().course_work_add_on_attachments_create(req, "courseId", "itemId")
11066/// .post_id("no")
11067/// .add_on_token("ipsum")
11068/// .doit().await;
11069/// # }
11070/// ```
11071pub struct CourseCourseWorkAddOnAttachmentCreateCall<'a, C>
11072where
11073 C: 'a,
11074{
11075 hub: &'a Classroom<C>,
11076 _request: AddOnAttachment,
11077 _course_id: String,
11078 _item_id: String,
11079 _post_id: Option<String>,
11080 _add_on_token: Option<String>,
11081 _delegate: Option<&'a mut dyn common::Delegate>,
11082 _additional_params: HashMap<String, String>,
11083 _scopes: BTreeSet<String>,
11084}
11085
11086impl<'a, C> common::CallBuilder for CourseCourseWorkAddOnAttachmentCreateCall<'a, C> {}
11087
11088impl<'a, C> CourseCourseWorkAddOnAttachmentCreateCall<'a, C>
11089where
11090 C: common::Connector,
11091{
11092 /// Perform the operation you have build so far.
11093 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
11094 use std::borrow::Cow;
11095 use std::io::{Read, Seek};
11096
11097 use common::{url::Params, ToParts};
11098 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11099
11100 let mut dd = common::DefaultDelegate;
11101 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11102 dlg.begin(common::MethodInfo {
11103 id: "classroom.courses.courseWork.addOnAttachments.create",
11104 http_method: hyper::Method::POST,
11105 });
11106
11107 for &field in ["alt", "courseId", "itemId", "postId", "addOnToken"].iter() {
11108 if self._additional_params.contains_key(field) {
11109 dlg.finished(false);
11110 return Err(common::Error::FieldClash(field));
11111 }
11112 }
11113
11114 let mut params = Params::with_capacity(7 + self._additional_params.len());
11115 params.push("courseId", self._course_id);
11116 params.push("itemId", self._item_id);
11117 if let Some(value) = self._post_id.as_ref() {
11118 params.push("postId", value);
11119 }
11120 if let Some(value) = self._add_on_token.as_ref() {
11121 params.push("addOnToken", value);
11122 }
11123
11124 params.extend(self._additional_params.iter());
11125
11126 params.push("alt", "json");
11127 let mut url = self.hub._base_url.clone()
11128 + "v1/courses/{courseId}/courseWork/{itemId}/addOnAttachments";
11129 if self._scopes.is_empty() {
11130 self._scopes
11131 .insert(Scope::AddonTeacher.as_ref().to_string());
11132 }
11133
11134 #[allow(clippy::single_element_loop)]
11135 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{itemId}", "itemId")].iter()
11136 {
11137 url = params.uri_replacement(url, param_name, find_this, false);
11138 }
11139 {
11140 let to_remove = ["itemId", "courseId"];
11141 params.remove_params(&to_remove);
11142 }
11143
11144 let url = params.parse_with_url(&url);
11145
11146 let mut json_mime_type = mime::APPLICATION_JSON;
11147 let mut request_value_reader = {
11148 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11149 common::remove_json_null_values(&mut value);
11150 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11151 serde_json::to_writer(&mut dst, &value).unwrap();
11152 dst
11153 };
11154 let request_size = request_value_reader
11155 .seek(std::io::SeekFrom::End(0))
11156 .unwrap();
11157 request_value_reader
11158 .seek(std::io::SeekFrom::Start(0))
11159 .unwrap();
11160
11161 loop {
11162 let token = match self
11163 .hub
11164 .auth
11165 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11166 .await
11167 {
11168 Ok(token) => token,
11169 Err(e) => match dlg.token(e) {
11170 Ok(token) => token,
11171 Err(e) => {
11172 dlg.finished(false);
11173 return Err(common::Error::MissingToken(e));
11174 }
11175 },
11176 };
11177 request_value_reader
11178 .seek(std::io::SeekFrom::Start(0))
11179 .unwrap();
11180 let mut req_result = {
11181 let client = &self.hub.client;
11182 dlg.pre_request();
11183 let mut req_builder = hyper::Request::builder()
11184 .method(hyper::Method::POST)
11185 .uri(url.as_str())
11186 .header(USER_AGENT, self.hub._user_agent.clone());
11187
11188 if let Some(token) = token.as_ref() {
11189 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11190 }
11191
11192 let request = req_builder
11193 .header(CONTENT_TYPE, json_mime_type.to_string())
11194 .header(CONTENT_LENGTH, request_size as u64)
11195 .body(common::to_body(
11196 request_value_reader.get_ref().clone().into(),
11197 ));
11198
11199 client.request(request.unwrap()).await
11200 };
11201
11202 match req_result {
11203 Err(err) => {
11204 if let common::Retry::After(d) = dlg.http_error(&err) {
11205 sleep(d).await;
11206 continue;
11207 }
11208 dlg.finished(false);
11209 return Err(common::Error::HttpError(err));
11210 }
11211 Ok(res) => {
11212 let (mut parts, body) = res.into_parts();
11213 let mut body = common::Body::new(body);
11214 if !parts.status.is_success() {
11215 let bytes = common::to_bytes(body).await.unwrap_or_default();
11216 let error = serde_json::from_str(&common::to_string(&bytes));
11217 let response = common::to_response(parts, bytes.into());
11218
11219 if let common::Retry::After(d) =
11220 dlg.http_failure(&response, error.as_ref().ok())
11221 {
11222 sleep(d).await;
11223 continue;
11224 }
11225
11226 dlg.finished(false);
11227
11228 return Err(match error {
11229 Ok(value) => common::Error::BadRequest(value),
11230 _ => common::Error::Failure(response),
11231 });
11232 }
11233 let response = {
11234 let bytes = common::to_bytes(body).await.unwrap_or_default();
11235 let encoded = common::to_string(&bytes);
11236 match serde_json::from_str(&encoded) {
11237 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11238 Err(error) => {
11239 dlg.response_json_decode_error(&encoded, &error);
11240 return Err(common::Error::JsonDecodeError(
11241 encoded.to_string(),
11242 error,
11243 ));
11244 }
11245 }
11246 };
11247
11248 dlg.finished(true);
11249 return Ok(response);
11250 }
11251 }
11252 }
11253 }
11254
11255 ///
11256 /// Sets the *request* property to the given value.
11257 ///
11258 /// Even though the property as already been set when instantiating this call,
11259 /// we provide this method for API completeness.
11260 pub fn request(
11261 mut self,
11262 new_value: AddOnAttachment,
11263 ) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C> {
11264 self._request = new_value;
11265 self
11266 }
11267 /// Required. Identifier of the course.
11268 ///
11269 /// Sets the *course id* path property to the given value.
11270 ///
11271 /// Even though the property as already been set when instantiating this call,
11272 /// we provide this method for API completeness.
11273 pub fn course_id(
11274 mut self,
11275 new_value: &str,
11276 ) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C> {
11277 self._course_id = new_value.to_string();
11278 self
11279 }
11280 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which to create the attachment. This field is required, but is not marked as such while we are migrating from post_id.
11281 ///
11282 /// Sets the *item id* path property to the given value.
11283 ///
11284 /// Even though the property as already been set when instantiating this call,
11285 /// we provide this method for API completeness.
11286 pub fn item_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C> {
11287 self._item_id = new_value.to_string();
11288 self
11289 }
11290 /// Optional. Deprecated, use `item_id` instead.
11291 ///
11292 /// Sets the *post id* query property to the given value.
11293 pub fn post_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C> {
11294 self._post_id = Some(new_value.to_string());
11295 self
11296 }
11297 /// Optional. Token that authorizes the request. The token is passed as a query parameter when the user is redirected from Classroom to the add-on's URL. This authorization token is required for in-Classroom attachment creation but optional for partner-first attachment creation. Returns an error if not provided for partner-first attachment creation and the developer projects that created the attachment and its parent stream item do not match.
11298 ///
11299 /// Sets the *add on token* query property to the given value.
11300 pub fn add_on_token(
11301 mut self,
11302 new_value: &str,
11303 ) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C> {
11304 self._add_on_token = Some(new_value.to_string());
11305 self
11306 }
11307 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11308 /// while executing the actual API request.
11309 ///
11310 /// ````text
11311 /// It should be used to handle progress information, and to implement a certain level of resilience.
11312 /// ````
11313 ///
11314 /// Sets the *delegate* property to the given value.
11315 pub fn delegate(
11316 mut self,
11317 new_value: &'a mut dyn common::Delegate,
11318 ) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C> {
11319 self._delegate = Some(new_value);
11320 self
11321 }
11322
11323 /// Set any additional parameter of the query string used in the request.
11324 /// It should be used to set parameters which are not yet available through their own
11325 /// setters.
11326 ///
11327 /// Please note that this method must not be used to set any of the known parameters
11328 /// which have their own setter method. If done anyway, the request will fail.
11329 ///
11330 /// # Additional Parameters
11331 ///
11332 /// * *$.xgafv* (query-string) - V1 error format.
11333 /// * *access_token* (query-string) - OAuth access token.
11334 /// * *alt* (query-string) - Data format for response.
11335 /// * *callback* (query-string) - JSONP
11336 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11337 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11338 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11339 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11340 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11341 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11342 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11343 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C>
11344 where
11345 T: AsRef<str>,
11346 {
11347 self._additional_params
11348 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11349 self
11350 }
11351
11352 /// Identifies the authorization scope for the method you are building.
11353 ///
11354 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11355 /// [`Scope::AddonTeacher`].
11356 ///
11357 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11358 /// tokens for more than one scope.
11359 ///
11360 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11361 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11362 /// sufficient, a read-write scope will do as well.
11363 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C>
11364 where
11365 St: AsRef<str>,
11366 {
11367 self._scopes.insert(String::from(scope.as_ref()));
11368 self
11369 }
11370 /// Identifies the authorization scope(s) for the method you are building.
11371 ///
11372 /// See [`Self::add_scope()`] for details.
11373 pub fn add_scopes<I, St>(
11374 mut self,
11375 scopes: I,
11376 ) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C>
11377 where
11378 I: IntoIterator<Item = St>,
11379 St: AsRef<str>,
11380 {
11381 self._scopes
11382 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11383 self
11384 }
11385
11386 /// Removes all scopes, and no default scope will be used either.
11387 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11388 /// for details).
11389 pub fn clear_scopes(mut self) -> CourseCourseWorkAddOnAttachmentCreateCall<'a, C> {
11390 self._scopes.clear();
11391 self
11392 }
11393}
11394
11395/// Deletes an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
11396///
11397/// A builder for the *courseWork.addOnAttachments.delete* method supported by a *course* resource.
11398/// It is not used directly, but through a [`CourseMethods`] instance.
11399///
11400/// # Example
11401///
11402/// Instantiate a resource method builder
11403///
11404/// ```test_harness,no_run
11405/// # extern crate hyper;
11406/// # extern crate hyper_rustls;
11407/// # extern crate google_classroom1 as classroom1;
11408/// # async fn dox() {
11409/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11410///
11411/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11412/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11413/// # .with_native_roots()
11414/// # .unwrap()
11415/// # .https_only()
11416/// # .enable_http2()
11417/// # .build();
11418///
11419/// # let executor = hyper_util::rt::TokioExecutor::new();
11420/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11421/// # secret,
11422/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11423/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11424/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11425/// # ),
11426/// # ).build().await.unwrap();
11427///
11428/// # let client = hyper_util::client::legacy::Client::builder(
11429/// # hyper_util::rt::TokioExecutor::new()
11430/// # )
11431/// # .build(
11432/// # hyper_rustls::HttpsConnectorBuilder::new()
11433/// # .with_native_roots()
11434/// # .unwrap()
11435/// # .https_or_http()
11436/// # .enable_http2()
11437/// # .build()
11438/// # );
11439/// # let mut hub = Classroom::new(client, auth);
11440/// // You can configure optional parameters by calling the respective setters at will, and
11441/// // execute the final call using `doit()`.
11442/// // Values shown here are possibly random and not representative !
11443/// let result = hub.courses().course_work_add_on_attachments_delete("courseId", "itemId", "attachmentId")
11444/// .post_id("voluptua.")
11445/// .doit().await;
11446/// # }
11447/// ```
11448pub struct CourseCourseWorkAddOnAttachmentDeleteCall<'a, C>
11449where
11450 C: 'a,
11451{
11452 hub: &'a Classroom<C>,
11453 _course_id: String,
11454 _item_id: String,
11455 _attachment_id: String,
11456 _post_id: Option<String>,
11457 _delegate: Option<&'a mut dyn common::Delegate>,
11458 _additional_params: HashMap<String, String>,
11459 _scopes: BTreeSet<String>,
11460}
11461
11462impl<'a, C> common::CallBuilder for CourseCourseWorkAddOnAttachmentDeleteCall<'a, C> {}
11463
11464impl<'a, C> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C>
11465where
11466 C: common::Connector,
11467{
11468 /// Perform the operation you have build so far.
11469 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11470 use std::borrow::Cow;
11471 use std::io::{Read, Seek};
11472
11473 use common::{url::Params, ToParts};
11474 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11475
11476 let mut dd = common::DefaultDelegate;
11477 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11478 dlg.begin(common::MethodInfo {
11479 id: "classroom.courses.courseWork.addOnAttachments.delete",
11480 http_method: hyper::Method::DELETE,
11481 });
11482
11483 for &field in ["alt", "courseId", "itemId", "attachmentId", "postId"].iter() {
11484 if self._additional_params.contains_key(field) {
11485 dlg.finished(false);
11486 return Err(common::Error::FieldClash(field));
11487 }
11488 }
11489
11490 let mut params = Params::with_capacity(6 + self._additional_params.len());
11491 params.push("courseId", self._course_id);
11492 params.push("itemId", self._item_id);
11493 params.push("attachmentId", self._attachment_id);
11494 if let Some(value) = self._post_id.as_ref() {
11495 params.push("postId", value);
11496 }
11497
11498 params.extend(self._additional_params.iter());
11499
11500 params.push("alt", "json");
11501 let mut url = self.hub._base_url.clone()
11502 + "v1/courses/{courseId}/courseWork/{itemId}/addOnAttachments/{attachmentId}";
11503 if self._scopes.is_empty() {
11504 self._scopes
11505 .insert(Scope::AddonTeacher.as_ref().to_string());
11506 }
11507
11508 #[allow(clippy::single_element_loop)]
11509 for &(find_this, param_name) in [
11510 ("{courseId}", "courseId"),
11511 ("{itemId}", "itemId"),
11512 ("{attachmentId}", "attachmentId"),
11513 ]
11514 .iter()
11515 {
11516 url = params.uri_replacement(url, param_name, find_this, false);
11517 }
11518 {
11519 let to_remove = ["attachmentId", "itemId", "courseId"];
11520 params.remove_params(&to_remove);
11521 }
11522
11523 let url = params.parse_with_url(&url);
11524
11525 loop {
11526 let token = match self
11527 .hub
11528 .auth
11529 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11530 .await
11531 {
11532 Ok(token) => token,
11533 Err(e) => match dlg.token(e) {
11534 Ok(token) => token,
11535 Err(e) => {
11536 dlg.finished(false);
11537 return Err(common::Error::MissingToken(e));
11538 }
11539 },
11540 };
11541 let mut req_result = {
11542 let client = &self.hub.client;
11543 dlg.pre_request();
11544 let mut req_builder = hyper::Request::builder()
11545 .method(hyper::Method::DELETE)
11546 .uri(url.as_str())
11547 .header(USER_AGENT, self.hub._user_agent.clone());
11548
11549 if let Some(token) = token.as_ref() {
11550 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11551 }
11552
11553 let request = req_builder
11554 .header(CONTENT_LENGTH, 0_u64)
11555 .body(common::to_body::<String>(None));
11556
11557 client.request(request.unwrap()).await
11558 };
11559
11560 match req_result {
11561 Err(err) => {
11562 if let common::Retry::After(d) = dlg.http_error(&err) {
11563 sleep(d).await;
11564 continue;
11565 }
11566 dlg.finished(false);
11567 return Err(common::Error::HttpError(err));
11568 }
11569 Ok(res) => {
11570 let (mut parts, body) = res.into_parts();
11571 let mut body = common::Body::new(body);
11572 if !parts.status.is_success() {
11573 let bytes = common::to_bytes(body).await.unwrap_or_default();
11574 let error = serde_json::from_str(&common::to_string(&bytes));
11575 let response = common::to_response(parts, bytes.into());
11576
11577 if let common::Retry::After(d) =
11578 dlg.http_failure(&response, error.as_ref().ok())
11579 {
11580 sleep(d).await;
11581 continue;
11582 }
11583
11584 dlg.finished(false);
11585
11586 return Err(match error {
11587 Ok(value) => common::Error::BadRequest(value),
11588 _ => common::Error::Failure(response),
11589 });
11590 }
11591 let response = {
11592 let bytes = common::to_bytes(body).await.unwrap_or_default();
11593 let encoded = common::to_string(&bytes);
11594 match serde_json::from_str(&encoded) {
11595 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11596 Err(error) => {
11597 dlg.response_json_decode_error(&encoded, &error);
11598 return Err(common::Error::JsonDecodeError(
11599 encoded.to_string(),
11600 error,
11601 ));
11602 }
11603 }
11604 };
11605
11606 dlg.finished(true);
11607 return Ok(response);
11608 }
11609 }
11610 }
11611 }
11612
11613 /// Required. Identifier of the course.
11614 ///
11615 /// Sets the *course id* path property to the given value.
11616 ///
11617 /// Even though the property as already been set when instantiating this call,
11618 /// we provide this method for API completeness.
11619 pub fn course_id(
11620 mut self,
11621 new_value: &str,
11622 ) -> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C> {
11623 self._course_id = new_value.to_string();
11624 self
11625 }
11626 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
11627 ///
11628 /// Sets the *item id* path property to the given value.
11629 ///
11630 /// Even though the property as already been set when instantiating this call,
11631 /// we provide this method for API completeness.
11632 pub fn item_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C> {
11633 self._item_id = new_value.to_string();
11634 self
11635 }
11636 /// Required. Identifier of the attachment.
11637 ///
11638 /// Sets the *attachment id* path property to the given value.
11639 ///
11640 /// Even though the property as already been set when instantiating this call,
11641 /// we provide this method for API completeness.
11642 pub fn attachment_id(
11643 mut self,
11644 new_value: &str,
11645 ) -> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C> {
11646 self._attachment_id = new_value.to_string();
11647 self
11648 }
11649 /// Optional. Deprecated, use `item_id` instead.
11650 ///
11651 /// Sets the *post id* query property to the given value.
11652 pub fn post_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C> {
11653 self._post_id = Some(new_value.to_string());
11654 self
11655 }
11656 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11657 /// while executing the actual API request.
11658 ///
11659 /// ````text
11660 /// It should be used to handle progress information, and to implement a certain level of resilience.
11661 /// ````
11662 ///
11663 /// Sets the *delegate* property to the given value.
11664 pub fn delegate(
11665 mut self,
11666 new_value: &'a mut dyn common::Delegate,
11667 ) -> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C> {
11668 self._delegate = Some(new_value);
11669 self
11670 }
11671
11672 /// Set any additional parameter of the query string used in the request.
11673 /// It should be used to set parameters which are not yet available through their own
11674 /// setters.
11675 ///
11676 /// Please note that this method must not be used to set any of the known parameters
11677 /// which have their own setter method. If done anyway, the request will fail.
11678 ///
11679 /// # Additional Parameters
11680 ///
11681 /// * *$.xgafv* (query-string) - V1 error format.
11682 /// * *access_token* (query-string) - OAuth access token.
11683 /// * *alt* (query-string) - Data format for response.
11684 /// * *callback* (query-string) - JSONP
11685 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11686 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11687 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11688 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11689 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11690 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11691 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11692 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C>
11693 where
11694 T: AsRef<str>,
11695 {
11696 self._additional_params
11697 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11698 self
11699 }
11700
11701 /// Identifies the authorization scope for the method you are building.
11702 ///
11703 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11704 /// [`Scope::AddonTeacher`].
11705 ///
11706 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11707 /// tokens for more than one scope.
11708 ///
11709 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11710 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11711 /// sufficient, a read-write scope will do as well.
11712 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C>
11713 where
11714 St: AsRef<str>,
11715 {
11716 self._scopes.insert(String::from(scope.as_ref()));
11717 self
11718 }
11719 /// Identifies the authorization scope(s) for the method you are building.
11720 ///
11721 /// See [`Self::add_scope()`] for details.
11722 pub fn add_scopes<I, St>(
11723 mut self,
11724 scopes: I,
11725 ) -> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C>
11726 where
11727 I: IntoIterator<Item = St>,
11728 St: AsRef<str>,
11729 {
11730 self._scopes
11731 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11732 self
11733 }
11734
11735 /// Removes all scopes, and no default scope will be used either.
11736 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11737 /// for details).
11738 pub fn clear_scopes(mut self) -> CourseCourseWorkAddOnAttachmentDeleteCall<'a, C> {
11739 self._scopes.clear();
11740 self
11741 }
11742}
11743
11744/// Returns an add-on attachment. Requires the add-on requesting the attachment to be the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
11745///
11746/// A builder for the *courseWork.addOnAttachments.get* method supported by a *course* resource.
11747/// It is not used directly, but through a [`CourseMethods`] instance.
11748///
11749/// # Example
11750///
11751/// Instantiate a resource method builder
11752///
11753/// ```test_harness,no_run
11754/// # extern crate hyper;
11755/// # extern crate hyper_rustls;
11756/// # extern crate google_classroom1 as classroom1;
11757/// # async fn dox() {
11758/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11759///
11760/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11761/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11762/// # .with_native_roots()
11763/// # .unwrap()
11764/// # .https_only()
11765/// # .enable_http2()
11766/// # .build();
11767///
11768/// # let executor = hyper_util::rt::TokioExecutor::new();
11769/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11770/// # secret,
11771/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11772/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11773/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11774/// # ),
11775/// # ).build().await.unwrap();
11776///
11777/// # let client = hyper_util::client::legacy::Client::builder(
11778/// # hyper_util::rt::TokioExecutor::new()
11779/// # )
11780/// # .build(
11781/// # hyper_rustls::HttpsConnectorBuilder::new()
11782/// # .with_native_roots()
11783/// # .unwrap()
11784/// # .https_or_http()
11785/// # .enable_http2()
11786/// # .build()
11787/// # );
11788/// # let mut hub = Classroom::new(client, auth);
11789/// // You can configure optional parameters by calling the respective setters at will, and
11790/// // execute the final call using `doit()`.
11791/// // Values shown here are possibly random and not representative !
11792/// let result = hub.courses().course_work_add_on_attachments_get("courseId", "itemId", "attachmentId")
11793/// .post_id("amet.")
11794/// .doit().await;
11795/// # }
11796/// ```
11797pub struct CourseCourseWorkAddOnAttachmentGetCall<'a, C>
11798where
11799 C: 'a,
11800{
11801 hub: &'a Classroom<C>,
11802 _course_id: String,
11803 _item_id: String,
11804 _attachment_id: String,
11805 _post_id: Option<String>,
11806 _delegate: Option<&'a mut dyn common::Delegate>,
11807 _additional_params: HashMap<String, String>,
11808 _scopes: BTreeSet<String>,
11809}
11810
11811impl<'a, C> common::CallBuilder for CourseCourseWorkAddOnAttachmentGetCall<'a, C> {}
11812
11813impl<'a, C> CourseCourseWorkAddOnAttachmentGetCall<'a, C>
11814where
11815 C: common::Connector,
11816{
11817 /// Perform the operation you have build so far.
11818 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
11819 use std::borrow::Cow;
11820 use std::io::{Read, Seek};
11821
11822 use common::{url::Params, ToParts};
11823 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11824
11825 let mut dd = common::DefaultDelegate;
11826 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11827 dlg.begin(common::MethodInfo {
11828 id: "classroom.courses.courseWork.addOnAttachments.get",
11829 http_method: hyper::Method::GET,
11830 });
11831
11832 for &field in ["alt", "courseId", "itemId", "attachmentId", "postId"].iter() {
11833 if self._additional_params.contains_key(field) {
11834 dlg.finished(false);
11835 return Err(common::Error::FieldClash(field));
11836 }
11837 }
11838
11839 let mut params = Params::with_capacity(6 + self._additional_params.len());
11840 params.push("courseId", self._course_id);
11841 params.push("itemId", self._item_id);
11842 params.push("attachmentId", self._attachment_id);
11843 if let Some(value) = self._post_id.as_ref() {
11844 params.push("postId", value);
11845 }
11846
11847 params.extend(self._additional_params.iter());
11848
11849 params.push("alt", "json");
11850 let mut url = self.hub._base_url.clone()
11851 + "v1/courses/{courseId}/courseWork/{itemId}/addOnAttachments/{attachmentId}";
11852 if self._scopes.is_empty() {
11853 self._scopes
11854 .insert(Scope::AddonStudent.as_ref().to_string());
11855 }
11856
11857 #[allow(clippy::single_element_loop)]
11858 for &(find_this, param_name) in [
11859 ("{courseId}", "courseId"),
11860 ("{itemId}", "itemId"),
11861 ("{attachmentId}", "attachmentId"),
11862 ]
11863 .iter()
11864 {
11865 url = params.uri_replacement(url, param_name, find_this, false);
11866 }
11867 {
11868 let to_remove = ["attachmentId", "itemId", "courseId"];
11869 params.remove_params(&to_remove);
11870 }
11871
11872 let url = params.parse_with_url(&url);
11873
11874 loop {
11875 let token = match self
11876 .hub
11877 .auth
11878 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11879 .await
11880 {
11881 Ok(token) => token,
11882 Err(e) => match dlg.token(e) {
11883 Ok(token) => token,
11884 Err(e) => {
11885 dlg.finished(false);
11886 return Err(common::Error::MissingToken(e));
11887 }
11888 },
11889 };
11890 let mut req_result = {
11891 let client = &self.hub.client;
11892 dlg.pre_request();
11893 let mut req_builder = hyper::Request::builder()
11894 .method(hyper::Method::GET)
11895 .uri(url.as_str())
11896 .header(USER_AGENT, self.hub._user_agent.clone());
11897
11898 if let Some(token) = token.as_ref() {
11899 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11900 }
11901
11902 let request = req_builder
11903 .header(CONTENT_LENGTH, 0_u64)
11904 .body(common::to_body::<String>(None));
11905
11906 client.request(request.unwrap()).await
11907 };
11908
11909 match req_result {
11910 Err(err) => {
11911 if let common::Retry::After(d) = dlg.http_error(&err) {
11912 sleep(d).await;
11913 continue;
11914 }
11915 dlg.finished(false);
11916 return Err(common::Error::HttpError(err));
11917 }
11918 Ok(res) => {
11919 let (mut parts, body) = res.into_parts();
11920 let mut body = common::Body::new(body);
11921 if !parts.status.is_success() {
11922 let bytes = common::to_bytes(body).await.unwrap_or_default();
11923 let error = serde_json::from_str(&common::to_string(&bytes));
11924 let response = common::to_response(parts, bytes.into());
11925
11926 if let common::Retry::After(d) =
11927 dlg.http_failure(&response, error.as_ref().ok())
11928 {
11929 sleep(d).await;
11930 continue;
11931 }
11932
11933 dlg.finished(false);
11934
11935 return Err(match error {
11936 Ok(value) => common::Error::BadRequest(value),
11937 _ => common::Error::Failure(response),
11938 });
11939 }
11940 let response = {
11941 let bytes = common::to_bytes(body).await.unwrap_or_default();
11942 let encoded = common::to_string(&bytes);
11943 match serde_json::from_str(&encoded) {
11944 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11945 Err(error) => {
11946 dlg.response_json_decode_error(&encoded, &error);
11947 return Err(common::Error::JsonDecodeError(
11948 encoded.to_string(),
11949 error,
11950 ));
11951 }
11952 }
11953 };
11954
11955 dlg.finished(true);
11956 return Ok(response);
11957 }
11958 }
11959 }
11960 }
11961
11962 /// Required. Identifier of the course.
11963 ///
11964 /// Sets the *course id* path property to the given value.
11965 ///
11966 /// Even though the property as already been set when instantiating this call,
11967 /// we provide this method for API completeness.
11968 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentGetCall<'a, C> {
11969 self._course_id = new_value.to_string();
11970 self
11971 }
11972 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
11973 ///
11974 /// Sets the *item id* path property to the given value.
11975 ///
11976 /// Even though the property as already been set when instantiating this call,
11977 /// we provide this method for API completeness.
11978 pub fn item_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentGetCall<'a, C> {
11979 self._item_id = new_value.to_string();
11980 self
11981 }
11982 /// Required. Identifier of the attachment.
11983 ///
11984 /// Sets the *attachment id* path property to the given value.
11985 ///
11986 /// Even though the property as already been set when instantiating this call,
11987 /// we provide this method for API completeness.
11988 pub fn attachment_id(
11989 mut self,
11990 new_value: &str,
11991 ) -> CourseCourseWorkAddOnAttachmentGetCall<'a, C> {
11992 self._attachment_id = new_value.to_string();
11993 self
11994 }
11995 /// Optional. Deprecated, use `item_id` instead.
11996 ///
11997 /// Sets the *post id* query property to the given value.
11998 pub fn post_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentGetCall<'a, C> {
11999 self._post_id = Some(new_value.to_string());
12000 self
12001 }
12002 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12003 /// while executing the actual API request.
12004 ///
12005 /// ````text
12006 /// It should be used to handle progress information, and to implement a certain level of resilience.
12007 /// ````
12008 ///
12009 /// Sets the *delegate* property to the given value.
12010 pub fn delegate(
12011 mut self,
12012 new_value: &'a mut dyn common::Delegate,
12013 ) -> CourseCourseWorkAddOnAttachmentGetCall<'a, C> {
12014 self._delegate = Some(new_value);
12015 self
12016 }
12017
12018 /// Set any additional parameter of the query string used in the request.
12019 /// It should be used to set parameters which are not yet available through their own
12020 /// setters.
12021 ///
12022 /// Please note that this method must not be used to set any of the known parameters
12023 /// which have their own setter method. If done anyway, the request will fail.
12024 ///
12025 /// # Additional Parameters
12026 ///
12027 /// * *$.xgafv* (query-string) - V1 error format.
12028 /// * *access_token* (query-string) - OAuth access token.
12029 /// * *alt* (query-string) - Data format for response.
12030 /// * *callback* (query-string) - JSONP
12031 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12032 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12033 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12034 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12035 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12036 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12037 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12038 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkAddOnAttachmentGetCall<'a, C>
12039 where
12040 T: AsRef<str>,
12041 {
12042 self._additional_params
12043 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12044 self
12045 }
12046
12047 /// Identifies the authorization scope for the method you are building.
12048 ///
12049 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12050 /// [`Scope::AddonStudent`].
12051 ///
12052 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12053 /// tokens for more than one scope.
12054 ///
12055 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12056 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12057 /// sufficient, a read-write scope will do as well.
12058 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkAddOnAttachmentGetCall<'a, C>
12059 where
12060 St: AsRef<str>,
12061 {
12062 self._scopes.insert(String::from(scope.as_ref()));
12063 self
12064 }
12065 /// Identifies the authorization scope(s) for the method you are building.
12066 ///
12067 /// See [`Self::add_scope()`] for details.
12068 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkAddOnAttachmentGetCall<'a, C>
12069 where
12070 I: IntoIterator<Item = St>,
12071 St: AsRef<str>,
12072 {
12073 self._scopes
12074 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12075 self
12076 }
12077
12078 /// Removes all scopes, and no default scope will be used either.
12079 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12080 /// for details).
12081 pub fn clear_scopes(mut self) -> CourseCourseWorkAddOnAttachmentGetCall<'a, C> {
12082 self._scopes.clear();
12083 self
12084 }
12085}
12086
12087/// Returns all attachments created by an add-on under the post. Requires the add-on to have active attachments on the post or have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
12088///
12089/// A builder for the *courseWork.addOnAttachments.list* method supported by a *course* resource.
12090/// It is not used directly, but through a [`CourseMethods`] instance.
12091///
12092/// # Example
12093///
12094/// Instantiate a resource method builder
12095///
12096/// ```test_harness,no_run
12097/// # extern crate hyper;
12098/// # extern crate hyper_rustls;
12099/// # extern crate google_classroom1 as classroom1;
12100/// # async fn dox() {
12101/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12102///
12103/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12104/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12105/// # .with_native_roots()
12106/// # .unwrap()
12107/// # .https_only()
12108/// # .enable_http2()
12109/// # .build();
12110///
12111/// # let executor = hyper_util::rt::TokioExecutor::new();
12112/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12113/// # secret,
12114/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12115/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12116/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12117/// # ),
12118/// # ).build().await.unwrap();
12119///
12120/// # let client = hyper_util::client::legacy::Client::builder(
12121/// # hyper_util::rt::TokioExecutor::new()
12122/// # )
12123/// # .build(
12124/// # hyper_rustls::HttpsConnectorBuilder::new()
12125/// # .with_native_roots()
12126/// # .unwrap()
12127/// # .https_or_http()
12128/// # .enable_http2()
12129/// # .build()
12130/// # );
12131/// # let mut hub = Classroom::new(client, auth);
12132/// // You can configure optional parameters by calling the respective setters at will, and
12133/// // execute the final call using `doit()`.
12134/// // Values shown here are possibly random and not representative !
12135/// let result = hub.courses().course_work_add_on_attachments_list("courseId", "itemId")
12136/// .post_id("dolores")
12137/// .page_token("gubergren")
12138/// .page_size(-74)
12139/// .doit().await;
12140/// # }
12141/// ```
12142pub struct CourseCourseWorkAddOnAttachmentListCall<'a, C>
12143where
12144 C: 'a,
12145{
12146 hub: &'a Classroom<C>,
12147 _course_id: String,
12148 _item_id: String,
12149 _post_id: Option<String>,
12150 _page_token: Option<String>,
12151 _page_size: Option<i32>,
12152 _delegate: Option<&'a mut dyn common::Delegate>,
12153 _additional_params: HashMap<String, String>,
12154 _scopes: BTreeSet<String>,
12155}
12156
12157impl<'a, C> common::CallBuilder for CourseCourseWorkAddOnAttachmentListCall<'a, C> {}
12158
12159impl<'a, C> CourseCourseWorkAddOnAttachmentListCall<'a, C>
12160where
12161 C: common::Connector,
12162{
12163 /// Perform the operation you have build so far.
12164 pub async fn doit(
12165 mut self,
12166 ) -> common::Result<(common::Response, ListAddOnAttachmentsResponse)> {
12167 use std::borrow::Cow;
12168 use std::io::{Read, Seek};
12169
12170 use common::{url::Params, ToParts};
12171 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12172
12173 let mut dd = common::DefaultDelegate;
12174 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12175 dlg.begin(common::MethodInfo {
12176 id: "classroom.courses.courseWork.addOnAttachments.list",
12177 http_method: hyper::Method::GET,
12178 });
12179
12180 for &field in [
12181 "alt",
12182 "courseId",
12183 "itemId",
12184 "postId",
12185 "pageToken",
12186 "pageSize",
12187 ]
12188 .iter()
12189 {
12190 if self._additional_params.contains_key(field) {
12191 dlg.finished(false);
12192 return Err(common::Error::FieldClash(field));
12193 }
12194 }
12195
12196 let mut params = Params::with_capacity(7 + self._additional_params.len());
12197 params.push("courseId", self._course_id);
12198 params.push("itemId", self._item_id);
12199 if let Some(value) = self._post_id.as_ref() {
12200 params.push("postId", value);
12201 }
12202 if let Some(value) = self._page_token.as_ref() {
12203 params.push("pageToken", value);
12204 }
12205 if let Some(value) = self._page_size.as_ref() {
12206 params.push("pageSize", value.to_string());
12207 }
12208
12209 params.extend(self._additional_params.iter());
12210
12211 params.push("alt", "json");
12212 let mut url = self.hub._base_url.clone()
12213 + "v1/courses/{courseId}/courseWork/{itemId}/addOnAttachments";
12214 if self._scopes.is_empty() {
12215 self._scopes
12216 .insert(Scope::AddonStudent.as_ref().to_string());
12217 }
12218
12219 #[allow(clippy::single_element_loop)]
12220 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{itemId}", "itemId")].iter()
12221 {
12222 url = params.uri_replacement(url, param_name, find_this, false);
12223 }
12224 {
12225 let to_remove = ["itemId", "courseId"];
12226 params.remove_params(&to_remove);
12227 }
12228
12229 let url = params.parse_with_url(&url);
12230
12231 loop {
12232 let token = match self
12233 .hub
12234 .auth
12235 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12236 .await
12237 {
12238 Ok(token) => token,
12239 Err(e) => match dlg.token(e) {
12240 Ok(token) => token,
12241 Err(e) => {
12242 dlg.finished(false);
12243 return Err(common::Error::MissingToken(e));
12244 }
12245 },
12246 };
12247 let mut req_result = {
12248 let client = &self.hub.client;
12249 dlg.pre_request();
12250 let mut req_builder = hyper::Request::builder()
12251 .method(hyper::Method::GET)
12252 .uri(url.as_str())
12253 .header(USER_AGENT, self.hub._user_agent.clone());
12254
12255 if let Some(token) = token.as_ref() {
12256 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12257 }
12258
12259 let request = req_builder
12260 .header(CONTENT_LENGTH, 0_u64)
12261 .body(common::to_body::<String>(None));
12262
12263 client.request(request.unwrap()).await
12264 };
12265
12266 match req_result {
12267 Err(err) => {
12268 if let common::Retry::After(d) = dlg.http_error(&err) {
12269 sleep(d).await;
12270 continue;
12271 }
12272 dlg.finished(false);
12273 return Err(common::Error::HttpError(err));
12274 }
12275 Ok(res) => {
12276 let (mut parts, body) = res.into_parts();
12277 let mut body = common::Body::new(body);
12278 if !parts.status.is_success() {
12279 let bytes = common::to_bytes(body).await.unwrap_or_default();
12280 let error = serde_json::from_str(&common::to_string(&bytes));
12281 let response = common::to_response(parts, bytes.into());
12282
12283 if let common::Retry::After(d) =
12284 dlg.http_failure(&response, error.as_ref().ok())
12285 {
12286 sleep(d).await;
12287 continue;
12288 }
12289
12290 dlg.finished(false);
12291
12292 return Err(match error {
12293 Ok(value) => common::Error::BadRequest(value),
12294 _ => common::Error::Failure(response),
12295 });
12296 }
12297 let response = {
12298 let bytes = common::to_bytes(body).await.unwrap_or_default();
12299 let encoded = common::to_string(&bytes);
12300 match serde_json::from_str(&encoded) {
12301 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12302 Err(error) => {
12303 dlg.response_json_decode_error(&encoded, &error);
12304 return Err(common::Error::JsonDecodeError(
12305 encoded.to_string(),
12306 error,
12307 ));
12308 }
12309 }
12310 };
12311
12312 dlg.finished(true);
12313 return Ok(response);
12314 }
12315 }
12316 }
12317 }
12318
12319 /// Required. Identifier of the course.
12320 ///
12321 /// Sets the *course id* path property to the given value.
12322 ///
12323 /// Even though the property as already been set when instantiating this call,
12324 /// we provide this method for API completeness.
12325 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentListCall<'a, C> {
12326 self._course_id = new_value.to_string();
12327 self
12328 }
12329 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` whose attachments should be enumerated. This field is required, but is not marked as such while we are migrating from post_id.
12330 ///
12331 /// Sets the *item id* path property to the given value.
12332 ///
12333 /// Even though the property as already been set when instantiating this call,
12334 /// we provide this method for API completeness.
12335 pub fn item_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentListCall<'a, C> {
12336 self._item_id = new_value.to_string();
12337 self
12338 }
12339 /// Optional. Identifier of the post under the course whose attachments to enumerate. Deprecated, use `item_id` instead.
12340 ///
12341 /// Sets the *post id* query property to the given value.
12342 pub fn post_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentListCall<'a, C> {
12343 self._post_id = Some(new_value.to_string());
12344 self
12345 }
12346 /// A page token, received from a previous `ListAddOnAttachments` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAddOnAttachments` must match the call that provided the page token.
12347 ///
12348 /// Sets the *page token* query property to the given value.
12349 pub fn page_token(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentListCall<'a, C> {
12350 self._page_token = Some(new_value.to_string());
12351 self
12352 }
12353 /// The maximum number of attachments to return. The service may return fewer than this value. If unspecified, at most 20 attachments will be returned. The maximum value is 20; values above 20 will be coerced to 20.
12354 ///
12355 /// Sets the *page size* query property to the given value.
12356 pub fn page_size(mut self, new_value: i32) -> CourseCourseWorkAddOnAttachmentListCall<'a, C> {
12357 self._page_size = Some(new_value);
12358 self
12359 }
12360 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12361 /// while executing the actual API request.
12362 ///
12363 /// ````text
12364 /// It should be used to handle progress information, and to implement a certain level of resilience.
12365 /// ````
12366 ///
12367 /// Sets the *delegate* property to the given value.
12368 pub fn delegate(
12369 mut self,
12370 new_value: &'a mut dyn common::Delegate,
12371 ) -> CourseCourseWorkAddOnAttachmentListCall<'a, C> {
12372 self._delegate = Some(new_value);
12373 self
12374 }
12375
12376 /// Set any additional parameter of the query string used in the request.
12377 /// It should be used to set parameters which are not yet available through their own
12378 /// setters.
12379 ///
12380 /// Please note that this method must not be used to set any of the known parameters
12381 /// which have their own setter method. If done anyway, the request will fail.
12382 ///
12383 /// # Additional Parameters
12384 ///
12385 /// * *$.xgafv* (query-string) - V1 error format.
12386 /// * *access_token* (query-string) - OAuth access token.
12387 /// * *alt* (query-string) - Data format for response.
12388 /// * *callback* (query-string) - JSONP
12389 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12390 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12391 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12392 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12393 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12394 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12395 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12396 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkAddOnAttachmentListCall<'a, C>
12397 where
12398 T: AsRef<str>,
12399 {
12400 self._additional_params
12401 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12402 self
12403 }
12404
12405 /// Identifies the authorization scope for the method you are building.
12406 ///
12407 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12408 /// [`Scope::AddonStudent`].
12409 ///
12410 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12411 /// tokens for more than one scope.
12412 ///
12413 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12414 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12415 /// sufficient, a read-write scope will do as well.
12416 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkAddOnAttachmentListCall<'a, C>
12417 where
12418 St: AsRef<str>,
12419 {
12420 self._scopes.insert(String::from(scope.as_ref()));
12421 self
12422 }
12423 /// Identifies the authorization scope(s) for the method you are building.
12424 ///
12425 /// See [`Self::add_scope()`] for details.
12426 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkAddOnAttachmentListCall<'a, C>
12427 where
12428 I: IntoIterator<Item = St>,
12429 St: AsRef<str>,
12430 {
12431 self._scopes
12432 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12433 self
12434 }
12435
12436 /// Removes all scopes, and no default scope will be used either.
12437 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12438 /// for details).
12439 pub fn clear_scopes(mut self) -> CourseCourseWorkAddOnAttachmentListCall<'a, C> {
12440 self._scopes.clear();
12441 self
12442 }
12443}
12444
12445/// Updates an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
12446///
12447/// A builder for the *courseWork.addOnAttachments.patch* method supported by a *course* resource.
12448/// It is not used directly, but through a [`CourseMethods`] instance.
12449///
12450/// # Example
12451///
12452/// Instantiate a resource method builder
12453///
12454/// ```test_harness,no_run
12455/// # extern crate hyper;
12456/// # extern crate hyper_rustls;
12457/// # extern crate google_classroom1 as classroom1;
12458/// use classroom1::api::AddOnAttachment;
12459/// # async fn dox() {
12460/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12461///
12462/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12463/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12464/// # .with_native_roots()
12465/// # .unwrap()
12466/// # .https_only()
12467/// # .enable_http2()
12468/// # .build();
12469///
12470/// # let executor = hyper_util::rt::TokioExecutor::new();
12471/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12472/// # secret,
12473/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12474/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12475/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12476/// # ),
12477/// # ).build().await.unwrap();
12478///
12479/// # let client = hyper_util::client::legacy::Client::builder(
12480/// # hyper_util::rt::TokioExecutor::new()
12481/// # )
12482/// # .build(
12483/// # hyper_rustls::HttpsConnectorBuilder::new()
12484/// # .with_native_roots()
12485/// # .unwrap()
12486/// # .https_or_http()
12487/// # .enable_http2()
12488/// # .build()
12489/// # );
12490/// # let mut hub = Classroom::new(client, auth);
12491/// // As the method needs a request, you would usually fill it with the desired information
12492/// // into the respective structure. Some of the parts shown here might not be applicable !
12493/// // Values shown here are possibly random and not representative !
12494/// let mut req = AddOnAttachment::default();
12495///
12496/// // You can configure optional parameters by calling the respective setters at will, and
12497/// // execute the final call using `doit()`.
12498/// // Values shown here are possibly random and not representative !
12499/// let result = hub.courses().course_work_add_on_attachments_patch(req, "courseId", "itemId", "attachmentId")
12500/// .update_mask(FieldMask::new::<&str>(&[]))
12501/// .post_id("dolore")
12502/// .doit().await;
12503/// # }
12504/// ```
12505pub struct CourseCourseWorkAddOnAttachmentPatchCall<'a, C>
12506where
12507 C: 'a,
12508{
12509 hub: &'a Classroom<C>,
12510 _request: AddOnAttachment,
12511 _course_id: String,
12512 _item_id: String,
12513 _attachment_id: String,
12514 _update_mask: Option<common::FieldMask>,
12515 _post_id: Option<String>,
12516 _delegate: Option<&'a mut dyn common::Delegate>,
12517 _additional_params: HashMap<String, String>,
12518 _scopes: BTreeSet<String>,
12519}
12520
12521impl<'a, C> common::CallBuilder for CourseCourseWorkAddOnAttachmentPatchCall<'a, C> {}
12522
12523impl<'a, C> CourseCourseWorkAddOnAttachmentPatchCall<'a, C>
12524where
12525 C: common::Connector,
12526{
12527 /// Perform the operation you have build so far.
12528 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
12529 use std::borrow::Cow;
12530 use std::io::{Read, Seek};
12531
12532 use common::{url::Params, ToParts};
12533 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12534
12535 let mut dd = common::DefaultDelegate;
12536 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12537 dlg.begin(common::MethodInfo {
12538 id: "classroom.courses.courseWork.addOnAttachments.patch",
12539 http_method: hyper::Method::PATCH,
12540 });
12541
12542 for &field in [
12543 "alt",
12544 "courseId",
12545 "itemId",
12546 "attachmentId",
12547 "updateMask",
12548 "postId",
12549 ]
12550 .iter()
12551 {
12552 if self._additional_params.contains_key(field) {
12553 dlg.finished(false);
12554 return Err(common::Error::FieldClash(field));
12555 }
12556 }
12557
12558 let mut params = Params::with_capacity(8 + self._additional_params.len());
12559 params.push("courseId", self._course_id);
12560 params.push("itemId", self._item_id);
12561 params.push("attachmentId", self._attachment_id);
12562 if let Some(value) = self._update_mask.as_ref() {
12563 params.push("updateMask", value.to_string());
12564 }
12565 if let Some(value) = self._post_id.as_ref() {
12566 params.push("postId", value);
12567 }
12568
12569 params.extend(self._additional_params.iter());
12570
12571 params.push("alt", "json");
12572 let mut url = self.hub._base_url.clone()
12573 + "v1/courses/{courseId}/courseWork/{itemId}/addOnAttachments/{attachmentId}";
12574 if self._scopes.is_empty() {
12575 self._scopes
12576 .insert(Scope::AddonTeacher.as_ref().to_string());
12577 }
12578
12579 #[allow(clippy::single_element_loop)]
12580 for &(find_this, param_name) in [
12581 ("{courseId}", "courseId"),
12582 ("{itemId}", "itemId"),
12583 ("{attachmentId}", "attachmentId"),
12584 ]
12585 .iter()
12586 {
12587 url = params.uri_replacement(url, param_name, find_this, false);
12588 }
12589 {
12590 let to_remove = ["attachmentId", "itemId", "courseId"];
12591 params.remove_params(&to_remove);
12592 }
12593
12594 let url = params.parse_with_url(&url);
12595
12596 let mut json_mime_type = mime::APPLICATION_JSON;
12597 let mut request_value_reader = {
12598 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12599 common::remove_json_null_values(&mut value);
12600 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12601 serde_json::to_writer(&mut dst, &value).unwrap();
12602 dst
12603 };
12604 let request_size = request_value_reader
12605 .seek(std::io::SeekFrom::End(0))
12606 .unwrap();
12607 request_value_reader
12608 .seek(std::io::SeekFrom::Start(0))
12609 .unwrap();
12610
12611 loop {
12612 let token = match self
12613 .hub
12614 .auth
12615 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12616 .await
12617 {
12618 Ok(token) => token,
12619 Err(e) => match dlg.token(e) {
12620 Ok(token) => token,
12621 Err(e) => {
12622 dlg.finished(false);
12623 return Err(common::Error::MissingToken(e));
12624 }
12625 },
12626 };
12627 request_value_reader
12628 .seek(std::io::SeekFrom::Start(0))
12629 .unwrap();
12630 let mut req_result = {
12631 let client = &self.hub.client;
12632 dlg.pre_request();
12633 let mut req_builder = hyper::Request::builder()
12634 .method(hyper::Method::PATCH)
12635 .uri(url.as_str())
12636 .header(USER_AGENT, self.hub._user_agent.clone());
12637
12638 if let Some(token) = token.as_ref() {
12639 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12640 }
12641
12642 let request = req_builder
12643 .header(CONTENT_TYPE, json_mime_type.to_string())
12644 .header(CONTENT_LENGTH, request_size as u64)
12645 .body(common::to_body(
12646 request_value_reader.get_ref().clone().into(),
12647 ));
12648
12649 client.request(request.unwrap()).await
12650 };
12651
12652 match req_result {
12653 Err(err) => {
12654 if let common::Retry::After(d) = dlg.http_error(&err) {
12655 sleep(d).await;
12656 continue;
12657 }
12658 dlg.finished(false);
12659 return Err(common::Error::HttpError(err));
12660 }
12661 Ok(res) => {
12662 let (mut parts, body) = res.into_parts();
12663 let mut body = common::Body::new(body);
12664 if !parts.status.is_success() {
12665 let bytes = common::to_bytes(body).await.unwrap_or_default();
12666 let error = serde_json::from_str(&common::to_string(&bytes));
12667 let response = common::to_response(parts, bytes.into());
12668
12669 if let common::Retry::After(d) =
12670 dlg.http_failure(&response, error.as_ref().ok())
12671 {
12672 sleep(d).await;
12673 continue;
12674 }
12675
12676 dlg.finished(false);
12677
12678 return Err(match error {
12679 Ok(value) => common::Error::BadRequest(value),
12680 _ => common::Error::Failure(response),
12681 });
12682 }
12683 let response = {
12684 let bytes = common::to_bytes(body).await.unwrap_or_default();
12685 let encoded = common::to_string(&bytes);
12686 match serde_json::from_str(&encoded) {
12687 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12688 Err(error) => {
12689 dlg.response_json_decode_error(&encoded, &error);
12690 return Err(common::Error::JsonDecodeError(
12691 encoded.to_string(),
12692 error,
12693 ));
12694 }
12695 }
12696 };
12697
12698 dlg.finished(true);
12699 return Ok(response);
12700 }
12701 }
12702 }
12703 }
12704
12705 ///
12706 /// Sets the *request* property to the given value.
12707 ///
12708 /// Even though the property as already been set when instantiating this call,
12709 /// we provide this method for API completeness.
12710 pub fn request(
12711 mut self,
12712 new_value: AddOnAttachment,
12713 ) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C> {
12714 self._request = new_value;
12715 self
12716 }
12717 /// Required. Identifier of the course.
12718 ///
12719 /// Sets the *course id* path property to the given value.
12720 ///
12721 /// Even though the property as already been set when instantiating this call,
12722 /// we provide this method for API completeness.
12723 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C> {
12724 self._course_id = new_value.to_string();
12725 self
12726 }
12727 /// Identifier of the post under which the attachment is attached.
12728 ///
12729 /// Sets the *item id* path property to the given value.
12730 ///
12731 /// Even though the property as already been set when instantiating this call,
12732 /// we provide this method for API completeness.
12733 pub fn item_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C> {
12734 self._item_id = new_value.to_string();
12735 self
12736 }
12737 /// Required. Identifier of the attachment.
12738 ///
12739 /// Sets the *attachment id* path property to the given value.
12740 ///
12741 /// Even though the property as already been set when instantiating this call,
12742 /// we provide this method for API completeness.
12743 pub fn attachment_id(
12744 mut self,
12745 new_value: &str,
12746 ) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C> {
12747 self._attachment_id = new_value.to_string();
12748 self
12749 }
12750 /// Required. Mask that identifies which fields on the attachment to update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the `AddOnAttachment` object. If a field that does not support empty values is included in the update mask and not set in the `AddOnAttachment` object, an `INVALID_ARGUMENT` error is returned. The following fields may be specified by teachers: * `title` * `teacher_view_uri` * `student_view_uri` * `student_work_review_uri` * `due_date` * `due_time` * `max_points`
12751 ///
12752 /// Sets the *update mask* query property to the given value.
12753 pub fn update_mask(
12754 mut self,
12755 new_value: common::FieldMask,
12756 ) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C> {
12757 self._update_mask = Some(new_value);
12758 self
12759 }
12760 /// Required. Identifier of the post under which the attachment is attached.
12761 ///
12762 /// Sets the *post id* query property to the given value.
12763 pub fn post_id(mut self, new_value: &str) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C> {
12764 self._post_id = Some(new_value.to_string());
12765 self
12766 }
12767 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12768 /// while executing the actual API request.
12769 ///
12770 /// ````text
12771 /// It should be used to handle progress information, and to implement a certain level of resilience.
12772 /// ````
12773 ///
12774 /// Sets the *delegate* property to the given value.
12775 pub fn delegate(
12776 mut self,
12777 new_value: &'a mut dyn common::Delegate,
12778 ) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C> {
12779 self._delegate = Some(new_value);
12780 self
12781 }
12782
12783 /// Set any additional parameter of the query string used in the request.
12784 /// It should be used to set parameters which are not yet available through their own
12785 /// setters.
12786 ///
12787 /// Please note that this method must not be used to set any of the known parameters
12788 /// which have their own setter method. If done anyway, the request will fail.
12789 ///
12790 /// # Additional Parameters
12791 ///
12792 /// * *$.xgafv* (query-string) - V1 error format.
12793 /// * *access_token* (query-string) - OAuth access token.
12794 /// * *alt* (query-string) - Data format for response.
12795 /// * *callback* (query-string) - JSONP
12796 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12797 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12798 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12799 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12800 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12801 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12802 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12803 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C>
12804 where
12805 T: AsRef<str>,
12806 {
12807 self._additional_params
12808 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12809 self
12810 }
12811
12812 /// Identifies the authorization scope for the method you are building.
12813 ///
12814 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12815 /// [`Scope::AddonTeacher`].
12816 ///
12817 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12818 /// tokens for more than one scope.
12819 ///
12820 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12821 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12822 /// sufficient, a read-write scope will do as well.
12823 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C>
12824 where
12825 St: AsRef<str>,
12826 {
12827 self._scopes.insert(String::from(scope.as_ref()));
12828 self
12829 }
12830 /// Identifies the authorization scope(s) for the method you are building.
12831 ///
12832 /// See [`Self::add_scope()`] for details.
12833 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C>
12834 where
12835 I: IntoIterator<Item = St>,
12836 St: AsRef<str>,
12837 {
12838 self._scopes
12839 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12840 self
12841 }
12842
12843 /// Removes all scopes, and no default scope will be used either.
12844 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12845 /// for details).
12846 pub fn clear_scopes(mut self) -> CourseCourseWorkAddOnAttachmentPatchCall<'a, C> {
12847 self._scopes.clear();
12848 self
12849 }
12850}
12851
12852/// Creates a rubric. The requesting user and course owner must have rubrics creation capabilities. For details, see [licensing requirements](https://developers.google.com/workspace/classroom/rubrics/limitations#license-requirements). For further details, see [Rubrics structure and known limitations](https://developers.google.com/classroom/rubrics/limitations). This request must be made by the Google Cloud console of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the parent course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user isn’t permitted to create rubrics for course work in the requested course. * `INTERNAL` if the request has insufficient OAuth scopes. * `INVALID_ARGUMENT` if the request is malformed and for the following request error: * `RubricCriteriaInvalidFormat` * `NOT_FOUND` if the requested course or course work don’t exist or the user doesn’t have access to the course or course work. * `FAILED_PRECONDITION` for the following request error: * `AttachmentNotVisible`
12853///
12854/// A builder for the *courseWork.rubrics.create* method supported by a *course* resource.
12855/// It is not used directly, but through a [`CourseMethods`] instance.
12856///
12857/// # Example
12858///
12859/// Instantiate a resource method builder
12860///
12861/// ```test_harness,no_run
12862/// # extern crate hyper;
12863/// # extern crate hyper_rustls;
12864/// # extern crate google_classroom1 as classroom1;
12865/// use classroom1::api::Rubric;
12866/// # async fn dox() {
12867/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12868///
12869/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12870/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12871/// # .with_native_roots()
12872/// # .unwrap()
12873/// # .https_only()
12874/// # .enable_http2()
12875/// # .build();
12876///
12877/// # let executor = hyper_util::rt::TokioExecutor::new();
12878/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12879/// # secret,
12880/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12881/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12882/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12883/// # ),
12884/// # ).build().await.unwrap();
12885///
12886/// # let client = hyper_util::client::legacy::Client::builder(
12887/// # hyper_util::rt::TokioExecutor::new()
12888/// # )
12889/// # .build(
12890/// # hyper_rustls::HttpsConnectorBuilder::new()
12891/// # .with_native_roots()
12892/// # .unwrap()
12893/// # .https_or_http()
12894/// # .enable_http2()
12895/// # .build()
12896/// # );
12897/// # let mut hub = Classroom::new(client, auth);
12898/// // As the method needs a request, you would usually fill it with the desired information
12899/// // into the respective structure. Some of the parts shown here might not be applicable !
12900/// // Values shown here are possibly random and not representative !
12901/// let mut req = Rubric::default();
12902///
12903/// // You can configure optional parameters by calling the respective setters at will, and
12904/// // execute the final call using `doit()`.
12905/// // Values shown here are possibly random and not representative !
12906/// let result = hub.courses().course_work_rubrics_create(req, "courseId", "courseWorkId")
12907/// .doit().await;
12908/// # }
12909/// ```
12910pub struct CourseCourseWorkRubricCreateCall<'a, C>
12911where
12912 C: 'a,
12913{
12914 hub: &'a Classroom<C>,
12915 _request: Rubric,
12916 _course_id: String,
12917 _course_work_id: String,
12918 _delegate: Option<&'a mut dyn common::Delegate>,
12919 _additional_params: HashMap<String, String>,
12920 _scopes: BTreeSet<String>,
12921}
12922
12923impl<'a, C> common::CallBuilder for CourseCourseWorkRubricCreateCall<'a, C> {}
12924
12925impl<'a, C> CourseCourseWorkRubricCreateCall<'a, C>
12926where
12927 C: common::Connector,
12928{
12929 /// Perform the operation you have build so far.
12930 pub async fn doit(mut self) -> common::Result<(common::Response, Rubric)> {
12931 use std::borrow::Cow;
12932 use std::io::{Read, Seek};
12933
12934 use common::{url::Params, ToParts};
12935 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12936
12937 let mut dd = common::DefaultDelegate;
12938 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12939 dlg.begin(common::MethodInfo {
12940 id: "classroom.courses.courseWork.rubrics.create",
12941 http_method: hyper::Method::POST,
12942 });
12943
12944 for &field in ["alt", "courseId", "courseWorkId"].iter() {
12945 if self._additional_params.contains_key(field) {
12946 dlg.finished(false);
12947 return Err(common::Error::FieldClash(field));
12948 }
12949 }
12950
12951 let mut params = Params::with_capacity(5 + self._additional_params.len());
12952 params.push("courseId", self._course_id);
12953 params.push("courseWorkId", self._course_work_id);
12954
12955 params.extend(self._additional_params.iter());
12956
12957 params.push("alt", "json");
12958 let mut url =
12959 self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{courseWorkId}/rubrics";
12960 if self._scopes.is_empty() {
12961 self._scopes
12962 .insert(Scope::CourseworkStudent.as_ref().to_string());
12963 }
12964
12965 #[allow(clippy::single_element_loop)]
12966 for &(find_this, param_name) in [
12967 ("{courseId}", "courseId"),
12968 ("{courseWorkId}", "courseWorkId"),
12969 ]
12970 .iter()
12971 {
12972 url = params.uri_replacement(url, param_name, find_this, false);
12973 }
12974 {
12975 let to_remove = ["courseWorkId", "courseId"];
12976 params.remove_params(&to_remove);
12977 }
12978
12979 let url = params.parse_with_url(&url);
12980
12981 let mut json_mime_type = mime::APPLICATION_JSON;
12982 let mut request_value_reader = {
12983 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12984 common::remove_json_null_values(&mut value);
12985 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12986 serde_json::to_writer(&mut dst, &value).unwrap();
12987 dst
12988 };
12989 let request_size = request_value_reader
12990 .seek(std::io::SeekFrom::End(0))
12991 .unwrap();
12992 request_value_reader
12993 .seek(std::io::SeekFrom::Start(0))
12994 .unwrap();
12995
12996 loop {
12997 let token = match self
12998 .hub
12999 .auth
13000 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13001 .await
13002 {
13003 Ok(token) => token,
13004 Err(e) => match dlg.token(e) {
13005 Ok(token) => token,
13006 Err(e) => {
13007 dlg.finished(false);
13008 return Err(common::Error::MissingToken(e));
13009 }
13010 },
13011 };
13012 request_value_reader
13013 .seek(std::io::SeekFrom::Start(0))
13014 .unwrap();
13015 let mut req_result = {
13016 let client = &self.hub.client;
13017 dlg.pre_request();
13018 let mut req_builder = hyper::Request::builder()
13019 .method(hyper::Method::POST)
13020 .uri(url.as_str())
13021 .header(USER_AGENT, self.hub._user_agent.clone());
13022
13023 if let Some(token) = token.as_ref() {
13024 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13025 }
13026
13027 let request = req_builder
13028 .header(CONTENT_TYPE, json_mime_type.to_string())
13029 .header(CONTENT_LENGTH, request_size as u64)
13030 .body(common::to_body(
13031 request_value_reader.get_ref().clone().into(),
13032 ));
13033
13034 client.request(request.unwrap()).await
13035 };
13036
13037 match req_result {
13038 Err(err) => {
13039 if let common::Retry::After(d) = dlg.http_error(&err) {
13040 sleep(d).await;
13041 continue;
13042 }
13043 dlg.finished(false);
13044 return Err(common::Error::HttpError(err));
13045 }
13046 Ok(res) => {
13047 let (mut parts, body) = res.into_parts();
13048 let mut body = common::Body::new(body);
13049 if !parts.status.is_success() {
13050 let bytes = common::to_bytes(body).await.unwrap_or_default();
13051 let error = serde_json::from_str(&common::to_string(&bytes));
13052 let response = common::to_response(parts, bytes.into());
13053
13054 if let common::Retry::After(d) =
13055 dlg.http_failure(&response, error.as_ref().ok())
13056 {
13057 sleep(d).await;
13058 continue;
13059 }
13060
13061 dlg.finished(false);
13062
13063 return Err(match error {
13064 Ok(value) => common::Error::BadRequest(value),
13065 _ => common::Error::Failure(response),
13066 });
13067 }
13068 let response = {
13069 let bytes = common::to_bytes(body).await.unwrap_or_default();
13070 let encoded = common::to_string(&bytes);
13071 match serde_json::from_str(&encoded) {
13072 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13073 Err(error) => {
13074 dlg.response_json_decode_error(&encoded, &error);
13075 return Err(common::Error::JsonDecodeError(
13076 encoded.to_string(),
13077 error,
13078 ));
13079 }
13080 }
13081 };
13082
13083 dlg.finished(true);
13084 return Ok(response);
13085 }
13086 }
13087 }
13088 }
13089
13090 ///
13091 /// Sets the *request* property to the given value.
13092 ///
13093 /// Even though the property as already been set when instantiating this call,
13094 /// we provide this method for API completeness.
13095 pub fn request(mut self, new_value: Rubric) -> CourseCourseWorkRubricCreateCall<'a, C> {
13096 self._request = new_value;
13097 self
13098 }
13099 /// Required. Identifier of the course.
13100 ///
13101 /// Sets the *course id* path property to the given value.
13102 ///
13103 /// Even though the property as already been set when instantiating this call,
13104 /// we provide this method for API completeness.
13105 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkRubricCreateCall<'a, C> {
13106 self._course_id = new_value.to_string();
13107 self
13108 }
13109 /// Required. Identifier of the course work.
13110 ///
13111 /// Sets the *course work id* path property to the given value.
13112 ///
13113 /// Even though the property as already been set when instantiating this call,
13114 /// we provide this method for API completeness.
13115 pub fn course_work_id(mut self, new_value: &str) -> CourseCourseWorkRubricCreateCall<'a, C> {
13116 self._course_work_id = new_value.to_string();
13117 self
13118 }
13119 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13120 /// while executing the actual API request.
13121 ///
13122 /// ````text
13123 /// It should be used to handle progress information, and to implement a certain level of resilience.
13124 /// ````
13125 ///
13126 /// Sets the *delegate* property to the given value.
13127 pub fn delegate(
13128 mut self,
13129 new_value: &'a mut dyn common::Delegate,
13130 ) -> CourseCourseWorkRubricCreateCall<'a, C> {
13131 self._delegate = Some(new_value);
13132 self
13133 }
13134
13135 /// Set any additional parameter of the query string used in the request.
13136 /// It should be used to set parameters which are not yet available through their own
13137 /// setters.
13138 ///
13139 /// Please note that this method must not be used to set any of the known parameters
13140 /// which have their own setter method. If done anyway, the request will fail.
13141 ///
13142 /// # Additional Parameters
13143 ///
13144 /// * *$.xgafv* (query-string) - V1 error format.
13145 /// * *access_token* (query-string) - OAuth access token.
13146 /// * *alt* (query-string) - Data format for response.
13147 /// * *callback* (query-string) - JSONP
13148 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13149 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13150 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13151 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13152 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13153 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13154 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13155 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkRubricCreateCall<'a, C>
13156 where
13157 T: AsRef<str>,
13158 {
13159 self._additional_params
13160 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13161 self
13162 }
13163
13164 /// Identifies the authorization scope for the method you are building.
13165 ///
13166 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13167 /// [`Scope::CourseworkStudent`].
13168 ///
13169 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13170 /// tokens for more than one scope.
13171 ///
13172 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13173 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13174 /// sufficient, a read-write scope will do as well.
13175 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkRubricCreateCall<'a, C>
13176 where
13177 St: AsRef<str>,
13178 {
13179 self._scopes.insert(String::from(scope.as_ref()));
13180 self
13181 }
13182 /// Identifies the authorization scope(s) for the method you are building.
13183 ///
13184 /// See [`Self::add_scope()`] for details.
13185 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkRubricCreateCall<'a, C>
13186 where
13187 I: IntoIterator<Item = St>,
13188 St: AsRef<str>,
13189 {
13190 self._scopes
13191 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13192 self
13193 }
13194
13195 /// Removes all scopes, and no default scope will be used either.
13196 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13197 /// for details).
13198 pub fn clear_scopes(mut self) -> CourseCourseWorkRubricCreateCall<'a, C> {
13199 self._scopes.clear();
13200 self
13201 }
13202}
13203
13204/// Deletes a rubric. The requesting user and course owner must have rubrics creation capabilities. For details, see [licensing requirements](https://developers.google.com/workspace/classroom/rubrics/limitations#license-requirements). This request must be made by the Google Cloud console of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding rubric. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project didn't create the corresponding rubric, or if the requesting user isn't permitted to delete the requested rubric. * `NOT_FOUND` if no rubric exists with the requested ID or the user does not have access to the course, course work, or rubric. * `INVALID_ARGUMENT` if grading has already started on the rubric.
13205///
13206/// A builder for the *courseWork.rubrics.delete* method supported by a *course* resource.
13207/// It is not used directly, but through a [`CourseMethods`] instance.
13208///
13209/// # Example
13210///
13211/// Instantiate a resource method builder
13212///
13213/// ```test_harness,no_run
13214/// # extern crate hyper;
13215/// # extern crate hyper_rustls;
13216/// # extern crate google_classroom1 as classroom1;
13217/// # async fn dox() {
13218/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13219///
13220/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13221/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13222/// # .with_native_roots()
13223/// # .unwrap()
13224/// # .https_only()
13225/// # .enable_http2()
13226/// # .build();
13227///
13228/// # let executor = hyper_util::rt::TokioExecutor::new();
13229/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13230/// # secret,
13231/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13232/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13233/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13234/// # ),
13235/// # ).build().await.unwrap();
13236///
13237/// # let client = hyper_util::client::legacy::Client::builder(
13238/// # hyper_util::rt::TokioExecutor::new()
13239/// # )
13240/// # .build(
13241/// # hyper_rustls::HttpsConnectorBuilder::new()
13242/// # .with_native_roots()
13243/// # .unwrap()
13244/// # .https_or_http()
13245/// # .enable_http2()
13246/// # .build()
13247/// # );
13248/// # let mut hub = Classroom::new(client, auth);
13249/// // You can configure optional parameters by calling the respective setters at will, and
13250/// // execute the final call using `doit()`.
13251/// // Values shown here are possibly random and not representative !
13252/// let result = hub.courses().course_work_rubrics_delete("courseId", "courseWorkId", "id")
13253/// .doit().await;
13254/// # }
13255/// ```
13256pub struct CourseCourseWorkRubricDeleteCall<'a, C>
13257where
13258 C: 'a,
13259{
13260 hub: &'a Classroom<C>,
13261 _course_id: String,
13262 _course_work_id: String,
13263 _id: String,
13264 _delegate: Option<&'a mut dyn common::Delegate>,
13265 _additional_params: HashMap<String, String>,
13266 _scopes: BTreeSet<String>,
13267}
13268
13269impl<'a, C> common::CallBuilder for CourseCourseWorkRubricDeleteCall<'a, C> {}
13270
13271impl<'a, C> CourseCourseWorkRubricDeleteCall<'a, C>
13272where
13273 C: common::Connector,
13274{
13275 /// Perform the operation you have build so far.
13276 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
13277 use std::borrow::Cow;
13278 use std::io::{Read, Seek};
13279
13280 use common::{url::Params, ToParts};
13281 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13282
13283 let mut dd = common::DefaultDelegate;
13284 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13285 dlg.begin(common::MethodInfo {
13286 id: "classroom.courses.courseWork.rubrics.delete",
13287 http_method: hyper::Method::DELETE,
13288 });
13289
13290 for &field in ["alt", "courseId", "courseWorkId", "id"].iter() {
13291 if self._additional_params.contains_key(field) {
13292 dlg.finished(false);
13293 return Err(common::Error::FieldClash(field));
13294 }
13295 }
13296
13297 let mut params = Params::with_capacity(5 + self._additional_params.len());
13298 params.push("courseId", self._course_id);
13299 params.push("courseWorkId", self._course_work_id);
13300 params.push("id", self._id);
13301
13302 params.extend(self._additional_params.iter());
13303
13304 params.push("alt", "json");
13305 let mut url = self.hub._base_url.clone()
13306 + "v1/courses/{courseId}/courseWork/{courseWorkId}/rubrics/{id}";
13307 if self._scopes.is_empty() {
13308 self._scopes
13309 .insert(Scope::CourseworkStudent.as_ref().to_string());
13310 }
13311
13312 #[allow(clippy::single_element_loop)]
13313 for &(find_this, param_name) in [
13314 ("{courseId}", "courseId"),
13315 ("{courseWorkId}", "courseWorkId"),
13316 ("{id}", "id"),
13317 ]
13318 .iter()
13319 {
13320 url = params.uri_replacement(url, param_name, find_this, false);
13321 }
13322 {
13323 let to_remove = ["id", "courseWorkId", "courseId"];
13324 params.remove_params(&to_remove);
13325 }
13326
13327 let url = params.parse_with_url(&url);
13328
13329 loop {
13330 let token = match self
13331 .hub
13332 .auth
13333 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13334 .await
13335 {
13336 Ok(token) => token,
13337 Err(e) => match dlg.token(e) {
13338 Ok(token) => token,
13339 Err(e) => {
13340 dlg.finished(false);
13341 return Err(common::Error::MissingToken(e));
13342 }
13343 },
13344 };
13345 let mut req_result = {
13346 let client = &self.hub.client;
13347 dlg.pre_request();
13348 let mut req_builder = hyper::Request::builder()
13349 .method(hyper::Method::DELETE)
13350 .uri(url.as_str())
13351 .header(USER_AGENT, self.hub._user_agent.clone());
13352
13353 if let Some(token) = token.as_ref() {
13354 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13355 }
13356
13357 let request = req_builder
13358 .header(CONTENT_LENGTH, 0_u64)
13359 .body(common::to_body::<String>(None));
13360
13361 client.request(request.unwrap()).await
13362 };
13363
13364 match req_result {
13365 Err(err) => {
13366 if let common::Retry::After(d) = dlg.http_error(&err) {
13367 sleep(d).await;
13368 continue;
13369 }
13370 dlg.finished(false);
13371 return Err(common::Error::HttpError(err));
13372 }
13373 Ok(res) => {
13374 let (mut parts, body) = res.into_parts();
13375 let mut body = common::Body::new(body);
13376 if !parts.status.is_success() {
13377 let bytes = common::to_bytes(body).await.unwrap_or_default();
13378 let error = serde_json::from_str(&common::to_string(&bytes));
13379 let response = common::to_response(parts, bytes.into());
13380
13381 if let common::Retry::After(d) =
13382 dlg.http_failure(&response, error.as_ref().ok())
13383 {
13384 sleep(d).await;
13385 continue;
13386 }
13387
13388 dlg.finished(false);
13389
13390 return Err(match error {
13391 Ok(value) => common::Error::BadRequest(value),
13392 _ => common::Error::Failure(response),
13393 });
13394 }
13395 let response = {
13396 let bytes = common::to_bytes(body).await.unwrap_or_default();
13397 let encoded = common::to_string(&bytes);
13398 match serde_json::from_str(&encoded) {
13399 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13400 Err(error) => {
13401 dlg.response_json_decode_error(&encoded, &error);
13402 return Err(common::Error::JsonDecodeError(
13403 encoded.to_string(),
13404 error,
13405 ));
13406 }
13407 }
13408 };
13409
13410 dlg.finished(true);
13411 return Ok(response);
13412 }
13413 }
13414 }
13415 }
13416
13417 /// Required. Identifier of the course.
13418 ///
13419 /// Sets the *course id* path property to the given value.
13420 ///
13421 /// Even though the property as already been set when instantiating this call,
13422 /// we provide this method for API completeness.
13423 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkRubricDeleteCall<'a, C> {
13424 self._course_id = new_value.to_string();
13425 self
13426 }
13427 /// Required. Identifier of the course work.
13428 ///
13429 /// Sets the *course work id* path property to the given value.
13430 ///
13431 /// Even though the property as already been set when instantiating this call,
13432 /// we provide this method for API completeness.
13433 pub fn course_work_id(mut self, new_value: &str) -> CourseCourseWorkRubricDeleteCall<'a, C> {
13434 self._course_work_id = new_value.to_string();
13435 self
13436 }
13437 /// Required. Identifier of the rubric.
13438 ///
13439 /// Sets the *id* path property to the given value.
13440 ///
13441 /// Even though the property as already been set when instantiating this call,
13442 /// we provide this method for API completeness.
13443 pub fn id(mut self, new_value: &str) -> CourseCourseWorkRubricDeleteCall<'a, C> {
13444 self._id = new_value.to_string();
13445 self
13446 }
13447 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13448 /// while executing the actual API request.
13449 ///
13450 /// ````text
13451 /// It should be used to handle progress information, and to implement a certain level of resilience.
13452 /// ````
13453 ///
13454 /// Sets the *delegate* property to the given value.
13455 pub fn delegate(
13456 mut self,
13457 new_value: &'a mut dyn common::Delegate,
13458 ) -> CourseCourseWorkRubricDeleteCall<'a, C> {
13459 self._delegate = Some(new_value);
13460 self
13461 }
13462
13463 /// Set any additional parameter of the query string used in the request.
13464 /// It should be used to set parameters which are not yet available through their own
13465 /// setters.
13466 ///
13467 /// Please note that this method must not be used to set any of the known parameters
13468 /// which have their own setter method. If done anyway, the request will fail.
13469 ///
13470 /// # Additional Parameters
13471 ///
13472 /// * *$.xgafv* (query-string) - V1 error format.
13473 /// * *access_token* (query-string) - OAuth access token.
13474 /// * *alt* (query-string) - Data format for response.
13475 /// * *callback* (query-string) - JSONP
13476 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13477 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13478 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13479 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13480 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13481 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13482 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13483 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkRubricDeleteCall<'a, C>
13484 where
13485 T: AsRef<str>,
13486 {
13487 self._additional_params
13488 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13489 self
13490 }
13491
13492 /// Identifies the authorization scope for the method you are building.
13493 ///
13494 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13495 /// [`Scope::CourseworkStudent`].
13496 ///
13497 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13498 /// tokens for more than one scope.
13499 ///
13500 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13501 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13502 /// sufficient, a read-write scope will do as well.
13503 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkRubricDeleteCall<'a, C>
13504 where
13505 St: AsRef<str>,
13506 {
13507 self._scopes.insert(String::from(scope.as_ref()));
13508 self
13509 }
13510 /// Identifies the authorization scope(s) for the method you are building.
13511 ///
13512 /// See [`Self::add_scope()`] for details.
13513 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkRubricDeleteCall<'a, C>
13514 where
13515 I: IntoIterator<Item = St>,
13516 St: AsRef<str>,
13517 {
13518 self._scopes
13519 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13520 self
13521 }
13522
13523 /// Removes all scopes, and no default scope will be used either.
13524 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13525 /// for details).
13526 pub fn clear_scopes(mut self) -> CourseCourseWorkRubricDeleteCall<'a, C> {
13527 self._scopes.clear();
13528 self
13529 }
13530}
13531
13532/// Returns a rubric. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or rubric doesn't exist or if the user doesn't have access to the corresponding course work.
13533///
13534/// A builder for the *courseWork.rubrics.get* method supported by a *course* resource.
13535/// It is not used directly, but through a [`CourseMethods`] instance.
13536///
13537/// # Example
13538///
13539/// Instantiate a resource method builder
13540///
13541/// ```test_harness,no_run
13542/// # extern crate hyper;
13543/// # extern crate hyper_rustls;
13544/// # extern crate google_classroom1 as classroom1;
13545/// # async fn dox() {
13546/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13547///
13548/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13549/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13550/// # .with_native_roots()
13551/// # .unwrap()
13552/// # .https_only()
13553/// # .enable_http2()
13554/// # .build();
13555///
13556/// # let executor = hyper_util::rt::TokioExecutor::new();
13557/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13558/// # secret,
13559/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13560/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13561/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13562/// # ),
13563/// # ).build().await.unwrap();
13564///
13565/// # let client = hyper_util::client::legacy::Client::builder(
13566/// # hyper_util::rt::TokioExecutor::new()
13567/// # )
13568/// # .build(
13569/// # hyper_rustls::HttpsConnectorBuilder::new()
13570/// # .with_native_roots()
13571/// # .unwrap()
13572/// # .https_or_http()
13573/// # .enable_http2()
13574/// # .build()
13575/// # );
13576/// # let mut hub = Classroom::new(client, auth);
13577/// // You can configure optional parameters by calling the respective setters at will, and
13578/// // execute the final call using `doit()`.
13579/// // Values shown here are possibly random and not representative !
13580/// let result = hub.courses().course_work_rubrics_get("courseId", "courseWorkId", "id")
13581/// .doit().await;
13582/// # }
13583/// ```
13584pub struct CourseCourseWorkRubricGetCall<'a, C>
13585where
13586 C: 'a,
13587{
13588 hub: &'a Classroom<C>,
13589 _course_id: String,
13590 _course_work_id: String,
13591 _id: String,
13592 _delegate: Option<&'a mut dyn common::Delegate>,
13593 _additional_params: HashMap<String, String>,
13594 _scopes: BTreeSet<String>,
13595}
13596
13597impl<'a, C> common::CallBuilder for CourseCourseWorkRubricGetCall<'a, C> {}
13598
13599impl<'a, C> CourseCourseWorkRubricGetCall<'a, C>
13600where
13601 C: common::Connector,
13602{
13603 /// Perform the operation you have build so far.
13604 pub async fn doit(mut self) -> common::Result<(common::Response, Rubric)> {
13605 use std::borrow::Cow;
13606 use std::io::{Read, Seek};
13607
13608 use common::{url::Params, ToParts};
13609 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13610
13611 let mut dd = common::DefaultDelegate;
13612 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13613 dlg.begin(common::MethodInfo {
13614 id: "classroom.courses.courseWork.rubrics.get",
13615 http_method: hyper::Method::GET,
13616 });
13617
13618 for &field in ["alt", "courseId", "courseWorkId", "id"].iter() {
13619 if self._additional_params.contains_key(field) {
13620 dlg.finished(false);
13621 return Err(common::Error::FieldClash(field));
13622 }
13623 }
13624
13625 let mut params = Params::with_capacity(5 + self._additional_params.len());
13626 params.push("courseId", self._course_id);
13627 params.push("courseWorkId", self._course_work_id);
13628 params.push("id", self._id);
13629
13630 params.extend(self._additional_params.iter());
13631
13632 params.push("alt", "json");
13633 let mut url = self.hub._base_url.clone()
13634 + "v1/courses/{courseId}/courseWork/{courseWorkId}/rubrics/{id}";
13635 if self._scopes.is_empty() {
13636 self._scopes
13637 .insert(Scope::CourseworkMeReadonly.as_ref().to_string());
13638 }
13639
13640 #[allow(clippy::single_element_loop)]
13641 for &(find_this, param_name) in [
13642 ("{courseId}", "courseId"),
13643 ("{courseWorkId}", "courseWorkId"),
13644 ("{id}", "id"),
13645 ]
13646 .iter()
13647 {
13648 url = params.uri_replacement(url, param_name, find_this, false);
13649 }
13650 {
13651 let to_remove = ["id", "courseWorkId", "courseId"];
13652 params.remove_params(&to_remove);
13653 }
13654
13655 let url = params.parse_with_url(&url);
13656
13657 loop {
13658 let token = match self
13659 .hub
13660 .auth
13661 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13662 .await
13663 {
13664 Ok(token) => token,
13665 Err(e) => match dlg.token(e) {
13666 Ok(token) => token,
13667 Err(e) => {
13668 dlg.finished(false);
13669 return Err(common::Error::MissingToken(e));
13670 }
13671 },
13672 };
13673 let mut req_result = {
13674 let client = &self.hub.client;
13675 dlg.pre_request();
13676 let mut req_builder = hyper::Request::builder()
13677 .method(hyper::Method::GET)
13678 .uri(url.as_str())
13679 .header(USER_AGENT, self.hub._user_agent.clone());
13680
13681 if let Some(token) = token.as_ref() {
13682 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13683 }
13684
13685 let request = req_builder
13686 .header(CONTENT_LENGTH, 0_u64)
13687 .body(common::to_body::<String>(None));
13688
13689 client.request(request.unwrap()).await
13690 };
13691
13692 match req_result {
13693 Err(err) => {
13694 if let common::Retry::After(d) = dlg.http_error(&err) {
13695 sleep(d).await;
13696 continue;
13697 }
13698 dlg.finished(false);
13699 return Err(common::Error::HttpError(err));
13700 }
13701 Ok(res) => {
13702 let (mut parts, body) = res.into_parts();
13703 let mut body = common::Body::new(body);
13704 if !parts.status.is_success() {
13705 let bytes = common::to_bytes(body).await.unwrap_or_default();
13706 let error = serde_json::from_str(&common::to_string(&bytes));
13707 let response = common::to_response(parts, bytes.into());
13708
13709 if let common::Retry::After(d) =
13710 dlg.http_failure(&response, error.as_ref().ok())
13711 {
13712 sleep(d).await;
13713 continue;
13714 }
13715
13716 dlg.finished(false);
13717
13718 return Err(match error {
13719 Ok(value) => common::Error::BadRequest(value),
13720 _ => common::Error::Failure(response),
13721 });
13722 }
13723 let response = {
13724 let bytes = common::to_bytes(body).await.unwrap_or_default();
13725 let encoded = common::to_string(&bytes);
13726 match serde_json::from_str(&encoded) {
13727 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13728 Err(error) => {
13729 dlg.response_json_decode_error(&encoded, &error);
13730 return Err(common::Error::JsonDecodeError(
13731 encoded.to_string(),
13732 error,
13733 ));
13734 }
13735 }
13736 };
13737
13738 dlg.finished(true);
13739 return Ok(response);
13740 }
13741 }
13742 }
13743 }
13744
13745 /// Required. Identifier of the course.
13746 ///
13747 /// Sets the *course id* path property to the given value.
13748 ///
13749 /// Even though the property as already been set when instantiating this call,
13750 /// we provide this method for API completeness.
13751 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkRubricGetCall<'a, C> {
13752 self._course_id = new_value.to_string();
13753 self
13754 }
13755 /// Required. Identifier of the course work.
13756 ///
13757 /// Sets the *course work id* path property to the given value.
13758 ///
13759 /// Even though the property as already been set when instantiating this call,
13760 /// we provide this method for API completeness.
13761 pub fn course_work_id(mut self, new_value: &str) -> CourseCourseWorkRubricGetCall<'a, C> {
13762 self._course_work_id = new_value.to_string();
13763 self
13764 }
13765 /// Required. Identifier of the rubric.
13766 ///
13767 /// Sets the *id* path property to the given value.
13768 ///
13769 /// Even though the property as already been set when instantiating this call,
13770 /// we provide this method for API completeness.
13771 pub fn id(mut self, new_value: &str) -> CourseCourseWorkRubricGetCall<'a, C> {
13772 self._id = new_value.to_string();
13773 self
13774 }
13775 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13776 /// while executing the actual API request.
13777 ///
13778 /// ````text
13779 /// It should be used to handle progress information, and to implement a certain level of resilience.
13780 /// ````
13781 ///
13782 /// Sets the *delegate* property to the given value.
13783 pub fn delegate(
13784 mut self,
13785 new_value: &'a mut dyn common::Delegate,
13786 ) -> CourseCourseWorkRubricGetCall<'a, C> {
13787 self._delegate = Some(new_value);
13788 self
13789 }
13790
13791 /// Set any additional parameter of the query string used in the request.
13792 /// It should be used to set parameters which are not yet available through their own
13793 /// setters.
13794 ///
13795 /// Please note that this method must not be used to set any of the known parameters
13796 /// which have their own setter method. If done anyway, the request will fail.
13797 ///
13798 /// # Additional Parameters
13799 ///
13800 /// * *$.xgafv* (query-string) - V1 error format.
13801 /// * *access_token* (query-string) - OAuth access token.
13802 /// * *alt* (query-string) - Data format for response.
13803 /// * *callback* (query-string) - JSONP
13804 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13805 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13806 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13807 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13808 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
13809 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13810 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13811 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkRubricGetCall<'a, C>
13812 where
13813 T: AsRef<str>,
13814 {
13815 self._additional_params
13816 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13817 self
13818 }
13819
13820 /// Identifies the authorization scope for the method you are building.
13821 ///
13822 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13823 /// [`Scope::CourseworkMeReadonly`].
13824 ///
13825 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13826 /// tokens for more than one scope.
13827 ///
13828 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13829 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13830 /// sufficient, a read-write scope will do as well.
13831 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkRubricGetCall<'a, C>
13832 where
13833 St: AsRef<str>,
13834 {
13835 self._scopes.insert(String::from(scope.as_ref()));
13836 self
13837 }
13838 /// Identifies the authorization scope(s) for the method you are building.
13839 ///
13840 /// See [`Self::add_scope()`] for details.
13841 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkRubricGetCall<'a, C>
13842 where
13843 I: IntoIterator<Item = St>,
13844 St: AsRef<str>,
13845 {
13846 self._scopes
13847 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13848 self
13849 }
13850
13851 /// Removes all scopes, and no default scope will be used either.
13852 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13853 /// for details).
13854 pub fn clear_scopes(mut self) -> CourseCourseWorkRubricGetCall<'a, C> {
13855 self._scopes.clear();
13856 self
13857 }
13858}
13859
13860/// Returns a list of rubrics that the requester is permitted to view. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work doesn't exist or if the user doesn't have access to the corresponding course work.
13861///
13862/// A builder for the *courseWork.rubrics.list* method supported by a *course* resource.
13863/// It is not used directly, but through a [`CourseMethods`] instance.
13864///
13865/// # Example
13866///
13867/// Instantiate a resource method builder
13868///
13869/// ```test_harness,no_run
13870/// # extern crate hyper;
13871/// # extern crate hyper_rustls;
13872/// # extern crate google_classroom1 as classroom1;
13873/// # async fn dox() {
13874/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13875///
13876/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13877/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13878/// # .with_native_roots()
13879/// # .unwrap()
13880/// # .https_only()
13881/// # .enable_http2()
13882/// # .build();
13883///
13884/// # let executor = hyper_util::rt::TokioExecutor::new();
13885/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13886/// # secret,
13887/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13888/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13889/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13890/// # ),
13891/// # ).build().await.unwrap();
13892///
13893/// # let client = hyper_util::client::legacy::Client::builder(
13894/// # hyper_util::rt::TokioExecutor::new()
13895/// # )
13896/// # .build(
13897/// # hyper_rustls::HttpsConnectorBuilder::new()
13898/// # .with_native_roots()
13899/// # .unwrap()
13900/// # .https_or_http()
13901/// # .enable_http2()
13902/// # .build()
13903/// # );
13904/// # let mut hub = Classroom::new(client, auth);
13905/// // You can configure optional parameters by calling the respective setters at will, and
13906/// // execute the final call using `doit()`.
13907/// // Values shown here are possibly random and not representative !
13908/// let result = hub.courses().course_work_rubrics_list("courseId", "courseWorkId")
13909/// .page_token("sed")
13910/// .page_size(-98)
13911/// .doit().await;
13912/// # }
13913/// ```
13914pub struct CourseCourseWorkRubricListCall<'a, C>
13915where
13916 C: 'a,
13917{
13918 hub: &'a Classroom<C>,
13919 _course_id: String,
13920 _course_work_id: String,
13921 _page_token: Option<String>,
13922 _page_size: Option<i32>,
13923 _delegate: Option<&'a mut dyn common::Delegate>,
13924 _additional_params: HashMap<String, String>,
13925 _scopes: BTreeSet<String>,
13926}
13927
13928impl<'a, C> common::CallBuilder for CourseCourseWorkRubricListCall<'a, C> {}
13929
13930impl<'a, C> CourseCourseWorkRubricListCall<'a, C>
13931where
13932 C: common::Connector,
13933{
13934 /// Perform the operation you have build so far.
13935 pub async fn doit(mut self) -> common::Result<(common::Response, ListRubricsResponse)> {
13936 use std::borrow::Cow;
13937 use std::io::{Read, Seek};
13938
13939 use common::{url::Params, ToParts};
13940 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13941
13942 let mut dd = common::DefaultDelegate;
13943 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13944 dlg.begin(common::MethodInfo {
13945 id: "classroom.courses.courseWork.rubrics.list",
13946 http_method: hyper::Method::GET,
13947 });
13948
13949 for &field in ["alt", "courseId", "courseWorkId", "pageToken", "pageSize"].iter() {
13950 if self._additional_params.contains_key(field) {
13951 dlg.finished(false);
13952 return Err(common::Error::FieldClash(field));
13953 }
13954 }
13955
13956 let mut params = Params::with_capacity(6 + self._additional_params.len());
13957 params.push("courseId", self._course_id);
13958 params.push("courseWorkId", self._course_work_id);
13959 if let Some(value) = self._page_token.as_ref() {
13960 params.push("pageToken", value);
13961 }
13962 if let Some(value) = self._page_size.as_ref() {
13963 params.push("pageSize", value.to_string());
13964 }
13965
13966 params.extend(self._additional_params.iter());
13967
13968 params.push("alt", "json");
13969 let mut url =
13970 self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{courseWorkId}/rubrics";
13971 if self._scopes.is_empty() {
13972 self._scopes
13973 .insert(Scope::CourseworkMeReadonly.as_ref().to_string());
13974 }
13975
13976 #[allow(clippy::single_element_loop)]
13977 for &(find_this, param_name) in [
13978 ("{courseId}", "courseId"),
13979 ("{courseWorkId}", "courseWorkId"),
13980 ]
13981 .iter()
13982 {
13983 url = params.uri_replacement(url, param_name, find_this, false);
13984 }
13985 {
13986 let to_remove = ["courseWorkId", "courseId"];
13987 params.remove_params(&to_remove);
13988 }
13989
13990 let url = params.parse_with_url(&url);
13991
13992 loop {
13993 let token = match self
13994 .hub
13995 .auth
13996 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13997 .await
13998 {
13999 Ok(token) => token,
14000 Err(e) => match dlg.token(e) {
14001 Ok(token) => token,
14002 Err(e) => {
14003 dlg.finished(false);
14004 return Err(common::Error::MissingToken(e));
14005 }
14006 },
14007 };
14008 let mut req_result = {
14009 let client = &self.hub.client;
14010 dlg.pre_request();
14011 let mut req_builder = hyper::Request::builder()
14012 .method(hyper::Method::GET)
14013 .uri(url.as_str())
14014 .header(USER_AGENT, self.hub._user_agent.clone());
14015
14016 if let Some(token) = token.as_ref() {
14017 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14018 }
14019
14020 let request = req_builder
14021 .header(CONTENT_LENGTH, 0_u64)
14022 .body(common::to_body::<String>(None));
14023
14024 client.request(request.unwrap()).await
14025 };
14026
14027 match req_result {
14028 Err(err) => {
14029 if let common::Retry::After(d) = dlg.http_error(&err) {
14030 sleep(d).await;
14031 continue;
14032 }
14033 dlg.finished(false);
14034 return Err(common::Error::HttpError(err));
14035 }
14036 Ok(res) => {
14037 let (mut parts, body) = res.into_parts();
14038 let mut body = common::Body::new(body);
14039 if !parts.status.is_success() {
14040 let bytes = common::to_bytes(body).await.unwrap_or_default();
14041 let error = serde_json::from_str(&common::to_string(&bytes));
14042 let response = common::to_response(parts, bytes.into());
14043
14044 if let common::Retry::After(d) =
14045 dlg.http_failure(&response, error.as_ref().ok())
14046 {
14047 sleep(d).await;
14048 continue;
14049 }
14050
14051 dlg.finished(false);
14052
14053 return Err(match error {
14054 Ok(value) => common::Error::BadRequest(value),
14055 _ => common::Error::Failure(response),
14056 });
14057 }
14058 let response = {
14059 let bytes = common::to_bytes(body).await.unwrap_or_default();
14060 let encoded = common::to_string(&bytes);
14061 match serde_json::from_str(&encoded) {
14062 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14063 Err(error) => {
14064 dlg.response_json_decode_error(&encoded, &error);
14065 return Err(common::Error::JsonDecodeError(
14066 encoded.to_string(),
14067 error,
14068 ));
14069 }
14070 }
14071 };
14072
14073 dlg.finished(true);
14074 return Ok(response);
14075 }
14076 }
14077 }
14078 }
14079
14080 /// Required. Identifier of the course.
14081 ///
14082 /// Sets the *course id* path property to the given value.
14083 ///
14084 /// Even though the property as already been set when instantiating this call,
14085 /// we provide this method for API completeness.
14086 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkRubricListCall<'a, C> {
14087 self._course_id = new_value.to_string();
14088 self
14089 }
14090 /// Required. Identifier of the course work.
14091 ///
14092 /// Sets the *course work id* path property to the given value.
14093 ///
14094 /// Even though the property as already been set when instantiating this call,
14095 /// we provide this method for API completeness.
14096 pub fn course_work_id(mut self, new_value: &str) -> CourseCourseWorkRubricListCall<'a, C> {
14097 self._course_work_id = new_value.to_string();
14098 self
14099 }
14100 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
14101 ///
14102 /// Sets the *page token* query property to the given value.
14103 pub fn page_token(mut self, new_value: &str) -> CourseCourseWorkRubricListCall<'a, C> {
14104 self._page_token = Some(new_value.to_string());
14105 self
14106 }
14107 /// The maximum number of rubrics to return. If unspecified, at most 1 rubric is returned. The maximum value is 1; values above 1 are coerced to 1.
14108 ///
14109 /// Sets the *page size* query property to the given value.
14110 pub fn page_size(mut self, new_value: i32) -> CourseCourseWorkRubricListCall<'a, C> {
14111 self._page_size = Some(new_value);
14112 self
14113 }
14114 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14115 /// while executing the actual API request.
14116 ///
14117 /// ````text
14118 /// It should be used to handle progress information, and to implement a certain level of resilience.
14119 /// ````
14120 ///
14121 /// Sets the *delegate* property to the given value.
14122 pub fn delegate(
14123 mut self,
14124 new_value: &'a mut dyn common::Delegate,
14125 ) -> CourseCourseWorkRubricListCall<'a, C> {
14126 self._delegate = Some(new_value);
14127 self
14128 }
14129
14130 /// Set any additional parameter of the query string used in the request.
14131 /// It should be used to set parameters which are not yet available through their own
14132 /// setters.
14133 ///
14134 /// Please note that this method must not be used to set any of the known parameters
14135 /// which have their own setter method. If done anyway, the request will fail.
14136 ///
14137 /// # Additional Parameters
14138 ///
14139 /// * *$.xgafv* (query-string) - V1 error format.
14140 /// * *access_token* (query-string) - OAuth access token.
14141 /// * *alt* (query-string) - Data format for response.
14142 /// * *callback* (query-string) - JSONP
14143 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14144 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14145 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14146 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14147 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14148 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14149 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14150 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkRubricListCall<'a, C>
14151 where
14152 T: AsRef<str>,
14153 {
14154 self._additional_params
14155 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14156 self
14157 }
14158
14159 /// Identifies the authorization scope for the method you are building.
14160 ///
14161 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14162 /// [`Scope::CourseworkMeReadonly`].
14163 ///
14164 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14165 /// tokens for more than one scope.
14166 ///
14167 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14168 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14169 /// sufficient, a read-write scope will do as well.
14170 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkRubricListCall<'a, C>
14171 where
14172 St: AsRef<str>,
14173 {
14174 self._scopes.insert(String::from(scope.as_ref()));
14175 self
14176 }
14177 /// Identifies the authorization scope(s) for the method you are building.
14178 ///
14179 /// See [`Self::add_scope()`] for details.
14180 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkRubricListCall<'a, C>
14181 where
14182 I: IntoIterator<Item = St>,
14183 St: AsRef<str>,
14184 {
14185 self._scopes
14186 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14187 self
14188 }
14189
14190 /// Removes all scopes, and no default scope will be used either.
14191 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14192 /// for details).
14193 pub fn clear_scopes(mut self) -> CourseCourseWorkRubricListCall<'a, C> {
14194 self._scopes.clear();
14195 self
14196 }
14197}
14198
14199/// Updates a rubric. See google.classroom.v1.Rubric for details of which fields can be updated. Rubric update capabilities are [limited](https://developers.google.com/classroom/rubrics/limitations) once grading has started. The requesting user and course owner must have rubrics creation capabilities. For details, see [licensing requirements](https://developers.google.com/workspace/classroom/rubrics/limitations#license-requirements). This request must be made by the Google Cloud console of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the parent course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project didn’t create the corresponding course work, if the user isn’t permitted to make the requested modification to the rubric, or for access errors. This error code is also returned if grading has already started on the rubric. * `INVALID_ARGUMENT` if the request is malformed and for the following request error: * `RubricCriteriaInvalidFormat` * `NOT_FOUND` if the requested course, course work, or rubric doesn’t exist or if the user doesn’t have access to the corresponding course work. * `INTERNAL` if grading has already started on the rubric.
14200///
14201/// A builder for the *courseWork.rubrics.patch* method supported by a *course* resource.
14202/// It is not used directly, but through a [`CourseMethods`] instance.
14203///
14204/// # Example
14205///
14206/// Instantiate a resource method builder
14207///
14208/// ```test_harness,no_run
14209/// # extern crate hyper;
14210/// # extern crate hyper_rustls;
14211/// # extern crate google_classroom1 as classroom1;
14212/// use classroom1::api::Rubric;
14213/// # async fn dox() {
14214/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14215///
14216/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14217/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14218/// # .with_native_roots()
14219/// # .unwrap()
14220/// # .https_only()
14221/// # .enable_http2()
14222/// # .build();
14223///
14224/// # let executor = hyper_util::rt::TokioExecutor::new();
14225/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14226/// # secret,
14227/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14228/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14229/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14230/// # ),
14231/// # ).build().await.unwrap();
14232///
14233/// # let client = hyper_util::client::legacy::Client::builder(
14234/// # hyper_util::rt::TokioExecutor::new()
14235/// # )
14236/// # .build(
14237/// # hyper_rustls::HttpsConnectorBuilder::new()
14238/// # .with_native_roots()
14239/// # .unwrap()
14240/// # .https_or_http()
14241/// # .enable_http2()
14242/// # .build()
14243/// # );
14244/// # let mut hub = Classroom::new(client, auth);
14245/// // As the method needs a request, you would usually fill it with the desired information
14246/// // into the respective structure. Some of the parts shown here might not be applicable !
14247/// // Values shown here are possibly random and not representative !
14248/// let mut req = Rubric::default();
14249///
14250/// // You can configure optional parameters by calling the respective setters at will, and
14251/// // execute the final call using `doit()`.
14252/// // Values shown here are possibly random and not representative !
14253/// let result = hub.courses().course_work_rubrics_patch(req, "courseId", "courseWorkId", "id")
14254/// .update_mask(FieldMask::new::<&str>(&[]))
14255/// .doit().await;
14256/// # }
14257/// ```
14258pub struct CourseCourseWorkRubricPatchCall<'a, C>
14259where
14260 C: 'a,
14261{
14262 hub: &'a Classroom<C>,
14263 _request: Rubric,
14264 _course_id: String,
14265 _course_work_id: String,
14266 _id: String,
14267 _update_mask: Option<common::FieldMask>,
14268 _delegate: Option<&'a mut dyn common::Delegate>,
14269 _additional_params: HashMap<String, String>,
14270 _scopes: BTreeSet<String>,
14271}
14272
14273impl<'a, C> common::CallBuilder for CourseCourseWorkRubricPatchCall<'a, C> {}
14274
14275impl<'a, C> CourseCourseWorkRubricPatchCall<'a, C>
14276where
14277 C: common::Connector,
14278{
14279 /// Perform the operation you have build so far.
14280 pub async fn doit(mut self) -> common::Result<(common::Response, Rubric)> {
14281 use std::borrow::Cow;
14282 use std::io::{Read, Seek};
14283
14284 use common::{url::Params, ToParts};
14285 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14286
14287 let mut dd = common::DefaultDelegate;
14288 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14289 dlg.begin(common::MethodInfo {
14290 id: "classroom.courses.courseWork.rubrics.patch",
14291 http_method: hyper::Method::PATCH,
14292 });
14293
14294 for &field in ["alt", "courseId", "courseWorkId", "id", "updateMask"].iter() {
14295 if self._additional_params.contains_key(field) {
14296 dlg.finished(false);
14297 return Err(common::Error::FieldClash(field));
14298 }
14299 }
14300
14301 let mut params = Params::with_capacity(7 + self._additional_params.len());
14302 params.push("courseId", self._course_id);
14303 params.push("courseWorkId", self._course_work_id);
14304 params.push("id", self._id);
14305 if let Some(value) = self._update_mask.as_ref() {
14306 params.push("updateMask", value.to_string());
14307 }
14308
14309 params.extend(self._additional_params.iter());
14310
14311 params.push("alt", "json");
14312 let mut url = self.hub._base_url.clone()
14313 + "v1/courses/{courseId}/courseWork/{courseWorkId}/rubrics/{id}";
14314 if self._scopes.is_empty() {
14315 self._scopes
14316 .insert(Scope::CourseworkStudent.as_ref().to_string());
14317 }
14318
14319 #[allow(clippy::single_element_loop)]
14320 for &(find_this, param_name) in [
14321 ("{courseId}", "courseId"),
14322 ("{courseWorkId}", "courseWorkId"),
14323 ("{id}", "id"),
14324 ]
14325 .iter()
14326 {
14327 url = params.uri_replacement(url, param_name, find_this, false);
14328 }
14329 {
14330 let to_remove = ["id", "courseWorkId", "courseId"];
14331 params.remove_params(&to_remove);
14332 }
14333
14334 let url = params.parse_with_url(&url);
14335
14336 let mut json_mime_type = mime::APPLICATION_JSON;
14337 let mut request_value_reader = {
14338 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14339 common::remove_json_null_values(&mut value);
14340 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14341 serde_json::to_writer(&mut dst, &value).unwrap();
14342 dst
14343 };
14344 let request_size = request_value_reader
14345 .seek(std::io::SeekFrom::End(0))
14346 .unwrap();
14347 request_value_reader
14348 .seek(std::io::SeekFrom::Start(0))
14349 .unwrap();
14350
14351 loop {
14352 let token = match self
14353 .hub
14354 .auth
14355 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14356 .await
14357 {
14358 Ok(token) => token,
14359 Err(e) => match dlg.token(e) {
14360 Ok(token) => token,
14361 Err(e) => {
14362 dlg.finished(false);
14363 return Err(common::Error::MissingToken(e));
14364 }
14365 },
14366 };
14367 request_value_reader
14368 .seek(std::io::SeekFrom::Start(0))
14369 .unwrap();
14370 let mut req_result = {
14371 let client = &self.hub.client;
14372 dlg.pre_request();
14373 let mut req_builder = hyper::Request::builder()
14374 .method(hyper::Method::PATCH)
14375 .uri(url.as_str())
14376 .header(USER_AGENT, self.hub._user_agent.clone());
14377
14378 if let Some(token) = token.as_ref() {
14379 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14380 }
14381
14382 let request = req_builder
14383 .header(CONTENT_TYPE, json_mime_type.to_string())
14384 .header(CONTENT_LENGTH, request_size as u64)
14385 .body(common::to_body(
14386 request_value_reader.get_ref().clone().into(),
14387 ));
14388
14389 client.request(request.unwrap()).await
14390 };
14391
14392 match req_result {
14393 Err(err) => {
14394 if let common::Retry::After(d) = dlg.http_error(&err) {
14395 sleep(d).await;
14396 continue;
14397 }
14398 dlg.finished(false);
14399 return Err(common::Error::HttpError(err));
14400 }
14401 Ok(res) => {
14402 let (mut parts, body) = res.into_parts();
14403 let mut body = common::Body::new(body);
14404 if !parts.status.is_success() {
14405 let bytes = common::to_bytes(body).await.unwrap_or_default();
14406 let error = serde_json::from_str(&common::to_string(&bytes));
14407 let response = common::to_response(parts, bytes.into());
14408
14409 if let common::Retry::After(d) =
14410 dlg.http_failure(&response, error.as_ref().ok())
14411 {
14412 sleep(d).await;
14413 continue;
14414 }
14415
14416 dlg.finished(false);
14417
14418 return Err(match error {
14419 Ok(value) => common::Error::BadRequest(value),
14420 _ => common::Error::Failure(response),
14421 });
14422 }
14423 let response = {
14424 let bytes = common::to_bytes(body).await.unwrap_or_default();
14425 let encoded = common::to_string(&bytes);
14426 match serde_json::from_str(&encoded) {
14427 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14428 Err(error) => {
14429 dlg.response_json_decode_error(&encoded, &error);
14430 return Err(common::Error::JsonDecodeError(
14431 encoded.to_string(),
14432 error,
14433 ));
14434 }
14435 }
14436 };
14437
14438 dlg.finished(true);
14439 return Ok(response);
14440 }
14441 }
14442 }
14443 }
14444
14445 ///
14446 /// Sets the *request* property to the given value.
14447 ///
14448 /// Even though the property as already been set when instantiating this call,
14449 /// we provide this method for API completeness.
14450 pub fn request(mut self, new_value: Rubric) -> CourseCourseWorkRubricPatchCall<'a, C> {
14451 self._request = new_value;
14452 self
14453 }
14454 /// Required. Identifier of the course.
14455 ///
14456 /// Sets the *course id* path property to the given value.
14457 ///
14458 /// Even though the property as already been set when instantiating this call,
14459 /// we provide this method for API completeness.
14460 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkRubricPatchCall<'a, C> {
14461 self._course_id = new_value.to_string();
14462 self
14463 }
14464 /// Required. Identifier of the course work.
14465 ///
14466 /// Sets the *course work id* path property to the given value.
14467 ///
14468 /// Even though the property as already been set when instantiating this call,
14469 /// we provide this method for API completeness.
14470 pub fn course_work_id(mut self, new_value: &str) -> CourseCourseWorkRubricPatchCall<'a, C> {
14471 self._course_work_id = new_value.to_string();
14472 self
14473 }
14474 /// Optional. Identifier of the rubric.
14475 ///
14476 /// Sets the *id* path property to the given value.
14477 ///
14478 /// Even though the property as already been set when instantiating this call,
14479 /// we provide this method for API completeness.
14480 pub fn id(mut self, new_value: &str) -> CourseCourseWorkRubricPatchCall<'a, C> {
14481 self._id = new_value.to_string();
14482 self
14483 }
14484 /// Optional. Mask that identifies which fields on the rubric to update. This field is required to do an update. The update fails if invalid fields are specified. There are multiple options to define the criteria of a rubric: the `source_spreadsheet_id` and the `criteria` list. Only one of these can be used at a time to define a rubric. The rubric `criteria` list is fully replaced by the rubric criteria specified in the update request. For example, if a criterion or level is missing from the request, it is deleted. New criteria and levels are added and an ID is assigned. Existing criteria and levels retain the previously assigned ID if the ID is specified in the request. The following fields can be specified by teachers: * `criteria` * `source_spreadsheet_id`
14485 ///
14486 /// Sets the *update mask* query property to the given value.
14487 pub fn update_mask(
14488 mut self,
14489 new_value: common::FieldMask,
14490 ) -> CourseCourseWorkRubricPatchCall<'a, C> {
14491 self._update_mask = Some(new_value);
14492 self
14493 }
14494 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14495 /// while executing the actual API request.
14496 ///
14497 /// ````text
14498 /// It should be used to handle progress information, and to implement a certain level of resilience.
14499 /// ````
14500 ///
14501 /// Sets the *delegate* property to the given value.
14502 pub fn delegate(
14503 mut self,
14504 new_value: &'a mut dyn common::Delegate,
14505 ) -> CourseCourseWorkRubricPatchCall<'a, C> {
14506 self._delegate = Some(new_value);
14507 self
14508 }
14509
14510 /// Set any additional parameter of the query string used in the request.
14511 /// It should be used to set parameters which are not yet available through their own
14512 /// setters.
14513 ///
14514 /// Please note that this method must not be used to set any of the known parameters
14515 /// which have their own setter method. If done anyway, the request will fail.
14516 ///
14517 /// # Additional Parameters
14518 ///
14519 /// * *$.xgafv* (query-string) - V1 error format.
14520 /// * *access_token* (query-string) - OAuth access token.
14521 /// * *alt* (query-string) - Data format for response.
14522 /// * *callback* (query-string) - JSONP
14523 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14524 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14525 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14526 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14527 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14528 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14529 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14530 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkRubricPatchCall<'a, C>
14531 where
14532 T: AsRef<str>,
14533 {
14534 self._additional_params
14535 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14536 self
14537 }
14538
14539 /// Identifies the authorization scope for the method you are building.
14540 ///
14541 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14542 /// [`Scope::CourseworkStudent`].
14543 ///
14544 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14545 /// tokens for more than one scope.
14546 ///
14547 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14548 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14549 /// sufficient, a read-write scope will do as well.
14550 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkRubricPatchCall<'a, C>
14551 where
14552 St: AsRef<str>,
14553 {
14554 self._scopes.insert(String::from(scope.as_ref()));
14555 self
14556 }
14557 /// Identifies the authorization scope(s) for the method you are building.
14558 ///
14559 /// See [`Self::add_scope()`] for details.
14560 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkRubricPatchCall<'a, C>
14561 where
14562 I: IntoIterator<Item = St>,
14563 St: AsRef<str>,
14564 {
14565 self._scopes
14566 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14567 self
14568 }
14569
14570 /// Removes all scopes, and no default scope will be used either.
14571 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14572 /// for details).
14573 pub fn clear_scopes(mut self) -> CourseCourseWorkRubricPatchCall<'a, C> {
14574 self._scopes.clear();
14575 self
14576 }
14577}
14578
14579/// Returns a student submission. * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, course work, or student submission or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
14580///
14581/// A builder for the *courseWork.studentSubmissions.get* method supported by a *course* resource.
14582/// It is not used directly, but through a [`CourseMethods`] instance.
14583///
14584/// # Example
14585///
14586/// Instantiate a resource method builder
14587///
14588/// ```test_harness,no_run
14589/// # extern crate hyper;
14590/// # extern crate hyper_rustls;
14591/// # extern crate google_classroom1 as classroom1;
14592/// # async fn dox() {
14593/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14594///
14595/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14596/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14597/// # .with_native_roots()
14598/// # .unwrap()
14599/// # .https_only()
14600/// # .enable_http2()
14601/// # .build();
14602///
14603/// # let executor = hyper_util::rt::TokioExecutor::new();
14604/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14605/// # secret,
14606/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14607/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14608/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14609/// # ),
14610/// # ).build().await.unwrap();
14611///
14612/// # let client = hyper_util::client::legacy::Client::builder(
14613/// # hyper_util::rt::TokioExecutor::new()
14614/// # )
14615/// # .build(
14616/// # hyper_rustls::HttpsConnectorBuilder::new()
14617/// # .with_native_roots()
14618/// # .unwrap()
14619/// # .https_or_http()
14620/// # .enable_http2()
14621/// # .build()
14622/// # );
14623/// # let mut hub = Classroom::new(client, auth);
14624/// // You can configure optional parameters by calling the respective setters at will, and
14625/// // execute the final call using `doit()`.
14626/// // Values shown here are possibly random and not representative !
14627/// let result = hub.courses().course_work_student_submissions_get("courseId", "courseWorkId", "id")
14628/// .doit().await;
14629/// # }
14630/// ```
14631pub struct CourseCourseWorkStudentSubmissionGetCall<'a, C>
14632where
14633 C: 'a,
14634{
14635 hub: &'a Classroom<C>,
14636 _course_id: String,
14637 _course_work_id: String,
14638 _id: String,
14639 _delegate: Option<&'a mut dyn common::Delegate>,
14640 _additional_params: HashMap<String, String>,
14641 _scopes: BTreeSet<String>,
14642}
14643
14644impl<'a, C> common::CallBuilder for CourseCourseWorkStudentSubmissionGetCall<'a, C> {}
14645
14646impl<'a, C> CourseCourseWorkStudentSubmissionGetCall<'a, C>
14647where
14648 C: common::Connector,
14649{
14650 /// Perform the operation you have build so far.
14651 pub async fn doit(mut self) -> common::Result<(common::Response, StudentSubmission)> {
14652 use std::borrow::Cow;
14653 use std::io::{Read, Seek};
14654
14655 use common::{url::Params, ToParts};
14656 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14657
14658 let mut dd = common::DefaultDelegate;
14659 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14660 dlg.begin(common::MethodInfo {
14661 id: "classroom.courses.courseWork.studentSubmissions.get",
14662 http_method: hyper::Method::GET,
14663 });
14664
14665 for &field in ["alt", "courseId", "courseWorkId", "id"].iter() {
14666 if self._additional_params.contains_key(field) {
14667 dlg.finished(false);
14668 return Err(common::Error::FieldClash(field));
14669 }
14670 }
14671
14672 let mut params = Params::with_capacity(5 + self._additional_params.len());
14673 params.push("courseId", self._course_id);
14674 params.push("courseWorkId", self._course_work_id);
14675 params.push("id", self._id);
14676
14677 params.extend(self._additional_params.iter());
14678
14679 params.push("alt", "json");
14680 let mut url = self.hub._base_url.clone()
14681 + "v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}";
14682 if self._scopes.is_empty() {
14683 self._scopes
14684 .insert(Scope::CourseworkMeReadonly.as_ref().to_string());
14685 }
14686
14687 #[allow(clippy::single_element_loop)]
14688 for &(find_this, param_name) in [
14689 ("{courseId}", "courseId"),
14690 ("{courseWorkId}", "courseWorkId"),
14691 ("{id}", "id"),
14692 ]
14693 .iter()
14694 {
14695 url = params.uri_replacement(url, param_name, find_this, false);
14696 }
14697 {
14698 let to_remove = ["id", "courseWorkId", "courseId"];
14699 params.remove_params(&to_remove);
14700 }
14701
14702 let url = params.parse_with_url(&url);
14703
14704 loop {
14705 let token = match self
14706 .hub
14707 .auth
14708 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14709 .await
14710 {
14711 Ok(token) => token,
14712 Err(e) => match dlg.token(e) {
14713 Ok(token) => token,
14714 Err(e) => {
14715 dlg.finished(false);
14716 return Err(common::Error::MissingToken(e));
14717 }
14718 },
14719 };
14720 let mut req_result = {
14721 let client = &self.hub.client;
14722 dlg.pre_request();
14723 let mut req_builder = hyper::Request::builder()
14724 .method(hyper::Method::GET)
14725 .uri(url.as_str())
14726 .header(USER_AGENT, self.hub._user_agent.clone());
14727
14728 if let Some(token) = token.as_ref() {
14729 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14730 }
14731
14732 let request = req_builder
14733 .header(CONTENT_LENGTH, 0_u64)
14734 .body(common::to_body::<String>(None));
14735
14736 client.request(request.unwrap()).await
14737 };
14738
14739 match req_result {
14740 Err(err) => {
14741 if let common::Retry::After(d) = dlg.http_error(&err) {
14742 sleep(d).await;
14743 continue;
14744 }
14745 dlg.finished(false);
14746 return Err(common::Error::HttpError(err));
14747 }
14748 Ok(res) => {
14749 let (mut parts, body) = res.into_parts();
14750 let mut body = common::Body::new(body);
14751 if !parts.status.is_success() {
14752 let bytes = common::to_bytes(body).await.unwrap_or_default();
14753 let error = serde_json::from_str(&common::to_string(&bytes));
14754 let response = common::to_response(parts, bytes.into());
14755
14756 if let common::Retry::After(d) =
14757 dlg.http_failure(&response, error.as_ref().ok())
14758 {
14759 sleep(d).await;
14760 continue;
14761 }
14762
14763 dlg.finished(false);
14764
14765 return Err(match error {
14766 Ok(value) => common::Error::BadRequest(value),
14767 _ => common::Error::Failure(response),
14768 });
14769 }
14770 let response = {
14771 let bytes = common::to_bytes(body).await.unwrap_or_default();
14772 let encoded = common::to_string(&bytes);
14773 match serde_json::from_str(&encoded) {
14774 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14775 Err(error) => {
14776 dlg.response_json_decode_error(&encoded, &error);
14777 return Err(common::Error::JsonDecodeError(
14778 encoded.to_string(),
14779 error,
14780 ));
14781 }
14782 }
14783 };
14784
14785 dlg.finished(true);
14786 return Ok(response);
14787 }
14788 }
14789 }
14790 }
14791
14792 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
14793 ///
14794 /// Sets the *course id* path property to the given value.
14795 ///
14796 /// Even though the property as already been set when instantiating this call,
14797 /// we provide this method for API completeness.
14798 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionGetCall<'a, C> {
14799 self._course_id = new_value.to_string();
14800 self
14801 }
14802 /// Identifier of the course work.
14803 ///
14804 /// Sets the *course work id* path property to the given value.
14805 ///
14806 /// Even though the property as already been set when instantiating this call,
14807 /// we provide this method for API completeness.
14808 pub fn course_work_id(
14809 mut self,
14810 new_value: &str,
14811 ) -> CourseCourseWorkStudentSubmissionGetCall<'a, C> {
14812 self._course_work_id = new_value.to_string();
14813 self
14814 }
14815 /// Identifier of the student submission.
14816 ///
14817 /// Sets the *id* path property to the given value.
14818 ///
14819 /// Even though the property as already been set when instantiating this call,
14820 /// we provide this method for API completeness.
14821 pub fn id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionGetCall<'a, C> {
14822 self._id = new_value.to_string();
14823 self
14824 }
14825 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14826 /// while executing the actual API request.
14827 ///
14828 /// ````text
14829 /// It should be used to handle progress information, and to implement a certain level of resilience.
14830 /// ````
14831 ///
14832 /// Sets the *delegate* property to the given value.
14833 pub fn delegate(
14834 mut self,
14835 new_value: &'a mut dyn common::Delegate,
14836 ) -> CourseCourseWorkStudentSubmissionGetCall<'a, C> {
14837 self._delegate = Some(new_value);
14838 self
14839 }
14840
14841 /// Set any additional parameter of the query string used in the request.
14842 /// It should be used to set parameters which are not yet available through their own
14843 /// setters.
14844 ///
14845 /// Please note that this method must not be used to set any of the known parameters
14846 /// which have their own setter method. If done anyway, the request will fail.
14847 ///
14848 /// # Additional Parameters
14849 ///
14850 /// * *$.xgafv* (query-string) - V1 error format.
14851 /// * *access_token* (query-string) - OAuth access token.
14852 /// * *alt* (query-string) - Data format for response.
14853 /// * *callback* (query-string) - JSONP
14854 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14855 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14856 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14857 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14858 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
14859 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14860 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14861 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkStudentSubmissionGetCall<'a, C>
14862 where
14863 T: AsRef<str>,
14864 {
14865 self._additional_params
14866 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14867 self
14868 }
14869
14870 /// Identifies the authorization scope for the method you are building.
14871 ///
14872 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14873 /// [`Scope::CourseworkMeReadonly`].
14874 ///
14875 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14876 /// tokens for more than one scope.
14877 ///
14878 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14879 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14880 /// sufficient, a read-write scope will do as well.
14881 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkStudentSubmissionGetCall<'a, C>
14882 where
14883 St: AsRef<str>,
14884 {
14885 self._scopes.insert(String::from(scope.as_ref()));
14886 self
14887 }
14888 /// Identifies the authorization scope(s) for the method you are building.
14889 ///
14890 /// See [`Self::add_scope()`] for details.
14891 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkStudentSubmissionGetCall<'a, C>
14892 where
14893 I: IntoIterator<Item = St>,
14894 St: AsRef<str>,
14895 {
14896 self._scopes
14897 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14898 self
14899 }
14900
14901 /// Removes all scopes, and no default scope will be used either.
14902 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14903 /// for details).
14904 pub fn clear_scopes(mut self) -> CourseCourseWorkStudentSubmissionGetCall<'a, C> {
14905 self._scopes.clear();
14906 self
14907 }
14908}
14909
14910/// Returns a list of student submissions that the requester is permitted to view, factoring in the OAuth scopes of the request. `-` may be specified as the `course_work_id` to include student submissions for multiple course work items. Course students may only view their own work. Course teachers and domain administrators may view all student submissions. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
14911///
14912/// A builder for the *courseWork.studentSubmissions.list* method supported by a *course* resource.
14913/// It is not used directly, but through a [`CourseMethods`] instance.
14914///
14915/// # Example
14916///
14917/// Instantiate a resource method builder
14918///
14919/// ```test_harness,no_run
14920/// # extern crate hyper;
14921/// # extern crate hyper_rustls;
14922/// # extern crate google_classroom1 as classroom1;
14923/// # async fn dox() {
14924/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14925///
14926/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14927/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14928/// # .with_native_roots()
14929/// # .unwrap()
14930/// # .https_only()
14931/// # .enable_http2()
14932/// # .build();
14933///
14934/// # let executor = hyper_util::rt::TokioExecutor::new();
14935/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14936/// # secret,
14937/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14938/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14939/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14940/// # ),
14941/// # ).build().await.unwrap();
14942///
14943/// # let client = hyper_util::client::legacy::Client::builder(
14944/// # hyper_util::rt::TokioExecutor::new()
14945/// # )
14946/// # .build(
14947/// # hyper_rustls::HttpsConnectorBuilder::new()
14948/// # .with_native_roots()
14949/// # .unwrap()
14950/// # .https_or_http()
14951/// # .enable_http2()
14952/// # .build()
14953/// # );
14954/// # let mut hub = Classroom::new(client, auth);
14955/// // You can configure optional parameters by calling the respective setters at will, and
14956/// // execute the final call using `doit()`.
14957/// // Values shown here are possibly random and not representative !
14958/// let result = hub.courses().course_work_student_submissions_list("courseId", "courseWorkId")
14959/// .user_id("sed")
14960/// .add_states("diam")
14961/// .page_token("dolores")
14962/// .page_size(-69)
14963/// .late("et")
14964/// .doit().await;
14965/// # }
14966/// ```
14967pub struct CourseCourseWorkStudentSubmissionListCall<'a, C>
14968where
14969 C: 'a,
14970{
14971 hub: &'a Classroom<C>,
14972 _course_id: String,
14973 _course_work_id: String,
14974 _user_id: Option<String>,
14975 _states: Vec<String>,
14976 _page_token: Option<String>,
14977 _page_size: Option<i32>,
14978 _late: Option<String>,
14979 _delegate: Option<&'a mut dyn common::Delegate>,
14980 _additional_params: HashMap<String, String>,
14981 _scopes: BTreeSet<String>,
14982}
14983
14984impl<'a, C> common::CallBuilder for CourseCourseWorkStudentSubmissionListCall<'a, C> {}
14985
14986impl<'a, C> CourseCourseWorkStudentSubmissionListCall<'a, C>
14987where
14988 C: common::Connector,
14989{
14990 /// Perform the operation you have build so far.
14991 pub async fn doit(
14992 mut self,
14993 ) -> common::Result<(common::Response, ListStudentSubmissionsResponse)> {
14994 use std::borrow::Cow;
14995 use std::io::{Read, Seek};
14996
14997 use common::{url::Params, ToParts};
14998 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14999
15000 let mut dd = common::DefaultDelegate;
15001 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15002 dlg.begin(common::MethodInfo {
15003 id: "classroom.courses.courseWork.studentSubmissions.list",
15004 http_method: hyper::Method::GET,
15005 });
15006
15007 for &field in [
15008 "alt",
15009 "courseId",
15010 "courseWorkId",
15011 "userId",
15012 "states",
15013 "pageToken",
15014 "pageSize",
15015 "late",
15016 ]
15017 .iter()
15018 {
15019 if self._additional_params.contains_key(field) {
15020 dlg.finished(false);
15021 return Err(common::Error::FieldClash(field));
15022 }
15023 }
15024
15025 let mut params = Params::with_capacity(9 + self._additional_params.len());
15026 params.push("courseId", self._course_id);
15027 params.push("courseWorkId", self._course_work_id);
15028 if let Some(value) = self._user_id.as_ref() {
15029 params.push("userId", value);
15030 }
15031 if !self._states.is_empty() {
15032 for f in self._states.iter() {
15033 params.push("states", f);
15034 }
15035 }
15036 if let Some(value) = self._page_token.as_ref() {
15037 params.push("pageToken", value);
15038 }
15039 if let Some(value) = self._page_size.as_ref() {
15040 params.push("pageSize", value.to_string());
15041 }
15042 if let Some(value) = self._late.as_ref() {
15043 params.push("late", value);
15044 }
15045
15046 params.extend(self._additional_params.iter());
15047
15048 params.push("alt", "json");
15049 let mut url = self.hub._base_url.clone()
15050 + "v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions";
15051 if self._scopes.is_empty() {
15052 self._scopes
15053 .insert(Scope::CourseworkMeReadonly.as_ref().to_string());
15054 }
15055
15056 #[allow(clippy::single_element_loop)]
15057 for &(find_this, param_name) in [
15058 ("{courseId}", "courseId"),
15059 ("{courseWorkId}", "courseWorkId"),
15060 ]
15061 .iter()
15062 {
15063 url = params.uri_replacement(url, param_name, find_this, false);
15064 }
15065 {
15066 let to_remove = ["courseWorkId", "courseId"];
15067 params.remove_params(&to_remove);
15068 }
15069
15070 let url = params.parse_with_url(&url);
15071
15072 loop {
15073 let token = match self
15074 .hub
15075 .auth
15076 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15077 .await
15078 {
15079 Ok(token) => token,
15080 Err(e) => match dlg.token(e) {
15081 Ok(token) => token,
15082 Err(e) => {
15083 dlg.finished(false);
15084 return Err(common::Error::MissingToken(e));
15085 }
15086 },
15087 };
15088 let mut req_result = {
15089 let client = &self.hub.client;
15090 dlg.pre_request();
15091 let mut req_builder = hyper::Request::builder()
15092 .method(hyper::Method::GET)
15093 .uri(url.as_str())
15094 .header(USER_AGENT, self.hub._user_agent.clone());
15095
15096 if let Some(token) = token.as_ref() {
15097 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15098 }
15099
15100 let request = req_builder
15101 .header(CONTENT_LENGTH, 0_u64)
15102 .body(common::to_body::<String>(None));
15103
15104 client.request(request.unwrap()).await
15105 };
15106
15107 match req_result {
15108 Err(err) => {
15109 if let common::Retry::After(d) = dlg.http_error(&err) {
15110 sleep(d).await;
15111 continue;
15112 }
15113 dlg.finished(false);
15114 return Err(common::Error::HttpError(err));
15115 }
15116 Ok(res) => {
15117 let (mut parts, body) = res.into_parts();
15118 let mut body = common::Body::new(body);
15119 if !parts.status.is_success() {
15120 let bytes = common::to_bytes(body).await.unwrap_or_default();
15121 let error = serde_json::from_str(&common::to_string(&bytes));
15122 let response = common::to_response(parts, bytes.into());
15123
15124 if let common::Retry::After(d) =
15125 dlg.http_failure(&response, error.as_ref().ok())
15126 {
15127 sleep(d).await;
15128 continue;
15129 }
15130
15131 dlg.finished(false);
15132
15133 return Err(match error {
15134 Ok(value) => common::Error::BadRequest(value),
15135 _ => common::Error::Failure(response),
15136 });
15137 }
15138 let response = {
15139 let bytes = common::to_bytes(body).await.unwrap_or_default();
15140 let encoded = common::to_string(&bytes);
15141 match serde_json::from_str(&encoded) {
15142 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15143 Err(error) => {
15144 dlg.response_json_decode_error(&encoded, &error);
15145 return Err(common::Error::JsonDecodeError(
15146 encoded.to_string(),
15147 error,
15148 ));
15149 }
15150 }
15151 };
15152
15153 dlg.finished(true);
15154 return Ok(response);
15155 }
15156 }
15157 }
15158 }
15159
15160 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
15161 ///
15162 /// Sets the *course id* path property to the given value.
15163 ///
15164 /// Even though the property as already been set when instantiating this call,
15165 /// we provide this method for API completeness.
15166 pub fn course_id(
15167 mut self,
15168 new_value: &str,
15169 ) -> CourseCourseWorkStudentSubmissionListCall<'a, C> {
15170 self._course_id = new_value.to_string();
15171 self
15172 }
15173 /// Identifier of the student work to request. This may be set to the string literal `"-"` to request student work for all course work in the specified course.
15174 ///
15175 /// Sets the *course work id* path property to the given value.
15176 ///
15177 /// Even though the property as already been set when instantiating this call,
15178 /// we provide this method for API completeness.
15179 pub fn course_work_id(
15180 mut self,
15181 new_value: &str,
15182 ) -> CourseCourseWorkStudentSubmissionListCall<'a, C> {
15183 self._course_work_id = new_value.to_string();
15184 self
15185 }
15186 /// Optional argument to restrict returned student work to those owned by the student with the specified identifier. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
15187 ///
15188 /// Sets the *user id* query property to the given value.
15189 pub fn user_id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionListCall<'a, C> {
15190 self._user_id = Some(new_value.to_string());
15191 self
15192 }
15193 /// Requested submission states. If specified, returned student submissions match one of the specified submission states.
15194 ///
15195 /// Append the given value to the *states* query property.
15196 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
15197 pub fn add_states(
15198 mut self,
15199 new_value: &str,
15200 ) -> CourseCourseWorkStudentSubmissionListCall<'a, C> {
15201 self._states.push(new_value.to_string());
15202 self
15203 }
15204 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
15205 ///
15206 /// Sets the *page token* query property to the given value.
15207 pub fn page_token(
15208 mut self,
15209 new_value: &str,
15210 ) -> CourseCourseWorkStudentSubmissionListCall<'a, C> {
15211 self._page_token = Some(new_value.to_string());
15212 self
15213 }
15214 /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.
15215 ///
15216 /// Sets the *page size* query property to the given value.
15217 pub fn page_size(mut self, new_value: i32) -> CourseCourseWorkStudentSubmissionListCall<'a, C> {
15218 self._page_size = Some(new_value);
15219 self
15220 }
15221 /// Requested lateness value. If specified, returned student submissions are restricted by the requested value. If unspecified, submissions are returned regardless of `late` value.
15222 ///
15223 /// Sets the *late* query property to the given value.
15224 pub fn late(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionListCall<'a, C> {
15225 self._late = Some(new_value.to_string());
15226 self
15227 }
15228 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15229 /// while executing the actual API request.
15230 ///
15231 /// ````text
15232 /// It should be used to handle progress information, and to implement a certain level of resilience.
15233 /// ````
15234 ///
15235 /// Sets the *delegate* property to the given value.
15236 pub fn delegate(
15237 mut self,
15238 new_value: &'a mut dyn common::Delegate,
15239 ) -> CourseCourseWorkStudentSubmissionListCall<'a, C> {
15240 self._delegate = Some(new_value);
15241 self
15242 }
15243
15244 /// Set any additional parameter of the query string used in the request.
15245 /// It should be used to set parameters which are not yet available through their own
15246 /// setters.
15247 ///
15248 /// Please note that this method must not be used to set any of the known parameters
15249 /// which have their own setter method. If done anyway, the request will fail.
15250 ///
15251 /// # Additional Parameters
15252 ///
15253 /// * *$.xgafv* (query-string) - V1 error format.
15254 /// * *access_token* (query-string) - OAuth access token.
15255 /// * *alt* (query-string) - Data format for response.
15256 /// * *callback* (query-string) - JSONP
15257 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15258 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15259 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15260 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15261 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15262 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15263 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15264 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkStudentSubmissionListCall<'a, C>
15265 where
15266 T: AsRef<str>,
15267 {
15268 self._additional_params
15269 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15270 self
15271 }
15272
15273 /// Identifies the authorization scope for the method you are building.
15274 ///
15275 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15276 /// [`Scope::CourseworkMeReadonly`].
15277 ///
15278 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15279 /// tokens for more than one scope.
15280 ///
15281 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15282 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15283 /// sufficient, a read-write scope will do as well.
15284 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkStudentSubmissionListCall<'a, C>
15285 where
15286 St: AsRef<str>,
15287 {
15288 self._scopes.insert(String::from(scope.as_ref()));
15289 self
15290 }
15291 /// Identifies the authorization scope(s) for the method you are building.
15292 ///
15293 /// See [`Self::add_scope()`] for details.
15294 pub fn add_scopes<I, St>(
15295 mut self,
15296 scopes: I,
15297 ) -> CourseCourseWorkStudentSubmissionListCall<'a, C>
15298 where
15299 I: IntoIterator<Item = St>,
15300 St: AsRef<str>,
15301 {
15302 self._scopes
15303 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15304 self
15305 }
15306
15307 /// Removes all scopes, and no default scope will be used either.
15308 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15309 /// for details).
15310 pub fn clear_scopes(mut self) -> CourseCourseWorkStudentSubmissionListCall<'a, C> {
15311 self._scopes.clear();
15312 self
15313 }
15314}
15315
15316/// Modifies attachments of student submission. Attachments may only be added to student submissions belonging to course work objects with a `workType` of `ASSIGNMENT`. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, if the user is not permitted to modify attachments on the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
15317///
15318/// A builder for the *courseWork.studentSubmissions.modifyAttachments* method supported by a *course* resource.
15319/// It is not used directly, but through a [`CourseMethods`] instance.
15320///
15321/// # Example
15322///
15323/// Instantiate a resource method builder
15324///
15325/// ```test_harness,no_run
15326/// # extern crate hyper;
15327/// # extern crate hyper_rustls;
15328/// # extern crate google_classroom1 as classroom1;
15329/// use classroom1::api::ModifyAttachmentsRequest;
15330/// # async fn dox() {
15331/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15332///
15333/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15334/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15335/// # .with_native_roots()
15336/// # .unwrap()
15337/// # .https_only()
15338/// # .enable_http2()
15339/// # .build();
15340///
15341/// # let executor = hyper_util::rt::TokioExecutor::new();
15342/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15343/// # secret,
15344/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15345/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15346/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15347/// # ),
15348/// # ).build().await.unwrap();
15349///
15350/// # let client = hyper_util::client::legacy::Client::builder(
15351/// # hyper_util::rt::TokioExecutor::new()
15352/// # )
15353/// # .build(
15354/// # hyper_rustls::HttpsConnectorBuilder::new()
15355/// # .with_native_roots()
15356/// # .unwrap()
15357/// # .https_or_http()
15358/// # .enable_http2()
15359/// # .build()
15360/// # );
15361/// # let mut hub = Classroom::new(client, auth);
15362/// // As the method needs a request, you would usually fill it with the desired information
15363/// // into the respective structure. Some of the parts shown here might not be applicable !
15364/// // Values shown here are possibly random and not representative !
15365/// let mut req = ModifyAttachmentsRequest::default();
15366///
15367/// // You can configure optional parameters by calling the respective setters at will, and
15368/// // execute the final call using `doit()`.
15369/// // Values shown here are possibly random and not representative !
15370/// let result = hub.courses().course_work_student_submissions_modify_attachments(req, "courseId", "courseWorkId", "id")
15371/// .doit().await;
15372/// # }
15373/// ```
15374pub struct CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C>
15375where
15376 C: 'a,
15377{
15378 hub: &'a Classroom<C>,
15379 _request: ModifyAttachmentsRequest,
15380 _course_id: String,
15381 _course_work_id: String,
15382 _id: String,
15383 _delegate: Option<&'a mut dyn common::Delegate>,
15384 _additional_params: HashMap<String, String>,
15385 _scopes: BTreeSet<String>,
15386}
15387
15388impl<'a, C> common::CallBuilder for CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C> {}
15389
15390impl<'a, C> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C>
15391where
15392 C: common::Connector,
15393{
15394 /// Perform the operation you have build so far.
15395 pub async fn doit(mut self) -> common::Result<(common::Response, StudentSubmission)> {
15396 use std::borrow::Cow;
15397 use std::io::{Read, Seek};
15398
15399 use common::{url::Params, ToParts};
15400 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15401
15402 let mut dd = common::DefaultDelegate;
15403 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15404 dlg.begin(common::MethodInfo {
15405 id: "classroom.courses.courseWork.studentSubmissions.modifyAttachments",
15406 http_method: hyper::Method::POST,
15407 });
15408
15409 for &field in ["alt", "courseId", "courseWorkId", "id"].iter() {
15410 if self._additional_params.contains_key(field) {
15411 dlg.finished(false);
15412 return Err(common::Error::FieldClash(field));
15413 }
15414 }
15415
15416 let mut params = Params::with_capacity(6 + self._additional_params.len());
15417 params.push("courseId", self._course_id);
15418 params.push("courseWorkId", self._course_work_id);
15419 params.push("id", self._id);
15420
15421 params.extend(self._additional_params.iter());
15422
15423 params.push("alt", "json");
15424 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}:modifyAttachments";
15425 if self._scopes.is_empty() {
15426 self._scopes
15427 .insert(Scope::CourseworkMe.as_ref().to_string());
15428 }
15429
15430 #[allow(clippy::single_element_loop)]
15431 for &(find_this, param_name) in [
15432 ("{courseId}", "courseId"),
15433 ("{courseWorkId}", "courseWorkId"),
15434 ("{id}", "id"),
15435 ]
15436 .iter()
15437 {
15438 url = params.uri_replacement(url, param_name, find_this, false);
15439 }
15440 {
15441 let to_remove = ["id", "courseWorkId", "courseId"];
15442 params.remove_params(&to_remove);
15443 }
15444
15445 let url = params.parse_with_url(&url);
15446
15447 let mut json_mime_type = mime::APPLICATION_JSON;
15448 let mut request_value_reader = {
15449 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15450 common::remove_json_null_values(&mut value);
15451 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15452 serde_json::to_writer(&mut dst, &value).unwrap();
15453 dst
15454 };
15455 let request_size = request_value_reader
15456 .seek(std::io::SeekFrom::End(0))
15457 .unwrap();
15458 request_value_reader
15459 .seek(std::io::SeekFrom::Start(0))
15460 .unwrap();
15461
15462 loop {
15463 let token = match self
15464 .hub
15465 .auth
15466 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15467 .await
15468 {
15469 Ok(token) => token,
15470 Err(e) => match dlg.token(e) {
15471 Ok(token) => token,
15472 Err(e) => {
15473 dlg.finished(false);
15474 return Err(common::Error::MissingToken(e));
15475 }
15476 },
15477 };
15478 request_value_reader
15479 .seek(std::io::SeekFrom::Start(0))
15480 .unwrap();
15481 let mut req_result = {
15482 let client = &self.hub.client;
15483 dlg.pre_request();
15484 let mut req_builder = hyper::Request::builder()
15485 .method(hyper::Method::POST)
15486 .uri(url.as_str())
15487 .header(USER_AGENT, self.hub._user_agent.clone());
15488
15489 if let Some(token) = token.as_ref() {
15490 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15491 }
15492
15493 let request = req_builder
15494 .header(CONTENT_TYPE, json_mime_type.to_string())
15495 .header(CONTENT_LENGTH, request_size as u64)
15496 .body(common::to_body(
15497 request_value_reader.get_ref().clone().into(),
15498 ));
15499
15500 client.request(request.unwrap()).await
15501 };
15502
15503 match req_result {
15504 Err(err) => {
15505 if let common::Retry::After(d) = dlg.http_error(&err) {
15506 sleep(d).await;
15507 continue;
15508 }
15509 dlg.finished(false);
15510 return Err(common::Error::HttpError(err));
15511 }
15512 Ok(res) => {
15513 let (mut parts, body) = res.into_parts();
15514 let mut body = common::Body::new(body);
15515 if !parts.status.is_success() {
15516 let bytes = common::to_bytes(body).await.unwrap_or_default();
15517 let error = serde_json::from_str(&common::to_string(&bytes));
15518 let response = common::to_response(parts, bytes.into());
15519
15520 if let common::Retry::After(d) =
15521 dlg.http_failure(&response, error.as_ref().ok())
15522 {
15523 sleep(d).await;
15524 continue;
15525 }
15526
15527 dlg.finished(false);
15528
15529 return Err(match error {
15530 Ok(value) => common::Error::BadRequest(value),
15531 _ => common::Error::Failure(response),
15532 });
15533 }
15534 let response = {
15535 let bytes = common::to_bytes(body).await.unwrap_or_default();
15536 let encoded = common::to_string(&bytes);
15537 match serde_json::from_str(&encoded) {
15538 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15539 Err(error) => {
15540 dlg.response_json_decode_error(&encoded, &error);
15541 return Err(common::Error::JsonDecodeError(
15542 encoded.to_string(),
15543 error,
15544 ));
15545 }
15546 }
15547 };
15548
15549 dlg.finished(true);
15550 return Ok(response);
15551 }
15552 }
15553 }
15554 }
15555
15556 ///
15557 /// Sets the *request* property to the given value.
15558 ///
15559 /// Even though the property as already been set when instantiating this call,
15560 /// we provide this method for API completeness.
15561 pub fn request(
15562 mut self,
15563 new_value: ModifyAttachmentsRequest,
15564 ) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C> {
15565 self._request = new_value;
15566 self
15567 }
15568 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
15569 ///
15570 /// Sets the *course id* path property to the given value.
15571 ///
15572 /// Even though the property as already been set when instantiating this call,
15573 /// we provide this method for API completeness.
15574 pub fn course_id(
15575 mut self,
15576 new_value: &str,
15577 ) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C> {
15578 self._course_id = new_value.to_string();
15579 self
15580 }
15581 /// Identifier of the course work.
15582 ///
15583 /// Sets the *course work id* path property to the given value.
15584 ///
15585 /// Even though the property as already been set when instantiating this call,
15586 /// we provide this method for API completeness.
15587 pub fn course_work_id(
15588 mut self,
15589 new_value: &str,
15590 ) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C> {
15591 self._course_work_id = new_value.to_string();
15592 self
15593 }
15594 /// Identifier of the student submission.
15595 ///
15596 /// Sets the *id* path property to the given value.
15597 ///
15598 /// Even though the property as already been set when instantiating this call,
15599 /// we provide this method for API completeness.
15600 pub fn id(
15601 mut self,
15602 new_value: &str,
15603 ) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C> {
15604 self._id = new_value.to_string();
15605 self
15606 }
15607 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15608 /// while executing the actual API request.
15609 ///
15610 /// ````text
15611 /// It should be used to handle progress information, and to implement a certain level of resilience.
15612 /// ````
15613 ///
15614 /// Sets the *delegate* property to the given value.
15615 pub fn delegate(
15616 mut self,
15617 new_value: &'a mut dyn common::Delegate,
15618 ) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C> {
15619 self._delegate = Some(new_value);
15620 self
15621 }
15622
15623 /// Set any additional parameter of the query string used in the request.
15624 /// It should be used to set parameters which are not yet available through their own
15625 /// setters.
15626 ///
15627 /// Please note that this method must not be used to set any of the known parameters
15628 /// which have their own setter method. If done anyway, the request will fail.
15629 ///
15630 /// # Additional Parameters
15631 ///
15632 /// * *$.xgafv* (query-string) - V1 error format.
15633 /// * *access_token* (query-string) - OAuth access token.
15634 /// * *alt* (query-string) - Data format for response.
15635 /// * *callback* (query-string) - JSONP
15636 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15637 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15638 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15639 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15640 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15641 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15642 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15643 pub fn param<T>(
15644 mut self,
15645 name: T,
15646 value: T,
15647 ) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C>
15648 where
15649 T: AsRef<str>,
15650 {
15651 self._additional_params
15652 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15653 self
15654 }
15655
15656 /// Identifies the authorization scope for the method you are building.
15657 ///
15658 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15659 /// [`Scope::CourseworkMe`].
15660 ///
15661 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15662 /// tokens for more than one scope.
15663 ///
15664 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15665 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15666 /// sufficient, a read-write scope will do as well.
15667 pub fn add_scope<St>(
15668 mut self,
15669 scope: St,
15670 ) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C>
15671 where
15672 St: AsRef<str>,
15673 {
15674 self._scopes.insert(String::from(scope.as_ref()));
15675 self
15676 }
15677 /// Identifies the authorization scope(s) for the method you are building.
15678 ///
15679 /// See [`Self::add_scope()`] for details.
15680 pub fn add_scopes<I, St>(
15681 mut self,
15682 scopes: I,
15683 ) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C>
15684 where
15685 I: IntoIterator<Item = St>,
15686 St: AsRef<str>,
15687 {
15688 self._scopes
15689 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15690 self
15691 }
15692
15693 /// Removes all scopes, and no default scope will be used either.
15694 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15695 /// for details).
15696 pub fn clear_scopes(mut self) -> CourseCourseWorkStudentSubmissionModifyAttachmentCall<'a, C> {
15697 self._scopes.clear();
15698 self
15699 }
15700}
15701
15702/// Updates one or more fields of a student submission. See google.classroom.v1.StudentSubmission for details of which fields may be updated and who may change them. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work, if the user is not permitted to make the requested modification to the student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
15703///
15704/// A builder for the *courseWork.studentSubmissions.patch* method supported by a *course* resource.
15705/// It is not used directly, but through a [`CourseMethods`] instance.
15706///
15707/// # Example
15708///
15709/// Instantiate a resource method builder
15710///
15711/// ```test_harness,no_run
15712/// # extern crate hyper;
15713/// # extern crate hyper_rustls;
15714/// # extern crate google_classroom1 as classroom1;
15715/// use classroom1::api::StudentSubmission;
15716/// # async fn dox() {
15717/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15718///
15719/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15720/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15721/// # .with_native_roots()
15722/// # .unwrap()
15723/// # .https_only()
15724/// # .enable_http2()
15725/// # .build();
15726///
15727/// # let executor = hyper_util::rt::TokioExecutor::new();
15728/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15729/// # secret,
15730/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15731/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15732/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15733/// # ),
15734/// # ).build().await.unwrap();
15735///
15736/// # let client = hyper_util::client::legacy::Client::builder(
15737/// # hyper_util::rt::TokioExecutor::new()
15738/// # )
15739/// # .build(
15740/// # hyper_rustls::HttpsConnectorBuilder::new()
15741/// # .with_native_roots()
15742/// # .unwrap()
15743/// # .https_or_http()
15744/// # .enable_http2()
15745/// # .build()
15746/// # );
15747/// # let mut hub = Classroom::new(client, auth);
15748/// // As the method needs a request, you would usually fill it with the desired information
15749/// // into the respective structure. Some of the parts shown here might not be applicable !
15750/// // Values shown here are possibly random and not representative !
15751/// let mut req = StudentSubmission::default();
15752///
15753/// // You can configure optional parameters by calling the respective setters at will, and
15754/// // execute the final call using `doit()`.
15755/// // Values shown here are possibly random and not representative !
15756/// let result = hub.courses().course_work_student_submissions_patch(req, "courseId", "courseWorkId", "id")
15757/// .update_mask(FieldMask::new::<&str>(&[]))
15758/// .doit().await;
15759/// # }
15760/// ```
15761pub struct CourseCourseWorkStudentSubmissionPatchCall<'a, C>
15762where
15763 C: 'a,
15764{
15765 hub: &'a Classroom<C>,
15766 _request: StudentSubmission,
15767 _course_id: String,
15768 _course_work_id: String,
15769 _id: String,
15770 _update_mask: Option<common::FieldMask>,
15771 _delegate: Option<&'a mut dyn common::Delegate>,
15772 _additional_params: HashMap<String, String>,
15773 _scopes: BTreeSet<String>,
15774}
15775
15776impl<'a, C> common::CallBuilder for CourseCourseWorkStudentSubmissionPatchCall<'a, C> {}
15777
15778impl<'a, C> CourseCourseWorkStudentSubmissionPatchCall<'a, C>
15779where
15780 C: common::Connector,
15781{
15782 /// Perform the operation you have build so far.
15783 pub async fn doit(mut self) -> common::Result<(common::Response, StudentSubmission)> {
15784 use std::borrow::Cow;
15785 use std::io::{Read, Seek};
15786
15787 use common::{url::Params, ToParts};
15788 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15789
15790 let mut dd = common::DefaultDelegate;
15791 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15792 dlg.begin(common::MethodInfo {
15793 id: "classroom.courses.courseWork.studentSubmissions.patch",
15794 http_method: hyper::Method::PATCH,
15795 });
15796
15797 for &field in ["alt", "courseId", "courseWorkId", "id", "updateMask"].iter() {
15798 if self._additional_params.contains_key(field) {
15799 dlg.finished(false);
15800 return Err(common::Error::FieldClash(field));
15801 }
15802 }
15803
15804 let mut params = Params::with_capacity(7 + self._additional_params.len());
15805 params.push("courseId", self._course_id);
15806 params.push("courseWorkId", self._course_work_id);
15807 params.push("id", self._id);
15808 if let Some(value) = self._update_mask.as_ref() {
15809 params.push("updateMask", value.to_string());
15810 }
15811
15812 params.extend(self._additional_params.iter());
15813
15814 params.push("alt", "json");
15815 let mut url = self.hub._base_url.clone()
15816 + "v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}";
15817 if self._scopes.is_empty() {
15818 self._scopes
15819 .insert(Scope::CourseworkMe.as_ref().to_string());
15820 }
15821
15822 #[allow(clippy::single_element_loop)]
15823 for &(find_this, param_name) in [
15824 ("{courseId}", "courseId"),
15825 ("{courseWorkId}", "courseWorkId"),
15826 ("{id}", "id"),
15827 ]
15828 .iter()
15829 {
15830 url = params.uri_replacement(url, param_name, find_this, false);
15831 }
15832 {
15833 let to_remove = ["id", "courseWorkId", "courseId"];
15834 params.remove_params(&to_remove);
15835 }
15836
15837 let url = params.parse_with_url(&url);
15838
15839 let mut json_mime_type = mime::APPLICATION_JSON;
15840 let mut request_value_reader = {
15841 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15842 common::remove_json_null_values(&mut value);
15843 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15844 serde_json::to_writer(&mut dst, &value).unwrap();
15845 dst
15846 };
15847 let request_size = request_value_reader
15848 .seek(std::io::SeekFrom::End(0))
15849 .unwrap();
15850 request_value_reader
15851 .seek(std::io::SeekFrom::Start(0))
15852 .unwrap();
15853
15854 loop {
15855 let token = match self
15856 .hub
15857 .auth
15858 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15859 .await
15860 {
15861 Ok(token) => token,
15862 Err(e) => match dlg.token(e) {
15863 Ok(token) => token,
15864 Err(e) => {
15865 dlg.finished(false);
15866 return Err(common::Error::MissingToken(e));
15867 }
15868 },
15869 };
15870 request_value_reader
15871 .seek(std::io::SeekFrom::Start(0))
15872 .unwrap();
15873 let mut req_result = {
15874 let client = &self.hub.client;
15875 dlg.pre_request();
15876 let mut req_builder = hyper::Request::builder()
15877 .method(hyper::Method::PATCH)
15878 .uri(url.as_str())
15879 .header(USER_AGENT, self.hub._user_agent.clone());
15880
15881 if let Some(token) = token.as_ref() {
15882 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15883 }
15884
15885 let request = req_builder
15886 .header(CONTENT_TYPE, json_mime_type.to_string())
15887 .header(CONTENT_LENGTH, request_size as u64)
15888 .body(common::to_body(
15889 request_value_reader.get_ref().clone().into(),
15890 ));
15891
15892 client.request(request.unwrap()).await
15893 };
15894
15895 match req_result {
15896 Err(err) => {
15897 if let common::Retry::After(d) = dlg.http_error(&err) {
15898 sleep(d).await;
15899 continue;
15900 }
15901 dlg.finished(false);
15902 return Err(common::Error::HttpError(err));
15903 }
15904 Ok(res) => {
15905 let (mut parts, body) = res.into_parts();
15906 let mut body = common::Body::new(body);
15907 if !parts.status.is_success() {
15908 let bytes = common::to_bytes(body).await.unwrap_or_default();
15909 let error = serde_json::from_str(&common::to_string(&bytes));
15910 let response = common::to_response(parts, bytes.into());
15911
15912 if let common::Retry::After(d) =
15913 dlg.http_failure(&response, error.as_ref().ok())
15914 {
15915 sleep(d).await;
15916 continue;
15917 }
15918
15919 dlg.finished(false);
15920
15921 return Err(match error {
15922 Ok(value) => common::Error::BadRequest(value),
15923 _ => common::Error::Failure(response),
15924 });
15925 }
15926 let response = {
15927 let bytes = common::to_bytes(body).await.unwrap_or_default();
15928 let encoded = common::to_string(&bytes);
15929 match serde_json::from_str(&encoded) {
15930 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15931 Err(error) => {
15932 dlg.response_json_decode_error(&encoded, &error);
15933 return Err(common::Error::JsonDecodeError(
15934 encoded.to_string(),
15935 error,
15936 ));
15937 }
15938 }
15939 };
15940
15941 dlg.finished(true);
15942 return Ok(response);
15943 }
15944 }
15945 }
15946 }
15947
15948 ///
15949 /// Sets the *request* property to the given value.
15950 ///
15951 /// Even though the property as already been set when instantiating this call,
15952 /// we provide this method for API completeness.
15953 pub fn request(
15954 mut self,
15955 new_value: StudentSubmission,
15956 ) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C> {
15957 self._request = new_value;
15958 self
15959 }
15960 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
15961 ///
15962 /// Sets the *course id* path property to the given value.
15963 ///
15964 /// Even though the property as already been set when instantiating this call,
15965 /// we provide this method for API completeness.
15966 pub fn course_id(
15967 mut self,
15968 new_value: &str,
15969 ) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C> {
15970 self._course_id = new_value.to_string();
15971 self
15972 }
15973 /// Identifier of the course work.
15974 ///
15975 /// Sets the *course work id* path property to the given value.
15976 ///
15977 /// Even though the property as already been set when instantiating this call,
15978 /// we provide this method for API completeness.
15979 pub fn course_work_id(
15980 mut self,
15981 new_value: &str,
15982 ) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C> {
15983 self._course_work_id = new_value.to_string();
15984 self
15985 }
15986 /// Identifier of the student submission.
15987 ///
15988 /// Sets the *id* path property to the given value.
15989 ///
15990 /// Even though the property as already been set when instantiating this call,
15991 /// we provide this method for API completeness.
15992 pub fn id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C> {
15993 self._id = new_value.to_string();
15994 self
15995 }
15996 /// Mask that identifies which fields on the student submission to update. This field is required to do an update. The update fails if invalid fields are specified. The following fields may be specified by teachers: * `draft_grade` * `assigned_grade`
15997 ///
15998 /// Sets the *update mask* query property to the given value.
15999 pub fn update_mask(
16000 mut self,
16001 new_value: common::FieldMask,
16002 ) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C> {
16003 self._update_mask = Some(new_value);
16004 self
16005 }
16006 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16007 /// while executing the actual API request.
16008 ///
16009 /// ````text
16010 /// It should be used to handle progress information, and to implement a certain level of resilience.
16011 /// ````
16012 ///
16013 /// Sets the *delegate* property to the given value.
16014 pub fn delegate(
16015 mut self,
16016 new_value: &'a mut dyn common::Delegate,
16017 ) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C> {
16018 self._delegate = Some(new_value);
16019 self
16020 }
16021
16022 /// Set any additional parameter of the query string used in the request.
16023 /// It should be used to set parameters which are not yet available through their own
16024 /// setters.
16025 ///
16026 /// Please note that this method must not be used to set any of the known parameters
16027 /// which have their own setter method. If done anyway, the request will fail.
16028 ///
16029 /// # Additional Parameters
16030 ///
16031 /// * *$.xgafv* (query-string) - V1 error format.
16032 /// * *access_token* (query-string) - OAuth access token.
16033 /// * *alt* (query-string) - Data format for response.
16034 /// * *callback* (query-string) - JSONP
16035 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16036 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16037 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16038 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16039 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16040 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16041 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16042 pub fn param<T>(
16043 mut self,
16044 name: T,
16045 value: T,
16046 ) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C>
16047 where
16048 T: AsRef<str>,
16049 {
16050 self._additional_params
16051 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16052 self
16053 }
16054
16055 /// Identifies the authorization scope for the method you are building.
16056 ///
16057 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16058 /// [`Scope::CourseworkMe`].
16059 ///
16060 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16061 /// tokens for more than one scope.
16062 ///
16063 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16064 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16065 /// sufficient, a read-write scope will do as well.
16066 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C>
16067 where
16068 St: AsRef<str>,
16069 {
16070 self._scopes.insert(String::from(scope.as_ref()));
16071 self
16072 }
16073 /// Identifies the authorization scope(s) for the method you are building.
16074 ///
16075 /// See [`Self::add_scope()`] for details.
16076 pub fn add_scopes<I, St>(
16077 mut self,
16078 scopes: I,
16079 ) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C>
16080 where
16081 I: IntoIterator<Item = St>,
16082 St: AsRef<str>,
16083 {
16084 self._scopes
16085 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16086 self
16087 }
16088
16089 /// Removes all scopes, and no default scope will be used either.
16090 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16091 /// for details).
16092 pub fn clear_scopes(mut self) -> CourseCourseWorkStudentSubmissionPatchCall<'a, C> {
16093 self._scopes.clear();
16094 self
16095 }
16096}
16097
16098/// Reclaims a student submission on behalf of the student that owns it. Reclaiming a student submission transfers ownership of attached Drive files to the student and updates the submission state. Only the student that owns the requested student submission may call this method, and only for a student submission that has been turned in. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, unsubmit the requested student submission, or for access errors. * `FAILED_PRECONDITION` if the student submission has not been turned in. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
16099///
16100/// A builder for the *courseWork.studentSubmissions.reclaim* method supported by a *course* resource.
16101/// It is not used directly, but through a [`CourseMethods`] instance.
16102///
16103/// # Example
16104///
16105/// Instantiate a resource method builder
16106///
16107/// ```test_harness,no_run
16108/// # extern crate hyper;
16109/// # extern crate hyper_rustls;
16110/// # extern crate google_classroom1 as classroom1;
16111/// use classroom1::api::ReclaimStudentSubmissionRequest;
16112/// # async fn dox() {
16113/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16114///
16115/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16116/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16117/// # .with_native_roots()
16118/// # .unwrap()
16119/// # .https_only()
16120/// # .enable_http2()
16121/// # .build();
16122///
16123/// # let executor = hyper_util::rt::TokioExecutor::new();
16124/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16125/// # secret,
16126/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16127/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16128/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16129/// # ),
16130/// # ).build().await.unwrap();
16131///
16132/// # let client = hyper_util::client::legacy::Client::builder(
16133/// # hyper_util::rt::TokioExecutor::new()
16134/// # )
16135/// # .build(
16136/// # hyper_rustls::HttpsConnectorBuilder::new()
16137/// # .with_native_roots()
16138/// # .unwrap()
16139/// # .https_or_http()
16140/// # .enable_http2()
16141/// # .build()
16142/// # );
16143/// # let mut hub = Classroom::new(client, auth);
16144/// // As the method needs a request, you would usually fill it with the desired information
16145/// // into the respective structure. Some of the parts shown here might not be applicable !
16146/// // Values shown here are possibly random and not representative !
16147/// let mut req = ReclaimStudentSubmissionRequest::default();
16148///
16149/// // You can configure optional parameters by calling the respective setters at will, and
16150/// // execute the final call using `doit()`.
16151/// // Values shown here are possibly random and not representative !
16152/// let result = hub.courses().course_work_student_submissions_reclaim(req, "courseId", "courseWorkId", "id")
16153/// .doit().await;
16154/// # }
16155/// ```
16156pub struct CourseCourseWorkStudentSubmissionReclaimCall<'a, C>
16157where
16158 C: 'a,
16159{
16160 hub: &'a Classroom<C>,
16161 _request: ReclaimStudentSubmissionRequest,
16162 _course_id: String,
16163 _course_work_id: String,
16164 _id: String,
16165 _delegate: Option<&'a mut dyn common::Delegate>,
16166 _additional_params: HashMap<String, String>,
16167 _scopes: BTreeSet<String>,
16168}
16169
16170impl<'a, C> common::CallBuilder for CourseCourseWorkStudentSubmissionReclaimCall<'a, C> {}
16171
16172impl<'a, C> CourseCourseWorkStudentSubmissionReclaimCall<'a, C>
16173where
16174 C: common::Connector,
16175{
16176 /// Perform the operation you have build so far.
16177 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
16178 use std::borrow::Cow;
16179 use std::io::{Read, Seek};
16180
16181 use common::{url::Params, ToParts};
16182 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16183
16184 let mut dd = common::DefaultDelegate;
16185 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16186 dlg.begin(common::MethodInfo {
16187 id: "classroom.courses.courseWork.studentSubmissions.reclaim",
16188 http_method: hyper::Method::POST,
16189 });
16190
16191 for &field in ["alt", "courseId", "courseWorkId", "id"].iter() {
16192 if self._additional_params.contains_key(field) {
16193 dlg.finished(false);
16194 return Err(common::Error::FieldClash(field));
16195 }
16196 }
16197
16198 let mut params = Params::with_capacity(6 + self._additional_params.len());
16199 params.push("courseId", self._course_id);
16200 params.push("courseWorkId", self._course_work_id);
16201 params.push("id", self._id);
16202
16203 params.extend(self._additional_params.iter());
16204
16205 params.push("alt", "json");
16206 let mut url = self.hub._base_url.clone()
16207 + "v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}:reclaim";
16208 if self._scopes.is_empty() {
16209 self._scopes
16210 .insert(Scope::CourseworkMe.as_ref().to_string());
16211 }
16212
16213 #[allow(clippy::single_element_loop)]
16214 for &(find_this, param_name) in [
16215 ("{courseId}", "courseId"),
16216 ("{courseWorkId}", "courseWorkId"),
16217 ("{id}", "id"),
16218 ]
16219 .iter()
16220 {
16221 url = params.uri_replacement(url, param_name, find_this, false);
16222 }
16223 {
16224 let to_remove = ["id", "courseWorkId", "courseId"];
16225 params.remove_params(&to_remove);
16226 }
16227
16228 let url = params.parse_with_url(&url);
16229
16230 let mut json_mime_type = mime::APPLICATION_JSON;
16231 let mut request_value_reader = {
16232 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16233 common::remove_json_null_values(&mut value);
16234 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16235 serde_json::to_writer(&mut dst, &value).unwrap();
16236 dst
16237 };
16238 let request_size = request_value_reader
16239 .seek(std::io::SeekFrom::End(0))
16240 .unwrap();
16241 request_value_reader
16242 .seek(std::io::SeekFrom::Start(0))
16243 .unwrap();
16244
16245 loop {
16246 let token = match self
16247 .hub
16248 .auth
16249 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16250 .await
16251 {
16252 Ok(token) => token,
16253 Err(e) => match dlg.token(e) {
16254 Ok(token) => token,
16255 Err(e) => {
16256 dlg.finished(false);
16257 return Err(common::Error::MissingToken(e));
16258 }
16259 },
16260 };
16261 request_value_reader
16262 .seek(std::io::SeekFrom::Start(0))
16263 .unwrap();
16264 let mut req_result = {
16265 let client = &self.hub.client;
16266 dlg.pre_request();
16267 let mut req_builder = hyper::Request::builder()
16268 .method(hyper::Method::POST)
16269 .uri(url.as_str())
16270 .header(USER_AGENT, self.hub._user_agent.clone());
16271
16272 if let Some(token) = token.as_ref() {
16273 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16274 }
16275
16276 let request = req_builder
16277 .header(CONTENT_TYPE, json_mime_type.to_string())
16278 .header(CONTENT_LENGTH, request_size as u64)
16279 .body(common::to_body(
16280 request_value_reader.get_ref().clone().into(),
16281 ));
16282
16283 client.request(request.unwrap()).await
16284 };
16285
16286 match req_result {
16287 Err(err) => {
16288 if let common::Retry::After(d) = dlg.http_error(&err) {
16289 sleep(d).await;
16290 continue;
16291 }
16292 dlg.finished(false);
16293 return Err(common::Error::HttpError(err));
16294 }
16295 Ok(res) => {
16296 let (mut parts, body) = res.into_parts();
16297 let mut body = common::Body::new(body);
16298 if !parts.status.is_success() {
16299 let bytes = common::to_bytes(body).await.unwrap_or_default();
16300 let error = serde_json::from_str(&common::to_string(&bytes));
16301 let response = common::to_response(parts, bytes.into());
16302
16303 if let common::Retry::After(d) =
16304 dlg.http_failure(&response, error.as_ref().ok())
16305 {
16306 sleep(d).await;
16307 continue;
16308 }
16309
16310 dlg.finished(false);
16311
16312 return Err(match error {
16313 Ok(value) => common::Error::BadRequest(value),
16314 _ => common::Error::Failure(response),
16315 });
16316 }
16317 let response = {
16318 let bytes = common::to_bytes(body).await.unwrap_or_default();
16319 let encoded = common::to_string(&bytes);
16320 match serde_json::from_str(&encoded) {
16321 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16322 Err(error) => {
16323 dlg.response_json_decode_error(&encoded, &error);
16324 return Err(common::Error::JsonDecodeError(
16325 encoded.to_string(),
16326 error,
16327 ));
16328 }
16329 }
16330 };
16331
16332 dlg.finished(true);
16333 return Ok(response);
16334 }
16335 }
16336 }
16337 }
16338
16339 ///
16340 /// Sets the *request* property to the given value.
16341 ///
16342 /// Even though the property as already been set when instantiating this call,
16343 /// we provide this method for API completeness.
16344 pub fn request(
16345 mut self,
16346 new_value: ReclaimStudentSubmissionRequest,
16347 ) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C> {
16348 self._request = new_value;
16349 self
16350 }
16351 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
16352 ///
16353 /// Sets the *course id* path property to the given value.
16354 ///
16355 /// Even though the property as already been set when instantiating this call,
16356 /// we provide this method for API completeness.
16357 pub fn course_id(
16358 mut self,
16359 new_value: &str,
16360 ) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C> {
16361 self._course_id = new_value.to_string();
16362 self
16363 }
16364 /// Identifier of the course work.
16365 ///
16366 /// Sets the *course work id* path property to the given value.
16367 ///
16368 /// Even though the property as already been set when instantiating this call,
16369 /// we provide this method for API completeness.
16370 pub fn course_work_id(
16371 mut self,
16372 new_value: &str,
16373 ) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C> {
16374 self._course_work_id = new_value.to_string();
16375 self
16376 }
16377 /// Identifier of the student submission.
16378 ///
16379 /// Sets the *id* path property to the given value.
16380 ///
16381 /// Even though the property as already been set when instantiating this call,
16382 /// we provide this method for API completeness.
16383 pub fn id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C> {
16384 self._id = new_value.to_string();
16385 self
16386 }
16387 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16388 /// while executing the actual API request.
16389 ///
16390 /// ````text
16391 /// It should be used to handle progress information, and to implement a certain level of resilience.
16392 /// ````
16393 ///
16394 /// Sets the *delegate* property to the given value.
16395 pub fn delegate(
16396 mut self,
16397 new_value: &'a mut dyn common::Delegate,
16398 ) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C> {
16399 self._delegate = Some(new_value);
16400 self
16401 }
16402
16403 /// Set any additional parameter of the query string used in the request.
16404 /// It should be used to set parameters which are not yet available through their own
16405 /// setters.
16406 ///
16407 /// Please note that this method must not be used to set any of the known parameters
16408 /// which have their own setter method. If done anyway, the request will fail.
16409 ///
16410 /// # Additional Parameters
16411 ///
16412 /// * *$.xgafv* (query-string) - V1 error format.
16413 /// * *access_token* (query-string) - OAuth access token.
16414 /// * *alt* (query-string) - Data format for response.
16415 /// * *callback* (query-string) - JSONP
16416 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16417 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16418 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16419 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16420 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16421 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16422 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16423 pub fn param<T>(
16424 mut self,
16425 name: T,
16426 value: T,
16427 ) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C>
16428 where
16429 T: AsRef<str>,
16430 {
16431 self._additional_params
16432 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16433 self
16434 }
16435
16436 /// Identifies the authorization scope for the method you are building.
16437 ///
16438 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16439 /// [`Scope::CourseworkMe`].
16440 ///
16441 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16442 /// tokens for more than one scope.
16443 ///
16444 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16445 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16446 /// sufficient, a read-write scope will do as well.
16447 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C>
16448 where
16449 St: AsRef<str>,
16450 {
16451 self._scopes.insert(String::from(scope.as_ref()));
16452 self
16453 }
16454 /// Identifies the authorization scope(s) for the method you are building.
16455 ///
16456 /// See [`Self::add_scope()`] for details.
16457 pub fn add_scopes<I, St>(
16458 mut self,
16459 scopes: I,
16460 ) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C>
16461 where
16462 I: IntoIterator<Item = St>,
16463 St: AsRef<str>,
16464 {
16465 self._scopes
16466 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16467 self
16468 }
16469
16470 /// Removes all scopes, and no default scope will be used either.
16471 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16472 /// for details).
16473 pub fn clear_scopes(mut self) -> CourseCourseWorkStudentSubmissionReclaimCall<'a, C> {
16474 self._scopes.clear();
16475 self
16476 }
16477}
16478
16479/// Returns a student submission. Returning a student submission transfers ownership of attached Drive files to the student and may also update the submission state. Unlike the Classroom application, returning a student submission does not set assignedGrade to the draftGrade value. Only a teacher of the course that contains the requested student submission may call this method. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, return the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
16480///
16481/// A builder for the *courseWork.studentSubmissions.return* method supported by a *course* resource.
16482/// It is not used directly, but through a [`CourseMethods`] instance.
16483///
16484/// # Example
16485///
16486/// Instantiate a resource method builder
16487///
16488/// ```test_harness,no_run
16489/// # extern crate hyper;
16490/// # extern crate hyper_rustls;
16491/// # extern crate google_classroom1 as classroom1;
16492/// use classroom1::api::ReturnStudentSubmissionRequest;
16493/// # async fn dox() {
16494/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16495///
16496/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16497/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16498/// # .with_native_roots()
16499/// # .unwrap()
16500/// # .https_only()
16501/// # .enable_http2()
16502/// # .build();
16503///
16504/// # let executor = hyper_util::rt::TokioExecutor::new();
16505/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16506/// # secret,
16507/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16508/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16509/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16510/// # ),
16511/// # ).build().await.unwrap();
16512///
16513/// # let client = hyper_util::client::legacy::Client::builder(
16514/// # hyper_util::rt::TokioExecutor::new()
16515/// # )
16516/// # .build(
16517/// # hyper_rustls::HttpsConnectorBuilder::new()
16518/// # .with_native_roots()
16519/// # .unwrap()
16520/// # .https_or_http()
16521/// # .enable_http2()
16522/// # .build()
16523/// # );
16524/// # let mut hub = Classroom::new(client, auth);
16525/// // As the method needs a request, you would usually fill it with the desired information
16526/// // into the respective structure. Some of the parts shown here might not be applicable !
16527/// // Values shown here are possibly random and not representative !
16528/// let mut req = ReturnStudentSubmissionRequest::default();
16529///
16530/// // You can configure optional parameters by calling the respective setters at will, and
16531/// // execute the final call using `doit()`.
16532/// // Values shown here are possibly random and not representative !
16533/// let result = hub.courses().course_work_student_submissions_return(req, "courseId", "courseWorkId", "id")
16534/// .doit().await;
16535/// # }
16536/// ```
16537pub struct CourseCourseWorkStudentSubmissionReturnCall<'a, C>
16538where
16539 C: 'a,
16540{
16541 hub: &'a Classroom<C>,
16542 _request: ReturnStudentSubmissionRequest,
16543 _course_id: String,
16544 _course_work_id: String,
16545 _id: String,
16546 _delegate: Option<&'a mut dyn common::Delegate>,
16547 _additional_params: HashMap<String, String>,
16548 _scopes: BTreeSet<String>,
16549}
16550
16551impl<'a, C> common::CallBuilder for CourseCourseWorkStudentSubmissionReturnCall<'a, C> {}
16552
16553impl<'a, C> CourseCourseWorkStudentSubmissionReturnCall<'a, C>
16554where
16555 C: common::Connector,
16556{
16557 /// Perform the operation you have build so far.
16558 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
16559 use std::borrow::Cow;
16560 use std::io::{Read, Seek};
16561
16562 use common::{url::Params, ToParts};
16563 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16564
16565 let mut dd = common::DefaultDelegate;
16566 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16567 dlg.begin(common::MethodInfo {
16568 id: "classroom.courses.courseWork.studentSubmissions.return",
16569 http_method: hyper::Method::POST,
16570 });
16571
16572 for &field in ["alt", "courseId", "courseWorkId", "id"].iter() {
16573 if self._additional_params.contains_key(field) {
16574 dlg.finished(false);
16575 return Err(common::Error::FieldClash(field));
16576 }
16577 }
16578
16579 let mut params = Params::with_capacity(6 + self._additional_params.len());
16580 params.push("courseId", self._course_id);
16581 params.push("courseWorkId", self._course_work_id);
16582 params.push("id", self._id);
16583
16584 params.extend(self._additional_params.iter());
16585
16586 params.push("alt", "json");
16587 let mut url = self.hub._base_url.clone()
16588 + "v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}:return";
16589 if self._scopes.is_empty() {
16590 self._scopes
16591 .insert(Scope::CourseworkStudent.as_ref().to_string());
16592 }
16593
16594 #[allow(clippy::single_element_loop)]
16595 for &(find_this, param_name) in [
16596 ("{courseId}", "courseId"),
16597 ("{courseWorkId}", "courseWorkId"),
16598 ("{id}", "id"),
16599 ]
16600 .iter()
16601 {
16602 url = params.uri_replacement(url, param_name, find_this, false);
16603 }
16604 {
16605 let to_remove = ["id", "courseWorkId", "courseId"];
16606 params.remove_params(&to_remove);
16607 }
16608
16609 let url = params.parse_with_url(&url);
16610
16611 let mut json_mime_type = mime::APPLICATION_JSON;
16612 let mut request_value_reader = {
16613 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16614 common::remove_json_null_values(&mut value);
16615 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16616 serde_json::to_writer(&mut dst, &value).unwrap();
16617 dst
16618 };
16619 let request_size = request_value_reader
16620 .seek(std::io::SeekFrom::End(0))
16621 .unwrap();
16622 request_value_reader
16623 .seek(std::io::SeekFrom::Start(0))
16624 .unwrap();
16625
16626 loop {
16627 let token = match self
16628 .hub
16629 .auth
16630 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16631 .await
16632 {
16633 Ok(token) => token,
16634 Err(e) => match dlg.token(e) {
16635 Ok(token) => token,
16636 Err(e) => {
16637 dlg.finished(false);
16638 return Err(common::Error::MissingToken(e));
16639 }
16640 },
16641 };
16642 request_value_reader
16643 .seek(std::io::SeekFrom::Start(0))
16644 .unwrap();
16645 let mut req_result = {
16646 let client = &self.hub.client;
16647 dlg.pre_request();
16648 let mut req_builder = hyper::Request::builder()
16649 .method(hyper::Method::POST)
16650 .uri(url.as_str())
16651 .header(USER_AGENT, self.hub._user_agent.clone());
16652
16653 if let Some(token) = token.as_ref() {
16654 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16655 }
16656
16657 let request = req_builder
16658 .header(CONTENT_TYPE, json_mime_type.to_string())
16659 .header(CONTENT_LENGTH, request_size as u64)
16660 .body(common::to_body(
16661 request_value_reader.get_ref().clone().into(),
16662 ));
16663
16664 client.request(request.unwrap()).await
16665 };
16666
16667 match req_result {
16668 Err(err) => {
16669 if let common::Retry::After(d) = dlg.http_error(&err) {
16670 sleep(d).await;
16671 continue;
16672 }
16673 dlg.finished(false);
16674 return Err(common::Error::HttpError(err));
16675 }
16676 Ok(res) => {
16677 let (mut parts, body) = res.into_parts();
16678 let mut body = common::Body::new(body);
16679 if !parts.status.is_success() {
16680 let bytes = common::to_bytes(body).await.unwrap_or_default();
16681 let error = serde_json::from_str(&common::to_string(&bytes));
16682 let response = common::to_response(parts, bytes.into());
16683
16684 if let common::Retry::After(d) =
16685 dlg.http_failure(&response, error.as_ref().ok())
16686 {
16687 sleep(d).await;
16688 continue;
16689 }
16690
16691 dlg.finished(false);
16692
16693 return Err(match error {
16694 Ok(value) => common::Error::BadRequest(value),
16695 _ => common::Error::Failure(response),
16696 });
16697 }
16698 let response = {
16699 let bytes = common::to_bytes(body).await.unwrap_or_default();
16700 let encoded = common::to_string(&bytes);
16701 match serde_json::from_str(&encoded) {
16702 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16703 Err(error) => {
16704 dlg.response_json_decode_error(&encoded, &error);
16705 return Err(common::Error::JsonDecodeError(
16706 encoded.to_string(),
16707 error,
16708 ));
16709 }
16710 }
16711 };
16712
16713 dlg.finished(true);
16714 return Ok(response);
16715 }
16716 }
16717 }
16718 }
16719
16720 ///
16721 /// Sets the *request* property to the given value.
16722 ///
16723 /// Even though the property as already been set when instantiating this call,
16724 /// we provide this method for API completeness.
16725 pub fn request(
16726 mut self,
16727 new_value: ReturnStudentSubmissionRequest,
16728 ) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C> {
16729 self._request = new_value;
16730 self
16731 }
16732 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
16733 ///
16734 /// Sets the *course id* path property to the given value.
16735 ///
16736 /// Even though the property as already been set when instantiating this call,
16737 /// we provide this method for API completeness.
16738 pub fn course_id(
16739 mut self,
16740 new_value: &str,
16741 ) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C> {
16742 self._course_id = new_value.to_string();
16743 self
16744 }
16745 /// Identifier of the course work.
16746 ///
16747 /// Sets the *course work id* path property to the given value.
16748 ///
16749 /// Even though the property as already been set when instantiating this call,
16750 /// we provide this method for API completeness.
16751 pub fn course_work_id(
16752 mut self,
16753 new_value: &str,
16754 ) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C> {
16755 self._course_work_id = new_value.to_string();
16756 self
16757 }
16758 /// Identifier of the student submission.
16759 ///
16760 /// Sets the *id* path property to the given value.
16761 ///
16762 /// Even though the property as already been set when instantiating this call,
16763 /// we provide this method for API completeness.
16764 pub fn id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C> {
16765 self._id = new_value.to_string();
16766 self
16767 }
16768 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16769 /// while executing the actual API request.
16770 ///
16771 /// ````text
16772 /// It should be used to handle progress information, and to implement a certain level of resilience.
16773 /// ````
16774 ///
16775 /// Sets the *delegate* property to the given value.
16776 pub fn delegate(
16777 mut self,
16778 new_value: &'a mut dyn common::Delegate,
16779 ) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C> {
16780 self._delegate = Some(new_value);
16781 self
16782 }
16783
16784 /// Set any additional parameter of the query string used in the request.
16785 /// It should be used to set parameters which are not yet available through their own
16786 /// setters.
16787 ///
16788 /// Please note that this method must not be used to set any of the known parameters
16789 /// which have their own setter method. If done anyway, the request will fail.
16790 ///
16791 /// # Additional Parameters
16792 ///
16793 /// * *$.xgafv* (query-string) - V1 error format.
16794 /// * *access_token* (query-string) - OAuth access token.
16795 /// * *alt* (query-string) - Data format for response.
16796 /// * *callback* (query-string) - JSONP
16797 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16798 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16799 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16800 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16801 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
16802 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16803 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16804 pub fn param<T>(
16805 mut self,
16806 name: T,
16807 value: T,
16808 ) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C>
16809 where
16810 T: AsRef<str>,
16811 {
16812 self._additional_params
16813 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16814 self
16815 }
16816
16817 /// Identifies the authorization scope for the method you are building.
16818 ///
16819 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16820 /// [`Scope::CourseworkStudent`].
16821 ///
16822 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16823 /// tokens for more than one scope.
16824 ///
16825 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16826 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16827 /// sufficient, a read-write scope will do as well.
16828 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C>
16829 where
16830 St: AsRef<str>,
16831 {
16832 self._scopes.insert(String::from(scope.as_ref()));
16833 self
16834 }
16835 /// Identifies the authorization scope(s) for the method you are building.
16836 ///
16837 /// See [`Self::add_scope()`] for details.
16838 pub fn add_scopes<I, St>(
16839 mut self,
16840 scopes: I,
16841 ) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C>
16842 where
16843 I: IntoIterator<Item = St>,
16844 St: AsRef<str>,
16845 {
16846 self._scopes
16847 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16848 self
16849 }
16850
16851 /// Removes all scopes, and no default scope will be used either.
16852 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16853 /// for details).
16854 pub fn clear_scopes(mut self) -> CourseCourseWorkStudentSubmissionReturnCall<'a, C> {
16855 self._scopes.clear();
16856 self
16857 }
16858}
16859
16860/// Turns in a student submission. Turning in a student submission transfers ownership of attached Drive files to the teacher and may also update the submission state. This may only be called by the student that owns the specified student submission. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, turn in the requested student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course, course work, or student submission does not exist.
16861///
16862/// A builder for the *courseWork.studentSubmissions.turnIn* method supported by a *course* resource.
16863/// It is not used directly, but through a [`CourseMethods`] instance.
16864///
16865/// # Example
16866///
16867/// Instantiate a resource method builder
16868///
16869/// ```test_harness,no_run
16870/// # extern crate hyper;
16871/// # extern crate hyper_rustls;
16872/// # extern crate google_classroom1 as classroom1;
16873/// use classroom1::api::TurnInStudentSubmissionRequest;
16874/// # async fn dox() {
16875/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16876///
16877/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16878/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16879/// # .with_native_roots()
16880/// # .unwrap()
16881/// # .https_only()
16882/// # .enable_http2()
16883/// # .build();
16884///
16885/// # let executor = hyper_util::rt::TokioExecutor::new();
16886/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16887/// # secret,
16888/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16889/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16890/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16891/// # ),
16892/// # ).build().await.unwrap();
16893///
16894/// # let client = hyper_util::client::legacy::Client::builder(
16895/// # hyper_util::rt::TokioExecutor::new()
16896/// # )
16897/// # .build(
16898/// # hyper_rustls::HttpsConnectorBuilder::new()
16899/// # .with_native_roots()
16900/// # .unwrap()
16901/// # .https_or_http()
16902/// # .enable_http2()
16903/// # .build()
16904/// # );
16905/// # let mut hub = Classroom::new(client, auth);
16906/// // As the method needs a request, you would usually fill it with the desired information
16907/// // into the respective structure. Some of the parts shown here might not be applicable !
16908/// // Values shown here are possibly random and not representative !
16909/// let mut req = TurnInStudentSubmissionRequest::default();
16910///
16911/// // You can configure optional parameters by calling the respective setters at will, and
16912/// // execute the final call using `doit()`.
16913/// // Values shown here are possibly random and not representative !
16914/// let result = hub.courses().course_work_student_submissions_turn_in(req, "courseId", "courseWorkId", "id")
16915/// .doit().await;
16916/// # }
16917/// ```
16918pub struct CourseCourseWorkStudentSubmissionTurnInCall<'a, C>
16919where
16920 C: 'a,
16921{
16922 hub: &'a Classroom<C>,
16923 _request: TurnInStudentSubmissionRequest,
16924 _course_id: String,
16925 _course_work_id: String,
16926 _id: String,
16927 _delegate: Option<&'a mut dyn common::Delegate>,
16928 _additional_params: HashMap<String, String>,
16929 _scopes: BTreeSet<String>,
16930}
16931
16932impl<'a, C> common::CallBuilder for CourseCourseWorkStudentSubmissionTurnInCall<'a, C> {}
16933
16934impl<'a, C> CourseCourseWorkStudentSubmissionTurnInCall<'a, C>
16935where
16936 C: common::Connector,
16937{
16938 /// Perform the operation you have build so far.
16939 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
16940 use std::borrow::Cow;
16941 use std::io::{Read, Seek};
16942
16943 use common::{url::Params, ToParts};
16944 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16945
16946 let mut dd = common::DefaultDelegate;
16947 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16948 dlg.begin(common::MethodInfo {
16949 id: "classroom.courses.courseWork.studentSubmissions.turnIn",
16950 http_method: hyper::Method::POST,
16951 });
16952
16953 for &field in ["alt", "courseId", "courseWorkId", "id"].iter() {
16954 if self._additional_params.contains_key(field) {
16955 dlg.finished(false);
16956 return Err(common::Error::FieldClash(field));
16957 }
16958 }
16959
16960 let mut params = Params::with_capacity(6 + self._additional_params.len());
16961 params.push("courseId", self._course_id);
16962 params.push("courseWorkId", self._course_work_id);
16963 params.push("id", self._id);
16964
16965 params.extend(self._additional_params.iter());
16966
16967 params.push("alt", "json");
16968 let mut url = self.hub._base_url.clone()
16969 + "v1/courses/{courseId}/courseWork/{courseWorkId}/studentSubmissions/{id}:turnIn";
16970 if self._scopes.is_empty() {
16971 self._scopes
16972 .insert(Scope::CourseworkMe.as_ref().to_string());
16973 }
16974
16975 #[allow(clippy::single_element_loop)]
16976 for &(find_this, param_name) in [
16977 ("{courseId}", "courseId"),
16978 ("{courseWorkId}", "courseWorkId"),
16979 ("{id}", "id"),
16980 ]
16981 .iter()
16982 {
16983 url = params.uri_replacement(url, param_name, find_this, false);
16984 }
16985 {
16986 let to_remove = ["id", "courseWorkId", "courseId"];
16987 params.remove_params(&to_remove);
16988 }
16989
16990 let url = params.parse_with_url(&url);
16991
16992 let mut json_mime_type = mime::APPLICATION_JSON;
16993 let mut request_value_reader = {
16994 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16995 common::remove_json_null_values(&mut value);
16996 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16997 serde_json::to_writer(&mut dst, &value).unwrap();
16998 dst
16999 };
17000 let request_size = request_value_reader
17001 .seek(std::io::SeekFrom::End(0))
17002 .unwrap();
17003 request_value_reader
17004 .seek(std::io::SeekFrom::Start(0))
17005 .unwrap();
17006
17007 loop {
17008 let token = match self
17009 .hub
17010 .auth
17011 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17012 .await
17013 {
17014 Ok(token) => token,
17015 Err(e) => match dlg.token(e) {
17016 Ok(token) => token,
17017 Err(e) => {
17018 dlg.finished(false);
17019 return Err(common::Error::MissingToken(e));
17020 }
17021 },
17022 };
17023 request_value_reader
17024 .seek(std::io::SeekFrom::Start(0))
17025 .unwrap();
17026 let mut req_result = {
17027 let client = &self.hub.client;
17028 dlg.pre_request();
17029 let mut req_builder = hyper::Request::builder()
17030 .method(hyper::Method::POST)
17031 .uri(url.as_str())
17032 .header(USER_AGENT, self.hub._user_agent.clone());
17033
17034 if let Some(token) = token.as_ref() {
17035 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17036 }
17037
17038 let request = req_builder
17039 .header(CONTENT_TYPE, json_mime_type.to_string())
17040 .header(CONTENT_LENGTH, request_size as u64)
17041 .body(common::to_body(
17042 request_value_reader.get_ref().clone().into(),
17043 ));
17044
17045 client.request(request.unwrap()).await
17046 };
17047
17048 match req_result {
17049 Err(err) => {
17050 if let common::Retry::After(d) = dlg.http_error(&err) {
17051 sleep(d).await;
17052 continue;
17053 }
17054 dlg.finished(false);
17055 return Err(common::Error::HttpError(err));
17056 }
17057 Ok(res) => {
17058 let (mut parts, body) = res.into_parts();
17059 let mut body = common::Body::new(body);
17060 if !parts.status.is_success() {
17061 let bytes = common::to_bytes(body).await.unwrap_or_default();
17062 let error = serde_json::from_str(&common::to_string(&bytes));
17063 let response = common::to_response(parts, bytes.into());
17064
17065 if let common::Retry::After(d) =
17066 dlg.http_failure(&response, error.as_ref().ok())
17067 {
17068 sleep(d).await;
17069 continue;
17070 }
17071
17072 dlg.finished(false);
17073
17074 return Err(match error {
17075 Ok(value) => common::Error::BadRequest(value),
17076 _ => common::Error::Failure(response),
17077 });
17078 }
17079 let response = {
17080 let bytes = common::to_bytes(body).await.unwrap_or_default();
17081 let encoded = common::to_string(&bytes);
17082 match serde_json::from_str(&encoded) {
17083 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17084 Err(error) => {
17085 dlg.response_json_decode_error(&encoded, &error);
17086 return Err(common::Error::JsonDecodeError(
17087 encoded.to_string(),
17088 error,
17089 ));
17090 }
17091 }
17092 };
17093
17094 dlg.finished(true);
17095 return Ok(response);
17096 }
17097 }
17098 }
17099 }
17100
17101 ///
17102 /// Sets the *request* property to the given value.
17103 ///
17104 /// Even though the property as already been set when instantiating this call,
17105 /// we provide this method for API completeness.
17106 pub fn request(
17107 mut self,
17108 new_value: TurnInStudentSubmissionRequest,
17109 ) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C> {
17110 self._request = new_value;
17111 self
17112 }
17113 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
17114 ///
17115 /// Sets the *course id* path property to the given value.
17116 ///
17117 /// Even though the property as already been set when instantiating this call,
17118 /// we provide this method for API completeness.
17119 pub fn course_id(
17120 mut self,
17121 new_value: &str,
17122 ) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C> {
17123 self._course_id = new_value.to_string();
17124 self
17125 }
17126 /// Identifier of the course work.
17127 ///
17128 /// Sets the *course work id* path property to the given value.
17129 ///
17130 /// Even though the property as already been set when instantiating this call,
17131 /// we provide this method for API completeness.
17132 pub fn course_work_id(
17133 mut self,
17134 new_value: &str,
17135 ) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C> {
17136 self._course_work_id = new_value.to_string();
17137 self
17138 }
17139 /// Identifier of the student submission.
17140 ///
17141 /// Sets the *id* path property to the given value.
17142 ///
17143 /// Even though the property as already been set when instantiating this call,
17144 /// we provide this method for API completeness.
17145 pub fn id(mut self, new_value: &str) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C> {
17146 self._id = new_value.to_string();
17147 self
17148 }
17149 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17150 /// while executing the actual API request.
17151 ///
17152 /// ````text
17153 /// It should be used to handle progress information, and to implement a certain level of resilience.
17154 /// ````
17155 ///
17156 /// Sets the *delegate* property to the given value.
17157 pub fn delegate(
17158 mut self,
17159 new_value: &'a mut dyn common::Delegate,
17160 ) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C> {
17161 self._delegate = Some(new_value);
17162 self
17163 }
17164
17165 /// Set any additional parameter of the query string used in the request.
17166 /// It should be used to set parameters which are not yet available through their own
17167 /// setters.
17168 ///
17169 /// Please note that this method must not be used to set any of the known parameters
17170 /// which have their own setter method. If done anyway, the request will fail.
17171 ///
17172 /// # Additional Parameters
17173 ///
17174 /// * *$.xgafv* (query-string) - V1 error format.
17175 /// * *access_token* (query-string) - OAuth access token.
17176 /// * *alt* (query-string) - Data format for response.
17177 /// * *callback* (query-string) - JSONP
17178 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17179 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17180 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17181 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17182 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17183 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17184 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17185 pub fn param<T>(
17186 mut self,
17187 name: T,
17188 value: T,
17189 ) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C>
17190 where
17191 T: AsRef<str>,
17192 {
17193 self._additional_params
17194 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17195 self
17196 }
17197
17198 /// Identifies the authorization scope for the method you are building.
17199 ///
17200 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17201 /// [`Scope::CourseworkMe`].
17202 ///
17203 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17204 /// tokens for more than one scope.
17205 ///
17206 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17207 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17208 /// sufficient, a read-write scope will do as well.
17209 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C>
17210 where
17211 St: AsRef<str>,
17212 {
17213 self._scopes.insert(String::from(scope.as_ref()));
17214 self
17215 }
17216 /// Identifies the authorization scope(s) for the method you are building.
17217 ///
17218 /// See [`Self::add_scope()`] for details.
17219 pub fn add_scopes<I, St>(
17220 mut self,
17221 scopes: I,
17222 ) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C>
17223 where
17224 I: IntoIterator<Item = St>,
17225 St: AsRef<str>,
17226 {
17227 self._scopes
17228 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17229 self
17230 }
17231
17232 /// Removes all scopes, and no default scope will be used either.
17233 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17234 /// for details).
17235 pub fn clear_scopes(mut self) -> CourseCourseWorkStudentSubmissionTurnInCall<'a, C> {
17236 self._scopes.clear();
17237 self
17238 }
17239}
17240
17241/// Creates course work. The resulting course work (and corresponding student submissions) are associated with the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to make the request. Classroom API requests to modify course work and student submissions must be made with an OAuth client ID from the associated Developer Console project. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create course work in the requested course, share a Drive attachment, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist. * `FAILED_PRECONDITION` for the following request error: * AttachmentNotVisible
17242///
17243/// A builder for the *courseWork.create* method supported by a *course* resource.
17244/// It is not used directly, but through a [`CourseMethods`] instance.
17245///
17246/// # Example
17247///
17248/// Instantiate a resource method builder
17249///
17250/// ```test_harness,no_run
17251/// # extern crate hyper;
17252/// # extern crate hyper_rustls;
17253/// # extern crate google_classroom1 as classroom1;
17254/// use classroom1::api::CourseWork;
17255/// # async fn dox() {
17256/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17257///
17258/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17259/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17260/// # .with_native_roots()
17261/// # .unwrap()
17262/// # .https_only()
17263/// # .enable_http2()
17264/// # .build();
17265///
17266/// # let executor = hyper_util::rt::TokioExecutor::new();
17267/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17268/// # secret,
17269/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17270/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17271/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17272/// # ),
17273/// # ).build().await.unwrap();
17274///
17275/// # let client = hyper_util::client::legacy::Client::builder(
17276/// # hyper_util::rt::TokioExecutor::new()
17277/// # )
17278/// # .build(
17279/// # hyper_rustls::HttpsConnectorBuilder::new()
17280/// # .with_native_roots()
17281/// # .unwrap()
17282/// # .https_or_http()
17283/// # .enable_http2()
17284/// # .build()
17285/// # );
17286/// # let mut hub = Classroom::new(client, auth);
17287/// // As the method needs a request, you would usually fill it with the desired information
17288/// // into the respective structure. Some of the parts shown here might not be applicable !
17289/// // Values shown here are possibly random and not representative !
17290/// let mut req = CourseWork::default();
17291///
17292/// // You can configure optional parameters by calling the respective setters at will, and
17293/// // execute the final call using `doit()`.
17294/// // Values shown here are possibly random and not representative !
17295/// let result = hub.courses().course_work_create(req, "courseId")
17296/// .doit().await;
17297/// # }
17298/// ```
17299pub struct CourseCourseWorkCreateCall<'a, C>
17300where
17301 C: 'a,
17302{
17303 hub: &'a Classroom<C>,
17304 _request: CourseWork,
17305 _course_id: String,
17306 _delegate: Option<&'a mut dyn common::Delegate>,
17307 _additional_params: HashMap<String, String>,
17308 _scopes: BTreeSet<String>,
17309}
17310
17311impl<'a, C> common::CallBuilder for CourseCourseWorkCreateCall<'a, C> {}
17312
17313impl<'a, C> CourseCourseWorkCreateCall<'a, C>
17314where
17315 C: common::Connector,
17316{
17317 /// Perform the operation you have build so far.
17318 pub async fn doit(mut self) -> common::Result<(common::Response, CourseWork)> {
17319 use std::borrow::Cow;
17320 use std::io::{Read, Seek};
17321
17322 use common::{url::Params, ToParts};
17323 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17324
17325 let mut dd = common::DefaultDelegate;
17326 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17327 dlg.begin(common::MethodInfo {
17328 id: "classroom.courses.courseWork.create",
17329 http_method: hyper::Method::POST,
17330 });
17331
17332 for &field in ["alt", "courseId"].iter() {
17333 if self._additional_params.contains_key(field) {
17334 dlg.finished(false);
17335 return Err(common::Error::FieldClash(field));
17336 }
17337 }
17338
17339 let mut params = Params::with_capacity(4 + self._additional_params.len());
17340 params.push("courseId", self._course_id);
17341
17342 params.extend(self._additional_params.iter());
17343
17344 params.push("alt", "json");
17345 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork";
17346 if self._scopes.is_empty() {
17347 self._scopes
17348 .insert(Scope::CourseworkStudent.as_ref().to_string());
17349 }
17350
17351 #[allow(clippy::single_element_loop)]
17352 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
17353 url = params.uri_replacement(url, param_name, find_this, false);
17354 }
17355 {
17356 let to_remove = ["courseId"];
17357 params.remove_params(&to_remove);
17358 }
17359
17360 let url = params.parse_with_url(&url);
17361
17362 let mut json_mime_type = mime::APPLICATION_JSON;
17363 let mut request_value_reader = {
17364 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17365 common::remove_json_null_values(&mut value);
17366 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17367 serde_json::to_writer(&mut dst, &value).unwrap();
17368 dst
17369 };
17370 let request_size = request_value_reader
17371 .seek(std::io::SeekFrom::End(0))
17372 .unwrap();
17373 request_value_reader
17374 .seek(std::io::SeekFrom::Start(0))
17375 .unwrap();
17376
17377 loop {
17378 let token = match self
17379 .hub
17380 .auth
17381 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17382 .await
17383 {
17384 Ok(token) => token,
17385 Err(e) => match dlg.token(e) {
17386 Ok(token) => token,
17387 Err(e) => {
17388 dlg.finished(false);
17389 return Err(common::Error::MissingToken(e));
17390 }
17391 },
17392 };
17393 request_value_reader
17394 .seek(std::io::SeekFrom::Start(0))
17395 .unwrap();
17396 let mut req_result = {
17397 let client = &self.hub.client;
17398 dlg.pre_request();
17399 let mut req_builder = hyper::Request::builder()
17400 .method(hyper::Method::POST)
17401 .uri(url.as_str())
17402 .header(USER_AGENT, self.hub._user_agent.clone());
17403
17404 if let Some(token) = token.as_ref() {
17405 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17406 }
17407
17408 let request = req_builder
17409 .header(CONTENT_TYPE, json_mime_type.to_string())
17410 .header(CONTENT_LENGTH, request_size as u64)
17411 .body(common::to_body(
17412 request_value_reader.get_ref().clone().into(),
17413 ));
17414
17415 client.request(request.unwrap()).await
17416 };
17417
17418 match req_result {
17419 Err(err) => {
17420 if let common::Retry::After(d) = dlg.http_error(&err) {
17421 sleep(d).await;
17422 continue;
17423 }
17424 dlg.finished(false);
17425 return Err(common::Error::HttpError(err));
17426 }
17427 Ok(res) => {
17428 let (mut parts, body) = res.into_parts();
17429 let mut body = common::Body::new(body);
17430 if !parts.status.is_success() {
17431 let bytes = common::to_bytes(body).await.unwrap_or_default();
17432 let error = serde_json::from_str(&common::to_string(&bytes));
17433 let response = common::to_response(parts, bytes.into());
17434
17435 if let common::Retry::After(d) =
17436 dlg.http_failure(&response, error.as_ref().ok())
17437 {
17438 sleep(d).await;
17439 continue;
17440 }
17441
17442 dlg.finished(false);
17443
17444 return Err(match error {
17445 Ok(value) => common::Error::BadRequest(value),
17446 _ => common::Error::Failure(response),
17447 });
17448 }
17449 let response = {
17450 let bytes = common::to_bytes(body).await.unwrap_or_default();
17451 let encoded = common::to_string(&bytes);
17452 match serde_json::from_str(&encoded) {
17453 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17454 Err(error) => {
17455 dlg.response_json_decode_error(&encoded, &error);
17456 return Err(common::Error::JsonDecodeError(
17457 encoded.to_string(),
17458 error,
17459 ));
17460 }
17461 }
17462 };
17463
17464 dlg.finished(true);
17465 return Ok(response);
17466 }
17467 }
17468 }
17469 }
17470
17471 ///
17472 /// Sets the *request* property to the given value.
17473 ///
17474 /// Even though the property as already been set when instantiating this call,
17475 /// we provide this method for API completeness.
17476 pub fn request(mut self, new_value: CourseWork) -> CourseCourseWorkCreateCall<'a, C> {
17477 self._request = new_value;
17478 self
17479 }
17480 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
17481 ///
17482 /// Sets the *course id* path property to the given value.
17483 ///
17484 /// Even though the property as already been set when instantiating this call,
17485 /// we provide this method for API completeness.
17486 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkCreateCall<'a, C> {
17487 self._course_id = new_value.to_string();
17488 self
17489 }
17490 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17491 /// while executing the actual API request.
17492 ///
17493 /// ````text
17494 /// It should be used to handle progress information, and to implement a certain level of resilience.
17495 /// ````
17496 ///
17497 /// Sets the *delegate* property to the given value.
17498 pub fn delegate(
17499 mut self,
17500 new_value: &'a mut dyn common::Delegate,
17501 ) -> CourseCourseWorkCreateCall<'a, C> {
17502 self._delegate = Some(new_value);
17503 self
17504 }
17505
17506 /// Set any additional parameter of the query string used in the request.
17507 /// It should be used to set parameters which are not yet available through their own
17508 /// setters.
17509 ///
17510 /// Please note that this method must not be used to set any of the known parameters
17511 /// which have their own setter method. If done anyway, the request will fail.
17512 ///
17513 /// # Additional Parameters
17514 ///
17515 /// * *$.xgafv* (query-string) - V1 error format.
17516 /// * *access_token* (query-string) - OAuth access token.
17517 /// * *alt* (query-string) - Data format for response.
17518 /// * *callback* (query-string) - JSONP
17519 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17520 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17521 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17522 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17523 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17524 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17525 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17526 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkCreateCall<'a, C>
17527 where
17528 T: AsRef<str>,
17529 {
17530 self._additional_params
17531 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17532 self
17533 }
17534
17535 /// Identifies the authorization scope for the method you are building.
17536 ///
17537 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17538 /// [`Scope::CourseworkStudent`].
17539 ///
17540 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17541 /// tokens for more than one scope.
17542 ///
17543 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17544 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17545 /// sufficient, a read-write scope will do as well.
17546 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkCreateCall<'a, C>
17547 where
17548 St: AsRef<str>,
17549 {
17550 self._scopes.insert(String::from(scope.as_ref()));
17551 self
17552 }
17553 /// Identifies the authorization scope(s) for the method you are building.
17554 ///
17555 /// See [`Self::add_scope()`] for details.
17556 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkCreateCall<'a, C>
17557 where
17558 I: IntoIterator<Item = St>,
17559 St: AsRef<str>,
17560 {
17561 self._scopes
17562 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17563 self
17564 }
17565
17566 /// Removes all scopes, and no default scope will be used either.
17567 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17568 /// for details).
17569 pub fn clear_scopes(mut self) -> CourseCourseWorkCreateCall<'a, C> {
17570 self._scopes.clear();
17571 self
17572 }
17573}
17574
17575/// Deletes a course work. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work, if the requesting user is not permitted to delete the requested course or for access errors. * `FAILED_PRECONDITION` if the requested course work has already been deleted. * `NOT_FOUND` if no course exists with the requested ID.
17576///
17577/// A builder for the *courseWork.delete* method supported by a *course* resource.
17578/// It is not used directly, but through a [`CourseMethods`] instance.
17579///
17580/// # Example
17581///
17582/// Instantiate a resource method builder
17583///
17584/// ```test_harness,no_run
17585/// # extern crate hyper;
17586/// # extern crate hyper_rustls;
17587/// # extern crate google_classroom1 as classroom1;
17588/// # async fn dox() {
17589/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17590///
17591/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17592/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17593/// # .with_native_roots()
17594/// # .unwrap()
17595/// # .https_only()
17596/// # .enable_http2()
17597/// # .build();
17598///
17599/// # let executor = hyper_util::rt::TokioExecutor::new();
17600/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17601/// # secret,
17602/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17603/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17604/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17605/// # ),
17606/// # ).build().await.unwrap();
17607///
17608/// # let client = hyper_util::client::legacy::Client::builder(
17609/// # hyper_util::rt::TokioExecutor::new()
17610/// # )
17611/// # .build(
17612/// # hyper_rustls::HttpsConnectorBuilder::new()
17613/// # .with_native_roots()
17614/// # .unwrap()
17615/// # .https_or_http()
17616/// # .enable_http2()
17617/// # .build()
17618/// # );
17619/// # let mut hub = Classroom::new(client, auth);
17620/// // You can configure optional parameters by calling the respective setters at will, and
17621/// // execute the final call using `doit()`.
17622/// // Values shown here are possibly random and not representative !
17623/// let result = hub.courses().course_work_delete("courseId", "id")
17624/// .doit().await;
17625/// # }
17626/// ```
17627pub struct CourseCourseWorkDeleteCall<'a, C>
17628where
17629 C: 'a,
17630{
17631 hub: &'a Classroom<C>,
17632 _course_id: String,
17633 _id: String,
17634 _delegate: Option<&'a mut dyn common::Delegate>,
17635 _additional_params: HashMap<String, String>,
17636 _scopes: BTreeSet<String>,
17637}
17638
17639impl<'a, C> common::CallBuilder for CourseCourseWorkDeleteCall<'a, C> {}
17640
17641impl<'a, C> CourseCourseWorkDeleteCall<'a, C>
17642where
17643 C: common::Connector,
17644{
17645 /// Perform the operation you have build so far.
17646 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
17647 use std::borrow::Cow;
17648 use std::io::{Read, Seek};
17649
17650 use common::{url::Params, ToParts};
17651 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17652
17653 let mut dd = common::DefaultDelegate;
17654 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17655 dlg.begin(common::MethodInfo {
17656 id: "classroom.courses.courseWork.delete",
17657 http_method: hyper::Method::DELETE,
17658 });
17659
17660 for &field in ["alt", "courseId", "id"].iter() {
17661 if self._additional_params.contains_key(field) {
17662 dlg.finished(false);
17663 return Err(common::Error::FieldClash(field));
17664 }
17665 }
17666
17667 let mut params = Params::with_capacity(4 + self._additional_params.len());
17668 params.push("courseId", self._course_id);
17669 params.push("id", self._id);
17670
17671 params.extend(self._additional_params.iter());
17672
17673 params.push("alt", "json");
17674 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{id}";
17675 if self._scopes.is_empty() {
17676 self._scopes
17677 .insert(Scope::CourseworkStudent.as_ref().to_string());
17678 }
17679
17680 #[allow(clippy::single_element_loop)]
17681 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
17682 url = params.uri_replacement(url, param_name, find_this, false);
17683 }
17684 {
17685 let to_remove = ["id", "courseId"];
17686 params.remove_params(&to_remove);
17687 }
17688
17689 let url = params.parse_with_url(&url);
17690
17691 loop {
17692 let token = match self
17693 .hub
17694 .auth
17695 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17696 .await
17697 {
17698 Ok(token) => token,
17699 Err(e) => match dlg.token(e) {
17700 Ok(token) => token,
17701 Err(e) => {
17702 dlg.finished(false);
17703 return Err(common::Error::MissingToken(e));
17704 }
17705 },
17706 };
17707 let mut req_result = {
17708 let client = &self.hub.client;
17709 dlg.pre_request();
17710 let mut req_builder = hyper::Request::builder()
17711 .method(hyper::Method::DELETE)
17712 .uri(url.as_str())
17713 .header(USER_AGENT, self.hub._user_agent.clone());
17714
17715 if let Some(token) = token.as_ref() {
17716 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17717 }
17718
17719 let request = req_builder
17720 .header(CONTENT_LENGTH, 0_u64)
17721 .body(common::to_body::<String>(None));
17722
17723 client.request(request.unwrap()).await
17724 };
17725
17726 match req_result {
17727 Err(err) => {
17728 if let common::Retry::After(d) = dlg.http_error(&err) {
17729 sleep(d).await;
17730 continue;
17731 }
17732 dlg.finished(false);
17733 return Err(common::Error::HttpError(err));
17734 }
17735 Ok(res) => {
17736 let (mut parts, body) = res.into_parts();
17737 let mut body = common::Body::new(body);
17738 if !parts.status.is_success() {
17739 let bytes = common::to_bytes(body).await.unwrap_or_default();
17740 let error = serde_json::from_str(&common::to_string(&bytes));
17741 let response = common::to_response(parts, bytes.into());
17742
17743 if let common::Retry::After(d) =
17744 dlg.http_failure(&response, error.as_ref().ok())
17745 {
17746 sleep(d).await;
17747 continue;
17748 }
17749
17750 dlg.finished(false);
17751
17752 return Err(match error {
17753 Ok(value) => common::Error::BadRequest(value),
17754 _ => common::Error::Failure(response),
17755 });
17756 }
17757 let response = {
17758 let bytes = common::to_bytes(body).await.unwrap_or_default();
17759 let encoded = common::to_string(&bytes);
17760 match serde_json::from_str(&encoded) {
17761 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17762 Err(error) => {
17763 dlg.response_json_decode_error(&encoded, &error);
17764 return Err(common::Error::JsonDecodeError(
17765 encoded.to_string(),
17766 error,
17767 ));
17768 }
17769 }
17770 };
17771
17772 dlg.finished(true);
17773 return Ok(response);
17774 }
17775 }
17776 }
17777 }
17778
17779 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
17780 ///
17781 /// Sets the *course id* path property to the given value.
17782 ///
17783 /// Even though the property as already been set when instantiating this call,
17784 /// we provide this method for API completeness.
17785 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkDeleteCall<'a, C> {
17786 self._course_id = new_value.to_string();
17787 self
17788 }
17789 /// Identifier of the course work to delete. This identifier is a Classroom-assigned identifier.
17790 ///
17791 /// Sets the *id* path property to the given value.
17792 ///
17793 /// Even though the property as already been set when instantiating this call,
17794 /// we provide this method for API completeness.
17795 pub fn id(mut self, new_value: &str) -> CourseCourseWorkDeleteCall<'a, C> {
17796 self._id = new_value.to_string();
17797 self
17798 }
17799 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17800 /// while executing the actual API request.
17801 ///
17802 /// ````text
17803 /// It should be used to handle progress information, and to implement a certain level of resilience.
17804 /// ````
17805 ///
17806 /// Sets the *delegate* property to the given value.
17807 pub fn delegate(
17808 mut self,
17809 new_value: &'a mut dyn common::Delegate,
17810 ) -> CourseCourseWorkDeleteCall<'a, C> {
17811 self._delegate = Some(new_value);
17812 self
17813 }
17814
17815 /// Set any additional parameter of the query string used in the request.
17816 /// It should be used to set parameters which are not yet available through their own
17817 /// setters.
17818 ///
17819 /// Please note that this method must not be used to set any of the known parameters
17820 /// which have their own setter method. If done anyway, the request will fail.
17821 ///
17822 /// # Additional Parameters
17823 ///
17824 /// * *$.xgafv* (query-string) - V1 error format.
17825 /// * *access_token* (query-string) - OAuth access token.
17826 /// * *alt* (query-string) - Data format for response.
17827 /// * *callback* (query-string) - JSONP
17828 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17829 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17830 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17831 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17832 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
17833 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17834 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17835 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkDeleteCall<'a, C>
17836 where
17837 T: AsRef<str>,
17838 {
17839 self._additional_params
17840 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17841 self
17842 }
17843
17844 /// Identifies the authorization scope for the method you are building.
17845 ///
17846 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17847 /// [`Scope::CourseworkStudent`].
17848 ///
17849 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17850 /// tokens for more than one scope.
17851 ///
17852 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17853 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17854 /// sufficient, a read-write scope will do as well.
17855 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkDeleteCall<'a, C>
17856 where
17857 St: AsRef<str>,
17858 {
17859 self._scopes.insert(String::from(scope.as_ref()));
17860 self
17861 }
17862 /// Identifies the authorization scope(s) for the method you are building.
17863 ///
17864 /// See [`Self::add_scope()`] for details.
17865 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkDeleteCall<'a, C>
17866 where
17867 I: IntoIterator<Item = St>,
17868 St: AsRef<str>,
17869 {
17870 self._scopes
17871 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17872 self
17873 }
17874
17875 /// Removes all scopes, and no default scope will be used either.
17876 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17877 /// for details).
17878 pub fn clear_scopes(mut self) -> CourseCourseWorkDeleteCall<'a, C> {
17879 self._scopes.clear();
17880 self
17881 }
17882}
17883
17884/// Returns course work. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work does not exist.
17885///
17886/// A builder for the *courseWork.get* method supported by a *course* resource.
17887/// It is not used directly, but through a [`CourseMethods`] instance.
17888///
17889/// # Example
17890///
17891/// Instantiate a resource method builder
17892///
17893/// ```test_harness,no_run
17894/// # extern crate hyper;
17895/// # extern crate hyper_rustls;
17896/// # extern crate google_classroom1 as classroom1;
17897/// # async fn dox() {
17898/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17899///
17900/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17901/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17902/// # .with_native_roots()
17903/// # .unwrap()
17904/// # .https_only()
17905/// # .enable_http2()
17906/// # .build();
17907///
17908/// # let executor = hyper_util::rt::TokioExecutor::new();
17909/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17910/// # secret,
17911/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17912/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17913/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17914/// # ),
17915/// # ).build().await.unwrap();
17916///
17917/// # let client = hyper_util::client::legacy::Client::builder(
17918/// # hyper_util::rt::TokioExecutor::new()
17919/// # )
17920/// # .build(
17921/// # hyper_rustls::HttpsConnectorBuilder::new()
17922/// # .with_native_roots()
17923/// # .unwrap()
17924/// # .https_or_http()
17925/// # .enable_http2()
17926/// # .build()
17927/// # );
17928/// # let mut hub = Classroom::new(client, auth);
17929/// // You can configure optional parameters by calling the respective setters at will, and
17930/// // execute the final call using `doit()`.
17931/// // Values shown here are possibly random and not representative !
17932/// let result = hub.courses().course_work_get("courseId", "id")
17933/// .doit().await;
17934/// # }
17935/// ```
17936pub struct CourseCourseWorkGetCall<'a, C>
17937where
17938 C: 'a,
17939{
17940 hub: &'a Classroom<C>,
17941 _course_id: String,
17942 _id: String,
17943 _delegate: Option<&'a mut dyn common::Delegate>,
17944 _additional_params: HashMap<String, String>,
17945 _scopes: BTreeSet<String>,
17946}
17947
17948impl<'a, C> common::CallBuilder for CourseCourseWorkGetCall<'a, C> {}
17949
17950impl<'a, C> CourseCourseWorkGetCall<'a, C>
17951where
17952 C: common::Connector,
17953{
17954 /// Perform the operation you have build so far.
17955 pub async fn doit(mut self) -> common::Result<(common::Response, CourseWork)> {
17956 use std::borrow::Cow;
17957 use std::io::{Read, Seek};
17958
17959 use common::{url::Params, ToParts};
17960 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17961
17962 let mut dd = common::DefaultDelegate;
17963 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17964 dlg.begin(common::MethodInfo {
17965 id: "classroom.courses.courseWork.get",
17966 http_method: hyper::Method::GET,
17967 });
17968
17969 for &field in ["alt", "courseId", "id"].iter() {
17970 if self._additional_params.contains_key(field) {
17971 dlg.finished(false);
17972 return Err(common::Error::FieldClash(field));
17973 }
17974 }
17975
17976 let mut params = Params::with_capacity(4 + self._additional_params.len());
17977 params.push("courseId", self._course_id);
17978 params.push("id", self._id);
17979
17980 params.extend(self._additional_params.iter());
17981
17982 params.push("alt", "json");
17983 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{id}";
17984 if self._scopes.is_empty() {
17985 self._scopes
17986 .insert(Scope::CourseworkMeReadonly.as_ref().to_string());
17987 }
17988
17989 #[allow(clippy::single_element_loop)]
17990 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
17991 url = params.uri_replacement(url, param_name, find_this, false);
17992 }
17993 {
17994 let to_remove = ["id", "courseId"];
17995 params.remove_params(&to_remove);
17996 }
17997
17998 let url = params.parse_with_url(&url);
17999
18000 loop {
18001 let token = match self
18002 .hub
18003 .auth
18004 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18005 .await
18006 {
18007 Ok(token) => token,
18008 Err(e) => match dlg.token(e) {
18009 Ok(token) => token,
18010 Err(e) => {
18011 dlg.finished(false);
18012 return Err(common::Error::MissingToken(e));
18013 }
18014 },
18015 };
18016 let mut req_result = {
18017 let client = &self.hub.client;
18018 dlg.pre_request();
18019 let mut req_builder = hyper::Request::builder()
18020 .method(hyper::Method::GET)
18021 .uri(url.as_str())
18022 .header(USER_AGENT, self.hub._user_agent.clone());
18023
18024 if let Some(token) = token.as_ref() {
18025 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18026 }
18027
18028 let request = req_builder
18029 .header(CONTENT_LENGTH, 0_u64)
18030 .body(common::to_body::<String>(None));
18031
18032 client.request(request.unwrap()).await
18033 };
18034
18035 match req_result {
18036 Err(err) => {
18037 if let common::Retry::After(d) = dlg.http_error(&err) {
18038 sleep(d).await;
18039 continue;
18040 }
18041 dlg.finished(false);
18042 return Err(common::Error::HttpError(err));
18043 }
18044 Ok(res) => {
18045 let (mut parts, body) = res.into_parts();
18046 let mut body = common::Body::new(body);
18047 if !parts.status.is_success() {
18048 let bytes = common::to_bytes(body).await.unwrap_or_default();
18049 let error = serde_json::from_str(&common::to_string(&bytes));
18050 let response = common::to_response(parts, bytes.into());
18051
18052 if let common::Retry::After(d) =
18053 dlg.http_failure(&response, error.as_ref().ok())
18054 {
18055 sleep(d).await;
18056 continue;
18057 }
18058
18059 dlg.finished(false);
18060
18061 return Err(match error {
18062 Ok(value) => common::Error::BadRequest(value),
18063 _ => common::Error::Failure(response),
18064 });
18065 }
18066 let response = {
18067 let bytes = common::to_bytes(body).await.unwrap_or_default();
18068 let encoded = common::to_string(&bytes);
18069 match serde_json::from_str(&encoded) {
18070 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18071 Err(error) => {
18072 dlg.response_json_decode_error(&encoded, &error);
18073 return Err(common::Error::JsonDecodeError(
18074 encoded.to_string(),
18075 error,
18076 ));
18077 }
18078 }
18079 };
18080
18081 dlg.finished(true);
18082 return Ok(response);
18083 }
18084 }
18085 }
18086 }
18087
18088 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
18089 ///
18090 /// Sets the *course id* path property to the given value.
18091 ///
18092 /// Even though the property as already been set when instantiating this call,
18093 /// we provide this method for API completeness.
18094 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkGetCall<'a, C> {
18095 self._course_id = new_value.to_string();
18096 self
18097 }
18098 /// Identifier of the course work.
18099 ///
18100 /// Sets the *id* path property to the given value.
18101 ///
18102 /// Even though the property as already been set when instantiating this call,
18103 /// we provide this method for API completeness.
18104 pub fn id(mut self, new_value: &str) -> CourseCourseWorkGetCall<'a, C> {
18105 self._id = new_value.to_string();
18106 self
18107 }
18108 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18109 /// while executing the actual API request.
18110 ///
18111 /// ````text
18112 /// It should be used to handle progress information, and to implement a certain level of resilience.
18113 /// ````
18114 ///
18115 /// Sets the *delegate* property to the given value.
18116 pub fn delegate(
18117 mut self,
18118 new_value: &'a mut dyn common::Delegate,
18119 ) -> CourseCourseWorkGetCall<'a, C> {
18120 self._delegate = Some(new_value);
18121 self
18122 }
18123
18124 /// Set any additional parameter of the query string used in the request.
18125 /// It should be used to set parameters which are not yet available through their own
18126 /// setters.
18127 ///
18128 /// Please note that this method must not be used to set any of the known parameters
18129 /// which have their own setter method. If done anyway, the request will fail.
18130 ///
18131 /// # Additional Parameters
18132 ///
18133 /// * *$.xgafv* (query-string) - V1 error format.
18134 /// * *access_token* (query-string) - OAuth access token.
18135 /// * *alt* (query-string) - Data format for response.
18136 /// * *callback* (query-string) - JSONP
18137 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18138 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18139 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18140 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18141 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18142 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18143 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18144 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkGetCall<'a, C>
18145 where
18146 T: AsRef<str>,
18147 {
18148 self._additional_params
18149 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18150 self
18151 }
18152
18153 /// Identifies the authorization scope for the method you are building.
18154 ///
18155 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18156 /// [`Scope::CourseworkMeReadonly`].
18157 ///
18158 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18159 /// tokens for more than one scope.
18160 ///
18161 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18162 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18163 /// sufficient, a read-write scope will do as well.
18164 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkGetCall<'a, C>
18165 where
18166 St: AsRef<str>,
18167 {
18168 self._scopes.insert(String::from(scope.as_ref()));
18169 self
18170 }
18171 /// Identifies the authorization scope(s) for the method you are building.
18172 ///
18173 /// See [`Self::add_scope()`] for details.
18174 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkGetCall<'a, C>
18175 where
18176 I: IntoIterator<Item = St>,
18177 St: AsRef<str>,
18178 {
18179 self._scopes
18180 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18181 self
18182 }
18183
18184 /// Removes all scopes, and no default scope will be used either.
18185 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18186 /// for details).
18187 pub fn clear_scopes(mut self) -> CourseCourseWorkGetCall<'a, C> {
18188 self._scopes.clear();
18189 self
18190 }
18191}
18192
18193/// Gets metadata for Classroom add-ons in the context of a specific post. To maintain the integrity of its own data and permissions model, an add-on should call this to validate query parameters and the requesting user's role whenever the add-on is opened in an [iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/iframes-overview). This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
18194///
18195/// A builder for the *courseWork.getAddOnContext* method supported by a *course* resource.
18196/// It is not used directly, but through a [`CourseMethods`] instance.
18197///
18198/// # Example
18199///
18200/// Instantiate a resource method builder
18201///
18202/// ```test_harness,no_run
18203/// # extern crate hyper;
18204/// # extern crate hyper_rustls;
18205/// # extern crate google_classroom1 as classroom1;
18206/// # async fn dox() {
18207/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18208///
18209/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18210/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18211/// # .with_native_roots()
18212/// # .unwrap()
18213/// # .https_only()
18214/// # .enable_http2()
18215/// # .build();
18216///
18217/// # let executor = hyper_util::rt::TokioExecutor::new();
18218/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18219/// # secret,
18220/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18221/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18222/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18223/// # ),
18224/// # ).build().await.unwrap();
18225///
18226/// # let client = hyper_util::client::legacy::Client::builder(
18227/// # hyper_util::rt::TokioExecutor::new()
18228/// # )
18229/// # .build(
18230/// # hyper_rustls::HttpsConnectorBuilder::new()
18231/// # .with_native_roots()
18232/// # .unwrap()
18233/// # .https_or_http()
18234/// # .enable_http2()
18235/// # .build()
18236/// # );
18237/// # let mut hub = Classroom::new(client, auth);
18238/// // You can configure optional parameters by calling the respective setters at will, and
18239/// // execute the final call using `doit()`.
18240/// // Values shown here are possibly random and not representative !
18241/// let result = hub.courses().course_work_get_add_on_context("courseId", "itemId")
18242/// .post_id("aliquyam")
18243/// .attachment_id("elitr")
18244/// .add_on_token("duo")
18245/// .doit().await;
18246/// # }
18247/// ```
18248pub struct CourseCourseWorkGetAddOnContextCall<'a, C>
18249where
18250 C: 'a,
18251{
18252 hub: &'a Classroom<C>,
18253 _course_id: String,
18254 _item_id: String,
18255 _post_id: Option<String>,
18256 _attachment_id: Option<String>,
18257 _add_on_token: Option<String>,
18258 _delegate: Option<&'a mut dyn common::Delegate>,
18259 _additional_params: HashMap<String, String>,
18260 _scopes: BTreeSet<String>,
18261}
18262
18263impl<'a, C> common::CallBuilder for CourseCourseWorkGetAddOnContextCall<'a, C> {}
18264
18265impl<'a, C> CourseCourseWorkGetAddOnContextCall<'a, C>
18266where
18267 C: common::Connector,
18268{
18269 /// Perform the operation you have build so far.
18270 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnContext)> {
18271 use std::borrow::Cow;
18272 use std::io::{Read, Seek};
18273
18274 use common::{url::Params, ToParts};
18275 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18276
18277 let mut dd = common::DefaultDelegate;
18278 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18279 dlg.begin(common::MethodInfo {
18280 id: "classroom.courses.courseWork.getAddOnContext",
18281 http_method: hyper::Method::GET,
18282 });
18283
18284 for &field in [
18285 "alt",
18286 "courseId",
18287 "itemId",
18288 "postId",
18289 "attachmentId",
18290 "addOnToken",
18291 ]
18292 .iter()
18293 {
18294 if self._additional_params.contains_key(field) {
18295 dlg.finished(false);
18296 return Err(common::Error::FieldClash(field));
18297 }
18298 }
18299
18300 let mut params = Params::with_capacity(7 + self._additional_params.len());
18301 params.push("courseId", self._course_id);
18302 params.push("itemId", self._item_id);
18303 if let Some(value) = self._post_id.as_ref() {
18304 params.push("postId", value);
18305 }
18306 if let Some(value) = self._attachment_id.as_ref() {
18307 params.push("attachmentId", value);
18308 }
18309 if let Some(value) = self._add_on_token.as_ref() {
18310 params.push("addOnToken", value);
18311 }
18312
18313 params.extend(self._additional_params.iter());
18314
18315 params.push("alt", "json");
18316 let mut url =
18317 self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{itemId}/addOnContext";
18318 if self._scopes.is_empty() {
18319 self._scopes
18320 .insert(Scope::AddonStudent.as_ref().to_string());
18321 }
18322
18323 #[allow(clippy::single_element_loop)]
18324 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{itemId}", "itemId")].iter()
18325 {
18326 url = params.uri_replacement(url, param_name, find_this, false);
18327 }
18328 {
18329 let to_remove = ["itemId", "courseId"];
18330 params.remove_params(&to_remove);
18331 }
18332
18333 let url = params.parse_with_url(&url);
18334
18335 loop {
18336 let token = match self
18337 .hub
18338 .auth
18339 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18340 .await
18341 {
18342 Ok(token) => token,
18343 Err(e) => match dlg.token(e) {
18344 Ok(token) => token,
18345 Err(e) => {
18346 dlg.finished(false);
18347 return Err(common::Error::MissingToken(e));
18348 }
18349 },
18350 };
18351 let mut req_result = {
18352 let client = &self.hub.client;
18353 dlg.pre_request();
18354 let mut req_builder = hyper::Request::builder()
18355 .method(hyper::Method::GET)
18356 .uri(url.as_str())
18357 .header(USER_AGENT, self.hub._user_agent.clone());
18358
18359 if let Some(token) = token.as_ref() {
18360 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18361 }
18362
18363 let request = req_builder
18364 .header(CONTENT_LENGTH, 0_u64)
18365 .body(common::to_body::<String>(None));
18366
18367 client.request(request.unwrap()).await
18368 };
18369
18370 match req_result {
18371 Err(err) => {
18372 if let common::Retry::After(d) = dlg.http_error(&err) {
18373 sleep(d).await;
18374 continue;
18375 }
18376 dlg.finished(false);
18377 return Err(common::Error::HttpError(err));
18378 }
18379 Ok(res) => {
18380 let (mut parts, body) = res.into_parts();
18381 let mut body = common::Body::new(body);
18382 if !parts.status.is_success() {
18383 let bytes = common::to_bytes(body).await.unwrap_or_default();
18384 let error = serde_json::from_str(&common::to_string(&bytes));
18385 let response = common::to_response(parts, bytes.into());
18386
18387 if let common::Retry::After(d) =
18388 dlg.http_failure(&response, error.as_ref().ok())
18389 {
18390 sleep(d).await;
18391 continue;
18392 }
18393
18394 dlg.finished(false);
18395
18396 return Err(match error {
18397 Ok(value) => common::Error::BadRequest(value),
18398 _ => common::Error::Failure(response),
18399 });
18400 }
18401 let response = {
18402 let bytes = common::to_bytes(body).await.unwrap_or_default();
18403 let encoded = common::to_string(&bytes);
18404 match serde_json::from_str(&encoded) {
18405 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18406 Err(error) => {
18407 dlg.response_json_decode_error(&encoded, &error);
18408 return Err(common::Error::JsonDecodeError(
18409 encoded.to_string(),
18410 error,
18411 ));
18412 }
18413 }
18414 };
18415
18416 dlg.finished(true);
18417 return Ok(response);
18418 }
18419 }
18420 }
18421 }
18422
18423 /// Required. Identifier of the course.
18424 ///
18425 /// Sets the *course id* path property to the given value.
18426 ///
18427 /// Even though the property as already been set when instantiating this call,
18428 /// we provide this method for API completeness.
18429 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkGetAddOnContextCall<'a, C> {
18430 self._course_id = new_value.to_string();
18431 self
18432 }
18433 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
18434 ///
18435 /// Sets the *item id* path property to the given value.
18436 ///
18437 /// Even though the property as already been set when instantiating this call,
18438 /// we provide this method for API completeness.
18439 pub fn item_id(mut self, new_value: &str) -> CourseCourseWorkGetAddOnContextCall<'a, C> {
18440 self._item_id = new_value.to_string();
18441 self
18442 }
18443 /// Optional. Deprecated, use `item_id` instead.
18444 ///
18445 /// Sets the *post id* query property to the given value.
18446 pub fn post_id(mut self, new_value: &str) -> CourseCourseWorkGetAddOnContextCall<'a, C> {
18447 self._post_id = Some(new_value.to_string());
18448 self
18449 }
18450 /// Optional. The identifier of the attachment. This field is required for all requests except when the user is in the [Attachment Discovery iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/attachment-discovery-iframe).
18451 ///
18452 /// Sets the *attachment id* query property to the given value.
18453 pub fn attachment_id(mut self, new_value: &str) -> CourseCourseWorkGetAddOnContextCall<'a, C> {
18454 self._attachment_id = Some(new_value.to_string());
18455 self
18456 }
18457 /// Optional. Token that authorizes the request. The token is passed as a query parameter when the user is redirected from Classroom to the add-on's URL. The authorization token is required when neither of the following is true: * The add-on has attachments on the post. * The developer project issuing the request is the same project that created the post.
18458 ///
18459 /// Sets the *add on token* query property to the given value.
18460 pub fn add_on_token(mut self, new_value: &str) -> CourseCourseWorkGetAddOnContextCall<'a, C> {
18461 self._add_on_token = Some(new_value.to_string());
18462 self
18463 }
18464 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18465 /// while executing the actual API request.
18466 ///
18467 /// ````text
18468 /// It should be used to handle progress information, and to implement a certain level of resilience.
18469 /// ````
18470 ///
18471 /// Sets the *delegate* property to the given value.
18472 pub fn delegate(
18473 mut self,
18474 new_value: &'a mut dyn common::Delegate,
18475 ) -> CourseCourseWorkGetAddOnContextCall<'a, C> {
18476 self._delegate = Some(new_value);
18477 self
18478 }
18479
18480 /// Set any additional parameter of the query string used in the request.
18481 /// It should be used to set parameters which are not yet available through their own
18482 /// setters.
18483 ///
18484 /// Please note that this method must not be used to set any of the known parameters
18485 /// which have their own setter method. If done anyway, the request will fail.
18486 ///
18487 /// # Additional Parameters
18488 ///
18489 /// * *$.xgafv* (query-string) - V1 error format.
18490 /// * *access_token* (query-string) - OAuth access token.
18491 /// * *alt* (query-string) - Data format for response.
18492 /// * *callback* (query-string) - JSONP
18493 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18494 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18495 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18496 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18497 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18498 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18499 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18500 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkGetAddOnContextCall<'a, C>
18501 where
18502 T: AsRef<str>,
18503 {
18504 self._additional_params
18505 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18506 self
18507 }
18508
18509 /// Identifies the authorization scope for the method you are building.
18510 ///
18511 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18512 /// [`Scope::AddonStudent`].
18513 ///
18514 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18515 /// tokens for more than one scope.
18516 ///
18517 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18518 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18519 /// sufficient, a read-write scope will do as well.
18520 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkGetAddOnContextCall<'a, C>
18521 where
18522 St: AsRef<str>,
18523 {
18524 self._scopes.insert(String::from(scope.as_ref()));
18525 self
18526 }
18527 /// Identifies the authorization scope(s) for the method you are building.
18528 ///
18529 /// See [`Self::add_scope()`] for details.
18530 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkGetAddOnContextCall<'a, C>
18531 where
18532 I: IntoIterator<Item = St>,
18533 St: AsRef<str>,
18534 {
18535 self._scopes
18536 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18537 self
18538 }
18539
18540 /// Removes all scopes, and no default scope will be used either.
18541 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18542 /// for details).
18543 pub fn clear_scopes(mut self) -> CourseCourseWorkGetAddOnContextCall<'a, C> {
18544 self._scopes.clear();
18545 self
18546 }
18547}
18548
18549/// Returns a list of course work that the requester is permitted to view. Course students may only view `PUBLISHED` course work. Course teachers and domain administrators may view all course work. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
18550///
18551/// A builder for the *courseWork.list* method supported by a *course* resource.
18552/// It is not used directly, but through a [`CourseMethods`] instance.
18553///
18554/// # Example
18555///
18556/// Instantiate a resource method builder
18557///
18558/// ```test_harness,no_run
18559/// # extern crate hyper;
18560/// # extern crate hyper_rustls;
18561/// # extern crate google_classroom1 as classroom1;
18562/// # async fn dox() {
18563/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18564///
18565/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18566/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18567/// # .with_native_roots()
18568/// # .unwrap()
18569/// # .https_only()
18570/// # .enable_http2()
18571/// # .build();
18572///
18573/// # let executor = hyper_util::rt::TokioExecutor::new();
18574/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18575/// # secret,
18576/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18577/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18578/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18579/// # ),
18580/// # ).build().await.unwrap();
18581///
18582/// # let client = hyper_util::client::legacy::Client::builder(
18583/// # hyper_util::rt::TokioExecutor::new()
18584/// # )
18585/// # .build(
18586/// # hyper_rustls::HttpsConnectorBuilder::new()
18587/// # .with_native_roots()
18588/// # .unwrap()
18589/// # .https_or_http()
18590/// # .enable_http2()
18591/// # .build()
18592/// # );
18593/// # let mut hub = Classroom::new(client, auth);
18594/// // You can configure optional parameters by calling the respective setters at will, and
18595/// // execute the final call using `doit()`.
18596/// // Values shown here are possibly random and not representative !
18597/// let result = hub.courses().course_work_list("courseId")
18598/// .page_token("est")
18599/// .page_size(-53)
18600/// .order_by("sed")
18601/// .add_course_work_states("eos")
18602/// .doit().await;
18603/// # }
18604/// ```
18605pub struct CourseCourseWorkListCall<'a, C>
18606where
18607 C: 'a,
18608{
18609 hub: &'a Classroom<C>,
18610 _course_id: String,
18611 _page_token: Option<String>,
18612 _page_size: Option<i32>,
18613 _order_by: Option<String>,
18614 _course_work_states: Vec<String>,
18615 _delegate: Option<&'a mut dyn common::Delegate>,
18616 _additional_params: HashMap<String, String>,
18617 _scopes: BTreeSet<String>,
18618}
18619
18620impl<'a, C> common::CallBuilder for CourseCourseWorkListCall<'a, C> {}
18621
18622impl<'a, C> CourseCourseWorkListCall<'a, C>
18623where
18624 C: common::Connector,
18625{
18626 /// Perform the operation you have build so far.
18627 pub async fn doit(mut self) -> common::Result<(common::Response, ListCourseWorkResponse)> {
18628 use std::borrow::Cow;
18629 use std::io::{Read, Seek};
18630
18631 use common::{url::Params, ToParts};
18632 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18633
18634 let mut dd = common::DefaultDelegate;
18635 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18636 dlg.begin(common::MethodInfo {
18637 id: "classroom.courses.courseWork.list",
18638 http_method: hyper::Method::GET,
18639 });
18640
18641 for &field in [
18642 "alt",
18643 "courseId",
18644 "pageToken",
18645 "pageSize",
18646 "orderBy",
18647 "courseWorkStates",
18648 ]
18649 .iter()
18650 {
18651 if self._additional_params.contains_key(field) {
18652 dlg.finished(false);
18653 return Err(common::Error::FieldClash(field));
18654 }
18655 }
18656
18657 let mut params = Params::with_capacity(7 + self._additional_params.len());
18658 params.push("courseId", self._course_id);
18659 if let Some(value) = self._page_token.as_ref() {
18660 params.push("pageToken", value);
18661 }
18662 if let Some(value) = self._page_size.as_ref() {
18663 params.push("pageSize", value.to_string());
18664 }
18665 if let Some(value) = self._order_by.as_ref() {
18666 params.push("orderBy", value);
18667 }
18668 if !self._course_work_states.is_empty() {
18669 for f in self._course_work_states.iter() {
18670 params.push("courseWorkStates", f);
18671 }
18672 }
18673
18674 params.extend(self._additional_params.iter());
18675
18676 params.push("alt", "json");
18677 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork";
18678 if self._scopes.is_empty() {
18679 self._scopes
18680 .insert(Scope::CourseworkMeReadonly.as_ref().to_string());
18681 }
18682
18683 #[allow(clippy::single_element_loop)]
18684 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
18685 url = params.uri_replacement(url, param_name, find_this, false);
18686 }
18687 {
18688 let to_remove = ["courseId"];
18689 params.remove_params(&to_remove);
18690 }
18691
18692 let url = params.parse_with_url(&url);
18693
18694 loop {
18695 let token = match self
18696 .hub
18697 .auth
18698 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18699 .await
18700 {
18701 Ok(token) => token,
18702 Err(e) => match dlg.token(e) {
18703 Ok(token) => token,
18704 Err(e) => {
18705 dlg.finished(false);
18706 return Err(common::Error::MissingToken(e));
18707 }
18708 },
18709 };
18710 let mut req_result = {
18711 let client = &self.hub.client;
18712 dlg.pre_request();
18713 let mut req_builder = hyper::Request::builder()
18714 .method(hyper::Method::GET)
18715 .uri(url.as_str())
18716 .header(USER_AGENT, self.hub._user_agent.clone());
18717
18718 if let Some(token) = token.as_ref() {
18719 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18720 }
18721
18722 let request = req_builder
18723 .header(CONTENT_LENGTH, 0_u64)
18724 .body(common::to_body::<String>(None));
18725
18726 client.request(request.unwrap()).await
18727 };
18728
18729 match req_result {
18730 Err(err) => {
18731 if let common::Retry::After(d) = dlg.http_error(&err) {
18732 sleep(d).await;
18733 continue;
18734 }
18735 dlg.finished(false);
18736 return Err(common::Error::HttpError(err));
18737 }
18738 Ok(res) => {
18739 let (mut parts, body) = res.into_parts();
18740 let mut body = common::Body::new(body);
18741 if !parts.status.is_success() {
18742 let bytes = common::to_bytes(body).await.unwrap_or_default();
18743 let error = serde_json::from_str(&common::to_string(&bytes));
18744 let response = common::to_response(parts, bytes.into());
18745
18746 if let common::Retry::After(d) =
18747 dlg.http_failure(&response, error.as_ref().ok())
18748 {
18749 sleep(d).await;
18750 continue;
18751 }
18752
18753 dlg.finished(false);
18754
18755 return Err(match error {
18756 Ok(value) => common::Error::BadRequest(value),
18757 _ => common::Error::Failure(response),
18758 });
18759 }
18760 let response = {
18761 let bytes = common::to_bytes(body).await.unwrap_or_default();
18762 let encoded = common::to_string(&bytes);
18763 match serde_json::from_str(&encoded) {
18764 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18765 Err(error) => {
18766 dlg.response_json_decode_error(&encoded, &error);
18767 return Err(common::Error::JsonDecodeError(
18768 encoded.to_string(),
18769 error,
18770 ));
18771 }
18772 }
18773 };
18774
18775 dlg.finished(true);
18776 return Ok(response);
18777 }
18778 }
18779 }
18780 }
18781
18782 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
18783 ///
18784 /// Sets the *course id* path property to the given value.
18785 ///
18786 /// Even though the property as already been set when instantiating this call,
18787 /// we provide this method for API completeness.
18788 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkListCall<'a, C> {
18789 self._course_id = new_value.to_string();
18790 self
18791 }
18792 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
18793 ///
18794 /// Sets the *page token* query property to the given value.
18795 pub fn page_token(mut self, new_value: &str) -> CourseCourseWorkListCall<'a, C> {
18796 self._page_token = Some(new_value.to_string());
18797 self
18798 }
18799 /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.
18800 ///
18801 /// Sets the *page size* query property to the given value.
18802 pub fn page_size(mut self, new_value: i32) -> CourseCourseWorkListCall<'a, C> {
18803 self._page_size = Some(new_value);
18804 self
18805 }
18806 /// Optional sort ordering for results. A comma-separated list of fields with an optional sort direction keyword. Supported fields are `updateTime` and `dueDate`. Supported direction keywords are `asc` and `desc`. If not specified, `updateTime desc` is the default behavior. Examples: `dueDate asc,updateTime desc`, `updateTime,dueDate desc`
18807 ///
18808 /// Sets the *order by* query property to the given value.
18809 pub fn order_by(mut self, new_value: &str) -> CourseCourseWorkListCall<'a, C> {
18810 self._order_by = Some(new_value.to_string());
18811 self
18812 }
18813 /// Restriction on the work status to return. Only courseWork that matches is returned. If unspecified, items with a work status of `PUBLISHED` is returned.
18814 ///
18815 /// Append the given value to the *course work states* query property.
18816 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
18817 pub fn add_course_work_states(mut self, new_value: &str) -> CourseCourseWorkListCall<'a, C> {
18818 self._course_work_states.push(new_value.to_string());
18819 self
18820 }
18821 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18822 /// while executing the actual API request.
18823 ///
18824 /// ````text
18825 /// It should be used to handle progress information, and to implement a certain level of resilience.
18826 /// ````
18827 ///
18828 /// Sets the *delegate* property to the given value.
18829 pub fn delegate(
18830 mut self,
18831 new_value: &'a mut dyn common::Delegate,
18832 ) -> CourseCourseWorkListCall<'a, C> {
18833 self._delegate = Some(new_value);
18834 self
18835 }
18836
18837 /// Set any additional parameter of the query string used in the request.
18838 /// It should be used to set parameters which are not yet available through their own
18839 /// setters.
18840 ///
18841 /// Please note that this method must not be used to set any of the known parameters
18842 /// which have their own setter method. If done anyway, the request will fail.
18843 ///
18844 /// # Additional Parameters
18845 ///
18846 /// * *$.xgafv* (query-string) - V1 error format.
18847 /// * *access_token* (query-string) - OAuth access token.
18848 /// * *alt* (query-string) - Data format for response.
18849 /// * *callback* (query-string) - JSONP
18850 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18851 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18852 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18853 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18854 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
18855 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18856 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18857 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkListCall<'a, C>
18858 where
18859 T: AsRef<str>,
18860 {
18861 self._additional_params
18862 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18863 self
18864 }
18865
18866 /// Identifies the authorization scope for the method you are building.
18867 ///
18868 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18869 /// [`Scope::CourseworkMeReadonly`].
18870 ///
18871 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18872 /// tokens for more than one scope.
18873 ///
18874 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18875 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18876 /// sufficient, a read-write scope will do as well.
18877 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkListCall<'a, C>
18878 where
18879 St: AsRef<str>,
18880 {
18881 self._scopes.insert(String::from(scope.as_ref()));
18882 self
18883 }
18884 /// Identifies the authorization scope(s) for the method you are building.
18885 ///
18886 /// See [`Self::add_scope()`] for details.
18887 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkListCall<'a, C>
18888 where
18889 I: IntoIterator<Item = St>,
18890 St: AsRef<str>,
18891 {
18892 self._scopes
18893 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18894 self
18895 }
18896
18897 /// Removes all scopes, and no default scope will be used either.
18898 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18899 /// for details).
18900 pub fn clear_scopes(mut self) -> CourseCourseWorkListCall<'a, C> {
18901 self._scopes.clear();
18902 self
18903 }
18904}
18905
18906/// Modifies assignee mode and options of a coursework. Only a teacher of the course that contains the coursework may call this method. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work does not exist. * `FAILED_PRECONDITION` for the following request error: * EmptyAssignees
18907///
18908/// A builder for the *courseWork.modifyAssignees* method supported by a *course* resource.
18909/// It is not used directly, but through a [`CourseMethods`] instance.
18910///
18911/// # Example
18912///
18913/// Instantiate a resource method builder
18914///
18915/// ```test_harness,no_run
18916/// # extern crate hyper;
18917/// # extern crate hyper_rustls;
18918/// # extern crate google_classroom1 as classroom1;
18919/// use classroom1::api::ModifyCourseWorkAssigneesRequest;
18920/// # async fn dox() {
18921/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18922///
18923/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18924/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18925/// # .with_native_roots()
18926/// # .unwrap()
18927/// # .https_only()
18928/// # .enable_http2()
18929/// # .build();
18930///
18931/// # let executor = hyper_util::rt::TokioExecutor::new();
18932/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18933/// # secret,
18934/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18935/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18936/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18937/// # ),
18938/// # ).build().await.unwrap();
18939///
18940/// # let client = hyper_util::client::legacy::Client::builder(
18941/// # hyper_util::rt::TokioExecutor::new()
18942/// # )
18943/// # .build(
18944/// # hyper_rustls::HttpsConnectorBuilder::new()
18945/// # .with_native_roots()
18946/// # .unwrap()
18947/// # .https_or_http()
18948/// # .enable_http2()
18949/// # .build()
18950/// # );
18951/// # let mut hub = Classroom::new(client, auth);
18952/// // As the method needs a request, you would usually fill it with the desired information
18953/// // into the respective structure. Some of the parts shown here might not be applicable !
18954/// // Values shown here are possibly random and not representative !
18955/// let mut req = ModifyCourseWorkAssigneesRequest::default();
18956///
18957/// // You can configure optional parameters by calling the respective setters at will, and
18958/// // execute the final call using `doit()`.
18959/// // Values shown here are possibly random and not representative !
18960/// let result = hub.courses().course_work_modify_assignees(req, "courseId", "id")
18961/// .doit().await;
18962/// # }
18963/// ```
18964pub struct CourseCourseWorkModifyAssigneeCall<'a, C>
18965where
18966 C: 'a,
18967{
18968 hub: &'a Classroom<C>,
18969 _request: ModifyCourseWorkAssigneesRequest,
18970 _course_id: String,
18971 _id: String,
18972 _delegate: Option<&'a mut dyn common::Delegate>,
18973 _additional_params: HashMap<String, String>,
18974 _scopes: BTreeSet<String>,
18975}
18976
18977impl<'a, C> common::CallBuilder for CourseCourseWorkModifyAssigneeCall<'a, C> {}
18978
18979impl<'a, C> CourseCourseWorkModifyAssigneeCall<'a, C>
18980where
18981 C: common::Connector,
18982{
18983 /// Perform the operation you have build so far.
18984 pub async fn doit(mut self) -> common::Result<(common::Response, CourseWork)> {
18985 use std::borrow::Cow;
18986 use std::io::{Read, Seek};
18987
18988 use common::{url::Params, ToParts};
18989 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18990
18991 let mut dd = common::DefaultDelegate;
18992 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18993 dlg.begin(common::MethodInfo {
18994 id: "classroom.courses.courseWork.modifyAssignees",
18995 http_method: hyper::Method::POST,
18996 });
18997
18998 for &field in ["alt", "courseId", "id"].iter() {
18999 if self._additional_params.contains_key(field) {
19000 dlg.finished(false);
19001 return Err(common::Error::FieldClash(field));
19002 }
19003 }
19004
19005 let mut params = Params::with_capacity(5 + self._additional_params.len());
19006 params.push("courseId", self._course_id);
19007 params.push("id", self._id);
19008
19009 params.extend(self._additional_params.iter());
19010
19011 params.push("alt", "json");
19012 let mut url =
19013 self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{id}:modifyAssignees";
19014 if self._scopes.is_empty() {
19015 self._scopes
19016 .insert(Scope::CourseworkStudent.as_ref().to_string());
19017 }
19018
19019 #[allow(clippy::single_element_loop)]
19020 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
19021 url = params.uri_replacement(url, param_name, find_this, false);
19022 }
19023 {
19024 let to_remove = ["id", "courseId"];
19025 params.remove_params(&to_remove);
19026 }
19027
19028 let url = params.parse_with_url(&url);
19029
19030 let mut json_mime_type = mime::APPLICATION_JSON;
19031 let mut request_value_reader = {
19032 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19033 common::remove_json_null_values(&mut value);
19034 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19035 serde_json::to_writer(&mut dst, &value).unwrap();
19036 dst
19037 };
19038 let request_size = request_value_reader
19039 .seek(std::io::SeekFrom::End(0))
19040 .unwrap();
19041 request_value_reader
19042 .seek(std::io::SeekFrom::Start(0))
19043 .unwrap();
19044
19045 loop {
19046 let token = match self
19047 .hub
19048 .auth
19049 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19050 .await
19051 {
19052 Ok(token) => token,
19053 Err(e) => match dlg.token(e) {
19054 Ok(token) => token,
19055 Err(e) => {
19056 dlg.finished(false);
19057 return Err(common::Error::MissingToken(e));
19058 }
19059 },
19060 };
19061 request_value_reader
19062 .seek(std::io::SeekFrom::Start(0))
19063 .unwrap();
19064 let mut req_result = {
19065 let client = &self.hub.client;
19066 dlg.pre_request();
19067 let mut req_builder = hyper::Request::builder()
19068 .method(hyper::Method::POST)
19069 .uri(url.as_str())
19070 .header(USER_AGENT, self.hub._user_agent.clone());
19071
19072 if let Some(token) = token.as_ref() {
19073 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19074 }
19075
19076 let request = req_builder
19077 .header(CONTENT_TYPE, json_mime_type.to_string())
19078 .header(CONTENT_LENGTH, request_size as u64)
19079 .body(common::to_body(
19080 request_value_reader.get_ref().clone().into(),
19081 ));
19082
19083 client.request(request.unwrap()).await
19084 };
19085
19086 match req_result {
19087 Err(err) => {
19088 if let common::Retry::After(d) = dlg.http_error(&err) {
19089 sleep(d).await;
19090 continue;
19091 }
19092 dlg.finished(false);
19093 return Err(common::Error::HttpError(err));
19094 }
19095 Ok(res) => {
19096 let (mut parts, body) = res.into_parts();
19097 let mut body = common::Body::new(body);
19098 if !parts.status.is_success() {
19099 let bytes = common::to_bytes(body).await.unwrap_or_default();
19100 let error = serde_json::from_str(&common::to_string(&bytes));
19101 let response = common::to_response(parts, bytes.into());
19102
19103 if let common::Retry::After(d) =
19104 dlg.http_failure(&response, error.as_ref().ok())
19105 {
19106 sleep(d).await;
19107 continue;
19108 }
19109
19110 dlg.finished(false);
19111
19112 return Err(match error {
19113 Ok(value) => common::Error::BadRequest(value),
19114 _ => common::Error::Failure(response),
19115 });
19116 }
19117 let response = {
19118 let bytes = common::to_bytes(body).await.unwrap_or_default();
19119 let encoded = common::to_string(&bytes);
19120 match serde_json::from_str(&encoded) {
19121 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19122 Err(error) => {
19123 dlg.response_json_decode_error(&encoded, &error);
19124 return Err(common::Error::JsonDecodeError(
19125 encoded.to_string(),
19126 error,
19127 ));
19128 }
19129 }
19130 };
19131
19132 dlg.finished(true);
19133 return Ok(response);
19134 }
19135 }
19136 }
19137 }
19138
19139 ///
19140 /// Sets the *request* property to the given value.
19141 ///
19142 /// Even though the property as already been set when instantiating this call,
19143 /// we provide this method for API completeness.
19144 pub fn request(
19145 mut self,
19146 new_value: ModifyCourseWorkAssigneesRequest,
19147 ) -> CourseCourseWorkModifyAssigneeCall<'a, C> {
19148 self._request = new_value;
19149 self
19150 }
19151 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
19152 ///
19153 /// Sets the *course id* path property to the given value.
19154 ///
19155 /// Even though the property as already been set when instantiating this call,
19156 /// we provide this method for API completeness.
19157 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkModifyAssigneeCall<'a, C> {
19158 self._course_id = new_value.to_string();
19159 self
19160 }
19161 /// Identifier of the coursework.
19162 ///
19163 /// Sets the *id* path property to the given value.
19164 ///
19165 /// Even though the property as already been set when instantiating this call,
19166 /// we provide this method for API completeness.
19167 pub fn id(mut self, new_value: &str) -> CourseCourseWorkModifyAssigneeCall<'a, C> {
19168 self._id = new_value.to_string();
19169 self
19170 }
19171 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19172 /// while executing the actual API request.
19173 ///
19174 /// ````text
19175 /// It should be used to handle progress information, and to implement a certain level of resilience.
19176 /// ````
19177 ///
19178 /// Sets the *delegate* property to the given value.
19179 pub fn delegate(
19180 mut self,
19181 new_value: &'a mut dyn common::Delegate,
19182 ) -> CourseCourseWorkModifyAssigneeCall<'a, C> {
19183 self._delegate = Some(new_value);
19184 self
19185 }
19186
19187 /// Set any additional parameter of the query string used in the request.
19188 /// It should be used to set parameters which are not yet available through their own
19189 /// setters.
19190 ///
19191 /// Please note that this method must not be used to set any of the known parameters
19192 /// which have their own setter method. If done anyway, the request will fail.
19193 ///
19194 /// # Additional Parameters
19195 ///
19196 /// * *$.xgafv* (query-string) - V1 error format.
19197 /// * *access_token* (query-string) - OAuth access token.
19198 /// * *alt* (query-string) - Data format for response.
19199 /// * *callback* (query-string) - JSONP
19200 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19201 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19202 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19203 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19204 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19205 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19206 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19207 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkModifyAssigneeCall<'a, C>
19208 where
19209 T: AsRef<str>,
19210 {
19211 self._additional_params
19212 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19213 self
19214 }
19215
19216 /// Identifies the authorization scope for the method you are building.
19217 ///
19218 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19219 /// [`Scope::CourseworkStudent`].
19220 ///
19221 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19222 /// tokens for more than one scope.
19223 ///
19224 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19225 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19226 /// sufficient, a read-write scope will do as well.
19227 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkModifyAssigneeCall<'a, C>
19228 where
19229 St: AsRef<str>,
19230 {
19231 self._scopes.insert(String::from(scope.as_ref()));
19232 self
19233 }
19234 /// Identifies the authorization scope(s) for the method you are building.
19235 ///
19236 /// See [`Self::add_scope()`] for details.
19237 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkModifyAssigneeCall<'a, C>
19238 where
19239 I: IntoIterator<Item = St>,
19240 St: AsRef<str>,
19241 {
19242 self._scopes
19243 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19244 self
19245 }
19246
19247 /// Removes all scopes, and no default scope will be used either.
19248 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19249 /// for details).
19250 pub fn clear_scopes(mut self) -> CourseCourseWorkModifyAssigneeCall<'a, C> {
19251 self._scopes.clear();
19252 self
19253 }
19254}
19255
19256/// Updates one or more fields of a course work. See google.classroom.v1.CourseWork for details of which fields may be updated and who may change them. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work, if the user is not permitted to make the requested modification to the student submission, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if the requested course work has already been deleted. * `NOT_FOUND` if the requested course or course work does not exist.
19257///
19258/// A builder for the *courseWork.patch* method supported by a *course* resource.
19259/// It is not used directly, but through a [`CourseMethods`] instance.
19260///
19261/// # Example
19262///
19263/// Instantiate a resource method builder
19264///
19265/// ```test_harness,no_run
19266/// # extern crate hyper;
19267/// # extern crate hyper_rustls;
19268/// # extern crate google_classroom1 as classroom1;
19269/// use classroom1::api::CourseWork;
19270/// # async fn dox() {
19271/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19272///
19273/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19274/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19275/// # .with_native_roots()
19276/// # .unwrap()
19277/// # .https_only()
19278/// # .enable_http2()
19279/// # .build();
19280///
19281/// # let executor = hyper_util::rt::TokioExecutor::new();
19282/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19283/// # secret,
19284/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19285/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19286/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19287/// # ),
19288/// # ).build().await.unwrap();
19289///
19290/// # let client = hyper_util::client::legacy::Client::builder(
19291/// # hyper_util::rt::TokioExecutor::new()
19292/// # )
19293/// # .build(
19294/// # hyper_rustls::HttpsConnectorBuilder::new()
19295/// # .with_native_roots()
19296/// # .unwrap()
19297/// # .https_or_http()
19298/// # .enable_http2()
19299/// # .build()
19300/// # );
19301/// # let mut hub = Classroom::new(client, auth);
19302/// // As the method needs a request, you would usually fill it with the desired information
19303/// // into the respective structure. Some of the parts shown here might not be applicable !
19304/// // Values shown here are possibly random and not representative !
19305/// let mut req = CourseWork::default();
19306///
19307/// // You can configure optional parameters by calling the respective setters at will, and
19308/// // execute the final call using `doit()`.
19309/// // Values shown here are possibly random and not representative !
19310/// let result = hub.courses().course_work_patch(req, "courseId", "id")
19311/// .update_mask(FieldMask::new::<&str>(&[]))
19312/// .doit().await;
19313/// # }
19314/// ```
19315pub struct CourseCourseWorkPatchCall<'a, C>
19316where
19317 C: 'a,
19318{
19319 hub: &'a Classroom<C>,
19320 _request: CourseWork,
19321 _course_id: String,
19322 _id: String,
19323 _update_mask: Option<common::FieldMask>,
19324 _delegate: Option<&'a mut dyn common::Delegate>,
19325 _additional_params: HashMap<String, String>,
19326 _scopes: BTreeSet<String>,
19327}
19328
19329impl<'a, C> common::CallBuilder for CourseCourseWorkPatchCall<'a, C> {}
19330
19331impl<'a, C> CourseCourseWorkPatchCall<'a, C>
19332where
19333 C: common::Connector,
19334{
19335 /// Perform the operation you have build so far.
19336 pub async fn doit(mut self) -> common::Result<(common::Response, CourseWork)> {
19337 use std::borrow::Cow;
19338 use std::io::{Read, Seek};
19339
19340 use common::{url::Params, ToParts};
19341 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19342
19343 let mut dd = common::DefaultDelegate;
19344 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19345 dlg.begin(common::MethodInfo {
19346 id: "classroom.courses.courseWork.patch",
19347 http_method: hyper::Method::PATCH,
19348 });
19349
19350 for &field in ["alt", "courseId", "id", "updateMask"].iter() {
19351 if self._additional_params.contains_key(field) {
19352 dlg.finished(false);
19353 return Err(common::Error::FieldClash(field));
19354 }
19355 }
19356
19357 let mut params = Params::with_capacity(6 + self._additional_params.len());
19358 params.push("courseId", self._course_id);
19359 params.push("id", self._id);
19360 if let Some(value) = self._update_mask.as_ref() {
19361 params.push("updateMask", value.to_string());
19362 }
19363
19364 params.extend(self._additional_params.iter());
19365
19366 params.push("alt", "json");
19367 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{id}";
19368 if self._scopes.is_empty() {
19369 self._scopes
19370 .insert(Scope::CourseworkStudent.as_ref().to_string());
19371 }
19372
19373 #[allow(clippy::single_element_loop)]
19374 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
19375 url = params.uri_replacement(url, param_name, find_this, false);
19376 }
19377 {
19378 let to_remove = ["id", "courseId"];
19379 params.remove_params(&to_remove);
19380 }
19381
19382 let url = params.parse_with_url(&url);
19383
19384 let mut json_mime_type = mime::APPLICATION_JSON;
19385 let mut request_value_reader = {
19386 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19387 common::remove_json_null_values(&mut value);
19388 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19389 serde_json::to_writer(&mut dst, &value).unwrap();
19390 dst
19391 };
19392 let request_size = request_value_reader
19393 .seek(std::io::SeekFrom::End(0))
19394 .unwrap();
19395 request_value_reader
19396 .seek(std::io::SeekFrom::Start(0))
19397 .unwrap();
19398
19399 loop {
19400 let token = match self
19401 .hub
19402 .auth
19403 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19404 .await
19405 {
19406 Ok(token) => token,
19407 Err(e) => match dlg.token(e) {
19408 Ok(token) => token,
19409 Err(e) => {
19410 dlg.finished(false);
19411 return Err(common::Error::MissingToken(e));
19412 }
19413 },
19414 };
19415 request_value_reader
19416 .seek(std::io::SeekFrom::Start(0))
19417 .unwrap();
19418 let mut req_result = {
19419 let client = &self.hub.client;
19420 dlg.pre_request();
19421 let mut req_builder = hyper::Request::builder()
19422 .method(hyper::Method::PATCH)
19423 .uri(url.as_str())
19424 .header(USER_AGENT, self.hub._user_agent.clone());
19425
19426 if let Some(token) = token.as_ref() {
19427 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19428 }
19429
19430 let request = req_builder
19431 .header(CONTENT_TYPE, json_mime_type.to_string())
19432 .header(CONTENT_LENGTH, request_size as u64)
19433 .body(common::to_body(
19434 request_value_reader.get_ref().clone().into(),
19435 ));
19436
19437 client.request(request.unwrap()).await
19438 };
19439
19440 match req_result {
19441 Err(err) => {
19442 if let common::Retry::After(d) = dlg.http_error(&err) {
19443 sleep(d).await;
19444 continue;
19445 }
19446 dlg.finished(false);
19447 return Err(common::Error::HttpError(err));
19448 }
19449 Ok(res) => {
19450 let (mut parts, body) = res.into_parts();
19451 let mut body = common::Body::new(body);
19452 if !parts.status.is_success() {
19453 let bytes = common::to_bytes(body).await.unwrap_or_default();
19454 let error = serde_json::from_str(&common::to_string(&bytes));
19455 let response = common::to_response(parts, bytes.into());
19456
19457 if let common::Retry::After(d) =
19458 dlg.http_failure(&response, error.as_ref().ok())
19459 {
19460 sleep(d).await;
19461 continue;
19462 }
19463
19464 dlg.finished(false);
19465
19466 return Err(match error {
19467 Ok(value) => common::Error::BadRequest(value),
19468 _ => common::Error::Failure(response),
19469 });
19470 }
19471 let response = {
19472 let bytes = common::to_bytes(body).await.unwrap_or_default();
19473 let encoded = common::to_string(&bytes);
19474 match serde_json::from_str(&encoded) {
19475 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19476 Err(error) => {
19477 dlg.response_json_decode_error(&encoded, &error);
19478 return Err(common::Error::JsonDecodeError(
19479 encoded.to_string(),
19480 error,
19481 ));
19482 }
19483 }
19484 };
19485
19486 dlg.finished(true);
19487 return Ok(response);
19488 }
19489 }
19490 }
19491 }
19492
19493 ///
19494 /// Sets the *request* property to the given value.
19495 ///
19496 /// Even though the property as already been set when instantiating this call,
19497 /// we provide this method for API completeness.
19498 pub fn request(mut self, new_value: CourseWork) -> CourseCourseWorkPatchCall<'a, C> {
19499 self._request = new_value;
19500 self
19501 }
19502 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
19503 ///
19504 /// Sets the *course id* path property to the given value.
19505 ///
19506 /// Even though the property as already been set when instantiating this call,
19507 /// we provide this method for API completeness.
19508 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkPatchCall<'a, C> {
19509 self._course_id = new_value.to_string();
19510 self
19511 }
19512 /// Identifier of the course work.
19513 ///
19514 /// Sets the *id* path property to the given value.
19515 ///
19516 /// Even though the property as already been set when instantiating this call,
19517 /// we provide this method for API completeness.
19518 pub fn id(mut self, new_value: &str) -> CourseCourseWorkPatchCall<'a, C> {
19519 self._id = new_value.to_string();
19520 self
19521 }
19522 /// Mask that identifies which fields on the course work to update. This field is required to do an update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the `CourseWork` object. If a field that does not support empty values is included in the update mask and not set in the `CourseWork` object, an `INVALID_ARGUMENT` error is returned. The following fields may be specified by teachers: * `title` * `description` * `state` * `due_date` * `due_time` * `max_points` * `scheduled_time` * `submission_modification_mode` * `topic_id` * `grading_period_id`
19523 ///
19524 /// Sets the *update mask* query property to the given value.
19525 pub fn update_mask(mut self, new_value: common::FieldMask) -> CourseCourseWorkPatchCall<'a, C> {
19526 self._update_mask = Some(new_value);
19527 self
19528 }
19529 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19530 /// while executing the actual API request.
19531 ///
19532 /// ````text
19533 /// It should be used to handle progress information, and to implement a certain level of resilience.
19534 /// ````
19535 ///
19536 /// Sets the *delegate* property to the given value.
19537 pub fn delegate(
19538 mut self,
19539 new_value: &'a mut dyn common::Delegate,
19540 ) -> CourseCourseWorkPatchCall<'a, C> {
19541 self._delegate = Some(new_value);
19542 self
19543 }
19544
19545 /// Set any additional parameter of the query string used in the request.
19546 /// It should be used to set parameters which are not yet available through their own
19547 /// setters.
19548 ///
19549 /// Please note that this method must not be used to set any of the known parameters
19550 /// which have their own setter method. If done anyway, the request will fail.
19551 ///
19552 /// # Additional Parameters
19553 ///
19554 /// * *$.xgafv* (query-string) - V1 error format.
19555 /// * *access_token* (query-string) - OAuth access token.
19556 /// * *alt* (query-string) - Data format for response.
19557 /// * *callback* (query-string) - JSONP
19558 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19559 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19560 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19561 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19562 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19563 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19564 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19565 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkPatchCall<'a, C>
19566 where
19567 T: AsRef<str>,
19568 {
19569 self._additional_params
19570 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19571 self
19572 }
19573
19574 /// Identifies the authorization scope for the method you are building.
19575 ///
19576 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19577 /// [`Scope::CourseworkStudent`].
19578 ///
19579 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19580 /// tokens for more than one scope.
19581 ///
19582 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19583 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19584 /// sufficient, a read-write scope will do as well.
19585 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkPatchCall<'a, C>
19586 where
19587 St: AsRef<str>,
19588 {
19589 self._scopes.insert(String::from(scope.as_ref()));
19590 self
19591 }
19592 /// Identifies the authorization scope(s) for the method you are building.
19593 ///
19594 /// See [`Self::add_scope()`] for details.
19595 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkPatchCall<'a, C>
19596 where
19597 I: IntoIterator<Item = St>,
19598 St: AsRef<str>,
19599 {
19600 self._scopes
19601 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19602 self
19603 }
19604
19605 /// Removes all scopes, and no default scope will be used either.
19606 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19607 /// for details).
19608 pub fn clear_scopes(mut self) -> CourseCourseWorkPatchCall<'a, C> {
19609 self._scopes.clear();
19610 self
19611 }
19612}
19613
19614/// Updates a rubric. See google.classroom.v1.Rubric for details of which fields can be updated. Rubric update capabilities are [limited](https://developers.google.com/classroom/rubrics/limitations) once grading has started. The requesting user and course owner must have rubrics creation capabilities. For details, see [licensing requirements](https://developers.google.com/workspace/classroom/rubrics/limitations#license-requirements). This request must be made by the Google Cloud console of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the parent course work item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project didn’t create the corresponding course work, if the user isn’t permitted to make the requested modification to the rubric, or for access errors. This error code is also returned if grading has already started on the rubric. * `INVALID_ARGUMENT` if the request is malformed and for the following request error: * `RubricCriteriaInvalidFormat` * `NOT_FOUND` if the requested course, course work, or rubric doesn’t exist or if the user doesn’t have access to the corresponding course work. * `INTERNAL` if grading has already started on the rubric.
19615///
19616/// A builder for the *courseWork.updateRubric* method supported by a *course* resource.
19617/// It is not used directly, but through a [`CourseMethods`] instance.
19618///
19619/// # Example
19620///
19621/// Instantiate a resource method builder
19622///
19623/// ```test_harness,no_run
19624/// # extern crate hyper;
19625/// # extern crate hyper_rustls;
19626/// # extern crate google_classroom1 as classroom1;
19627/// use classroom1::api::Rubric;
19628/// # async fn dox() {
19629/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19630///
19631/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19632/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19633/// # .with_native_roots()
19634/// # .unwrap()
19635/// # .https_only()
19636/// # .enable_http2()
19637/// # .build();
19638///
19639/// # let executor = hyper_util::rt::TokioExecutor::new();
19640/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19641/// # secret,
19642/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19643/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19644/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19645/// # ),
19646/// # ).build().await.unwrap();
19647///
19648/// # let client = hyper_util::client::legacy::Client::builder(
19649/// # hyper_util::rt::TokioExecutor::new()
19650/// # )
19651/// # .build(
19652/// # hyper_rustls::HttpsConnectorBuilder::new()
19653/// # .with_native_roots()
19654/// # .unwrap()
19655/// # .https_or_http()
19656/// # .enable_http2()
19657/// # .build()
19658/// # );
19659/// # let mut hub = Classroom::new(client, auth);
19660/// // As the method needs a request, you would usually fill it with the desired information
19661/// // into the respective structure. Some of the parts shown here might not be applicable !
19662/// // Values shown here are possibly random and not representative !
19663/// let mut req = Rubric::default();
19664///
19665/// // You can configure optional parameters by calling the respective setters at will, and
19666/// // execute the final call using `doit()`.
19667/// // Values shown here are possibly random and not representative !
19668/// let result = hub.courses().course_work_update_rubric(req, "courseId", "courseWorkId")
19669/// .update_mask(FieldMask::new::<&str>(&[]))
19670/// .id("sea")
19671/// .doit().await;
19672/// # }
19673/// ```
19674pub struct CourseCourseWorkUpdateRubricCall<'a, C>
19675where
19676 C: 'a,
19677{
19678 hub: &'a Classroom<C>,
19679 _request: Rubric,
19680 _course_id: String,
19681 _course_work_id: String,
19682 _update_mask: Option<common::FieldMask>,
19683 _id: Option<String>,
19684 _delegate: Option<&'a mut dyn common::Delegate>,
19685 _additional_params: HashMap<String, String>,
19686 _scopes: BTreeSet<String>,
19687}
19688
19689impl<'a, C> common::CallBuilder for CourseCourseWorkUpdateRubricCall<'a, C> {}
19690
19691impl<'a, C> CourseCourseWorkUpdateRubricCall<'a, C>
19692where
19693 C: common::Connector,
19694{
19695 /// Perform the operation you have build so far.
19696 pub async fn doit(mut self) -> common::Result<(common::Response, Rubric)> {
19697 use std::borrow::Cow;
19698 use std::io::{Read, Seek};
19699
19700 use common::{url::Params, ToParts};
19701 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19702
19703 let mut dd = common::DefaultDelegate;
19704 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19705 dlg.begin(common::MethodInfo {
19706 id: "classroom.courses.courseWork.updateRubric",
19707 http_method: hyper::Method::PATCH,
19708 });
19709
19710 for &field in ["alt", "courseId", "courseWorkId", "updateMask", "id"].iter() {
19711 if self._additional_params.contains_key(field) {
19712 dlg.finished(false);
19713 return Err(common::Error::FieldClash(field));
19714 }
19715 }
19716
19717 let mut params = Params::with_capacity(7 + self._additional_params.len());
19718 params.push("courseId", self._course_id);
19719 params.push("courseWorkId", self._course_work_id);
19720 if let Some(value) = self._update_mask.as_ref() {
19721 params.push("updateMask", value.to_string());
19722 }
19723 if let Some(value) = self._id.as_ref() {
19724 params.push("id", value);
19725 }
19726
19727 params.extend(self._additional_params.iter());
19728
19729 params.push("alt", "json");
19730 let mut url =
19731 self.hub._base_url.clone() + "v1/courses/{courseId}/courseWork/{courseWorkId}/rubric";
19732 if self._scopes.is_empty() {
19733 self._scopes
19734 .insert(Scope::CourseworkStudent.as_ref().to_string());
19735 }
19736
19737 #[allow(clippy::single_element_loop)]
19738 for &(find_this, param_name) in [
19739 ("{courseId}", "courseId"),
19740 ("{courseWorkId}", "courseWorkId"),
19741 ]
19742 .iter()
19743 {
19744 url = params.uri_replacement(url, param_name, find_this, false);
19745 }
19746 {
19747 let to_remove = ["courseWorkId", "courseId"];
19748 params.remove_params(&to_remove);
19749 }
19750
19751 let url = params.parse_with_url(&url);
19752
19753 let mut json_mime_type = mime::APPLICATION_JSON;
19754 let mut request_value_reader = {
19755 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19756 common::remove_json_null_values(&mut value);
19757 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19758 serde_json::to_writer(&mut dst, &value).unwrap();
19759 dst
19760 };
19761 let request_size = request_value_reader
19762 .seek(std::io::SeekFrom::End(0))
19763 .unwrap();
19764 request_value_reader
19765 .seek(std::io::SeekFrom::Start(0))
19766 .unwrap();
19767
19768 loop {
19769 let token = match self
19770 .hub
19771 .auth
19772 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19773 .await
19774 {
19775 Ok(token) => token,
19776 Err(e) => match dlg.token(e) {
19777 Ok(token) => token,
19778 Err(e) => {
19779 dlg.finished(false);
19780 return Err(common::Error::MissingToken(e));
19781 }
19782 },
19783 };
19784 request_value_reader
19785 .seek(std::io::SeekFrom::Start(0))
19786 .unwrap();
19787 let mut req_result = {
19788 let client = &self.hub.client;
19789 dlg.pre_request();
19790 let mut req_builder = hyper::Request::builder()
19791 .method(hyper::Method::PATCH)
19792 .uri(url.as_str())
19793 .header(USER_AGENT, self.hub._user_agent.clone());
19794
19795 if let Some(token) = token.as_ref() {
19796 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19797 }
19798
19799 let request = req_builder
19800 .header(CONTENT_TYPE, json_mime_type.to_string())
19801 .header(CONTENT_LENGTH, request_size as u64)
19802 .body(common::to_body(
19803 request_value_reader.get_ref().clone().into(),
19804 ));
19805
19806 client.request(request.unwrap()).await
19807 };
19808
19809 match req_result {
19810 Err(err) => {
19811 if let common::Retry::After(d) = dlg.http_error(&err) {
19812 sleep(d).await;
19813 continue;
19814 }
19815 dlg.finished(false);
19816 return Err(common::Error::HttpError(err));
19817 }
19818 Ok(res) => {
19819 let (mut parts, body) = res.into_parts();
19820 let mut body = common::Body::new(body);
19821 if !parts.status.is_success() {
19822 let bytes = common::to_bytes(body).await.unwrap_or_default();
19823 let error = serde_json::from_str(&common::to_string(&bytes));
19824 let response = common::to_response(parts, bytes.into());
19825
19826 if let common::Retry::After(d) =
19827 dlg.http_failure(&response, error.as_ref().ok())
19828 {
19829 sleep(d).await;
19830 continue;
19831 }
19832
19833 dlg.finished(false);
19834
19835 return Err(match error {
19836 Ok(value) => common::Error::BadRequest(value),
19837 _ => common::Error::Failure(response),
19838 });
19839 }
19840 let response = {
19841 let bytes = common::to_bytes(body).await.unwrap_or_default();
19842 let encoded = common::to_string(&bytes);
19843 match serde_json::from_str(&encoded) {
19844 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19845 Err(error) => {
19846 dlg.response_json_decode_error(&encoded, &error);
19847 return Err(common::Error::JsonDecodeError(
19848 encoded.to_string(),
19849 error,
19850 ));
19851 }
19852 }
19853 };
19854
19855 dlg.finished(true);
19856 return Ok(response);
19857 }
19858 }
19859 }
19860 }
19861
19862 ///
19863 /// Sets the *request* property to the given value.
19864 ///
19865 /// Even though the property as already been set when instantiating this call,
19866 /// we provide this method for API completeness.
19867 pub fn request(mut self, new_value: Rubric) -> CourseCourseWorkUpdateRubricCall<'a, C> {
19868 self._request = new_value;
19869 self
19870 }
19871 /// Required. Identifier of the course.
19872 ///
19873 /// Sets the *course id* path property to the given value.
19874 ///
19875 /// Even though the property as already been set when instantiating this call,
19876 /// we provide this method for API completeness.
19877 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkUpdateRubricCall<'a, C> {
19878 self._course_id = new_value.to_string();
19879 self
19880 }
19881 /// Required. Identifier of the course work.
19882 ///
19883 /// Sets the *course work id* path property to the given value.
19884 ///
19885 /// Even though the property as already been set when instantiating this call,
19886 /// we provide this method for API completeness.
19887 pub fn course_work_id(mut self, new_value: &str) -> CourseCourseWorkUpdateRubricCall<'a, C> {
19888 self._course_work_id = new_value.to_string();
19889 self
19890 }
19891 /// Optional. Mask that identifies which fields on the rubric to update. This field is required to do an update. The update fails if invalid fields are specified. There are multiple options to define the criteria of a rubric: the `source_spreadsheet_id` and the `criteria` list. Only one of these can be used at a time to define a rubric. The rubric `criteria` list is fully replaced by the rubric criteria specified in the update request. For example, if a criterion or level is missing from the request, it is deleted. New criteria and levels are added and an ID is assigned. Existing criteria and levels retain the previously assigned ID if the ID is specified in the request. The following fields can be specified by teachers: * `criteria` * `source_spreadsheet_id`
19892 ///
19893 /// Sets the *update mask* query property to the given value.
19894 pub fn update_mask(
19895 mut self,
19896 new_value: common::FieldMask,
19897 ) -> CourseCourseWorkUpdateRubricCall<'a, C> {
19898 self._update_mask = Some(new_value);
19899 self
19900 }
19901 /// Optional. Identifier of the rubric.
19902 ///
19903 /// Sets the *id* query property to the given value.
19904 pub fn id(mut self, new_value: &str) -> CourseCourseWorkUpdateRubricCall<'a, C> {
19905 self._id = Some(new_value.to_string());
19906 self
19907 }
19908 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19909 /// while executing the actual API request.
19910 ///
19911 /// ````text
19912 /// It should be used to handle progress information, and to implement a certain level of resilience.
19913 /// ````
19914 ///
19915 /// Sets the *delegate* property to the given value.
19916 pub fn delegate(
19917 mut self,
19918 new_value: &'a mut dyn common::Delegate,
19919 ) -> CourseCourseWorkUpdateRubricCall<'a, C> {
19920 self._delegate = Some(new_value);
19921 self
19922 }
19923
19924 /// Set any additional parameter of the query string used in the request.
19925 /// It should be used to set parameters which are not yet available through their own
19926 /// setters.
19927 ///
19928 /// Please note that this method must not be used to set any of the known parameters
19929 /// which have their own setter method. If done anyway, the request will fail.
19930 ///
19931 /// # Additional Parameters
19932 ///
19933 /// * *$.xgafv* (query-string) - V1 error format.
19934 /// * *access_token* (query-string) - OAuth access token.
19935 /// * *alt* (query-string) - Data format for response.
19936 /// * *callback* (query-string) - JSONP
19937 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19938 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19939 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19940 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19941 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
19942 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19943 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19944 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkUpdateRubricCall<'a, C>
19945 where
19946 T: AsRef<str>,
19947 {
19948 self._additional_params
19949 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19950 self
19951 }
19952
19953 /// Identifies the authorization scope for the method you are building.
19954 ///
19955 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19956 /// [`Scope::CourseworkStudent`].
19957 ///
19958 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19959 /// tokens for more than one scope.
19960 ///
19961 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19962 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19963 /// sufficient, a read-write scope will do as well.
19964 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkUpdateRubricCall<'a, C>
19965 where
19966 St: AsRef<str>,
19967 {
19968 self._scopes.insert(String::from(scope.as_ref()));
19969 self
19970 }
19971 /// Identifies the authorization scope(s) for the method you are building.
19972 ///
19973 /// See [`Self::add_scope()`] for details.
19974 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkUpdateRubricCall<'a, C>
19975 where
19976 I: IntoIterator<Item = St>,
19977 St: AsRef<str>,
19978 {
19979 self._scopes
19980 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19981 self
19982 }
19983
19984 /// Removes all scopes, and no default scope will be used either.
19985 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19986 /// for details).
19987 pub fn clear_scopes(mut self) -> CourseCourseWorkUpdateRubricCall<'a, C> {
19988 self._scopes.clear();
19989 self
19990 }
19991}
19992
19993/// Creates an add-on attachment under a post. Requires the add-on to have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
19994///
19995/// A builder for the *courseWorkMaterials.addOnAttachments.create* method supported by a *course* resource.
19996/// It is not used directly, but through a [`CourseMethods`] instance.
19997///
19998/// # Example
19999///
20000/// Instantiate a resource method builder
20001///
20002/// ```test_harness,no_run
20003/// # extern crate hyper;
20004/// # extern crate hyper_rustls;
20005/// # extern crate google_classroom1 as classroom1;
20006/// use classroom1::api::AddOnAttachment;
20007/// # async fn dox() {
20008/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20009///
20010/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20011/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20012/// # .with_native_roots()
20013/// # .unwrap()
20014/// # .https_only()
20015/// # .enable_http2()
20016/// # .build();
20017///
20018/// # let executor = hyper_util::rt::TokioExecutor::new();
20019/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20020/// # secret,
20021/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20022/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20023/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20024/// # ),
20025/// # ).build().await.unwrap();
20026///
20027/// # let client = hyper_util::client::legacy::Client::builder(
20028/// # hyper_util::rt::TokioExecutor::new()
20029/// # )
20030/// # .build(
20031/// # hyper_rustls::HttpsConnectorBuilder::new()
20032/// # .with_native_roots()
20033/// # .unwrap()
20034/// # .https_or_http()
20035/// # .enable_http2()
20036/// # .build()
20037/// # );
20038/// # let mut hub = Classroom::new(client, auth);
20039/// // As the method needs a request, you would usually fill it with the desired information
20040/// // into the respective structure. Some of the parts shown here might not be applicable !
20041/// // Values shown here are possibly random and not representative !
20042/// let mut req = AddOnAttachment::default();
20043///
20044/// // You can configure optional parameters by calling the respective setters at will, and
20045/// // execute the final call using `doit()`.
20046/// // Values shown here are possibly random and not representative !
20047/// let result = hub.courses().course_work_materials_add_on_attachments_create(req, "courseId", "itemId")
20048/// .post_id("dolore")
20049/// .add_on_token("eirmod")
20050/// .doit().await;
20051/// # }
20052/// ```
20053pub struct CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C>
20054where
20055 C: 'a,
20056{
20057 hub: &'a Classroom<C>,
20058 _request: AddOnAttachment,
20059 _course_id: String,
20060 _item_id: String,
20061 _post_id: Option<String>,
20062 _add_on_token: Option<String>,
20063 _delegate: Option<&'a mut dyn common::Delegate>,
20064 _additional_params: HashMap<String, String>,
20065 _scopes: BTreeSet<String>,
20066}
20067
20068impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C> {}
20069
20070impl<'a, C> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C>
20071where
20072 C: common::Connector,
20073{
20074 /// Perform the operation you have build so far.
20075 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
20076 use std::borrow::Cow;
20077 use std::io::{Read, Seek};
20078
20079 use common::{url::Params, ToParts};
20080 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20081
20082 let mut dd = common::DefaultDelegate;
20083 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20084 dlg.begin(common::MethodInfo {
20085 id: "classroom.courses.courseWorkMaterials.addOnAttachments.create",
20086 http_method: hyper::Method::POST,
20087 });
20088
20089 for &field in ["alt", "courseId", "itemId", "postId", "addOnToken"].iter() {
20090 if self._additional_params.contains_key(field) {
20091 dlg.finished(false);
20092 return Err(common::Error::FieldClash(field));
20093 }
20094 }
20095
20096 let mut params = Params::with_capacity(7 + self._additional_params.len());
20097 params.push("courseId", self._course_id);
20098 params.push("itemId", self._item_id);
20099 if let Some(value) = self._post_id.as_ref() {
20100 params.push("postId", value);
20101 }
20102 if let Some(value) = self._add_on_token.as_ref() {
20103 params.push("addOnToken", value);
20104 }
20105
20106 params.extend(self._additional_params.iter());
20107
20108 params.push("alt", "json");
20109 let mut url = self.hub._base_url.clone()
20110 + "v1/courses/{courseId}/courseWorkMaterials/{itemId}/addOnAttachments";
20111 if self._scopes.is_empty() {
20112 self._scopes
20113 .insert(Scope::AddonTeacher.as_ref().to_string());
20114 }
20115
20116 #[allow(clippy::single_element_loop)]
20117 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{itemId}", "itemId")].iter()
20118 {
20119 url = params.uri_replacement(url, param_name, find_this, false);
20120 }
20121 {
20122 let to_remove = ["itemId", "courseId"];
20123 params.remove_params(&to_remove);
20124 }
20125
20126 let url = params.parse_with_url(&url);
20127
20128 let mut json_mime_type = mime::APPLICATION_JSON;
20129 let mut request_value_reader = {
20130 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20131 common::remove_json_null_values(&mut value);
20132 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20133 serde_json::to_writer(&mut dst, &value).unwrap();
20134 dst
20135 };
20136 let request_size = request_value_reader
20137 .seek(std::io::SeekFrom::End(0))
20138 .unwrap();
20139 request_value_reader
20140 .seek(std::io::SeekFrom::Start(0))
20141 .unwrap();
20142
20143 loop {
20144 let token = match self
20145 .hub
20146 .auth
20147 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20148 .await
20149 {
20150 Ok(token) => token,
20151 Err(e) => match dlg.token(e) {
20152 Ok(token) => token,
20153 Err(e) => {
20154 dlg.finished(false);
20155 return Err(common::Error::MissingToken(e));
20156 }
20157 },
20158 };
20159 request_value_reader
20160 .seek(std::io::SeekFrom::Start(0))
20161 .unwrap();
20162 let mut req_result = {
20163 let client = &self.hub.client;
20164 dlg.pre_request();
20165 let mut req_builder = hyper::Request::builder()
20166 .method(hyper::Method::POST)
20167 .uri(url.as_str())
20168 .header(USER_AGENT, self.hub._user_agent.clone());
20169
20170 if let Some(token) = token.as_ref() {
20171 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20172 }
20173
20174 let request = req_builder
20175 .header(CONTENT_TYPE, json_mime_type.to_string())
20176 .header(CONTENT_LENGTH, request_size as u64)
20177 .body(common::to_body(
20178 request_value_reader.get_ref().clone().into(),
20179 ));
20180
20181 client.request(request.unwrap()).await
20182 };
20183
20184 match req_result {
20185 Err(err) => {
20186 if let common::Retry::After(d) = dlg.http_error(&err) {
20187 sleep(d).await;
20188 continue;
20189 }
20190 dlg.finished(false);
20191 return Err(common::Error::HttpError(err));
20192 }
20193 Ok(res) => {
20194 let (mut parts, body) = res.into_parts();
20195 let mut body = common::Body::new(body);
20196 if !parts.status.is_success() {
20197 let bytes = common::to_bytes(body).await.unwrap_or_default();
20198 let error = serde_json::from_str(&common::to_string(&bytes));
20199 let response = common::to_response(parts, bytes.into());
20200
20201 if let common::Retry::After(d) =
20202 dlg.http_failure(&response, error.as_ref().ok())
20203 {
20204 sleep(d).await;
20205 continue;
20206 }
20207
20208 dlg.finished(false);
20209
20210 return Err(match error {
20211 Ok(value) => common::Error::BadRequest(value),
20212 _ => common::Error::Failure(response),
20213 });
20214 }
20215 let response = {
20216 let bytes = common::to_bytes(body).await.unwrap_or_default();
20217 let encoded = common::to_string(&bytes);
20218 match serde_json::from_str(&encoded) {
20219 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20220 Err(error) => {
20221 dlg.response_json_decode_error(&encoded, &error);
20222 return Err(common::Error::JsonDecodeError(
20223 encoded.to_string(),
20224 error,
20225 ));
20226 }
20227 }
20228 };
20229
20230 dlg.finished(true);
20231 return Ok(response);
20232 }
20233 }
20234 }
20235 }
20236
20237 ///
20238 /// Sets the *request* property to the given value.
20239 ///
20240 /// Even though the property as already been set when instantiating this call,
20241 /// we provide this method for API completeness.
20242 pub fn request(
20243 mut self,
20244 new_value: AddOnAttachment,
20245 ) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C> {
20246 self._request = new_value;
20247 self
20248 }
20249 /// Required. Identifier of the course.
20250 ///
20251 /// Sets the *course id* path property to the given value.
20252 ///
20253 /// Even though the property as already been set when instantiating this call,
20254 /// we provide this method for API completeness.
20255 pub fn course_id(
20256 mut self,
20257 new_value: &str,
20258 ) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C> {
20259 self._course_id = new_value.to_string();
20260 self
20261 }
20262 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which to create the attachment. This field is required, but is not marked as such while we are migrating from post_id.
20263 ///
20264 /// Sets the *item id* path property to the given value.
20265 ///
20266 /// Even though the property as already been set when instantiating this call,
20267 /// we provide this method for API completeness.
20268 pub fn item_id(
20269 mut self,
20270 new_value: &str,
20271 ) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C> {
20272 self._item_id = new_value.to_string();
20273 self
20274 }
20275 /// Optional. Deprecated, use `item_id` instead.
20276 ///
20277 /// Sets the *post id* query property to the given value.
20278 pub fn post_id(
20279 mut self,
20280 new_value: &str,
20281 ) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C> {
20282 self._post_id = Some(new_value.to_string());
20283 self
20284 }
20285 /// Optional. Token that authorizes the request. The token is passed as a query parameter when the user is redirected from Classroom to the add-on's URL. This authorization token is required for in-Classroom attachment creation but optional for partner-first attachment creation. Returns an error if not provided for partner-first attachment creation and the developer projects that created the attachment and its parent stream item do not match.
20286 ///
20287 /// Sets the *add on token* query property to the given value.
20288 pub fn add_on_token(
20289 mut self,
20290 new_value: &str,
20291 ) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C> {
20292 self._add_on_token = Some(new_value.to_string());
20293 self
20294 }
20295 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20296 /// while executing the actual API request.
20297 ///
20298 /// ````text
20299 /// It should be used to handle progress information, and to implement a certain level of resilience.
20300 /// ````
20301 ///
20302 /// Sets the *delegate* property to the given value.
20303 pub fn delegate(
20304 mut self,
20305 new_value: &'a mut dyn common::Delegate,
20306 ) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C> {
20307 self._delegate = Some(new_value);
20308 self
20309 }
20310
20311 /// Set any additional parameter of the query string used in the request.
20312 /// It should be used to set parameters which are not yet available through their own
20313 /// setters.
20314 ///
20315 /// Please note that this method must not be used to set any of the known parameters
20316 /// which have their own setter method. If done anyway, the request will fail.
20317 ///
20318 /// # Additional Parameters
20319 ///
20320 /// * *$.xgafv* (query-string) - V1 error format.
20321 /// * *access_token* (query-string) - OAuth access token.
20322 /// * *alt* (query-string) - Data format for response.
20323 /// * *callback* (query-string) - JSONP
20324 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20325 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20326 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20327 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20328 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
20329 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20330 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20331 pub fn param<T>(
20332 mut self,
20333 name: T,
20334 value: T,
20335 ) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C>
20336 where
20337 T: AsRef<str>,
20338 {
20339 self._additional_params
20340 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20341 self
20342 }
20343
20344 /// Identifies the authorization scope for the method you are building.
20345 ///
20346 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20347 /// [`Scope::AddonTeacher`].
20348 ///
20349 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20350 /// tokens for more than one scope.
20351 ///
20352 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20353 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20354 /// sufficient, a read-write scope will do as well.
20355 pub fn add_scope<St>(
20356 mut self,
20357 scope: St,
20358 ) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C>
20359 where
20360 St: AsRef<str>,
20361 {
20362 self._scopes.insert(String::from(scope.as_ref()));
20363 self
20364 }
20365 /// Identifies the authorization scope(s) for the method you are building.
20366 ///
20367 /// See [`Self::add_scope()`] for details.
20368 pub fn add_scopes<I, St>(
20369 mut self,
20370 scopes: I,
20371 ) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C>
20372 where
20373 I: IntoIterator<Item = St>,
20374 St: AsRef<str>,
20375 {
20376 self._scopes
20377 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20378 self
20379 }
20380
20381 /// Removes all scopes, and no default scope will be used either.
20382 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20383 /// for details).
20384 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialAddOnAttachmentCreateCall<'a, C> {
20385 self._scopes.clear();
20386 self
20387 }
20388}
20389
20390/// Deletes an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
20391///
20392/// A builder for the *courseWorkMaterials.addOnAttachments.delete* method supported by a *course* resource.
20393/// It is not used directly, but through a [`CourseMethods`] instance.
20394///
20395/// # Example
20396///
20397/// Instantiate a resource method builder
20398///
20399/// ```test_harness,no_run
20400/// # extern crate hyper;
20401/// # extern crate hyper_rustls;
20402/// # extern crate google_classroom1 as classroom1;
20403/// # async fn dox() {
20404/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20405///
20406/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20407/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20408/// # .with_native_roots()
20409/// # .unwrap()
20410/// # .https_only()
20411/// # .enable_http2()
20412/// # .build();
20413///
20414/// # let executor = hyper_util::rt::TokioExecutor::new();
20415/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20416/// # secret,
20417/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20418/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20419/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20420/// # ),
20421/// # ).build().await.unwrap();
20422///
20423/// # let client = hyper_util::client::legacy::Client::builder(
20424/// # hyper_util::rt::TokioExecutor::new()
20425/// # )
20426/// # .build(
20427/// # hyper_rustls::HttpsConnectorBuilder::new()
20428/// # .with_native_roots()
20429/// # .unwrap()
20430/// # .https_or_http()
20431/// # .enable_http2()
20432/// # .build()
20433/// # );
20434/// # let mut hub = Classroom::new(client, auth);
20435/// // You can configure optional parameters by calling the respective setters at will, and
20436/// // execute the final call using `doit()`.
20437/// // Values shown here are possibly random and not representative !
20438/// let result = hub.courses().course_work_materials_add_on_attachments_delete("courseId", "itemId", "attachmentId")
20439/// .post_id("erat")
20440/// .doit().await;
20441/// # }
20442/// ```
20443pub struct CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C>
20444where
20445 C: 'a,
20446{
20447 hub: &'a Classroom<C>,
20448 _course_id: String,
20449 _item_id: String,
20450 _attachment_id: String,
20451 _post_id: Option<String>,
20452 _delegate: Option<&'a mut dyn common::Delegate>,
20453 _additional_params: HashMap<String, String>,
20454 _scopes: BTreeSet<String>,
20455}
20456
20457impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C> {}
20458
20459impl<'a, C> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C>
20460where
20461 C: common::Connector,
20462{
20463 /// Perform the operation you have build so far.
20464 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
20465 use std::borrow::Cow;
20466 use std::io::{Read, Seek};
20467
20468 use common::{url::Params, ToParts};
20469 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20470
20471 let mut dd = common::DefaultDelegate;
20472 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20473 dlg.begin(common::MethodInfo {
20474 id: "classroom.courses.courseWorkMaterials.addOnAttachments.delete",
20475 http_method: hyper::Method::DELETE,
20476 });
20477
20478 for &field in ["alt", "courseId", "itemId", "attachmentId", "postId"].iter() {
20479 if self._additional_params.contains_key(field) {
20480 dlg.finished(false);
20481 return Err(common::Error::FieldClash(field));
20482 }
20483 }
20484
20485 let mut params = Params::with_capacity(6 + self._additional_params.len());
20486 params.push("courseId", self._course_id);
20487 params.push("itemId", self._item_id);
20488 params.push("attachmentId", self._attachment_id);
20489 if let Some(value) = self._post_id.as_ref() {
20490 params.push("postId", value);
20491 }
20492
20493 params.extend(self._additional_params.iter());
20494
20495 params.push("alt", "json");
20496 let mut url = self.hub._base_url.clone()
20497 + "v1/courses/{courseId}/courseWorkMaterials/{itemId}/addOnAttachments/{attachmentId}";
20498 if self._scopes.is_empty() {
20499 self._scopes
20500 .insert(Scope::AddonTeacher.as_ref().to_string());
20501 }
20502
20503 #[allow(clippy::single_element_loop)]
20504 for &(find_this, param_name) in [
20505 ("{courseId}", "courseId"),
20506 ("{itemId}", "itemId"),
20507 ("{attachmentId}", "attachmentId"),
20508 ]
20509 .iter()
20510 {
20511 url = params.uri_replacement(url, param_name, find_this, false);
20512 }
20513 {
20514 let to_remove = ["attachmentId", "itemId", "courseId"];
20515 params.remove_params(&to_remove);
20516 }
20517
20518 let url = params.parse_with_url(&url);
20519
20520 loop {
20521 let token = match self
20522 .hub
20523 .auth
20524 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20525 .await
20526 {
20527 Ok(token) => token,
20528 Err(e) => match dlg.token(e) {
20529 Ok(token) => token,
20530 Err(e) => {
20531 dlg.finished(false);
20532 return Err(common::Error::MissingToken(e));
20533 }
20534 },
20535 };
20536 let mut req_result = {
20537 let client = &self.hub.client;
20538 dlg.pre_request();
20539 let mut req_builder = hyper::Request::builder()
20540 .method(hyper::Method::DELETE)
20541 .uri(url.as_str())
20542 .header(USER_AGENT, self.hub._user_agent.clone());
20543
20544 if let Some(token) = token.as_ref() {
20545 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20546 }
20547
20548 let request = req_builder
20549 .header(CONTENT_LENGTH, 0_u64)
20550 .body(common::to_body::<String>(None));
20551
20552 client.request(request.unwrap()).await
20553 };
20554
20555 match req_result {
20556 Err(err) => {
20557 if let common::Retry::After(d) = dlg.http_error(&err) {
20558 sleep(d).await;
20559 continue;
20560 }
20561 dlg.finished(false);
20562 return Err(common::Error::HttpError(err));
20563 }
20564 Ok(res) => {
20565 let (mut parts, body) = res.into_parts();
20566 let mut body = common::Body::new(body);
20567 if !parts.status.is_success() {
20568 let bytes = common::to_bytes(body).await.unwrap_or_default();
20569 let error = serde_json::from_str(&common::to_string(&bytes));
20570 let response = common::to_response(parts, bytes.into());
20571
20572 if let common::Retry::After(d) =
20573 dlg.http_failure(&response, error.as_ref().ok())
20574 {
20575 sleep(d).await;
20576 continue;
20577 }
20578
20579 dlg.finished(false);
20580
20581 return Err(match error {
20582 Ok(value) => common::Error::BadRequest(value),
20583 _ => common::Error::Failure(response),
20584 });
20585 }
20586 let response = {
20587 let bytes = common::to_bytes(body).await.unwrap_or_default();
20588 let encoded = common::to_string(&bytes);
20589 match serde_json::from_str(&encoded) {
20590 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20591 Err(error) => {
20592 dlg.response_json_decode_error(&encoded, &error);
20593 return Err(common::Error::JsonDecodeError(
20594 encoded.to_string(),
20595 error,
20596 ));
20597 }
20598 }
20599 };
20600
20601 dlg.finished(true);
20602 return Ok(response);
20603 }
20604 }
20605 }
20606 }
20607
20608 /// Required. Identifier of the course.
20609 ///
20610 /// Sets the *course id* path property to the given value.
20611 ///
20612 /// Even though the property as already been set when instantiating this call,
20613 /// we provide this method for API completeness.
20614 pub fn course_id(
20615 mut self,
20616 new_value: &str,
20617 ) -> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C> {
20618 self._course_id = new_value.to_string();
20619 self
20620 }
20621 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
20622 ///
20623 /// Sets the *item id* path property to the given value.
20624 ///
20625 /// Even though the property as already been set when instantiating this call,
20626 /// we provide this method for API completeness.
20627 pub fn item_id(
20628 mut self,
20629 new_value: &str,
20630 ) -> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C> {
20631 self._item_id = new_value.to_string();
20632 self
20633 }
20634 /// Required. Identifier of the attachment.
20635 ///
20636 /// Sets the *attachment id* path property to the given value.
20637 ///
20638 /// Even though the property as already been set when instantiating this call,
20639 /// we provide this method for API completeness.
20640 pub fn attachment_id(
20641 mut self,
20642 new_value: &str,
20643 ) -> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C> {
20644 self._attachment_id = new_value.to_string();
20645 self
20646 }
20647 /// Optional. Deprecated, use `item_id` instead.
20648 ///
20649 /// Sets the *post id* query property to the given value.
20650 pub fn post_id(
20651 mut self,
20652 new_value: &str,
20653 ) -> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C> {
20654 self._post_id = Some(new_value.to_string());
20655 self
20656 }
20657 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20658 /// while executing the actual API request.
20659 ///
20660 /// ````text
20661 /// It should be used to handle progress information, and to implement a certain level of resilience.
20662 /// ````
20663 ///
20664 /// Sets the *delegate* property to the given value.
20665 pub fn delegate(
20666 mut self,
20667 new_value: &'a mut dyn common::Delegate,
20668 ) -> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C> {
20669 self._delegate = Some(new_value);
20670 self
20671 }
20672
20673 /// Set any additional parameter of the query string used in the request.
20674 /// It should be used to set parameters which are not yet available through their own
20675 /// setters.
20676 ///
20677 /// Please note that this method must not be used to set any of the known parameters
20678 /// which have their own setter method. If done anyway, the request will fail.
20679 ///
20680 /// # Additional Parameters
20681 ///
20682 /// * *$.xgafv* (query-string) - V1 error format.
20683 /// * *access_token* (query-string) - OAuth access token.
20684 /// * *alt* (query-string) - Data format for response.
20685 /// * *callback* (query-string) - JSONP
20686 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20687 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20688 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20689 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20690 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
20691 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20692 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20693 pub fn param<T>(
20694 mut self,
20695 name: T,
20696 value: T,
20697 ) -> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C>
20698 where
20699 T: AsRef<str>,
20700 {
20701 self._additional_params
20702 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20703 self
20704 }
20705
20706 /// Identifies the authorization scope for the method you are building.
20707 ///
20708 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20709 /// [`Scope::AddonTeacher`].
20710 ///
20711 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20712 /// tokens for more than one scope.
20713 ///
20714 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20715 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20716 /// sufficient, a read-write scope will do as well.
20717 pub fn add_scope<St>(
20718 mut self,
20719 scope: St,
20720 ) -> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C>
20721 where
20722 St: AsRef<str>,
20723 {
20724 self._scopes.insert(String::from(scope.as_ref()));
20725 self
20726 }
20727 /// Identifies the authorization scope(s) for the method you are building.
20728 ///
20729 /// See [`Self::add_scope()`] for details.
20730 pub fn add_scopes<I, St>(
20731 mut self,
20732 scopes: I,
20733 ) -> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C>
20734 where
20735 I: IntoIterator<Item = St>,
20736 St: AsRef<str>,
20737 {
20738 self._scopes
20739 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20740 self
20741 }
20742
20743 /// Removes all scopes, and no default scope will be used either.
20744 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20745 /// for details).
20746 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialAddOnAttachmentDeleteCall<'a, C> {
20747 self._scopes.clear();
20748 self
20749 }
20750}
20751
20752/// Returns an add-on attachment. Requires the add-on requesting the attachment to be the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
20753///
20754/// A builder for the *courseWorkMaterials.addOnAttachments.get* method supported by a *course* resource.
20755/// It is not used directly, but through a [`CourseMethods`] instance.
20756///
20757/// # Example
20758///
20759/// Instantiate a resource method builder
20760///
20761/// ```test_harness,no_run
20762/// # extern crate hyper;
20763/// # extern crate hyper_rustls;
20764/// # extern crate google_classroom1 as classroom1;
20765/// # async fn dox() {
20766/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20767///
20768/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20769/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20770/// # .with_native_roots()
20771/// # .unwrap()
20772/// # .https_only()
20773/// # .enable_http2()
20774/// # .build();
20775///
20776/// # let executor = hyper_util::rt::TokioExecutor::new();
20777/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20778/// # secret,
20779/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20780/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20781/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20782/// # ),
20783/// # ).build().await.unwrap();
20784///
20785/// # let client = hyper_util::client::legacy::Client::builder(
20786/// # hyper_util::rt::TokioExecutor::new()
20787/// # )
20788/// # .build(
20789/// # hyper_rustls::HttpsConnectorBuilder::new()
20790/// # .with_native_roots()
20791/// # .unwrap()
20792/// # .https_or_http()
20793/// # .enable_http2()
20794/// # .build()
20795/// # );
20796/// # let mut hub = Classroom::new(client, auth);
20797/// // You can configure optional parameters by calling the respective setters at will, and
20798/// // execute the final call using `doit()`.
20799/// // Values shown here are possibly random and not representative !
20800/// let result = hub.courses().course_work_materials_add_on_attachments_get("courseId", "itemId", "attachmentId")
20801/// .post_id("sea")
20802/// .doit().await;
20803/// # }
20804/// ```
20805pub struct CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C>
20806where
20807 C: 'a,
20808{
20809 hub: &'a Classroom<C>,
20810 _course_id: String,
20811 _item_id: String,
20812 _attachment_id: String,
20813 _post_id: Option<String>,
20814 _delegate: Option<&'a mut dyn common::Delegate>,
20815 _additional_params: HashMap<String, String>,
20816 _scopes: BTreeSet<String>,
20817}
20818
20819impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C> {}
20820
20821impl<'a, C> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C>
20822where
20823 C: common::Connector,
20824{
20825 /// Perform the operation you have build so far.
20826 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
20827 use std::borrow::Cow;
20828 use std::io::{Read, Seek};
20829
20830 use common::{url::Params, ToParts};
20831 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20832
20833 let mut dd = common::DefaultDelegate;
20834 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20835 dlg.begin(common::MethodInfo {
20836 id: "classroom.courses.courseWorkMaterials.addOnAttachments.get",
20837 http_method: hyper::Method::GET,
20838 });
20839
20840 for &field in ["alt", "courseId", "itemId", "attachmentId", "postId"].iter() {
20841 if self._additional_params.contains_key(field) {
20842 dlg.finished(false);
20843 return Err(common::Error::FieldClash(field));
20844 }
20845 }
20846
20847 let mut params = Params::with_capacity(6 + self._additional_params.len());
20848 params.push("courseId", self._course_id);
20849 params.push("itemId", self._item_id);
20850 params.push("attachmentId", self._attachment_id);
20851 if let Some(value) = self._post_id.as_ref() {
20852 params.push("postId", value);
20853 }
20854
20855 params.extend(self._additional_params.iter());
20856
20857 params.push("alt", "json");
20858 let mut url = self.hub._base_url.clone()
20859 + "v1/courses/{courseId}/courseWorkMaterials/{itemId}/addOnAttachments/{attachmentId}";
20860 if self._scopes.is_empty() {
20861 self._scopes
20862 .insert(Scope::AddonStudent.as_ref().to_string());
20863 }
20864
20865 #[allow(clippy::single_element_loop)]
20866 for &(find_this, param_name) in [
20867 ("{courseId}", "courseId"),
20868 ("{itemId}", "itemId"),
20869 ("{attachmentId}", "attachmentId"),
20870 ]
20871 .iter()
20872 {
20873 url = params.uri_replacement(url, param_name, find_this, false);
20874 }
20875 {
20876 let to_remove = ["attachmentId", "itemId", "courseId"];
20877 params.remove_params(&to_remove);
20878 }
20879
20880 let url = params.parse_with_url(&url);
20881
20882 loop {
20883 let token = match self
20884 .hub
20885 .auth
20886 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20887 .await
20888 {
20889 Ok(token) => token,
20890 Err(e) => match dlg.token(e) {
20891 Ok(token) => token,
20892 Err(e) => {
20893 dlg.finished(false);
20894 return Err(common::Error::MissingToken(e));
20895 }
20896 },
20897 };
20898 let mut req_result = {
20899 let client = &self.hub.client;
20900 dlg.pre_request();
20901 let mut req_builder = hyper::Request::builder()
20902 .method(hyper::Method::GET)
20903 .uri(url.as_str())
20904 .header(USER_AGENT, self.hub._user_agent.clone());
20905
20906 if let Some(token) = token.as_ref() {
20907 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20908 }
20909
20910 let request = req_builder
20911 .header(CONTENT_LENGTH, 0_u64)
20912 .body(common::to_body::<String>(None));
20913
20914 client.request(request.unwrap()).await
20915 };
20916
20917 match req_result {
20918 Err(err) => {
20919 if let common::Retry::After(d) = dlg.http_error(&err) {
20920 sleep(d).await;
20921 continue;
20922 }
20923 dlg.finished(false);
20924 return Err(common::Error::HttpError(err));
20925 }
20926 Ok(res) => {
20927 let (mut parts, body) = res.into_parts();
20928 let mut body = common::Body::new(body);
20929 if !parts.status.is_success() {
20930 let bytes = common::to_bytes(body).await.unwrap_or_default();
20931 let error = serde_json::from_str(&common::to_string(&bytes));
20932 let response = common::to_response(parts, bytes.into());
20933
20934 if let common::Retry::After(d) =
20935 dlg.http_failure(&response, error.as_ref().ok())
20936 {
20937 sleep(d).await;
20938 continue;
20939 }
20940
20941 dlg.finished(false);
20942
20943 return Err(match error {
20944 Ok(value) => common::Error::BadRequest(value),
20945 _ => common::Error::Failure(response),
20946 });
20947 }
20948 let response = {
20949 let bytes = common::to_bytes(body).await.unwrap_or_default();
20950 let encoded = common::to_string(&bytes);
20951 match serde_json::from_str(&encoded) {
20952 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20953 Err(error) => {
20954 dlg.response_json_decode_error(&encoded, &error);
20955 return Err(common::Error::JsonDecodeError(
20956 encoded.to_string(),
20957 error,
20958 ));
20959 }
20960 }
20961 };
20962
20963 dlg.finished(true);
20964 return Ok(response);
20965 }
20966 }
20967 }
20968 }
20969
20970 /// Required. Identifier of the course.
20971 ///
20972 /// Sets the *course id* path property to the given value.
20973 ///
20974 /// Even though the property as already been set when instantiating this call,
20975 /// we provide this method for API completeness.
20976 pub fn course_id(
20977 mut self,
20978 new_value: &str,
20979 ) -> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C> {
20980 self._course_id = new_value.to_string();
20981 self
20982 }
20983 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
20984 ///
20985 /// Sets the *item id* path property to the given value.
20986 ///
20987 /// Even though the property as already been set when instantiating this call,
20988 /// we provide this method for API completeness.
20989 pub fn item_id(
20990 mut self,
20991 new_value: &str,
20992 ) -> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C> {
20993 self._item_id = new_value.to_string();
20994 self
20995 }
20996 /// Required. Identifier of the attachment.
20997 ///
20998 /// Sets the *attachment id* path property to the given value.
20999 ///
21000 /// Even though the property as already been set when instantiating this call,
21001 /// we provide this method for API completeness.
21002 pub fn attachment_id(
21003 mut self,
21004 new_value: &str,
21005 ) -> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C> {
21006 self._attachment_id = new_value.to_string();
21007 self
21008 }
21009 /// Optional. Deprecated, use `item_id` instead.
21010 ///
21011 /// Sets the *post id* query property to the given value.
21012 pub fn post_id(
21013 mut self,
21014 new_value: &str,
21015 ) -> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C> {
21016 self._post_id = Some(new_value.to_string());
21017 self
21018 }
21019 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21020 /// while executing the actual API request.
21021 ///
21022 /// ````text
21023 /// It should be used to handle progress information, and to implement a certain level of resilience.
21024 /// ````
21025 ///
21026 /// Sets the *delegate* property to the given value.
21027 pub fn delegate(
21028 mut self,
21029 new_value: &'a mut dyn common::Delegate,
21030 ) -> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C> {
21031 self._delegate = Some(new_value);
21032 self
21033 }
21034
21035 /// Set any additional parameter of the query string used in the request.
21036 /// It should be used to set parameters which are not yet available through their own
21037 /// setters.
21038 ///
21039 /// Please note that this method must not be used to set any of the known parameters
21040 /// which have their own setter method. If done anyway, the request will fail.
21041 ///
21042 /// # Additional Parameters
21043 ///
21044 /// * *$.xgafv* (query-string) - V1 error format.
21045 /// * *access_token* (query-string) - OAuth access token.
21046 /// * *alt* (query-string) - Data format for response.
21047 /// * *callback* (query-string) - JSONP
21048 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21049 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21050 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21051 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21052 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
21053 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21054 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21055 pub fn param<T>(
21056 mut self,
21057 name: T,
21058 value: T,
21059 ) -> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C>
21060 where
21061 T: AsRef<str>,
21062 {
21063 self._additional_params
21064 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21065 self
21066 }
21067
21068 /// Identifies the authorization scope for the method you are building.
21069 ///
21070 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21071 /// [`Scope::AddonStudent`].
21072 ///
21073 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21074 /// tokens for more than one scope.
21075 ///
21076 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21077 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21078 /// sufficient, a read-write scope will do as well.
21079 pub fn add_scope<St>(
21080 mut self,
21081 scope: St,
21082 ) -> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C>
21083 where
21084 St: AsRef<str>,
21085 {
21086 self._scopes.insert(String::from(scope.as_ref()));
21087 self
21088 }
21089 /// Identifies the authorization scope(s) for the method you are building.
21090 ///
21091 /// See [`Self::add_scope()`] for details.
21092 pub fn add_scopes<I, St>(
21093 mut self,
21094 scopes: I,
21095 ) -> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C>
21096 where
21097 I: IntoIterator<Item = St>,
21098 St: AsRef<str>,
21099 {
21100 self._scopes
21101 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21102 self
21103 }
21104
21105 /// Removes all scopes, and no default scope will be used either.
21106 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21107 /// for details).
21108 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialAddOnAttachmentGetCall<'a, C> {
21109 self._scopes.clear();
21110 self
21111 }
21112}
21113
21114/// Returns all attachments created by an add-on under the post. Requires the add-on to have active attachments on the post or have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
21115///
21116/// A builder for the *courseWorkMaterials.addOnAttachments.list* method supported by a *course* resource.
21117/// It is not used directly, but through a [`CourseMethods`] instance.
21118///
21119/// # Example
21120///
21121/// Instantiate a resource method builder
21122///
21123/// ```test_harness,no_run
21124/// # extern crate hyper;
21125/// # extern crate hyper_rustls;
21126/// # extern crate google_classroom1 as classroom1;
21127/// # async fn dox() {
21128/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21129///
21130/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21131/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21132/// # .with_native_roots()
21133/// # .unwrap()
21134/// # .https_only()
21135/// # .enable_http2()
21136/// # .build();
21137///
21138/// # let executor = hyper_util::rt::TokioExecutor::new();
21139/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21140/// # secret,
21141/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21142/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21143/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21144/// # ),
21145/// # ).build().await.unwrap();
21146///
21147/// # let client = hyper_util::client::legacy::Client::builder(
21148/// # hyper_util::rt::TokioExecutor::new()
21149/// # )
21150/// # .build(
21151/// # hyper_rustls::HttpsConnectorBuilder::new()
21152/// # .with_native_roots()
21153/// # .unwrap()
21154/// # .https_or_http()
21155/// # .enable_http2()
21156/// # .build()
21157/// # );
21158/// # let mut hub = Classroom::new(client, auth);
21159/// // You can configure optional parameters by calling the respective setters at will, and
21160/// // execute the final call using `doit()`.
21161/// // Values shown here are possibly random and not representative !
21162/// let result = hub.courses().course_work_materials_add_on_attachments_list("courseId", "itemId")
21163/// .post_id("et")
21164/// .page_token("At")
21165/// .page_size(-4)
21166/// .doit().await;
21167/// # }
21168/// ```
21169pub struct CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C>
21170where
21171 C: 'a,
21172{
21173 hub: &'a Classroom<C>,
21174 _course_id: String,
21175 _item_id: String,
21176 _post_id: Option<String>,
21177 _page_token: Option<String>,
21178 _page_size: Option<i32>,
21179 _delegate: Option<&'a mut dyn common::Delegate>,
21180 _additional_params: HashMap<String, String>,
21181 _scopes: BTreeSet<String>,
21182}
21183
21184impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C> {}
21185
21186impl<'a, C> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C>
21187where
21188 C: common::Connector,
21189{
21190 /// Perform the operation you have build so far.
21191 pub async fn doit(
21192 mut self,
21193 ) -> common::Result<(common::Response, ListAddOnAttachmentsResponse)> {
21194 use std::borrow::Cow;
21195 use std::io::{Read, Seek};
21196
21197 use common::{url::Params, ToParts};
21198 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21199
21200 let mut dd = common::DefaultDelegate;
21201 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21202 dlg.begin(common::MethodInfo {
21203 id: "classroom.courses.courseWorkMaterials.addOnAttachments.list",
21204 http_method: hyper::Method::GET,
21205 });
21206
21207 for &field in [
21208 "alt",
21209 "courseId",
21210 "itemId",
21211 "postId",
21212 "pageToken",
21213 "pageSize",
21214 ]
21215 .iter()
21216 {
21217 if self._additional_params.contains_key(field) {
21218 dlg.finished(false);
21219 return Err(common::Error::FieldClash(field));
21220 }
21221 }
21222
21223 let mut params = Params::with_capacity(7 + self._additional_params.len());
21224 params.push("courseId", self._course_id);
21225 params.push("itemId", self._item_id);
21226 if let Some(value) = self._post_id.as_ref() {
21227 params.push("postId", value);
21228 }
21229 if let Some(value) = self._page_token.as_ref() {
21230 params.push("pageToken", value);
21231 }
21232 if let Some(value) = self._page_size.as_ref() {
21233 params.push("pageSize", value.to_string());
21234 }
21235
21236 params.extend(self._additional_params.iter());
21237
21238 params.push("alt", "json");
21239 let mut url = self.hub._base_url.clone()
21240 + "v1/courses/{courseId}/courseWorkMaterials/{itemId}/addOnAttachments";
21241 if self._scopes.is_empty() {
21242 self._scopes
21243 .insert(Scope::AddonStudent.as_ref().to_string());
21244 }
21245
21246 #[allow(clippy::single_element_loop)]
21247 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{itemId}", "itemId")].iter()
21248 {
21249 url = params.uri_replacement(url, param_name, find_this, false);
21250 }
21251 {
21252 let to_remove = ["itemId", "courseId"];
21253 params.remove_params(&to_remove);
21254 }
21255
21256 let url = params.parse_with_url(&url);
21257
21258 loop {
21259 let token = match self
21260 .hub
21261 .auth
21262 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21263 .await
21264 {
21265 Ok(token) => token,
21266 Err(e) => match dlg.token(e) {
21267 Ok(token) => token,
21268 Err(e) => {
21269 dlg.finished(false);
21270 return Err(common::Error::MissingToken(e));
21271 }
21272 },
21273 };
21274 let mut req_result = {
21275 let client = &self.hub.client;
21276 dlg.pre_request();
21277 let mut req_builder = hyper::Request::builder()
21278 .method(hyper::Method::GET)
21279 .uri(url.as_str())
21280 .header(USER_AGENT, self.hub._user_agent.clone());
21281
21282 if let Some(token) = token.as_ref() {
21283 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21284 }
21285
21286 let request = req_builder
21287 .header(CONTENT_LENGTH, 0_u64)
21288 .body(common::to_body::<String>(None));
21289
21290 client.request(request.unwrap()).await
21291 };
21292
21293 match req_result {
21294 Err(err) => {
21295 if let common::Retry::After(d) = dlg.http_error(&err) {
21296 sleep(d).await;
21297 continue;
21298 }
21299 dlg.finished(false);
21300 return Err(common::Error::HttpError(err));
21301 }
21302 Ok(res) => {
21303 let (mut parts, body) = res.into_parts();
21304 let mut body = common::Body::new(body);
21305 if !parts.status.is_success() {
21306 let bytes = common::to_bytes(body).await.unwrap_or_default();
21307 let error = serde_json::from_str(&common::to_string(&bytes));
21308 let response = common::to_response(parts, bytes.into());
21309
21310 if let common::Retry::After(d) =
21311 dlg.http_failure(&response, error.as_ref().ok())
21312 {
21313 sleep(d).await;
21314 continue;
21315 }
21316
21317 dlg.finished(false);
21318
21319 return Err(match error {
21320 Ok(value) => common::Error::BadRequest(value),
21321 _ => common::Error::Failure(response),
21322 });
21323 }
21324 let response = {
21325 let bytes = common::to_bytes(body).await.unwrap_or_default();
21326 let encoded = common::to_string(&bytes);
21327 match serde_json::from_str(&encoded) {
21328 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21329 Err(error) => {
21330 dlg.response_json_decode_error(&encoded, &error);
21331 return Err(common::Error::JsonDecodeError(
21332 encoded.to_string(),
21333 error,
21334 ));
21335 }
21336 }
21337 };
21338
21339 dlg.finished(true);
21340 return Ok(response);
21341 }
21342 }
21343 }
21344 }
21345
21346 /// Required. Identifier of the course.
21347 ///
21348 /// Sets the *course id* path property to the given value.
21349 ///
21350 /// Even though the property as already been set when instantiating this call,
21351 /// we provide this method for API completeness.
21352 pub fn course_id(
21353 mut self,
21354 new_value: &str,
21355 ) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C> {
21356 self._course_id = new_value.to_string();
21357 self
21358 }
21359 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` whose attachments should be enumerated. This field is required, but is not marked as such while we are migrating from post_id.
21360 ///
21361 /// Sets the *item id* path property to the given value.
21362 ///
21363 /// Even though the property as already been set when instantiating this call,
21364 /// we provide this method for API completeness.
21365 pub fn item_id(
21366 mut self,
21367 new_value: &str,
21368 ) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C> {
21369 self._item_id = new_value.to_string();
21370 self
21371 }
21372 /// Optional. Identifier of the post under the course whose attachments to enumerate. Deprecated, use `item_id` instead.
21373 ///
21374 /// Sets the *post id* query property to the given value.
21375 pub fn post_id(
21376 mut self,
21377 new_value: &str,
21378 ) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C> {
21379 self._post_id = Some(new_value.to_string());
21380 self
21381 }
21382 /// A page token, received from a previous `ListAddOnAttachments` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAddOnAttachments` must match the call that provided the page token.
21383 ///
21384 /// Sets the *page token* query property to the given value.
21385 pub fn page_token(
21386 mut self,
21387 new_value: &str,
21388 ) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C> {
21389 self._page_token = Some(new_value.to_string());
21390 self
21391 }
21392 /// The maximum number of attachments to return. The service may return fewer than this value. If unspecified, at most 20 attachments will be returned. The maximum value is 20; values above 20 will be coerced to 20.
21393 ///
21394 /// Sets the *page size* query property to the given value.
21395 pub fn page_size(
21396 mut self,
21397 new_value: i32,
21398 ) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C> {
21399 self._page_size = Some(new_value);
21400 self
21401 }
21402 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21403 /// while executing the actual API request.
21404 ///
21405 /// ````text
21406 /// It should be used to handle progress information, and to implement a certain level of resilience.
21407 /// ````
21408 ///
21409 /// Sets the *delegate* property to the given value.
21410 pub fn delegate(
21411 mut self,
21412 new_value: &'a mut dyn common::Delegate,
21413 ) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C> {
21414 self._delegate = Some(new_value);
21415 self
21416 }
21417
21418 /// Set any additional parameter of the query string used in the request.
21419 /// It should be used to set parameters which are not yet available through their own
21420 /// setters.
21421 ///
21422 /// Please note that this method must not be used to set any of the known parameters
21423 /// which have their own setter method. If done anyway, the request will fail.
21424 ///
21425 /// # Additional Parameters
21426 ///
21427 /// * *$.xgafv* (query-string) - V1 error format.
21428 /// * *access_token* (query-string) - OAuth access token.
21429 /// * *alt* (query-string) - Data format for response.
21430 /// * *callback* (query-string) - JSONP
21431 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21432 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21433 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21434 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21435 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
21436 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21437 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21438 pub fn param<T>(
21439 mut self,
21440 name: T,
21441 value: T,
21442 ) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C>
21443 where
21444 T: AsRef<str>,
21445 {
21446 self._additional_params
21447 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21448 self
21449 }
21450
21451 /// Identifies the authorization scope for the method you are building.
21452 ///
21453 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21454 /// [`Scope::AddonStudent`].
21455 ///
21456 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21457 /// tokens for more than one scope.
21458 ///
21459 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21460 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21461 /// sufficient, a read-write scope will do as well.
21462 pub fn add_scope<St>(
21463 mut self,
21464 scope: St,
21465 ) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C>
21466 where
21467 St: AsRef<str>,
21468 {
21469 self._scopes.insert(String::from(scope.as_ref()));
21470 self
21471 }
21472 /// Identifies the authorization scope(s) for the method you are building.
21473 ///
21474 /// See [`Self::add_scope()`] for details.
21475 pub fn add_scopes<I, St>(
21476 mut self,
21477 scopes: I,
21478 ) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C>
21479 where
21480 I: IntoIterator<Item = St>,
21481 St: AsRef<str>,
21482 {
21483 self._scopes
21484 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21485 self
21486 }
21487
21488 /// Removes all scopes, and no default scope will be used either.
21489 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21490 /// for details).
21491 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialAddOnAttachmentListCall<'a, C> {
21492 self._scopes.clear();
21493 self
21494 }
21495}
21496
21497/// Updates an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
21498///
21499/// A builder for the *courseWorkMaterials.addOnAttachments.patch* method supported by a *course* resource.
21500/// It is not used directly, but through a [`CourseMethods`] instance.
21501///
21502/// # Example
21503///
21504/// Instantiate a resource method builder
21505///
21506/// ```test_harness,no_run
21507/// # extern crate hyper;
21508/// # extern crate hyper_rustls;
21509/// # extern crate google_classroom1 as classroom1;
21510/// use classroom1::api::AddOnAttachment;
21511/// # async fn dox() {
21512/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21513///
21514/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21515/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21516/// # .with_native_roots()
21517/// # .unwrap()
21518/// # .https_only()
21519/// # .enable_http2()
21520/// # .build();
21521///
21522/// # let executor = hyper_util::rt::TokioExecutor::new();
21523/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21524/// # secret,
21525/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21526/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21527/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21528/// # ),
21529/// # ).build().await.unwrap();
21530///
21531/// # let client = hyper_util::client::legacy::Client::builder(
21532/// # hyper_util::rt::TokioExecutor::new()
21533/// # )
21534/// # .build(
21535/// # hyper_rustls::HttpsConnectorBuilder::new()
21536/// # .with_native_roots()
21537/// # .unwrap()
21538/// # .https_or_http()
21539/// # .enable_http2()
21540/// # .build()
21541/// # );
21542/// # let mut hub = Classroom::new(client, auth);
21543/// // As the method needs a request, you would usually fill it with the desired information
21544/// // into the respective structure. Some of the parts shown here might not be applicable !
21545/// // Values shown here are possibly random and not representative !
21546/// let mut req = AddOnAttachment::default();
21547///
21548/// // You can configure optional parameters by calling the respective setters at will, and
21549/// // execute the final call using `doit()`.
21550/// // Values shown here are possibly random and not representative !
21551/// let result = hub.courses().course_work_materials_add_on_attachments_patch(req, "courseId", "itemId", "attachmentId")
21552/// .update_mask(FieldMask::new::<&str>(&[]))
21553/// .post_id("sea")
21554/// .doit().await;
21555/// # }
21556/// ```
21557pub struct CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C>
21558where
21559 C: 'a,
21560{
21561 hub: &'a Classroom<C>,
21562 _request: AddOnAttachment,
21563 _course_id: String,
21564 _item_id: String,
21565 _attachment_id: String,
21566 _update_mask: Option<common::FieldMask>,
21567 _post_id: Option<String>,
21568 _delegate: Option<&'a mut dyn common::Delegate>,
21569 _additional_params: HashMap<String, String>,
21570 _scopes: BTreeSet<String>,
21571}
21572
21573impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C> {}
21574
21575impl<'a, C> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C>
21576where
21577 C: common::Connector,
21578{
21579 /// Perform the operation you have build so far.
21580 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
21581 use std::borrow::Cow;
21582 use std::io::{Read, Seek};
21583
21584 use common::{url::Params, ToParts};
21585 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21586
21587 let mut dd = common::DefaultDelegate;
21588 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21589 dlg.begin(common::MethodInfo {
21590 id: "classroom.courses.courseWorkMaterials.addOnAttachments.patch",
21591 http_method: hyper::Method::PATCH,
21592 });
21593
21594 for &field in [
21595 "alt",
21596 "courseId",
21597 "itemId",
21598 "attachmentId",
21599 "updateMask",
21600 "postId",
21601 ]
21602 .iter()
21603 {
21604 if self._additional_params.contains_key(field) {
21605 dlg.finished(false);
21606 return Err(common::Error::FieldClash(field));
21607 }
21608 }
21609
21610 let mut params = Params::with_capacity(8 + self._additional_params.len());
21611 params.push("courseId", self._course_id);
21612 params.push("itemId", self._item_id);
21613 params.push("attachmentId", self._attachment_id);
21614 if let Some(value) = self._update_mask.as_ref() {
21615 params.push("updateMask", value.to_string());
21616 }
21617 if let Some(value) = self._post_id.as_ref() {
21618 params.push("postId", value);
21619 }
21620
21621 params.extend(self._additional_params.iter());
21622
21623 params.push("alt", "json");
21624 let mut url = self.hub._base_url.clone()
21625 + "v1/courses/{courseId}/courseWorkMaterials/{itemId}/addOnAttachments/{attachmentId}";
21626 if self._scopes.is_empty() {
21627 self._scopes
21628 .insert(Scope::AddonTeacher.as_ref().to_string());
21629 }
21630
21631 #[allow(clippy::single_element_loop)]
21632 for &(find_this, param_name) in [
21633 ("{courseId}", "courseId"),
21634 ("{itemId}", "itemId"),
21635 ("{attachmentId}", "attachmentId"),
21636 ]
21637 .iter()
21638 {
21639 url = params.uri_replacement(url, param_name, find_this, false);
21640 }
21641 {
21642 let to_remove = ["attachmentId", "itemId", "courseId"];
21643 params.remove_params(&to_remove);
21644 }
21645
21646 let url = params.parse_with_url(&url);
21647
21648 let mut json_mime_type = mime::APPLICATION_JSON;
21649 let mut request_value_reader = {
21650 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21651 common::remove_json_null_values(&mut value);
21652 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21653 serde_json::to_writer(&mut dst, &value).unwrap();
21654 dst
21655 };
21656 let request_size = request_value_reader
21657 .seek(std::io::SeekFrom::End(0))
21658 .unwrap();
21659 request_value_reader
21660 .seek(std::io::SeekFrom::Start(0))
21661 .unwrap();
21662
21663 loop {
21664 let token = match self
21665 .hub
21666 .auth
21667 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21668 .await
21669 {
21670 Ok(token) => token,
21671 Err(e) => match dlg.token(e) {
21672 Ok(token) => token,
21673 Err(e) => {
21674 dlg.finished(false);
21675 return Err(common::Error::MissingToken(e));
21676 }
21677 },
21678 };
21679 request_value_reader
21680 .seek(std::io::SeekFrom::Start(0))
21681 .unwrap();
21682 let mut req_result = {
21683 let client = &self.hub.client;
21684 dlg.pre_request();
21685 let mut req_builder = hyper::Request::builder()
21686 .method(hyper::Method::PATCH)
21687 .uri(url.as_str())
21688 .header(USER_AGENT, self.hub._user_agent.clone());
21689
21690 if let Some(token) = token.as_ref() {
21691 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21692 }
21693
21694 let request = req_builder
21695 .header(CONTENT_TYPE, json_mime_type.to_string())
21696 .header(CONTENT_LENGTH, request_size as u64)
21697 .body(common::to_body(
21698 request_value_reader.get_ref().clone().into(),
21699 ));
21700
21701 client.request(request.unwrap()).await
21702 };
21703
21704 match req_result {
21705 Err(err) => {
21706 if let common::Retry::After(d) = dlg.http_error(&err) {
21707 sleep(d).await;
21708 continue;
21709 }
21710 dlg.finished(false);
21711 return Err(common::Error::HttpError(err));
21712 }
21713 Ok(res) => {
21714 let (mut parts, body) = res.into_parts();
21715 let mut body = common::Body::new(body);
21716 if !parts.status.is_success() {
21717 let bytes = common::to_bytes(body).await.unwrap_or_default();
21718 let error = serde_json::from_str(&common::to_string(&bytes));
21719 let response = common::to_response(parts, bytes.into());
21720
21721 if let common::Retry::After(d) =
21722 dlg.http_failure(&response, error.as_ref().ok())
21723 {
21724 sleep(d).await;
21725 continue;
21726 }
21727
21728 dlg.finished(false);
21729
21730 return Err(match error {
21731 Ok(value) => common::Error::BadRequest(value),
21732 _ => common::Error::Failure(response),
21733 });
21734 }
21735 let response = {
21736 let bytes = common::to_bytes(body).await.unwrap_or_default();
21737 let encoded = common::to_string(&bytes);
21738 match serde_json::from_str(&encoded) {
21739 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21740 Err(error) => {
21741 dlg.response_json_decode_error(&encoded, &error);
21742 return Err(common::Error::JsonDecodeError(
21743 encoded.to_string(),
21744 error,
21745 ));
21746 }
21747 }
21748 };
21749
21750 dlg.finished(true);
21751 return Ok(response);
21752 }
21753 }
21754 }
21755 }
21756
21757 ///
21758 /// Sets the *request* property to the given value.
21759 ///
21760 /// Even though the property as already been set when instantiating this call,
21761 /// we provide this method for API completeness.
21762 pub fn request(
21763 mut self,
21764 new_value: AddOnAttachment,
21765 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C> {
21766 self._request = new_value;
21767 self
21768 }
21769 /// Required. Identifier of the course.
21770 ///
21771 /// Sets the *course id* path property to the given value.
21772 ///
21773 /// Even though the property as already been set when instantiating this call,
21774 /// we provide this method for API completeness.
21775 pub fn course_id(
21776 mut self,
21777 new_value: &str,
21778 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C> {
21779 self._course_id = new_value.to_string();
21780 self
21781 }
21782 /// Identifier of the post under which the attachment is attached.
21783 ///
21784 /// Sets the *item id* path property to the given value.
21785 ///
21786 /// Even though the property as already been set when instantiating this call,
21787 /// we provide this method for API completeness.
21788 pub fn item_id(
21789 mut self,
21790 new_value: &str,
21791 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C> {
21792 self._item_id = new_value.to_string();
21793 self
21794 }
21795 /// Required. Identifier of the attachment.
21796 ///
21797 /// Sets the *attachment id* path property to the given value.
21798 ///
21799 /// Even though the property as already been set when instantiating this call,
21800 /// we provide this method for API completeness.
21801 pub fn attachment_id(
21802 mut self,
21803 new_value: &str,
21804 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C> {
21805 self._attachment_id = new_value.to_string();
21806 self
21807 }
21808 /// Required. Mask that identifies which fields on the attachment to update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the `AddOnAttachment` object. If a field that does not support empty values is included in the update mask and not set in the `AddOnAttachment` object, an `INVALID_ARGUMENT` error is returned. The following fields may be specified by teachers: * `title` * `teacher_view_uri` * `student_view_uri` * `student_work_review_uri` * `due_date` * `due_time` * `max_points`
21809 ///
21810 /// Sets the *update mask* query property to the given value.
21811 pub fn update_mask(
21812 mut self,
21813 new_value: common::FieldMask,
21814 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C> {
21815 self._update_mask = Some(new_value);
21816 self
21817 }
21818 /// Required. Identifier of the post under which the attachment is attached.
21819 ///
21820 /// Sets the *post id* query property to the given value.
21821 pub fn post_id(
21822 mut self,
21823 new_value: &str,
21824 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C> {
21825 self._post_id = Some(new_value.to_string());
21826 self
21827 }
21828 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21829 /// while executing the actual API request.
21830 ///
21831 /// ````text
21832 /// It should be used to handle progress information, and to implement a certain level of resilience.
21833 /// ````
21834 ///
21835 /// Sets the *delegate* property to the given value.
21836 pub fn delegate(
21837 mut self,
21838 new_value: &'a mut dyn common::Delegate,
21839 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C> {
21840 self._delegate = Some(new_value);
21841 self
21842 }
21843
21844 /// Set any additional parameter of the query string used in the request.
21845 /// It should be used to set parameters which are not yet available through their own
21846 /// setters.
21847 ///
21848 /// Please note that this method must not be used to set any of the known parameters
21849 /// which have their own setter method. If done anyway, the request will fail.
21850 ///
21851 /// # Additional Parameters
21852 ///
21853 /// * *$.xgafv* (query-string) - V1 error format.
21854 /// * *access_token* (query-string) - OAuth access token.
21855 /// * *alt* (query-string) - Data format for response.
21856 /// * *callback* (query-string) - JSONP
21857 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21858 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21859 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21860 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21861 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
21862 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21863 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21864 pub fn param<T>(
21865 mut self,
21866 name: T,
21867 value: T,
21868 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C>
21869 where
21870 T: AsRef<str>,
21871 {
21872 self._additional_params
21873 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21874 self
21875 }
21876
21877 /// Identifies the authorization scope for the method you are building.
21878 ///
21879 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21880 /// [`Scope::AddonTeacher`].
21881 ///
21882 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21883 /// tokens for more than one scope.
21884 ///
21885 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21886 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21887 /// sufficient, a read-write scope will do as well.
21888 pub fn add_scope<St>(
21889 mut self,
21890 scope: St,
21891 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C>
21892 where
21893 St: AsRef<str>,
21894 {
21895 self._scopes.insert(String::from(scope.as_ref()));
21896 self
21897 }
21898 /// Identifies the authorization scope(s) for the method you are building.
21899 ///
21900 /// See [`Self::add_scope()`] for details.
21901 pub fn add_scopes<I, St>(
21902 mut self,
21903 scopes: I,
21904 ) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C>
21905 where
21906 I: IntoIterator<Item = St>,
21907 St: AsRef<str>,
21908 {
21909 self._scopes
21910 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21911 self
21912 }
21913
21914 /// Removes all scopes, and no default scope will be used either.
21915 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21916 /// for details).
21917 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialAddOnAttachmentPatchCall<'a, C> {
21918 self._scopes.clear();
21919 self
21920 }
21921}
21922
21923/// Creates a course work material. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create course work material in the requested course, share a Drive attachment, or for access errors. * `INVALID_ARGUMENT` if the request is malformed or if more than 20 * materials are provided. * `NOT_FOUND` if the requested course does not exist. * `FAILED_PRECONDITION` for the following request error: * AttachmentNotVisible
21924///
21925/// A builder for the *courseWorkMaterials.create* method supported by a *course* resource.
21926/// It is not used directly, but through a [`CourseMethods`] instance.
21927///
21928/// # Example
21929///
21930/// Instantiate a resource method builder
21931///
21932/// ```test_harness,no_run
21933/// # extern crate hyper;
21934/// # extern crate hyper_rustls;
21935/// # extern crate google_classroom1 as classroom1;
21936/// use classroom1::api::CourseWorkMaterial;
21937/// # async fn dox() {
21938/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21939///
21940/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21941/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21942/// # .with_native_roots()
21943/// # .unwrap()
21944/// # .https_only()
21945/// # .enable_http2()
21946/// # .build();
21947///
21948/// # let executor = hyper_util::rt::TokioExecutor::new();
21949/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21950/// # secret,
21951/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21952/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21953/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21954/// # ),
21955/// # ).build().await.unwrap();
21956///
21957/// # let client = hyper_util::client::legacy::Client::builder(
21958/// # hyper_util::rt::TokioExecutor::new()
21959/// # )
21960/// # .build(
21961/// # hyper_rustls::HttpsConnectorBuilder::new()
21962/// # .with_native_roots()
21963/// # .unwrap()
21964/// # .https_or_http()
21965/// # .enable_http2()
21966/// # .build()
21967/// # );
21968/// # let mut hub = Classroom::new(client, auth);
21969/// // As the method needs a request, you would usually fill it with the desired information
21970/// // into the respective structure. Some of the parts shown here might not be applicable !
21971/// // Values shown here are possibly random and not representative !
21972/// let mut req = CourseWorkMaterial::default();
21973///
21974/// // You can configure optional parameters by calling the respective setters at will, and
21975/// // execute the final call using `doit()`.
21976/// // Values shown here are possibly random and not representative !
21977/// let result = hub.courses().course_work_materials_create(req, "courseId")
21978/// .doit().await;
21979/// # }
21980/// ```
21981pub struct CourseCourseWorkMaterialCreateCall<'a, C>
21982where
21983 C: 'a,
21984{
21985 hub: &'a Classroom<C>,
21986 _request: CourseWorkMaterial,
21987 _course_id: String,
21988 _delegate: Option<&'a mut dyn common::Delegate>,
21989 _additional_params: HashMap<String, String>,
21990 _scopes: BTreeSet<String>,
21991}
21992
21993impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialCreateCall<'a, C> {}
21994
21995impl<'a, C> CourseCourseWorkMaterialCreateCall<'a, C>
21996where
21997 C: common::Connector,
21998{
21999 /// Perform the operation you have build so far.
22000 pub async fn doit(mut self) -> common::Result<(common::Response, CourseWorkMaterial)> {
22001 use std::borrow::Cow;
22002 use std::io::{Read, Seek};
22003
22004 use common::{url::Params, ToParts};
22005 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22006
22007 let mut dd = common::DefaultDelegate;
22008 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22009 dlg.begin(common::MethodInfo {
22010 id: "classroom.courses.courseWorkMaterials.create",
22011 http_method: hyper::Method::POST,
22012 });
22013
22014 for &field in ["alt", "courseId"].iter() {
22015 if self._additional_params.contains_key(field) {
22016 dlg.finished(false);
22017 return Err(common::Error::FieldClash(field));
22018 }
22019 }
22020
22021 let mut params = Params::with_capacity(4 + self._additional_params.len());
22022 params.push("courseId", self._course_id);
22023
22024 params.extend(self._additional_params.iter());
22025
22026 params.push("alt", "json");
22027 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWorkMaterials";
22028 if self._scopes.is_empty() {
22029 self._scopes
22030 .insert(Scope::Courseworkmaterial.as_ref().to_string());
22031 }
22032
22033 #[allow(clippy::single_element_loop)]
22034 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
22035 url = params.uri_replacement(url, param_name, find_this, false);
22036 }
22037 {
22038 let to_remove = ["courseId"];
22039 params.remove_params(&to_remove);
22040 }
22041
22042 let url = params.parse_with_url(&url);
22043
22044 let mut json_mime_type = mime::APPLICATION_JSON;
22045 let mut request_value_reader = {
22046 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22047 common::remove_json_null_values(&mut value);
22048 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22049 serde_json::to_writer(&mut dst, &value).unwrap();
22050 dst
22051 };
22052 let request_size = request_value_reader
22053 .seek(std::io::SeekFrom::End(0))
22054 .unwrap();
22055 request_value_reader
22056 .seek(std::io::SeekFrom::Start(0))
22057 .unwrap();
22058
22059 loop {
22060 let token = match self
22061 .hub
22062 .auth
22063 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22064 .await
22065 {
22066 Ok(token) => token,
22067 Err(e) => match dlg.token(e) {
22068 Ok(token) => token,
22069 Err(e) => {
22070 dlg.finished(false);
22071 return Err(common::Error::MissingToken(e));
22072 }
22073 },
22074 };
22075 request_value_reader
22076 .seek(std::io::SeekFrom::Start(0))
22077 .unwrap();
22078 let mut req_result = {
22079 let client = &self.hub.client;
22080 dlg.pre_request();
22081 let mut req_builder = hyper::Request::builder()
22082 .method(hyper::Method::POST)
22083 .uri(url.as_str())
22084 .header(USER_AGENT, self.hub._user_agent.clone());
22085
22086 if let Some(token) = token.as_ref() {
22087 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22088 }
22089
22090 let request = req_builder
22091 .header(CONTENT_TYPE, json_mime_type.to_string())
22092 .header(CONTENT_LENGTH, request_size as u64)
22093 .body(common::to_body(
22094 request_value_reader.get_ref().clone().into(),
22095 ));
22096
22097 client.request(request.unwrap()).await
22098 };
22099
22100 match req_result {
22101 Err(err) => {
22102 if let common::Retry::After(d) = dlg.http_error(&err) {
22103 sleep(d).await;
22104 continue;
22105 }
22106 dlg.finished(false);
22107 return Err(common::Error::HttpError(err));
22108 }
22109 Ok(res) => {
22110 let (mut parts, body) = res.into_parts();
22111 let mut body = common::Body::new(body);
22112 if !parts.status.is_success() {
22113 let bytes = common::to_bytes(body).await.unwrap_or_default();
22114 let error = serde_json::from_str(&common::to_string(&bytes));
22115 let response = common::to_response(parts, bytes.into());
22116
22117 if let common::Retry::After(d) =
22118 dlg.http_failure(&response, error.as_ref().ok())
22119 {
22120 sleep(d).await;
22121 continue;
22122 }
22123
22124 dlg.finished(false);
22125
22126 return Err(match error {
22127 Ok(value) => common::Error::BadRequest(value),
22128 _ => common::Error::Failure(response),
22129 });
22130 }
22131 let response = {
22132 let bytes = common::to_bytes(body).await.unwrap_or_default();
22133 let encoded = common::to_string(&bytes);
22134 match serde_json::from_str(&encoded) {
22135 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22136 Err(error) => {
22137 dlg.response_json_decode_error(&encoded, &error);
22138 return Err(common::Error::JsonDecodeError(
22139 encoded.to_string(),
22140 error,
22141 ));
22142 }
22143 }
22144 };
22145
22146 dlg.finished(true);
22147 return Ok(response);
22148 }
22149 }
22150 }
22151 }
22152
22153 ///
22154 /// Sets the *request* property to the given value.
22155 ///
22156 /// Even though the property as already been set when instantiating this call,
22157 /// we provide this method for API completeness.
22158 pub fn request(
22159 mut self,
22160 new_value: CourseWorkMaterial,
22161 ) -> CourseCourseWorkMaterialCreateCall<'a, C> {
22162 self._request = new_value;
22163 self
22164 }
22165 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
22166 ///
22167 /// Sets the *course id* path property to the given value.
22168 ///
22169 /// Even though the property as already been set when instantiating this call,
22170 /// we provide this method for API completeness.
22171 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkMaterialCreateCall<'a, C> {
22172 self._course_id = new_value.to_string();
22173 self
22174 }
22175 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22176 /// while executing the actual API request.
22177 ///
22178 /// ````text
22179 /// It should be used to handle progress information, and to implement a certain level of resilience.
22180 /// ````
22181 ///
22182 /// Sets the *delegate* property to the given value.
22183 pub fn delegate(
22184 mut self,
22185 new_value: &'a mut dyn common::Delegate,
22186 ) -> CourseCourseWorkMaterialCreateCall<'a, C> {
22187 self._delegate = Some(new_value);
22188 self
22189 }
22190
22191 /// Set any additional parameter of the query string used in the request.
22192 /// It should be used to set parameters which are not yet available through their own
22193 /// setters.
22194 ///
22195 /// Please note that this method must not be used to set any of the known parameters
22196 /// which have their own setter method. If done anyway, the request will fail.
22197 ///
22198 /// # Additional Parameters
22199 ///
22200 /// * *$.xgafv* (query-string) - V1 error format.
22201 /// * *access_token* (query-string) - OAuth access token.
22202 /// * *alt* (query-string) - Data format for response.
22203 /// * *callback* (query-string) - JSONP
22204 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22205 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22206 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22207 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22208 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
22209 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22210 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22211 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkMaterialCreateCall<'a, C>
22212 where
22213 T: AsRef<str>,
22214 {
22215 self._additional_params
22216 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22217 self
22218 }
22219
22220 /// Identifies the authorization scope for the method you are building.
22221 ///
22222 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22223 /// [`Scope::Courseworkmaterial`].
22224 ///
22225 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22226 /// tokens for more than one scope.
22227 ///
22228 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22229 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22230 /// sufficient, a read-write scope will do as well.
22231 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkMaterialCreateCall<'a, C>
22232 where
22233 St: AsRef<str>,
22234 {
22235 self._scopes.insert(String::from(scope.as_ref()));
22236 self
22237 }
22238 /// Identifies the authorization scope(s) for the method you are building.
22239 ///
22240 /// See [`Self::add_scope()`] for details.
22241 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkMaterialCreateCall<'a, C>
22242 where
22243 I: IntoIterator<Item = St>,
22244 St: AsRef<str>,
22245 {
22246 self._scopes
22247 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22248 self
22249 }
22250
22251 /// Removes all scopes, and no default scope will be used either.
22252 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22253 /// for details).
22254 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialCreateCall<'a, C> {
22255 self._scopes.clear();
22256 self
22257 }
22258}
22259
22260/// Deletes a course work material. This request must be made by the Developer Console project of the [OAuth client ID](https://support.google.com/cloud/answer/6158849) used to create the corresponding course work material item. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding course work material, if the requesting user is not permitted to delete the requested course or for access errors. * `FAILED_PRECONDITION` if the requested course work material has already been deleted. * `NOT_FOUND` if no course exists with the requested ID.
22261///
22262/// A builder for the *courseWorkMaterials.delete* method supported by a *course* resource.
22263/// It is not used directly, but through a [`CourseMethods`] instance.
22264///
22265/// # Example
22266///
22267/// Instantiate a resource method builder
22268///
22269/// ```test_harness,no_run
22270/// # extern crate hyper;
22271/// # extern crate hyper_rustls;
22272/// # extern crate google_classroom1 as classroom1;
22273/// # async fn dox() {
22274/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22275///
22276/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22277/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22278/// # .with_native_roots()
22279/// # .unwrap()
22280/// # .https_only()
22281/// # .enable_http2()
22282/// # .build();
22283///
22284/// # let executor = hyper_util::rt::TokioExecutor::new();
22285/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22286/// # secret,
22287/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22288/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22289/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22290/// # ),
22291/// # ).build().await.unwrap();
22292///
22293/// # let client = hyper_util::client::legacy::Client::builder(
22294/// # hyper_util::rt::TokioExecutor::new()
22295/// # )
22296/// # .build(
22297/// # hyper_rustls::HttpsConnectorBuilder::new()
22298/// # .with_native_roots()
22299/// # .unwrap()
22300/// # .https_or_http()
22301/// # .enable_http2()
22302/// # .build()
22303/// # );
22304/// # let mut hub = Classroom::new(client, auth);
22305/// // You can configure optional parameters by calling the respective setters at will, and
22306/// // execute the final call using `doit()`.
22307/// // Values shown here are possibly random and not representative !
22308/// let result = hub.courses().course_work_materials_delete("courseId", "id")
22309/// .doit().await;
22310/// # }
22311/// ```
22312pub struct CourseCourseWorkMaterialDeleteCall<'a, C>
22313where
22314 C: 'a,
22315{
22316 hub: &'a Classroom<C>,
22317 _course_id: String,
22318 _id: String,
22319 _delegate: Option<&'a mut dyn common::Delegate>,
22320 _additional_params: HashMap<String, String>,
22321 _scopes: BTreeSet<String>,
22322}
22323
22324impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialDeleteCall<'a, C> {}
22325
22326impl<'a, C> CourseCourseWorkMaterialDeleteCall<'a, C>
22327where
22328 C: common::Connector,
22329{
22330 /// Perform the operation you have build so far.
22331 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
22332 use std::borrow::Cow;
22333 use std::io::{Read, Seek};
22334
22335 use common::{url::Params, ToParts};
22336 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22337
22338 let mut dd = common::DefaultDelegate;
22339 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22340 dlg.begin(common::MethodInfo {
22341 id: "classroom.courses.courseWorkMaterials.delete",
22342 http_method: hyper::Method::DELETE,
22343 });
22344
22345 for &field in ["alt", "courseId", "id"].iter() {
22346 if self._additional_params.contains_key(field) {
22347 dlg.finished(false);
22348 return Err(common::Error::FieldClash(field));
22349 }
22350 }
22351
22352 let mut params = Params::with_capacity(4 + self._additional_params.len());
22353 params.push("courseId", self._course_id);
22354 params.push("id", self._id);
22355
22356 params.extend(self._additional_params.iter());
22357
22358 params.push("alt", "json");
22359 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWorkMaterials/{id}";
22360 if self._scopes.is_empty() {
22361 self._scopes
22362 .insert(Scope::Courseworkmaterial.as_ref().to_string());
22363 }
22364
22365 #[allow(clippy::single_element_loop)]
22366 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
22367 url = params.uri_replacement(url, param_name, find_this, false);
22368 }
22369 {
22370 let to_remove = ["id", "courseId"];
22371 params.remove_params(&to_remove);
22372 }
22373
22374 let url = params.parse_with_url(&url);
22375
22376 loop {
22377 let token = match self
22378 .hub
22379 .auth
22380 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22381 .await
22382 {
22383 Ok(token) => token,
22384 Err(e) => match dlg.token(e) {
22385 Ok(token) => token,
22386 Err(e) => {
22387 dlg.finished(false);
22388 return Err(common::Error::MissingToken(e));
22389 }
22390 },
22391 };
22392 let mut req_result = {
22393 let client = &self.hub.client;
22394 dlg.pre_request();
22395 let mut req_builder = hyper::Request::builder()
22396 .method(hyper::Method::DELETE)
22397 .uri(url.as_str())
22398 .header(USER_AGENT, self.hub._user_agent.clone());
22399
22400 if let Some(token) = token.as_ref() {
22401 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22402 }
22403
22404 let request = req_builder
22405 .header(CONTENT_LENGTH, 0_u64)
22406 .body(common::to_body::<String>(None));
22407
22408 client.request(request.unwrap()).await
22409 };
22410
22411 match req_result {
22412 Err(err) => {
22413 if let common::Retry::After(d) = dlg.http_error(&err) {
22414 sleep(d).await;
22415 continue;
22416 }
22417 dlg.finished(false);
22418 return Err(common::Error::HttpError(err));
22419 }
22420 Ok(res) => {
22421 let (mut parts, body) = res.into_parts();
22422 let mut body = common::Body::new(body);
22423 if !parts.status.is_success() {
22424 let bytes = common::to_bytes(body).await.unwrap_or_default();
22425 let error = serde_json::from_str(&common::to_string(&bytes));
22426 let response = common::to_response(parts, bytes.into());
22427
22428 if let common::Retry::After(d) =
22429 dlg.http_failure(&response, error.as_ref().ok())
22430 {
22431 sleep(d).await;
22432 continue;
22433 }
22434
22435 dlg.finished(false);
22436
22437 return Err(match error {
22438 Ok(value) => common::Error::BadRequest(value),
22439 _ => common::Error::Failure(response),
22440 });
22441 }
22442 let response = {
22443 let bytes = common::to_bytes(body).await.unwrap_or_default();
22444 let encoded = common::to_string(&bytes);
22445 match serde_json::from_str(&encoded) {
22446 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22447 Err(error) => {
22448 dlg.response_json_decode_error(&encoded, &error);
22449 return Err(common::Error::JsonDecodeError(
22450 encoded.to_string(),
22451 error,
22452 ));
22453 }
22454 }
22455 };
22456
22457 dlg.finished(true);
22458 return Ok(response);
22459 }
22460 }
22461 }
22462 }
22463
22464 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
22465 ///
22466 /// Sets the *course id* path property to the given value.
22467 ///
22468 /// Even though the property as already been set when instantiating this call,
22469 /// we provide this method for API completeness.
22470 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkMaterialDeleteCall<'a, C> {
22471 self._course_id = new_value.to_string();
22472 self
22473 }
22474 /// Identifier of the course work material to delete. This identifier is a Classroom-assigned identifier.
22475 ///
22476 /// Sets the *id* path property to the given value.
22477 ///
22478 /// Even though the property as already been set when instantiating this call,
22479 /// we provide this method for API completeness.
22480 pub fn id(mut self, new_value: &str) -> CourseCourseWorkMaterialDeleteCall<'a, C> {
22481 self._id = new_value.to_string();
22482 self
22483 }
22484 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22485 /// while executing the actual API request.
22486 ///
22487 /// ````text
22488 /// It should be used to handle progress information, and to implement a certain level of resilience.
22489 /// ````
22490 ///
22491 /// Sets the *delegate* property to the given value.
22492 pub fn delegate(
22493 mut self,
22494 new_value: &'a mut dyn common::Delegate,
22495 ) -> CourseCourseWorkMaterialDeleteCall<'a, C> {
22496 self._delegate = Some(new_value);
22497 self
22498 }
22499
22500 /// Set any additional parameter of the query string used in the request.
22501 /// It should be used to set parameters which are not yet available through their own
22502 /// setters.
22503 ///
22504 /// Please note that this method must not be used to set any of the known parameters
22505 /// which have their own setter method. If done anyway, the request will fail.
22506 ///
22507 /// # Additional Parameters
22508 ///
22509 /// * *$.xgafv* (query-string) - V1 error format.
22510 /// * *access_token* (query-string) - OAuth access token.
22511 /// * *alt* (query-string) - Data format for response.
22512 /// * *callback* (query-string) - JSONP
22513 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22514 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22515 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22516 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22517 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
22518 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22519 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22520 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkMaterialDeleteCall<'a, C>
22521 where
22522 T: AsRef<str>,
22523 {
22524 self._additional_params
22525 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22526 self
22527 }
22528
22529 /// Identifies the authorization scope for the method you are building.
22530 ///
22531 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22532 /// [`Scope::Courseworkmaterial`].
22533 ///
22534 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22535 /// tokens for more than one scope.
22536 ///
22537 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22538 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22539 /// sufficient, a read-write scope will do as well.
22540 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkMaterialDeleteCall<'a, C>
22541 where
22542 St: AsRef<str>,
22543 {
22544 self._scopes.insert(String::from(scope.as_ref()));
22545 self
22546 }
22547 /// Identifies the authorization scope(s) for the method you are building.
22548 ///
22549 /// See [`Self::add_scope()`] for details.
22550 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkMaterialDeleteCall<'a, C>
22551 where
22552 I: IntoIterator<Item = St>,
22553 St: AsRef<str>,
22554 {
22555 self._scopes
22556 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22557 self
22558 }
22559
22560 /// Removes all scopes, and no default scope will be used either.
22561 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22562 /// for details).
22563 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialDeleteCall<'a, C> {
22564 self._scopes.clear();
22565 self
22566 }
22567}
22568
22569/// Returns a course work material. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or course work material, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or course work material does not exist.
22570///
22571/// A builder for the *courseWorkMaterials.get* method supported by a *course* resource.
22572/// It is not used directly, but through a [`CourseMethods`] instance.
22573///
22574/// # Example
22575///
22576/// Instantiate a resource method builder
22577///
22578/// ```test_harness,no_run
22579/// # extern crate hyper;
22580/// # extern crate hyper_rustls;
22581/// # extern crate google_classroom1 as classroom1;
22582/// # async fn dox() {
22583/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22584///
22585/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22586/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22587/// # .with_native_roots()
22588/// # .unwrap()
22589/// # .https_only()
22590/// # .enable_http2()
22591/// # .build();
22592///
22593/// # let executor = hyper_util::rt::TokioExecutor::new();
22594/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22595/// # secret,
22596/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22597/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22598/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22599/// # ),
22600/// # ).build().await.unwrap();
22601///
22602/// # let client = hyper_util::client::legacy::Client::builder(
22603/// # hyper_util::rt::TokioExecutor::new()
22604/// # )
22605/// # .build(
22606/// # hyper_rustls::HttpsConnectorBuilder::new()
22607/// # .with_native_roots()
22608/// # .unwrap()
22609/// # .https_or_http()
22610/// # .enable_http2()
22611/// # .build()
22612/// # );
22613/// # let mut hub = Classroom::new(client, auth);
22614/// // You can configure optional parameters by calling the respective setters at will, and
22615/// // execute the final call using `doit()`.
22616/// // Values shown here are possibly random and not representative !
22617/// let result = hub.courses().course_work_materials_get("courseId", "id")
22618/// .doit().await;
22619/// # }
22620/// ```
22621pub struct CourseCourseWorkMaterialGetCall<'a, C>
22622where
22623 C: 'a,
22624{
22625 hub: &'a Classroom<C>,
22626 _course_id: String,
22627 _id: String,
22628 _delegate: Option<&'a mut dyn common::Delegate>,
22629 _additional_params: HashMap<String, String>,
22630 _scopes: BTreeSet<String>,
22631}
22632
22633impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialGetCall<'a, C> {}
22634
22635impl<'a, C> CourseCourseWorkMaterialGetCall<'a, C>
22636where
22637 C: common::Connector,
22638{
22639 /// Perform the operation you have build so far.
22640 pub async fn doit(mut self) -> common::Result<(common::Response, CourseWorkMaterial)> {
22641 use std::borrow::Cow;
22642 use std::io::{Read, Seek};
22643
22644 use common::{url::Params, ToParts};
22645 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22646
22647 let mut dd = common::DefaultDelegate;
22648 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22649 dlg.begin(common::MethodInfo {
22650 id: "classroom.courses.courseWorkMaterials.get",
22651 http_method: hyper::Method::GET,
22652 });
22653
22654 for &field in ["alt", "courseId", "id"].iter() {
22655 if self._additional_params.contains_key(field) {
22656 dlg.finished(false);
22657 return Err(common::Error::FieldClash(field));
22658 }
22659 }
22660
22661 let mut params = Params::with_capacity(4 + self._additional_params.len());
22662 params.push("courseId", self._course_id);
22663 params.push("id", self._id);
22664
22665 params.extend(self._additional_params.iter());
22666
22667 params.push("alt", "json");
22668 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWorkMaterials/{id}";
22669 if self._scopes.is_empty() {
22670 self._scopes
22671 .insert(Scope::CourseworkmaterialReadonly.as_ref().to_string());
22672 }
22673
22674 #[allow(clippy::single_element_loop)]
22675 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
22676 url = params.uri_replacement(url, param_name, find_this, false);
22677 }
22678 {
22679 let to_remove = ["id", "courseId"];
22680 params.remove_params(&to_remove);
22681 }
22682
22683 let url = params.parse_with_url(&url);
22684
22685 loop {
22686 let token = match self
22687 .hub
22688 .auth
22689 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22690 .await
22691 {
22692 Ok(token) => token,
22693 Err(e) => match dlg.token(e) {
22694 Ok(token) => token,
22695 Err(e) => {
22696 dlg.finished(false);
22697 return Err(common::Error::MissingToken(e));
22698 }
22699 },
22700 };
22701 let mut req_result = {
22702 let client = &self.hub.client;
22703 dlg.pre_request();
22704 let mut req_builder = hyper::Request::builder()
22705 .method(hyper::Method::GET)
22706 .uri(url.as_str())
22707 .header(USER_AGENT, self.hub._user_agent.clone());
22708
22709 if let Some(token) = token.as_ref() {
22710 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22711 }
22712
22713 let request = req_builder
22714 .header(CONTENT_LENGTH, 0_u64)
22715 .body(common::to_body::<String>(None));
22716
22717 client.request(request.unwrap()).await
22718 };
22719
22720 match req_result {
22721 Err(err) => {
22722 if let common::Retry::After(d) = dlg.http_error(&err) {
22723 sleep(d).await;
22724 continue;
22725 }
22726 dlg.finished(false);
22727 return Err(common::Error::HttpError(err));
22728 }
22729 Ok(res) => {
22730 let (mut parts, body) = res.into_parts();
22731 let mut body = common::Body::new(body);
22732 if !parts.status.is_success() {
22733 let bytes = common::to_bytes(body).await.unwrap_or_default();
22734 let error = serde_json::from_str(&common::to_string(&bytes));
22735 let response = common::to_response(parts, bytes.into());
22736
22737 if let common::Retry::After(d) =
22738 dlg.http_failure(&response, error.as_ref().ok())
22739 {
22740 sleep(d).await;
22741 continue;
22742 }
22743
22744 dlg.finished(false);
22745
22746 return Err(match error {
22747 Ok(value) => common::Error::BadRequest(value),
22748 _ => common::Error::Failure(response),
22749 });
22750 }
22751 let response = {
22752 let bytes = common::to_bytes(body).await.unwrap_or_default();
22753 let encoded = common::to_string(&bytes);
22754 match serde_json::from_str(&encoded) {
22755 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22756 Err(error) => {
22757 dlg.response_json_decode_error(&encoded, &error);
22758 return Err(common::Error::JsonDecodeError(
22759 encoded.to_string(),
22760 error,
22761 ));
22762 }
22763 }
22764 };
22765
22766 dlg.finished(true);
22767 return Ok(response);
22768 }
22769 }
22770 }
22771 }
22772
22773 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
22774 ///
22775 /// Sets the *course id* path property to the given value.
22776 ///
22777 /// Even though the property as already been set when instantiating this call,
22778 /// we provide this method for API completeness.
22779 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkMaterialGetCall<'a, C> {
22780 self._course_id = new_value.to_string();
22781 self
22782 }
22783 /// Identifier of the course work material.
22784 ///
22785 /// Sets the *id* path property to the given value.
22786 ///
22787 /// Even though the property as already been set when instantiating this call,
22788 /// we provide this method for API completeness.
22789 pub fn id(mut self, new_value: &str) -> CourseCourseWorkMaterialGetCall<'a, C> {
22790 self._id = new_value.to_string();
22791 self
22792 }
22793 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22794 /// while executing the actual API request.
22795 ///
22796 /// ````text
22797 /// It should be used to handle progress information, and to implement a certain level of resilience.
22798 /// ````
22799 ///
22800 /// Sets the *delegate* property to the given value.
22801 pub fn delegate(
22802 mut self,
22803 new_value: &'a mut dyn common::Delegate,
22804 ) -> CourseCourseWorkMaterialGetCall<'a, C> {
22805 self._delegate = Some(new_value);
22806 self
22807 }
22808
22809 /// Set any additional parameter of the query string used in the request.
22810 /// It should be used to set parameters which are not yet available through their own
22811 /// setters.
22812 ///
22813 /// Please note that this method must not be used to set any of the known parameters
22814 /// which have their own setter method. If done anyway, the request will fail.
22815 ///
22816 /// # Additional Parameters
22817 ///
22818 /// * *$.xgafv* (query-string) - V1 error format.
22819 /// * *access_token* (query-string) - OAuth access token.
22820 /// * *alt* (query-string) - Data format for response.
22821 /// * *callback* (query-string) - JSONP
22822 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22823 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22824 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22825 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22826 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
22827 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22828 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22829 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkMaterialGetCall<'a, C>
22830 where
22831 T: AsRef<str>,
22832 {
22833 self._additional_params
22834 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22835 self
22836 }
22837
22838 /// Identifies the authorization scope for the method you are building.
22839 ///
22840 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22841 /// [`Scope::CourseworkmaterialReadonly`].
22842 ///
22843 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22844 /// tokens for more than one scope.
22845 ///
22846 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22847 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22848 /// sufficient, a read-write scope will do as well.
22849 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkMaterialGetCall<'a, C>
22850 where
22851 St: AsRef<str>,
22852 {
22853 self._scopes.insert(String::from(scope.as_ref()));
22854 self
22855 }
22856 /// Identifies the authorization scope(s) for the method you are building.
22857 ///
22858 /// See [`Self::add_scope()`] for details.
22859 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkMaterialGetCall<'a, C>
22860 where
22861 I: IntoIterator<Item = St>,
22862 St: AsRef<str>,
22863 {
22864 self._scopes
22865 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22866 self
22867 }
22868
22869 /// Removes all scopes, and no default scope will be used either.
22870 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22871 /// for details).
22872 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialGetCall<'a, C> {
22873 self._scopes.clear();
22874 self
22875 }
22876}
22877
22878/// Gets metadata for Classroom add-ons in the context of a specific post. To maintain the integrity of its own data and permissions model, an add-on should call this to validate query parameters and the requesting user's role whenever the add-on is opened in an [iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/iframes-overview). This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
22879///
22880/// A builder for the *courseWorkMaterials.getAddOnContext* method supported by a *course* resource.
22881/// It is not used directly, but through a [`CourseMethods`] instance.
22882///
22883/// # Example
22884///
22885/// Instantiate a resource method builder
22886///
22887/// ```test_harness,no_run
22888/// # extern crate hyper;
22889/// # extern crate hyper_rustls;
22890/// # extern crate google_classroom1 as classroom1;
22891/// # async fn dox() {
22892/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22893///
22894/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22895/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22896/// # .with_native_roots()
22897/// # .unwrap()
22898/// # .https_only()
22899/// # .enable_http2()
22900/// # .build();
22901///
22902/// # let executor = hyper_util::rt::TokioExecutor::new();
22903/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22904/// # secret,
22905/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22906/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22907/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22908/// # ),
22909/// # ).build().await.unwrap();
22910///
22911/// # let client = hyper_util::client::legacy::Client::builder(
22912/// # hyper_util::rt::TokioExecutor::new()
22913/// # )
22914/// # .build(
22915/// # hyper_rustls::HttpsConnectorBuilder::new()
22916/// # .with_native_roots()
22917/// # .unwrap()
22918/// # .https_or_http()
22919/// # .enable_http2()
22920/// # .build()
22921/// # );
22922/// # let mut hub = Classroom::new(client, auth);
22923/// // You can configure optional parameters by calling the respective setters at will, and
22924/// // execute the final call using `doit()`.
22925/// // Values shown here are possibly random and not representative !
22926/// let result = hub.courses().course_work_materials_get_add_on_context("courseId", "itemId")
22927/// .post_id("aliquyam")
22928/// .attachment_id("eos")
22929/// .add_on_token("At")
22930/// .doit().await;
22931/// # }
22932/// ```
22933pub struct CourseCourseWorkMaterialGetAddOnContextCall<'a, C>
22934where
22935 C: 'a,
22936{
22937 hub: &'a Classroom<C>,
22938 _course_id: String,
22939 _item_id: String,
22940 _post_id: Option<String>,
22941 _attachment_id: Option<String>,
22942 _add_on_token: Option<String>,
22943 _delegate: Option<&'a mut dyn common::Delegate>,
22944 _additional_params: HashMap<String, String>,
22945 _scopes: BTreeSet<String>,
22946}
22947
22948impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialGetAddOnContextCall<'a, C> {}
22949
22950impl<'a, C> CourseCourseWorkMaterialGetAddOnContextCall<'a, C>
22951where
22952 C: common::Connector,
22953{
22954 /// Perform the operation you have build so far.
22955 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnContext)> {
22956 use std::borrow::Cow;
22957 use std::io::{Read, Seek};
22958
22959 use common::{url::Params, ToParts};
22960 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22961
22962 let mut dd = common::DefaultDelegate;
22963 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22964 dlg.begin(common::MethodInfo {
22965 id: "classroom.courses.courseWorkMaterials.getAddOnContext",
22966 http_method: hyper::Method::GET,
22967 });
22968
22969 for &field in [
22970 "alt",
22971 "courseId",
22972 "itemId",
22973 "postId",
22974 "attachmentId",
22975 "addOnToken",
22976 ]
22977 .iter()
22978 {
22979 if self._additional_params.contains_key(field) {
22980 dlg.finished(false);
22981 return Err(common::Error::FieldClash(field));
22982 }
22983 }
22984
22985 let mut params = Params::with_capacity(7 + self._additional_params.len());
22986 params.push("courseId", self._course_id);
22987 params.push("itemId", self._item_id);
22988 if let Some(value) = self._post_id.as_ref() {
22989 params.push("postId", value);
22990 }
22991 if let Some(value) = self._attachment_id.as_ref() {
22992 params.push("attachmentId", value);
22993 }
22994 if let Some(value) = self._add_on_token.as_ref() {
22995 params.push("addOnToken", value);
22996 }
22997
22998 params.extend(self._additional_params.iter());
22999
23000 params.push("alt", "json");
23001 let mut url = self.hub._base_url.clone()
23002 + "v1/courses/{courseId}/courseWorkMaterials/{itemId}/addOnContext";
23003 if self._scopes.is_empty() {
23004 self._scopes
23005 .insert(Scope::AddonStudent.as_ref().to_string());
23006 }
23007
23008 #[allow(clippy::single_element_loop)]
23009 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{itemId}", "itemId")].iter()
23010 {
23011 url = params.uri_replacement(url, param_name, find_this, false);
23012 }
23013 {
23014 let to_remove = ["itemId", "courseId"];
23015 params.remove_params(&to_remove);
23016 }
23017
23018 let url = params.parse_with_url(&url);
23019
23020 loop {
23021 let token = match self
23022 .hub
23023 .auth
23024 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23025 .await
23026 {
23027 Ok(token) => token,
23028 Err(e) => match dlg.token(e) {
23029 Ok(token) => token,
23030 Err(e) => {
23031 dlg.finished(false);
23032 return Err(common::Error::MissingToken(e));
23033 }
23034 },
23035 };
23036 let mut req_result = {
23037 let client = &self.hub.client;
23038 dlg.pre_request();
23039 let mut req_builder = hyper::Request::builder()
23040 .method(hyper::Method::GET)
23041 .uri(url.as_str())
23042 .header(USER_AGENT, self.hub._user_agent.clone());
23043
23044 if let Some(token) = token.as_ref() {
23045 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23046 }
23047
23048 let request = req_builder
23049 .header(CONTENT_LENGTH, 0_u64)
23050 .body(common::to_body::<String>(None));
23051
23052 client.request(request.unwrap()).await
23053 };
23054
23055 match req_result {
23056 Err(err) => {
23057 if let common::Retry::After(d) = dlg.http_error(&err) {
23058 sleep(d).await;
23059 continue;
23060 }
23061 dlg.finished(false);
23062 return Err(common::Error::HttpError(err));
23063 }
23064 Ok(res) => {
23065 let (mut parts, body) = res.into_parts();
23066 let mut body = common::Body::new(body);
23067 if !parts.status.is_success() {
23068 let bytes = common::to_bytes(body).await.unwrap_or_default();
23069 let error = serde_json::from_str(&common::to_string(&bytes));
23070 let response = common::to_response(parts, bytes.into());
23071
23072 if let common::Retry::After(d) =
23073 dlg.http_failure(&response, error.as_ref().ok())
23074 {
23075 sleep(d).await;
23076 continue;
23077 }
23078
23079 dlg.finished(false);
23080
23081 return Err(match error {
23082 Ok(value) => common::Error::BadRequest(value),
23083 _ => common::Error::Failure(response),
23084 });
23085 }
23086 let response = {
23087 let bytes = common::to_bytes(body).await.unwrap_or_default();
23088 let encoded = common::to_string(&bytes);
23089 match serde_json::from_str(&encoded) {
23090 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23091 Err(error) => {
23092 dlg.response_json_decode_error(&encoded, &error);
23093 return Err(common::Error::JsonDecodeError(
23094 encoded.to_string(),
23095 error,
23096 ));
23097 }
23098 }
23099 };
23100
23101 dlg.finished(true);
23102 return Ok(response);
23103 }
23104 }
23105 }
23106 }
23107
23108 /// Required. Identifier of the course.
23109 ///
23110 /// Sets the *course id* path property to the given value.
23111 ///
23112 /// Even though the property as already been set when instantiating this call,
23113 /// we provide this method for API completeness.
23114 pub fn course_id(
23115 mut self,
23116 new_value: &str,
23117 ) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C> {
23118 self._course_id = new_value.to_string();
23119 self
23120 }
23121 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
23122 ///
23123 /// Sets the *item id* path property to the given value.
23124 ///
23125 /// Even though the property as already been set when instantiating this call,
23126 /// we provide this method for API completeness.
23127 pub fn item_id(
23128 mut self,
23129 new_value: &str,
23130 ) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C> {
23131 self._item_id = new_value.to_string();
23132 self
23133 }
23134 /// Optional. Deprecated, use `item_id` instead.
23135 ///
23136 /// Sets the *post id* query property to the given value.
23137 pub fn post_id(
23138 mut self,
23139 new_value: &str,
23140 ) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C> {
23141 self._post_id = Some(new_value.to_string());
23142 self
23143 }
23144 /// Optional. The identifier of the attachment. This field is required for all requests except when the user is in the [Attachment Discovery iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/attachment-discovery-iframe).
23145 ///
23146 /// Sets the *attachment id* query property to the given value.
23147 pub fn attachment_id(
23148 mut self,
23149 new_value: &str,
23150 ) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C> {
23151 self._attachment_id = Some(new_value.to_string());
23152 self
23153 }
23154 /// Optional. Token that authorizes the request. The token is passed as a query parameter when the user is redirected from Classroom to the add-on's URL. The authorization token is required when neither of the following is true: * The add-on has attachments on the post. * The developer project issuing the request is the same project that created the post.
23155 ///
23156 /// Sets the *add on token* query property to the given value.
23157 pub fn add_on_token(
23158 mut self,
23159 new_value: &str,
23160 ) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C> {
23161 self._add_on_token = Some(new_value.to_string());
23162 self
23163 }
23164 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23165 /// while executing the actual API request.
23166 ///
23167 /// ````text
23168 /// It should be used to handle progress information, and to implement a certain level of resilience.
23169 /// ````
23170 ///
23171 /// Sets the *delegate* property to the given value.
23172 pub fn delegate(
23173 mut self,
23174 new_value: &'a mut dyn common::Delegate,
23175 ) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C> {
23176 self._delegate = Some(new_value);
23177 self
23178 }
23179
23180 /// Set any additional parameter of the query string used in the request.
23181 /// It should be used to set parameters which are not yet available through their own
23182 /// setters.
23183 ///
23184 /// Please note that this method must not be used to set any of the known parameters
23185 /// which have their own setter method. If done anyway, the request will fail.
23186 ///
23187 /// # Additional Parameters
23188 ///
23189 /// * *$.xgafv* (query-string) - V1 error format.
23190 /// * *access_token* (query-string) - OAuth access token.
23191 /// * *alt* (query-string) - Data format for response.
23192 /// * *callback* (query-string) - JSONP
23193 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23194 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23195 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23196 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23197 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
23198 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23199 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23200 pub fn param<T>(
23201 mut self,
23202 name: T,
23203 value: T,
23204 ) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C>
23205 where
23206 T: AsRef<str>,
23207 {
23208 self._additional_params
23209 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23210 self
23211 }
23212
23213 /// Identifies the authorization scope for the method you are building.
23214 ///
23215 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23216 /// [`Scope::AddonStudent`].
23217 ///
23218 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23219 /// tokens for more than one scope.
23220 ///
23221 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23222 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23223 /// sufficient, a read-write scope will do as well.
23224 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C>
23225 where
23226 St: AsRef<str>,
23227 {
23228 self._scopes.insert(String::from(scope.as_ref()));
23229 self
23230 }
23231 /// Identifies the authorization scope(s) for the method you are building.
23232 ///
23233 /// See [`Self::add_scope()`] for details.
23234 pub fn add_scopes<I, St>(
23235 mut self,
23236 scopes: I,
23237 ) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C>
23238 where
23239 I: IntoIterator<Item = St>,
23240 St: AsRef<str>,
23241 {
23242 self._scopes
23243 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23244 self
23245 }
23246
23247 /// Removes all scopes, and no default scope will be used either.
23248 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23249 /// for details).
23250 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialGetAddOnContextCall<'a, C> {
23251 self._scopes.clear();
23252 self
23253 }
23254}
23255
23256/// Returns a list of course work material that the requester is permitted to view. Course students may only view `PUBLISHED` course work material. Course teachers and domain administrators may view all course work material. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
23257///
23258/// A builder for the *courseWorkMaterials.list* method supported by a *course* resource.
23259/// It is not used directly, but through a [`CourseMethods`] instance.
23260///
23261/// # Example
23262///
23263/// Instantiate a resource method builder
23264///
23265/// ```test_harness,no_run
23266/// # extern crate hyper;
23267/// # extern crate hyper_rustls;
23268/// # extern crate google_classroom1 as classroom1;
23269/// # async fn dox() {
23270/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23271///
23272/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23273/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23274/// # .with_native_roots()
23275/// # .unwrap()
23276/// # .https_only()
23277/// # .enable_http2()
23278/// # .build();
23279///
23280/// # let executor = hyper_util::rt::TokioExecutor::new();
23281/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23282/// # secret,
23283/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23284/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23285/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23286/// # ),
23287/// # ).build().await.unwrap();
23288///
23289/// # let client = hyper_util::client::legacy::Client::builder(
23290/// # hyper_util::rt::TokioExecutor::new()
23291/// # )
23292/// # .build(
23293/// # hyper_rustls::HttpsConnectorBuilder::new()
23294/// # .with_native_roots()
23295/// # .unwrap()
23296/// # .https_or_http()
23297/// # .enable_http2()
23298/// # .build()
23299/// # );
23300/// # let mut hub = Classroom::new(client, auth);
23301/// // You can configure optional parameters by calling the respective setters at will, and
23302/// // execute the final call using `doit()`.
23303/// // Values shown here are possibly random and not representative !
23304/// let result = hub.courses().course_work_materials_list("courseId")
23305/// .page_token("consetetur")
23306/// .page_size(-62)
23307/// .order_by("dolor")
23308/// .material_link("aliquyam")
23309/// .material_drive_id("no")
23310/// .add_course_work_material_states("amet.")
23311/// .doit().await;
23312/// # }
23313/// ```
23314pub struct CourseCourseWorkMaterialListCall<'a, C>
23315where
23316 C: 'a,
23317{
23318 hub: &'a Classroom<C>,
23319 _course_id: String,
23320 _page_token: Option<String>,
23321 _page_size: Option<i32>,
23322 _order_by: Option<String>,
23323 _material_link: Option<String>,
23324 _material_drive_id: Option<String>,
23325 _course_work_material_states: Vec<String>,
23326 _delegate: Option<&'a mut dyn common::Delegate>,
23327 _additional_params: HashMap<String, String>,
23328 _scopes: BTreeSet<String>,
23329}
23330
23331impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialListCall<'a, C> {}
23332
23333impl<'a, C> CourseCourseWorkMaterialListCall<'a, C>
23334where
23335 C: common::Connector,
23336{
23337 /// Perform the operation you have build so far.
23338 pub async fn doit(
23339 mut self,
23340 ) -> common::Result<(common::Response, ListCourseWorkMaterialResponse)> {
23341 use std::borrow::Cow;
23342 use std::io::{Read, Seek};
23343
23344 use common::{url::Params, ToParts};
23345 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23346
23347 let mut dd = common::DefaultDelegate;
23348 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23349 dlg.begin(common::MethodInfo {
23350 id: "classroom.courses.courseWorkMaterials.list",
23351 http_method: hyper::Method::GET,
23352 });
23353
23354 for &field in [
23355 "alt",
23356 "courseId",
23357 "pageToken",
23358 "pageSize",
23359 "orderBy",
23360 "materialLink",
23361 "materialDriveId",
23362 "courseWorkMaterialStates",
23363 ]
23364 .iter()
23365 {
23366 if self._additional_params.contains_key(field) {
23367 dlg.finished(false);
23368 return Err(common::Error::FieldClash(field));
23369 }
23370 }
23371
23372 let mut params = Params::with_capacity(9 + self._additional_params.len());
23373 params.push("courseId", self._course_id);
23374 if let Some(value) = self._page_token.as_ref() {
23375 params.push("pageToken", value);
23376 }
23377 if let Some(value) = self._page_size.as_ref() {
23378 params.push("pageSize", value.to_string());
23379 }
23380 if let Some(value) = self._order_by.as_ref() {
23381 params.push("orderBy", value);
23382 }
23383 if let Some(value) = self._material_link.as_ref() {
23384 params.push("materialLink", value);
23385 }
23386 if let Some(value) = self._material_drive_id.as_ref() {
23387 params.push("materialDriveId", value);
23388 }
23389 if !self._course_work_material_states.is_empty() {
23390 for f in self._course_work_material_states.iter() {
23391 params.push("courseWorkMaterialStates", f);
23392 }
23393 }
23394
23395 params.extend(self._additional_params.iter());
23396
23397 params.push("alt", "json");
23398 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWorkMaterials";
23399 if self._scopes.is_empty() {
23400 self._scopes
23401 .insert(Scope::CourseworkmaterialReadonly.as_ref().to_string());
23402 }
23403
23404 #[allow(clippy::single_element_loop)]
23405 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
23406 url = params.uri_replacement(url, param_name, find_this, false);
23407 }
23408 {
23409 let to_remove = ["courseId"];
23410 params.remove_params(&to_remove);
23411 }
23412
23413 let url = params.parse_with_url(&url);
23414
23415 loop {
23416 let token = match self
23417 .hub
23418 .auth
23419 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23420 .await
23421 {
23422 Ok(token) => token,
23423 Err(e) => match dlg.token(e) {
23424 Ok(token) => token,
23425 Err(e) => {
23426 dlg.finished(false);
23427 return Err(common::Error::MissingToken(e));
23428 }
23429 },
23430 };
23431 let mut req_result = {
23432 let client = &self.hub.client;
23433 dlg.pre_request();
23434 let mut req_builder = hyper::Request::builder()
23435 .method(hyper::Method::GET)
23436 .uri(url.as_str())
23437 .header(USER_AGENT, self.hub._user_agent.clone());
23438
23439 if let Some(token) = token.as_ref() {
23440 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23441 }
23442
23443 let request = req_builder
23444 .header(CONTENT_LENGTH, 0_u64)
23445 .body(common::to_body::<String>(None));
23446
23447 client.request(request.unwrap()).await
23448 };
23449
23450 match req_result {
23451 Err(err) => {
23452 if let common::Retry::After(d) = dlg.http_error(&err) {
23453 sleep(d).await;
23454 continue;
23455 }
23456 dlg.finished(false);
23457 return Err(common::Error::HttpError(err));
23458 }
23459 Ok(res) => {
23460 let (mut parts, body) = res.into_parts();
23461 let mut body = common::Body::new(body);
23462 if !parts.status.is_success() {
23463 let bytes = common::to_bytes(body).await.unwrap_or_default();
23464 let error = serde_json::from_str(&common::to_string(&bytes));
23465 let response = common::to_response(parts, bytes.into());
23466
23467 if let common::Retry::After(d) =
23468 dlg.http_failure(&response, error.as_ref().ok())
23469 {
23470 sleep(d).await;
23471 continue;
23472 }
23473
23474 dlg.finished(false);
23475
23476 return Err(match error {
23477 Ok(value) => common::Error::BadRequest(value),
23478 _ => common::Error::Failure(response),
23479 });
23480 }
23481 let response = {
23482 let bytes = common::to_bytes(body).await.unwrap_or_default();
23483 let encoded = common::to_string(&bytes);
23484 match serde_json::from_str(&encoded) {
23485 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23486 Err(error) => {
23487 dlg.response_json_decode_error(&encoded, &error);
23488 return Err(common::Error::JsonDecodeError(
23489 encoded.to_string(),
23490 error,
23491 ));
23492 }
23493 }
23494 };
23495
23496 dlg.finished(true);
23497 return Ok(response);
23498 }
23499 }
23500 }
23501 }
23502
23503 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
23504 ///
23505 /// Sets the *course id* path property to the given value.
23506 ///
23507 /// Even though the property as already been set when instantiating this call,
23508 /// we provide this method for API completeness.
23509 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkMaterialListCall<'a, C> {
23510 self._course_id = new_value.to_string();
23511 self
23512 }
23513 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
23514 ///
23515 /// Sets the *page token* query property to the given value.
23516 pub fn page_token(mut self, new_value: &str) -> CourseCourseWorkMaterialListCall<'a, C> {
23517 self._page_token = Some(new_value.to_string());
23518 self
23519 }
23520 /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.
23521 ///
23522 /// Sets the *page size* query property to the given value.
23523 pub fn page_size(mut self, new_value: i32) -> CourseCourseWorkMaterialListCall<'a, C> {
23524 self._page_size = Some(new_value);
23525 self
23526 }
23527 /// Optional sort ordering for results. A comma-separated list of fields with an optional sort direction keyword. Supported field is `updateTime`. Supported direction keywords are `asc` and `desc`. If not specified, `updateTime desc` is the default behavior. Examples: `updateTime asc`, `updateTime`
23528 ///
23529 /// Sets the *order by* query property to the given value.
23530 pub fn order_by(mut self, new_value: &str) -> CourseCourseWorkMaterialListCall<'a, C> {
23531 self._order_by = Some(new_value.to_string());
23532 self
23533 }
23534 /// Optional filtering for course work material with at least one link material whose URL partially matches the provided string.
23535 ///
23536 /// Sets the *material link* query property to the given value.
23537 pub fn material_link(mut self, new_value: &str) -> CourseCourseWorkMaterialListCall<'a, C> {
23538 self._material_link = Some(new_value.to_string());
23539 self
23540 }
23541 /// Optional filtering for course work material with at least one Drive material whose ID matches the provided string. If `material_link` is also specified, course work material must have materials matching both filters.
23542 ///
23543 /// Sets the *material drive id* query property to the given value.
23544 pub fn material_drive_id(mut self, new_value: &str) -> CourseCourseWorkMaterialListCall<'a, C> {
23545 self._material_drive_id = Some(new_value.to_string());
23546 self
23547 }
23548 /// Restriction on the work status to return. Only course work material that matches is returned. If unspecified, items with a work status of `PUBLISHED` is returned.
23549 ///
23550 /// Append the given value to the *course work material states* query property.
23551 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
23552 pub fn add_course_work_material_states(
23553 mut self,
23554 new_value: &str,
23555 ) -> CourseCourseWorkMaterialListCall<'a, C> {
23556 self._course_work_material_states
23557 .push(new_value.to_string());
23558 self
23559 }
23560 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23561 /// while executing the actual API request.
23562 ///
23563 /// ````text
23564 /// It should be used to handle progress information, and to implement a certain level of resilience.
23565 /// ````
23566 ///
23567 /// Sets the *delegate* property to the given value.
23568 pub fn delegate(
23569 mut self,
23570 new_value: &'a mut dyn common::Delegate,
23571 ) -> CourseCourseWorkMaterialListCall<'a, C> {
23572 self._delegate = Some(new_value);
23573 self
23574 }
23575
23576 /// Set any additional parameter of the query string used in the request.
23577 /// It should be used to set parameters which are not yet available through their own
23578 /// setters.
23579 ///
23580 /// Please note that this method must not be used to set any of the known parameters
23581 /// which have their own setter method. If done anyway, the request will fail.
23582 ///
23583 /// # Additional Parameters
23584 ///
23585 /// * *$.xgafv* (query-string) - V1 error format.
23586 /// * *access_token* (query-string) - OAuth access token.
23587 /// * *alt* (query-string) - Data format for response.
23588 /// * *callback* (query-string) - JSONP
23589 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23590 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23591 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23592 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23593 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
23594 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23595 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23596 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkMaterialListCall<'a, C>
23597 where
23598 T: AsRef<str>,
23599 {
23600 self._additional_params
23601 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23602 self
23603 }
23604
23605 /// Identifies the authorization scope for the method you are building.
23606 ///
23607 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23608 /// [`Scope::CourseworkmaterialReadonly`].
23609 ///
23610 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23611 /// tokens for more than one scope.
23612 ///
23613 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23614 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23615 /// sufficient, a read-write scope will do as well.
23616 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkMaterialListCall<'a, C>
23617 where
23618 St: AsRef<str>,
23619 {
23620 self._scopes.insert(String::from(scope.as_ref()));
23621 self
23622 }
23623 /// Identifies the authorization scope(s) for the method you are building.
23624 ///
23625 /// See [`Self::add_scope()`] for details.
23626 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkMaterialListCall<'a, C>
23627 where
23628 I: IntoIterator<Item = St>,
23629 St: AsRef<str>,
23630 {
23631 self._scopes
23632 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23633 self
23634 }
23635
23636 /// Removes all scopes, and no default scope will be used either.
23637 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23638 /// for details).
23639 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialListCall<'a, C> {
23640 self._scopes.clear();
23641 self
23642 }
23643}
23644
23645/// Updates one or more fields of a course work material. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if the requested course work material has already been deleted. * `NOT_FOUND` if the requested course or course work material does not exist
23646///
23647/// A builder for the *courseWorkMaterials.patch* method supported by a *course* resource.
23648/// It is not used directly, but through a [`CourseMethods`] instance.
23649///
23650/// # Example
23651///
23652/// Instantiate a resource method builder
23653///
23654/// ```test_harness,no_run
23655/// # extern crate hyper;
23656/// # extern crate hyper_rustls;
23657/// # extern crate google_classroom1 as classroom1;
23658/// use classroom1::api::CourseWorkMaterial;
23659/// # async fn dox() {
23660/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23661///
23662/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23663/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23664/// # .with_native_roots()
23665/// # .unwrap()
23666/// # .https_only()
23667/// # .enable_http2()
23668/// # .build();
23669///
23670/// # let executor = hyper_util::rt::TokioExecutor::new();
23671/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23672/// # secret,
23673/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23674/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23675/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23676/// # ),
23677/// # ).build().await.unwrap();
23678///
23679/// # let client = hyper_util::client::legacy::Client::builder(
23680/// # hyper_util::rt::TokioExecutor::new()
23681/// # )
23682/// # .build(
23683/// # hyper_rustls::HttpsConnectorBuilder::new()
23684/// # .with_native_roots()
23685/// # .unwrap()
23686/// # .https_or_http()
23687/// # .enable_http2()
23688/// # .build()
23689/// # );
23690/// # let mut hub = Classroom::new(client, auth);
23691/// // As the method needs a request, you would usually fill it with the desired information
23692/// // into the respective structure. Some of the parts shown here might not be applicable !
23693/// // Values shown here are possibly random and not representative !
23694/// let mut req = CourseWorkMaterial::default();
23695///
23696/// // You can configure optional parameters by calling the respective setters at will, and
23697/// // execute the final call using `doit()`.
23698/// // Values shown here are possibly random and not representative !
23699/// let result = hub.courses().course_work_materials_patch(req, "courseId", "id")
23700/// .update_mask(FieldMask::new::<&str>(&[]))
23701/// .doit().await;
23702/// # }
23703/// ```
23704pub struct CourseCourseWorkMaterialPatchCall<'a, C>
23705where
23706 C: 'a,
23707{
23708 hub: &'a Classroom<C>,
23709 _request: CourseWorkMaterial,
23710 _course_id: String,
23711 _id: String,
23712 _update_mask: Option<common::FieldMask>,
23713 _delegate: Option<&'a mut dyn common::Delegate>,
23714 _additional_params: HashMap<String, String>,
23715 _scopes: BTreeSet<String>,
23716}
23717
23718impl<'a, C> common::CallBuilder for CourseCourseWorkMaterialPatchCall<'a, C> {}
23719
23720impl<'a, C> CourseCourseWorkMaterialPatchCall<'a, C>
23721where
23722 C: common::Connector,
23723{
23724 /// Perform the operation you have build so far.
23725 pub async fn doit(mut self) -> common::Result<(common::Response, CourseWorkMaterial)> {
23726 use std::borrow::Cow;
23727 use std::io::{Read, Seek};
23728
23729 use common::{url::Params, ToParts};
23730 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23731
23732 let mut dd = common::DefaultDelegate;
23733 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23734 dlg.begin(common::MethodInfo {
23735 id: "classroom.courses.courseWorkMaterials.patch",
23736 http_method: hyper::Method::PATCH,
23737 });
23738
23739 for &field in ["alt", "courseId", "id", "updateMask"].iter() {
23740 if self._additional_params.contains_key(field) {
23741 dlg.finished(false);
23742 return Err(common::Error::FieldClash(field));
23743 }
23744 }
23745
23746 let mut params = Params::with_capacity(6 + self._additional_params.len());
23747 params.push("courseId", self._course_id);
23748 params.push("id", self._id);
23749 if let Some(value) = self._update_mask.as_ref() {
23750 params.push("updateMask", value.to_string());
23751 }
23752
23753 params.extend(self._additional_params.iter());
23754
23755 params.push("alt", "json");
23756 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/courseWorkMaterials/{id}";
23757 if self._scopes.is_empty() {
23758 self._scopes
23759 .insert(Scope::Courseworkmaterial.as_ref().to_string());
23760 }
23761
23762 #[allow(clippy::single_element_loop)]
23763 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
23764 url = params.uri_replacement(url, param_name, find_this, false);
23765 }
23766 {
23767 let to_remove = ["id", "courseId"];
23768 params.remove_params(&to_remove);
23769 }
23770
23771 let url = params.parse_with_url(&url);
23772
23773 let mut json_mime_type = mime::APPLICATION_JSON;
23774 let mut request_value_reader = {
23775 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23776 common::remove_json_null_values(&mut value);
23777 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23778 serde_json::to_writer(&mut dst, &value).unwrap();
23779 dst
23780 };
23781 let request_size = request_value_reader
23782 .seek(std::io::SeekFrom::End(0))
23783 .unwrap();
23784 request_value_reader
23785 .seek(std::io::SeekFrom::Start(0))
23786 .unwrap();
23787
23788 loop {
23789 let token = match self
23790 .hub
23791 .auth
23792 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23793 .await
23794 {
23795 Ok(token) => token,
23796 Err(e) => match dlg.token(e) {
23797 Ok(token) => token,
23798 Err(e) => {
23799 dlg.finished(false);
23800 return Err(common::Error::MissingToken(e));
23801 }
23802 },
23803 };
23804 request_value_reader
23805 .seek(std::io::SeekFrom::Start(0))
23806 .unwrap();
23807 let mut req_result = {
23808 let client = &self.hub.client;
23809 dlg.pre_request();
23810 let mut req_builder = hyper::Request::builder()
23811 .method(hyper::Method::PATCH)
23812 .uri(url.as_str())
23813 .header(USER_AGENT, self.hub._user_agent.clone());
23814
23815 if let Some(token) = token.as_ref() {
23816 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23817 }
23818
23819 let request = req_builder
23820 .header(CONTENT_TYPE, json_mime_type.to_string())
23821 .header(CONTENT_LENGTH, request_size as u64)
23822 .body(common::to_body(
23823 request_value_reader.get_ref().clone().into(),
23824 ));
23825
23826 client.request(request.unwrap()).await
23827 };
23828
23829 match req_result {
23830 Err(err) => {
23831 if let common::Retry::After(d) = dlg.http_error(&err) {
23832 sleep(d).await;
23833 continue;
23834 }
23835 dlg.finished(false);
23836 return Err(common::Error::HttpError(err));
23837 }
23838 Ok(res) => {
23839 let (mut parts, body) = res.into_parts();
23840 let mut body = common::Body::new(body);
23841 if !parts.status.is_success() {
23842 let bytes = common::to_bytes(body).await.unwrap_or_default();
23843 let error = serde_json::from_str(&common::to_string(&bytes));
23844 let response = common::to_response(parts, bytes.into());
23845
23846 if let common::Retry::After(d) =
23847 dlg.http_failure(&response, error.as_ref().ok())
23848 {
23849 sleep(d).await;
23850 continue;
23851 }
23852
23853 dlg.finished(false);
23854
23855 return Err(match error {
23856 Ok(value) => common::Error::BadRequest(value),
23857 _ => common::Error::Failure(response),
23858 });
23859 }
23860 let response = {
23861 let bytes = common::to_bytes(body).await.unwrap_or_default();
23862 let encoded = common::to_string(&bytes);
23863 match serde_json::from_str(&encoded) {
23864 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23865 Err(error) => {
23866 dlg.response_json_decode_error(&encoded, &error);
23867 return Err(common::Error::JsonDecodeError(
23868 encoded.to_string(),
23869 error,
23870 ));
23871 }
23872 }
23873 };
23874
23875 dlg.finished(true);
23876 return Ok(response);
23877 }
23878 }
23879 }
23880 }
23881
23882 ///
23883 /// Sets the *request* property to the given value.
23884 ///
23885 /// Even though the property as already been set when instantiating this call,
23886 /// we provide this method for API completeness.
23887 pub fn request(
23888 mut self,
23889 new_value: CourseWorkMaterial,
23890 ) -> CourseCourseWorkMaterialPatchCall<'a, C> {
23891 self._request = new_value;
23892 self
23893 }
23894 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
23895 ///
23896 /// Sets the *course id* path property to the given value.
23897 ///
23898 /// Even though the property as already been set when instantiating this call,
23899 /// we provide this method for API completeness.
23900 pub fn course_id(mut self, new_value: &str) -> CourseCourseWorkMaterialPatchCall<'a, C> {
23901 self._course_id = new_value.to_string();
23902 self
23903 }
23904 /// Identifier of the course work material.
23905 ///
23906 /// Sets the *id* path property to the given value.
23907 ///
23908 /// Even though the property as already been set when instantiating this call,
23909 /// we provide this method for API completeness.
23910 pub fn id(mut self, new_value: &str) -> CourseCourseWorkMaterialPatchCall<'a, C> {
23911 self._id = new_value.to_string();
23912 self
23913 }
23914 /// Mask that identifies which fields on the course work material to update. This field is required to do an update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the course work material object. If a field that does not support empty values is included in the update mask and not set in the course work material object, an `INVALID_ARGUMENT` error is returned. The following fields may be specified by teachers: * `title` * `description` * `state` * `scheduled_time` * `topic_id`
23915 ///
23916 /// Sets the *update mask* query property to the given value.
23917 pub fn update_mask(
23918 mut self,
23919 new_value: common::FieldMask,
23920 ) -> CourseCourseWorkMaterialPatchCall<'a, C> {
23921 self._update_mask = Some(new_value);
23922 self
23923 }
23924 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23925 /// while executing the actual API request.
23926 ///
23927 /// ````text
23928 /// It should be used to handle progress information, and to implement a certain level of resilience.
23929 /// ````
23930 ///
23931 /// Sets the *delegate* property to the given value.
23932 pub fn delegate(
23933 mut self,
23934 new_value: &'a mut dyn common::Delegate,
23935 ) -> CourseCourseWorkMaterialPatchCall<'a, C> {
23936 self._delegate = Some(new_value);
23937 self
23938 }
23939
23940 /// Set any additional parameter of the query string used in the request.
23941 /// It should be used to set parameters which are not yet available through their own
23942 /// setters.
23943 ///
23944 /// Please note that this method must not be used to set any of the known parameters
23945 /// which have their own setter method. If done anyway, the request will fail.
23946 ///
23947 /// # Additional Parameters
23948 ///
23949 /// * *$.xgafv* (query-string) - V1 error format.
23950 /// * *access_token* (query-string) - OAuth access token.
23951 /// * *alt* (query-string) - Data format for response.
23952 /// * *callback* (query-string) - JSONP
23953 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23954 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23955 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23956 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23957 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
23958 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23959 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23960 pub fn param<T>(mut self, name: T, value: T) -> CourseCourseWorkMaterialPatchCall<'a, C>
23961 where
23962 T: AsRef<str>,
23963 {
23964 self._additional_params
23965 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23966 self
23967 }
23968
23969 /// Identifies the authorization scope for the method you are building.
23970 ///
23971 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23972 /// [`Scope::Courseworkmaterial`].
23973 ///
23974 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23975 /// tokens for more than one scope.
23976 ///
23977 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23978 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23979 /// sufficient, a read-write scope will do as well.
23980 pub fn add_scope<St>(mut self, scope: St) -> CourseCourseWorkMaterialPatchCall<'a, C>
23981 where
23982 St: AsRef<str>,
23983 {
23984 self._scopes.insert(String::from(scope.as_ref()));
23985 self
23986 }
23987 /// Identifies the authorization scope(s) for the method you are building.
23988 ///
23989 /// See [`Self::add_scope()`] for details.
23990 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCourseWorkMaterialPatchCall<'a, C>
23991 where
23992 I: IntoIterator<Item = St>,
23993 St: AsRef<str>,
23994 {
23995 self._scopes
23996 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23997 self
23998 }
23999
24000 /// Removes all scopes, and no default scope will be used either.
24001 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24002 /// for details).
24003 pub fn clear_scopes(mut self) -> CourseCourseWorkMaterialPatchCall<'a, C> {
24004 self._scopes.clear();
24005 self
24006 }
24007}
24008
24009/// Returns a student submission for an add-on attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
24010///
24011/// A builder for the *posts.addOnAttachments.studentSubmissions.get* method supported by a *course* resource.
24012/// It is not used directly, but through a [`CourseMethods`] instance.
24013///
24014/// # Example
24015///
24016/// Instantiate a resource method builder
24017///
24018/// ```test_harness,no_run
24019/// # extern crate hyper;
24020/// # extern crate hyper_rustls;
24021/// # extern crate google_classroom1 as classroom1;
24022/// # async fn dox() {
24023/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24024///
24025/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24026/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24027/// # .with_native_roots()
24028/// # .unwrap()
24029/// # .https_only()
24030/// # .enable_http2()
24031/// # .build();
24032///
24033/// # let executor = hyper_util::rt::TokioExecutor::new();
24034/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24035/// # secret,
24036/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24037/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24038/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24039/// # ),
24040/// # ).build().await.unwrap();
24041///
24042/// # let client = hyper_util::client::legacy::Client::builder(
24043/// # hyper_util::rt::TokioExecutor::new()
24044/// # )
24045/// # .build(
24046/// # hyper_rustls::HttpsConnectorBuilder::new()
24047/// # .with_native_roots()
24048/// # .unwrap()
24049/// # .https_or_http()
24050/// # .enable_http2()
24051/// # .build()
24052/// # );
24053/// # let mut hub = Classroom::new(client, auth);
24054/// // You can configure optional parameters by calling the respective setters at will, and
24055/// // execute the final call using `doit()`.
24056/// // Values shown here are possibly random and not representative !
24057/// let result = hub.courses().posts_add_on_attachments_student_submissions_get("courseId", "postId", "attachmentId", "submissionId")
24058/// .item_id("sit")
24059/// .doit().await;
24060/// # }
24061/// ```
24062pub struct CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C>
24063where
24064 C: 'a,
24065{
24066 hub: &'a Classroom<C>,
24067 _course_id: String,
24068 _post_id: String,
24069 _attachment_id: String,
24070 _submission_id: String,
24071 _item_id: Option<String>,
24072 _delegate: Option<&'a mut dyn common::Delegate>,
24073 _additional_params: HashMap<String, String>,
24074 _scopes: BTreeSet<String>,
24075}
24076
24077impl<'a, C> common::CallBuilder for CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C> {}
24078
24079impl<'a, C> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C>
24080where
24081 C: common::Connector,
24082{
24083 /// Perform the operation you have build so far.
24084 pub async fn doit(
24085 mut self,
24086 ) -> common::Result<(common::Response, AddOnAttachmentStudentSubmission)> {
24087 use std::borrow::Cow;
24088 use std::io::{Read, Seek};
24089
24090 use common::{url::Params, ToParts};
24091 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24092
24093 let mut dd = common::DefaultDelegate;
24094 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24095 dlg.begin(common::MethodInfo {
24096 id: "classroom.courses.posts.addOnAttachments.studentSubmissions.get",
24097 http_method: hyper::Method::GET,
24098 });
24099
24100 for &field in [
24101 "alt",
24102 "courseId",
24103 "postId",
24104 "attachmentId",
24105 "submissionId",
24106 "itemId",
24107 ]
24108 .iter()
24109 {
24110 if self._additional_params.contains_key(field) {
24111 dlg.finished(false);
24112 return Err(common::Error::FieldClash(field));
24113 }
24114 }
24115
24116 let mut params = Params::with_capacity(7 + self._additional_params.len());
24117 params.push("courseId", self._course_id);
24118 params.push("postId", self._post_id);
24119 params.push("attachmentId", self._attachment_id);
24120 params.push("submissionId", self._submission_id);
24121 if let Some(value) = self._item_id.as_ref() {
24122 params.push("itemId", value);
24123 }
24124
24125 params.extend(self._additional_params.iter());
24126
24127 params.push("alt", "json");
24128 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/posts/{postId}/addOnAttachments/{attachmentId}/studentSubmissions/{submissionId}";
24129 if self._scopes.is_empty() {
24130 self._scopes
24131 .insert(Scope::StudentSubmissionStudentReadonly.as_ref().to_string());
24132 }
24133
24134 #[allow(clippy::single_element_loop)]
24135 for &(find_this, param_name) in [
24136 ("{courseId}", "courseId"),
24137 ("{postId}", "postId"),
24138 ("{attachmentId}", "attachmentId"),
24139 ("{submissionId}", "submissionId"),
24140 ]
24141 .iter()
24142 {
24143 url = params.uri_replacement(url, param_name, find_this, false);
24144 }
24145 {
24146 let to_remove = ["submissionId", "attachmentId", "postId", "courseId"];
24147 params.remove_params(&to_remove);
24148 }
24149
24150 let url = params.parse_with_url(&url);
24151
24152 loop {
24153 let token = match self
24154 .hub
24155 .auth
24156 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24157 .await
24158 {
24159 Ok(token) => token,
24160 Err(e) => match dlg.token(e) {
24161 Ok(token) => token,
24162 Err(e) => {
24163 dlg.finished(false);
24164 return Err(common::Error::MissingToken(e));
24165 }
24166 },
24167 };
24168 let mut req_result = {
24169 let client = &self.hub.client;
24170 dlg.pre_request();
24171 let mut req_builder = hyper::Request::builder()
24172 .method(hyper::Method::GET)
24173 .uri(url.as_str())
24174 .header(USER_AGENT, self.hub._user_agent.clone());
24175
24176 if let Some(token) = token.as_ref() {
24177 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24178 }
24179
24180 let request = req_builder
24181 .header(CONTENT_LENGTH, 0_u64)
24182 .body(common::to_body::<String>(None));
24183
24184 client.request(request.unwrap()).await
24185 };
24186
24187 match req_result {
24188 Err(err) => {
24189 if let common::Retry::After(d) = dlg.http_error(&err) {
24190 sleep(d).await;
24191 continue;
24192 }
24193 dlg.finished(false);
24194 return Err(common::Error::HttpError(err));
24195 }
24196 Ok(res) => {
24197 let (mut parts, body) = res.into_parts();
24198 let mut body = common::Body::new(body);
24199 if !parts.status.is_success() {
24200 let bytes = common::to_bytes(body).await.unwrap_or_default();
24201 let error = serde_json::from_str(&common::to_string(&bytes));
24202 let response = common::to_response(parts, bytes.into());
24203
24204 if let common::Retry::After(d) =
24205 dlg.http_failure(&response, error.as_ref().ok())
24206 {
24207 sleep(d).await;
24208 continue;
24209 }
24210
24211 dlg.finished(false);
24212
24213 return Err(match error {
24214 Ok(value) => common::Error::BadRequest(value),
24215 _ => common::Error::Failure(response),
24216 });
24217 }
24218 let response = {
24219 let bytes = common::to_bytes(body).await.unwrap_or_default();
24220 let encoded = common::to_string(&bytes);
24221 match serde_json::from_str(&encoded) {
24222 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24223 Err(error) => {
24224 dlg.response_json_decode_error(&encoded, &error);
24225 return Err(common::Error::JsonDecodeError(
24226 encoded.to_string(),
24227 error,
24228 ));
24229 }
24230 }
24231 };
24232
24233 dlg.finished(true);
24234 return Ok(response);
24235 }
24236 }
24237 }
24238 }
24239
24240 /// Required. Identifier of the course.
24241 ///
24242 /// Sets the *course id* path property to the given value.
24243 ///
24244 /// Even though the property as already been set when instantiating this call,
24245 /// we provide this method for API completeness.
24246 pub fn course_id(
24247 mut self,
24248 new_value: &str,
24249 ) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C> {
24250 self._course_id = new_value.to_string();
24251 self
24252 }
24253 /// Optional. Deprecated, use `item_id` instead.
24254 ///
24255 /// Sets the *post id* path property to the given value.
24256 ///
24257 /// Even though the property as already been set when instantiating this call,
24258 /// we provide this method for API completeness.
24259 pub fn post_id(
24260 mut self,
24261 new_value: &str,
24262 ) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C> {
24263 self._post_id = new_value.to_string();
24264 self
24265 }
24266 /// Required. Identifier of the attachment.
24267 ///
24268 /// Sets the *attachment id* path property to the given value.
24269 ///
24270 /// Even though the property as already been set when instantiating this call,
24271 /// we provide this method for API completeness.
24272 pub fn attachment_id(
24273 mut self,
24274 new_value: &str,
24275 ) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C> {
24276 self._attachment_id = new_value.to_string();
24277 self
24278 }
24279 /// Required. Identifier of the student’s submission.
24280 ///
24281 /// Sets the *submission id* path property to the given value.
24282 ///
24283 /// Even though the property as already been set when instantiating this call,
24284 /// we provide this method for API completeness.
24285 pub fn submission_id(
24286 mut self,
24287 new_value: &str,
24288 ) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C> {
24289 self._submission_id = new_value.to_string();
24290 self
24291 }
24292 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
24293 ///
24294 /// Sets the *item id* query property to the given value.
24295 pub fn item_id(
24296 mut self,
24297 new_value: &str,
24298 ) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C> {
24299 self._item_id = Some(new_value.to_string());
24300 self
24301 }
24302 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24303 /// while executing the actual API request.
24304 ///
24305 /// ````text
24306 /// It should be used to handle progress information, and to implement a certain level of resilience.
24307 /// ````
24308 ///
24309 /// Sets the *delegate* property to the given value.
24310 pub fn delegate(
24311 mut self,
24312 new_value: &'a mut dyn common::Delegate,
24313 ) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C> {
24314 self._delegate = Some(new_value);
24315 self
24316 }
24317
24318 /// Set any additional parameter of the query string used in the request.
24319 /// It should be used to set parameters which are not yet available through their own
24320 /// setters.
24321 ///
24322 /// Please note that this method must not be used to set any of the known parameters
24323 /// which have their own setter method. If done anyway, the request will fail.
24324 ///
24325 /// # Additional Parameters
24326 ///
24327 /// * *$.xgafv* (query-string) - V1 error format.
24328 /// * *access_token* (query-string) - OAuth access token.
24329 /// * *alt* (query-string) - Data format for response.
24330 /// * *callback* (query-string) - JSONP
24331 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24332 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
24333 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24334 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24335 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
24336 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24337 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24338 pub fn param<T>(
24339 mut self,
24340 name: T,
24341 value: T,
24342 ) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C>
24343 where
24344 T: AsRef<str>,
24345 {
24346 self._additional_params
24347 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24348 self
24349 }
24350
24351 /// Identifies the authorization scope for the method you are building.
24352 ///
24353 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24354 /// [`Scope::StudentSubmissionStudentReadonly`].
24355 ///
24356 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24357 /// tokens for more than one scope.
24358 ///
24359 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24360 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24361 /// sufficient, a read-write scope will do as well.
24362 pub fn add_scope<St>(
24363 mut self,
24364 scope: St,
24365 ) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C>
24366 where
24367 St: AsRef<str>,
24368 {
24369 self._scopes.insert(String::from(scope.as_ref()));
24370 self
24371 }
24372 /// Identifies the authorization scope(s) for the method you are building.
24373 ///
24374 /// See [`Self::add_scope()`] for details.
24375 pub fn add_scopes<I, St>(
24376 mut self,
24377 scopes: I,
24378 ) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C>
24379 where
24380 I: IntoIterator<Item = St>,
24381 St: AsRef<str>,
24382 {
24383 self._scopes
24384 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24385 self
24386 }
24387
24388 /// Removes all scopes, and no default scope will be used either.
24389 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24390 /// for details).
24391 pub fn clear_scopes(mut self) -> CoursePostAddOnAttachmentStudentSubmissionGetCall<'a, C> {
24392 self._scopes.clear();
24393 self
24394 }
24395}
24396
24397/// Updates data associated with an add-on attachment submission. Requires the add-on to have been the original creator of the attachment and the attachment to have a positive `max_points` value set. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
24398///
24399/// A builder for the *posts.addOnAttachments.studentSubmissions.patch* method supported by a *course* resource.
24400/// It is not used directly, but through a [`CourseMethods`] instance.
24401///
24402/// # Example
24403///
24404/// Instantiate a resource method builder
24405///
24406/// ```test_harness,no_run
24407/// # extern crate hyper;
24408/// # extern crate hyper_rustls;
24409/// # extern crate google_classroom1 as classroom1;
24410/// use classroom1::api::AddOnAttachmentStudentSubmission;
24411/// # async fn dox() {
24412/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24413///
24414/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24415/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24416/// # .with_native_roots()
24417/// # .unwrap()
24418/// # .https_only()
24419/// # .enable_http2()
24420/// # .build();
24421///
24422/// # let executor = hyper_util::rt::TokioExecutor::new();
24423/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24424/// # secret,
24425/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24426/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24427/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24428/// # ),
24429/// # ).build().await.unwrap();
24430///
24431/// # let client = hyper_util::client::legacy::Client::builder(
24432/// # hyper_util::rt::TokioExecutor::new()
24433/// # )
24434/// # .build(
24435/// # hyper_rustls::HttpsConnectorBuilder::new()
24436/// # .with_native_roots()
24437/// # .unwrap()
24438/// # .https_or_http()
24439/// # .enable_http2()
24440/// # .build()
24441/// # );
24442/// # let mut hub = Classroom::new(client, auth);
24443/// // As the method needs a request, you would usually fill it with the desired information
24444/// // into the respective structure. Some of the parts shown here might not be applicable !
24445/// // Values shown here are possibly random and not representative !
24446/// let mut req = AddOnAttachmentStudentSubmission::default();
24447///
24448/// // You can configure optional parameters by calling the respective setters at will, and
24449/// // execute the final call using `doit()`.
24450/// // Values shown here are possibly random and not representative !
24451/// let result = hub.courses().posts_add_on_attachments_student_submissions_patch(req, "courseId", "postId", "attachmentId", "submissionId")
24452/// .update_mask(FieldMask::new::<&str>(&[]))
24453/// .item_id("rebum.")
24454/// .doit().await;
24455/// # }
24456/// ```
24457pub struct CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C>
24458where
24459 C: 'a,
24460{
24461 hub: &'a Classroom<C>,
24462 _request: AddOnAttachmentStudentSubmission,
24463 _course_id: String,
24464 _post_id: String,
24465 _attachment_id: String,
24466 _submission_id: String,
24467 _update_mask: Option<common::FieldMask>,
24468 _item_id: Option<String>,
24469 _delegate: Option<&'a mut dyn common::Delegate>,
24470 _additional_params: HashMap<String, String>,
24471 _scopes: BTreeSet<String>,
24472}
24473
24474impl<'a, C> common::CallBuilder for CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {}
24475
24476impl<'a, C> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C>
24477where
24478 C: common::Connector,
24479{
24480 /// Perform the operation you have build so far.
24481 pub async fn doit(
24482 mut self,
24483 ) -> common::Result<(common::Response, AddOnAttachmentStudentSubmission)> {
24484 use std::borrow::Cow;
24485 use std::io::{Read, Seek};
24486
24487 use common::{url::Params, ToParts};
24488 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24489
24490 let mut dd = common::DefaultDelegate;
24491 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24492 dlg.begin(common::MethodInfo {
24493 id: "classroom.courses.posts.addOnAttachments.studentSubmissions.patch",
24494 http_method: hyper::Method::PATCH,
24495 });
24496
24497 for &field in [
24498 "alt",
24499 "courseId",
24500 "postId",
24501 "attachmentId",
24502 "submissionId",
24503 "updateMask",
24504 "itemId",
24505 ]
24506 .iter()
24507 {
24508 if self._additional_params.contains_key(field) {
24509 dlg.finished(false);
24510 return Err(common::Error::FieldClash(field));
24511 }
24512 }
24513
24514 let mut params = Params::with_capacity(9 + self._additional_params.len());
24515 params.push("courseId", self._course_id);
24516 params.push("postId", self._post_id);
24517 params.push("attachmentId", self._attachment_id);
24518 params.push("submissionId", self._submission_id);
24519 if let Some(value) = self._update_mask.as_ref() {
24520 params.push("updateMask", value.to_string());
24521 }
24522 if let Some(value) = self._item_id.as_ref() {
24523 params.push("itemId", value);
24524 }
24525
24526 params.extend(self._additional_params.iter());
24527
24528 params.push("alt", "json");
24529 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/posts/{postId}/addOnAttachments/{attachmentId}/studentSubmissions/{submissionId}";
24530 if self._scopes.is_empty() {
24531 self._scopes
24532 .insert(Scope::AddonTeacher.as_ref().to_string());
24533 }
24534
24535 #[allow(clippy::single_element_loop)]
24536 for &(find_this, param_name) in [
24537 ("{courseId}", "courseId"),
24538 ("{postId}", "postId"),
24539 ("{attachmentId}", "attachmentId"),
24540 ("{submissionId}", "submissionId"),
24541 ]
24542 .iter()
24543 {
24544 url = params.uri_replacement(url, param_name, find_this, false);
24545 }
24546 {
24547 let to_remove = ["submissionId", "attachmentId", "postId", "courseId"];
24548 params.remove_params(&to_remove);
24549 }
24550
24551 let url = params.parse_with_url(&url);
24552
24553 let mut json_mime_type = mime::APPLICATION_JSON;
24554 let mut request_value_reader = {
24555 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24556 common::remove_json_null_values(&mut value);
24557 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24558 serde_json::to_writer(&mut dst, &value).unwrap();
24559 dst
24560 };
24561 let request_size = request_value_reader
24562 .seek(std::io::SeekFrom::End(0))
24563 .unwrap();
24564 request_value_reader
24565 .seek(std::io::SeekFrom::Start(0))
24566 .unwrap();
24567
24568 loop {
24569 let token = match self
24570 .hub
24571 .auth
24572 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24573 .await
24574 {
24575 Ok(token) => token,
24576 Err(e) => match dlg.token(e) {
24577 Ok(token) => token,
24578 Err(e) => {
24579 dlg.finished(false);
24580 return Err(common::Error::MissingToken(e));
24581 }
24582 },
24583 };
24584 request_value_reader
24585 .seek(std::io::SeekFrom::Start(0))
24586 .unwrap();
24587 let mut req_result = {
24588 let client = &self.hub.client;
24589 dlg.pre_request();
24590 let mut req_builder = hyper::Request::builder()
24591 .method(hyper::Method::PATCH)
24592 .uri(url.as_str())
24593 .header(USER_AGENT, self.hub._user_agent.clone());
24594
24595 if let Some(token) = token.as_ref() {
24596 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24597 }
24598
24599 let request = req_builder
24600 .header(CONTENT_TYPE, json_mime_type.to_string())
24601 .header(CONTENT_LENGTH, request_size as u64)
24602 .body(common::to_body(
24603 request_value_reader.get_ref().clone().into(),
24604 ));
24605
24606 client.request(request.unwrap()).await
24607 };
24608
24609 match req_result {
24610 Err(err) => {
24611 if let common::Retry::After(d) = dlg.http_error(&err) {
24612 sleep(d).await;
24613 continue;
24614 }
24615 dlg.finished(false);
24616 return Err(common::Error::HttpError(err));
24617 }
24618 Ok(res) => {
24619 let (mut parts, body) = res.into_parts();
24620 let mut body = common::Body::new(body);
24621 if !parts.status.is_success() {
24622 let bytes = common::to_bytes(body).await.unwrap_or_default();
24623 let error = serde_json::from_str(&common::to_string(&bytes));
24624 let response = common::to_response(parts, bytes.into());
24625
24626 if let common::Retry::After(d) =
24627 dlg.http_failure(&response, error.as_ref().ok())
24628 {
24629 sleep(d).await;
24630 continue;
24631 }
24632
24633 dlg.finished(false);
24634
24635 return Err(match error {
24636 Ok(value) => common::Error::BadRequest(value),
24637 _ => common::Error::Failure(response),
24638 });
24639 }
24640 let response = {
24641 let bytes = common::to_bytes(body).await.unwrap_or_default();
24642 let encoded = common::to_string(&bytes);
24643 match serde_json::from_str(&encoded) {
24644 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24645 Err(error) => {
24646 dlg.response_json_decode_error(&encoded, &error);
24647 return Err(common::Error::JsonDecodeError(
24648 encoded.to_string(),
24649 error,
24650 ));
24651 }
24652 }
24653 };
24654
24655 dlg.finished(true);
24656 return Ok(response);
24657 }
24658 }
24659 }
24660 }
24661
24662 ///
24663 /// Sets the *request* property to the given value.
24664 ///
24665 /// Even though the property as already been set when instantiating this call,
24666 /// we provide this method for API completeness.
24667 pub fn request(
24668 mut self,
24669 new_value: AddOnAttachmentStudentSubmission,
24670 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
24671 self._request = new_value;
24672 self
24673 }
24674 /// Required. Identifier of the course.
24675 ///
24676 /// Sets the *course id* path property to the given value.
24677 ///
24678 /// Even though the property as already been set when instantiating this call,
24679 /// we provide this method for API completeness.
24680 pub fn course_id(
24681 mut self,
24682 new_value: &str,
24683 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
24684 self._course_id = new_value.to_string();
24685 self
24686 }
24687 /// Optional. Deprecated, use `item_id` instead.
24688 ///
24689 /// Sets the *post id* path property to the given value.
24690 ///
24691 /// Even though the property as already been set when instantiating this call,
24692 /// we provide this method for API completeness.
24693 pub fn post_id(
24694 mut self,
24695 new_value: &str,
24696 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
24697 self._post_id = new_value.to_string();
24698 self
24699 }
24700 /// Required. Identifier of the attachment.
24701 ///
24702 /// Sets the *attachment id* path property to the given value.
24703 ///
24704 /// Even though the property as already been set when instantiating this call,
24705 /// we provide this method for API completeness.
24706 pub fn attachment_id(
24707 mut self,
24708 new_value: &str,
24709 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
24710 self._attachment_id = new_value.to_string();
24711 self
24712 }
24713 /// Required. Identifier of the student's submission.
24714 ///
24715 /// Sets the *submission id* path property to the given value.
24716 ///
24717 /// Even though the property as already been set when instantiating this call,
24718 /// we provide this method for API completeness.
24719 pub fn submission_id(
24720 mut self,
24721 new_value: &str,
24722 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
24723 self._submission_id = new_value.to_string();
24724 self
24725 }
24726 /// Required. Mask that identifies which fields on the attachment to update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the `AddOnAttachmentStudentSubmission` object. The following fields may be specified by teachers: * `points_earned`
24727 ///
24728 /// Sets the *update mask* query property to the given value.
24729 pub fn update_mask(
24730 mut self,
24731 new_value: common::FieldMask,
24732 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
24733 self._update_mask = Some(new_value);
24734 self
24735 }
24736 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
24737 ///
24738 /// Sets the *item id* query property to the given value.
24739 pub fn item_id(
24740 mut self,
24741 new_value: &str,
24742 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
24743 self._item_id = Some(new_value.to_string());
24744 self
24745 }
24746 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24747 /// while executing the actual API request.
24748 ///
24749 /// ````text
24750 /// It should be used to handle progress information, and to implement a certain level of resilience.
24751 /// ````
24752 ///
24753 /// Sets the *delegate* property to the given value.
24754 pub fn delegate(
24755 mut self,
24756 new_value: &'a mut dyn common::Delegate,
24757 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
24758 self._delegate = Some(new_value);
24759 self
24760 }
24761
24762 /// Set any additional parameter of the query string used in the request.
24763 /// It should be used to set parameters which are not yet available through their own
24764 /// setters.
24765 ///
24766 /// Please note that this method must not be used to set any of the known parameters
24767 /// which have their own setter method. If done anyway, the request will fail.
24768 ///
24769 /// # Additional Parameters
24770 ///
24771 /// * *$.xgafv* (query-string) - V1 error format.
24772 /// * *access_token* (query-string) - OAuth access token.
24773 /// * *alt* (query-string) - Data format for response.
24774 /// * *callback* (query-string) - JSONP
24775 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24776 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
24777 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24778 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24779 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
24780 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24781 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24782 pub fn param<T>(
24783 mut self,
24784 name: T,
24785 value: T,
24786 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C>
24787 where
24788 T: AsRef<str>,
24789 {
24790 self._additional_params
24791 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24792 self
24793 }
24794
24795 /// Identifies the authorization scope for the method you are building.
24796 ///
24797 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24798 /// [`Scope::AddonTeacher`].
24799 ///
24800 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24801 /// tokens for more than one scope.
24802 ///
24803 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24804 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24805 /// sufficient, a read-write scope will do as well.
24806 pub fn add_scope<St>(
24807 mut self,
24808 scope: St,
24809 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C>
24810 where
24811 St: AsRef<str>,
24812 {
24813 self._scopes.insert(String::from(scope.as_ref()));
24814 self
24815 }
24816 /// Identifies the authorization scope(s) for the method you are building.
24817 ///
24818 /// See [`Self::add_scope()`] for details.
24819 pub fn add_scopes<I, St>(
24820 mut self,
24821 scopes: I,
24822 ) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C>
24823 where
24824 I: IntoIterator<Item = St>,
24825 St: AsRef<str>,
24826 {
24827 self._scopes
24828 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24829 self
24830 }
24831
24832 /// Removes all scopes, and no default scope will be used either.
24833 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24834 /// for details).
24835 pub fn clear_scopes(mut self) -> CoursePostAddOnAttachmentStudentSubmissionPatchCall<'a, C> {
24836 self._scopes.clear();
24837 self
24838 }
24839}
24840
24841/// Creates an add-on attachment under a post. Requires the add-on to have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
24842///
24843/// A builder for the *posts.addOnAttachments.create* method supported by a *course* resource.
24844/// It is not used directly, but through a [`CourseMethods`] instance.
24845///
24846/// # Example
24847///
24848/// Instantiate a resource method builder
24849///
24850/// ```test_harness,no_run
24851/// # extern crate hyper;
24852/// # extern crate hyper_rustls;
24853/// # extern crate google_classroom1 as classroom1;
24854/// use classroom1::api::AddOnAttachment;
24855/// # async fn dox() {
24856/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24857///
24858/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24859/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24860/// # .with_native_roots()
24861/// # .unwrap()
24862/// # .https_only()
24863/// # .enable_http2()
24864/// # .build();
24865///
24866/// # let executor = hyper_util::rt::TokioExecutor::new();
24867/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24868/// # secret,
24869/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24870/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24871/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24872/// # ),
24873/// # ).build().await.unwrap();
24874///
24875/// # let client = hyper_util::client::legacy::Client::builder(
24876/// # hyper_util::rt::TokioExecutor::new()
24877/// # )
24878/// # .build(
24879/// # hyper_rustls::HttpsConnectorBuilder::new()
24880/// # .with_native_roots()
24881/// # .unwrap()
24882/// # .https_or_http()
24883/// # .enable_http2()
24884/// # .build()
24885/// # );
24886/// # let mut hub = Classroom::new(client, auth);
24887/// // As the method needs a request, you would usually fill it with the desired information
24888/// // into the respective structure. Some of the parts shown here might not be applicable !
24889/// // Values shown here are possibly random and not representative !
24890/// let mut req = AddOnAttachment::default();
24891///
24892/// // You can configure optional parameters by calling the respective setters at will, and
24893/// // execute the final call using `doit()`.
24894/// // Values shown here are possibly random and not representative !
24895/// let result = hub.courses().posts_add_on_attachments_create(req, "courseId", "postId")
24896/// .item_id("justo")
24897/// .add_on_token("amet.")
24898/// .doit().await;
24899/// # }
24900/// ```
24901pub struct CoursePostAddOnAttachmentCreateCall<'a, C>
24902where
24903 C: 'a,
24904{
24905 hub: &'a Classroom<C>,
24906 _request: AddOnAttachment,
24907 _course_id: String,
24908 _post_id: String,
24909 _item_id: Option<String>,
24910 _add_on_token: Option<String>,
24911 _delegate: Option<&'a mut dyn common::Delegate>,
24912 _additional_params: HashMap<String, String>,
24913 _scopes: BTreeSet<String>,
24914}
24915
24916impl<'a, C> common::CallBuilder for CoursePostAddOnAttachmentCreateCall<'a, C> {}
24917
24918impl<'a, C> CoursePostAddOnAttachmentCreateCall<'a, C>
24919where
24920 C: common::Connector,
24921{
24922 /// Perform the operation you have build so far.
24923 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
24924 use std::borrow::Cow;
24925 use std::io::{Read, Seek};
24926
24927 use common::{url::Params, ToParts};
24928 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24929
24930 let mut dd = common::DefaultDelegate;
24931 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24932 dlg.begin(common::MethodInfo {
24933 id: "classroom.courses.posts.addOnAttachments.create",
24934 http_method: hyper::Method::POST,
24935 });
24936
24937 for &field in ["alt", "courseId", "postId", "itemId", "addOnToken"].iter() {
24938 if self._additional_params.contains_key(field) {
24939 dlg.finished(false);
24940 return Err(common::Error::FieldClash(field));
24941 }
24942 }
24943
24944 let mut params = Params::with_capacity(7 + self._additional_params.len());
24945 params.push("courseId", self._course_id);
24946 params.push("postId", self._post_id);
24947 if let Some(value) = self._item_id.as_ref() {
24948 params.push("itemId", value);
24949 }
24950 if let Some(value) = self._add_on_token.as_ref() {
24951 params.push("addOnToken", value);
24952 }
24953
24954 params.extend(self._additional_params.iter());
24955
24956 params.push("alt", "json");
24957 let mut url =
24958 self.hub._base_url.clone() + "v1/courses/{courseId}/posts/{postId}/addOnAttachments";
24959 if self._scopes.is_empty() {
24960 self._scopes
24961 .insert(Scope::AddonTeacher.as_ref().to_string());
24962 }
24963
24964 #[allow(clippy::single_element_loop)]
24965 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{postId}", "postId")].iter()
24966 {
24967 url = params.uri_replacement(url, param_name, find_this, false);
24968 }
24969 {
24970 let to_remove = ["postId", "courseId"];
24971 params.remove_params(&to_remove);
24972 }
24973
24974 let url = params.parse_with_url(&url);
24975
24976 let mut json_mime_type = mime::APPLICATION_JSON;
24977 let mut request_value_reader = {
24978 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24979 common::remove_json_null_values(&mut value);
24980 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24981 serde_json::to_writer(&mut dst, &value).unwrap();
24982 dst
24983 };
24984 let request_size = request_value_reader
24985 .seek(std::io::SeekFrom::End(0))
24986 .unwrap();
24987 request_value_reader
24988 .seek(std::io::SeekFrom::Start(0))
24989 .unwrap();
24990
24991 loop {
24992 let token = match self
24993 .hub
24994 .auth
24995 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24996 .await
24997 {
24998 Ok(token) => token,
24999 Err(e) => match dlg.token(e) {
25000 Ok(token) => token,
25001 Err(e) => {
25002 dlg.finished(false);
25003 return Err(common::Error::MissingToken(e));
25004 }
25005 },
25006 };
25007 request_value_reader
25008 .seek(std::io::SeekFrom::Start(0))
25009 .unwrap();
25010 let mut req_result = {
25011 let client = &self.hub.client;
25012 dlg.pre_request();
25013 let mut req_builder = hyper::Request::builder()
25014 .method(hyper::Method::POST)
25015 .uri(url.as_str())
25016 .header(USER_AGENT, self.hub._user_agent.clone());
25017
25018 if let Some(token) = token.as_ref() {
25019 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25020 }
25021
25022 let request = req_builder
25023 .header(CONTENT_TYPE, json_mime_type.to_string())
25024 .header(CONTENT_LENGTH, request_size as u64)
25025 .body(common::to_body(
25026 request_value_reader.get_ref().clone().into(),
25027 ));
25028
25029 client.request(request.unwrap()).await
25030 };
25031
25032 match req_result {
25033 Err(err) => {
25034 if let common::Retry::After(d) = dlg.http_error(&err) {
25035 sleep(d).await;
25036 continue;
25037 }
25038 dlg.finished(false);
25039 return Err(common::Error::HttpError(err));
25040 }
25041 Ok(res) => {
25042 let (mut parts, body) = res.into_parts();
25043 let mut body = common::Body::new(body);
25044 if !parts.status.is_success() {
25045 let bytes = common::to_bytes(body).await.unwrap_or_default();
25046 let error = serde_json::from_str(&common::to_string(&bytes));
25047 let response = common::to_response(parts, bytes.into());
25048
25049 if let common::Retry::After(d) =
25050 dlg.http_failure(&response, error.as_ref().ok())
25051 {
25052 sleep(d).await;
25053 continue;
25054 }
25055
25056 dlg.finished(false);
25057
25058 return Err(match error {
25059 Ok(value) => common::Error::BadRequest(value),
25060 _ => common::Error::Failure(response),
25061 });
25062 }
25063 let response = {
25064 let bytes = common::to_bytes(body).await.unwrap_or_default();
25065 let encoded = common::to_string(&bytes);
25066 match serde_json::from_str(&encoded) {
25067 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25068 Err(error) => {
25069 dlg.response_json_decode_error(&encoded, &error);
25070 return Err(common::Error::JsonDecodeError(
25071 encoded.to_string(),
25072 error,
25073 ));
25074 }
25075 }
25076 };
25077
25078 dlg.finished(true);
25079 return Ok(response);
25080 }
25081 }
25082 }
25083 }
25084
25085 ///
25086 /// Sets the *request* property to the given value.
25087 ///
25088 /// Even though the property as already been set when instantiating this call,
25089 /// we provide this method for API completeness.
25090 pub fn request(
25091 mut self,
25092 new_value: AddOnAttachment,
25093 ) -> CoursePostAddOnAttachmentCreateCall<'a, C> {
25094 self._request = new_value;
25095 self
25096 }
25097 /// Required. Identifier of the course.
25098 ///
25099 /// Sets the *course id* path property to the given value.
25100 ///
25101 /// Even though the property as already been set when instantiating this call,
25102 /// we provide this method for API completeness.
25103 pub fn course_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentCreateCall<'a, C> {
25104 self._course_id = new_value.to_string();
25105 self
25106 }
25107 /// Optional. Deprecated, use `item_id` instead.
25108 ///
25109 /// Sets the *post id* path property to the given value.
25110 ///
25111 /// Even though the property as already been set when instantiating this call,
25112 /// we provide this method for API completeness.
25113 pub fn post_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentCreateCall<'a, C> {
25114 self._post_id = new_value.to_string();
25115 self
25116 }
25117 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which to create the attachment. This field is required, but is not marked as such while we are migrating from post_id.
25118 ///
25119 /// Sets the *item id* query property to the given value.
25120 pub fn item_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentCreateCall<'a, C> {
25121 self._item_id = Some(new_value.to_string());
25122 self
25123 }
25124 /// Optional. Token that authorizes the request. The token is passed as a query parameter when the user is redirected from Classroom to the add-on's URL. This authorization token is required for in-Classroom attachment creation but optional for partner-first attachment creation. Returns an error if not provided for partner-first attachment creation and the developer projects that created the attachment and its parent stream item do not match.
25125 ///
25126 /// Sets the *add on token* query property to the given value.
25127 pub fn add_on_token(mut self, new_value: &str) -> CoursePostAddOnAttachmentCreateCall<'a, C> {
25128 self._add_on_token = Some(new_value.to_string());
25129 self
25130 }
25131 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25132 /// while executing the actual API request.
25133 ///
25134 /// ````text
25135 /// It should be used to handle progress information, and to implement a certain level of resilience.
25136 /// ````
25137 ///
25138 /// Sets the *delegate* property to the given value.
25139 pub fn delegate(
25140 mut self,
25141 new_value: &'a mut dyn common::Delegate,
25142 ) -> CoursePostAddOnAttachmentCreateCall<'a, C> {
25143 self._delegate = Some(new_value);
25144 self
25145 }
25146
25147 /// Set any additional parameter of the query string used in the request.
25148 /// It should be used to set parameters which are not yet available through their own
25149 /// setters.
25150 ///
25151 /// Please note that this method must not be used to set any of the known parameters
25152 /// which have their own setter method. If done anyway, the request will fail.
25153 ///
25154 /// # Additional Parameters
25155 ///
25156 /// * *$.xgafv* (query-string) - V1 error format.
25157 /// * *access_token* (query-string) - OAuth access token.
25158 /// * *alt* (query-string) - Data format for response.
25159 /// * *callback* (query-string) - JSONP
25160 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25161 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
25162 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25163 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25164 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
25165 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25166 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25167 pub fn param<T>(mut self, name: T, value: T) -> CoursePostAddOnAttachmentCreateCall<'a, C>
25168 where
25169 T: AsRef<str>,
25170 {
25171 self._additional_params
25172 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25173 self
25174 }
25175
25176 /// Identifies the authorization scope for the method you are building.
25177 ///
25178 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25179 /// [`Scope::AddonTeacher`].
25180 ///
25181 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25182 /// tokens for more than one scope.
25183 ///
25184 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25185 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25186 /// sufficient, a read-write scope will do as well.
25187 pub fn add_scope<St>(mut self, scope: St) -> CoursePostAddOnAttachmentCreateCall<'a, C>
25188 where
25189 St: AsRef<str>,
25190 {
25191 self._scopes.insert(String::from(scope.as_ref()));
25192 self
25193 }
25194 /// Identifies the authorization scope(s) for the method you are building.
25195 ///
25196 /// See [`Self::add_scope()`] for details.
25197 pub fn add_scopes<I, St>(mut self, scopes: I) -> CoursePostAddOnAttachmentCreateCall<'a, C>
25198 where
25199 I: IntoIterator<Item = St>,
25200 St: AsRef<str>,
25201 {
25202 self._scopes
25203 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25204 self
25205 }
25206
25207 /// Removes all scopes, and no default scope will be used either.
25208 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25209 /// for details).
25210 pub fn clear_scopes(mut self) -> CoursePostAddOnAttachmentCreateCall<'a, C> {
25211 self._scopes.clear();
25212 self
25213 }
25214}
25215
25216/// Deletes an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
25217///
25218/// A builder for the *posts.addOnAttachments.delete* method supported by a *course* resource.
25219/// It is not used directly, but through a [`CourseMethods`] instance.
25220///
25221/// # Example
25222///
25223/// Instantiate a resource method builder
25224///
25225/// ```test_harness,no_run
25226/// # extern crate hyper;
25227/// # extern crate hyper_rustls;
25228/// # extern crate google_classroom1 as classroom1;
25229/// # async fn dox() {
25230/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25231///
25232/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25233/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25234/// # .with_native_roots()
25235/// # .unwrap()
25236/// # .https_only()
25237/// # .enable_http2()
25238/// # .build();
25239///
25240/// # let executor = hyper_util::rt::TokioExecutor::new();
25241/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25242/// # secret,
25243/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25244/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25245/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25246/// # ),
25247/// # ).build().await.unwrap();
25248///
25249/// # let client = hyper_util::client::legacy::Client::builder(
25250/// # hyper_util::rt::TokioExecutor::new()
25251/// # )
25252/// # .build(
25253/// # hyper_rustls::HttpsConnectorBuilder::new()
25254/// # .with_native_roots()
25255/// # .unwrap()
25256/// # .https_or_http()
25257/// # .enable_http2()
25258/// # .build()
25259/// # );
25260/// # let mut hub = Classroom::new(client, auth);
25261/// // You can configure optional parameters by calling the respective setters at will, and
25262/// // execute the final call using `doit()`.
25263/// // Values shown here are possibly random and not representative !
25264/// let result = hub.courses().posts_add_on_attachments_delete("courseId", "postId", "attachmentId")
25265/// .item_id("kasd")
25266/// .doit().await;
25267/// # }
25268/// ```
25269pub struct CoursePostAddOnAttachmentDeleteCall<'a, C>
25270where
25271 C: 'a,
25272{
25273 hub: &'a Classroom<C>,
25274 _course_id: String,
25275 _post_id: String,
25276 _attachment_id: String,
25277 _item_id: Option<String>,
25278 _delegate: Option<&'a mut dyn common::Delegate>,
25279 _additional_params: HashMap<String, String>,
25280 _scopes: BTreeSet<String>,
25281}
25282
25283impl<'a, C> common::CallBuilder for CoursePostAddOnAttachmentDeleteCall<'a, C> {}
25284
25285impl<'a, C> CoursePostAddOnAttachmentDeleteCall<'a, C>
25286where
25287 C: common::Connector,
25288{
25289 /// Perform the operation you have build so far.
25290 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
25291 use std::borrow::Cow;
25292 use std::io::{Read, Seek};
25293
25294 use common::{url::Params, ToParts};
25295 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25296
25297 let mut dd = common::DefaultDelegate;
25298 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25299 dlg.begin(common::MethodInfo {
25300 id: "classroom.courses.posts.addOnAttachments.delete",
25301 http_method: hyper::Method::DELETE,
25302 });
25303
25304 for &field in ["alt", "courseId", "postId", "attachmentId", "itemId"].iter() {
25305 if self._additional_params.contains_key(field) {
25306 dlg.finished(false);
25307 return Err(common::Error::FieldClash(field));
25308 }
25309 }
25310
25311 let mut params = Params::with_capacity(6 + self._additional_params.len());
25312 params.push("courseId", self._course_id);
25313 params.push("postId", self._post_id);
25314 params.push("attachmentId", self._attachment_id);
25315 if let Some(value) = self._item_id.as_ref() {
25316 params.push("itemId", value);
25317 }
25318
25319 params.extend(self._additional_params.iter());
25320
25321 params.push("alt", "json");
25322 let mut url = self.hub._base_url.clone()
25323 + "v1/courses/{courseId}/posts/{postId}/addOnAttachments/{attachmentId}";
25324 if self._scopes.is_empty() {
25325 self._scopes
25326 .insert(Scope::AddonTeacher.as_ref().to_string());
25327 }
25328
25329 #[allow(clippy::single_element_loop)]
25330 for &(find_this, param_name) in [
25331 ("{courseId}", "courseId"),
25332 ("{postId}", "postId"),
25333 ("{attachmentId}", "attachmentId"),
25334 ]
25335 .iter()
25336 {
25337 url = params.uri_replacement(url, param_name, find_this, false);
25338 }
25339 {
25340 let to_remove = ["attachmentId", "postId", "courseId"];
25341 params.remove_params(&to_remove);
25342 }
25343
25344 let url = params.parse_with_url(&url);
25345
25346 loop {
25347 let token = match self
25348 .hub
25349 .auth
25350 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25351 .await
25352 {
25353 Ok(token) => token,
25354 Err(e) => match dlg.token(e) {
25355 Ok(token) => token,
25356 Err(e) => {
25357 dlg.finished(false);
25358 return Err(common::Error::MissingToken(e));
25359 }
25360 },
25361 };
25362 let mut req_result = {
25363 let client = &self.hub.client;
25364 dlg.pre_request();
25365 let mut req_builder = hyper::Request::builder()
25366 .method(hyper::Method::DELETE)
25367 .uri(url.as_str())
25368 .header(USER_AGENT, self.hub._user_agent.clone());
25369
25370 if let Some(token) = token.as_ref() {
25371 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25372 }
25373
25374 let request = req_builder
25375 .header(CONTENT_LENGTH, 0_u64)
25376 .body(common::to_body::<String>(None));
25377
25378 client.request(request.unwrap()).await
25379 };
25380
25381 match req_result {
25382 Err(err) => {
25383 if let common::Retry::After(d) = dlg.http_error(&err) {
25384 sleep(d).await;
25385 continue;
25386 }
25387 dlg.finished(false);
25388 return Err(common::Error::HttpError(err));
25389 }
25390 Ok(res) => {
25391 let (mut parts, body) = res.into_parts();
25392 let mut body = common::Body::new(body);
25393 if !parts.status.is_success() {
25394 let bytes = common::to_bytes(body).await.unwrap_or_default();
25395 let error = serde_json::from_str(&common::to_string(&bytes));
25396 let response = common::to_response(parts, bytes.into());
25397
25398 if let common::Retry::After(d) =
25399 dlg.http_failure(&response, error.as_ref().ok())
25400 {
25401 sleep(d).await;
25402 continue;
25403 }
25404
25405 dlg.finished(false);
25406
25407 return Err(match error {
25408 Ok(value) => common::Error::BadRequest(value),
25409 _ => common::Error::Failure(response),
25410 });
25411 }
25412 let response = {
25413 let bytes = common::to_bytes(body).await.unwrap_or_default();
25414 let encoded = common::to_string(&bytes);
25415 match serde_json::from_str(&encoded) {
25416 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25417 Err(error) => {
25418 dlg.response_json_decode_error(&encoded, &error);
25419 return Err(common::Error::JsonDecodeError(
25420 encoded.to_string(),
25421 error,
25422 ));
25423 }
25424 }
25425 };
25426
25427 dlg.finished(true);
25428 return Ok(response);
25429 }
25430 }
25431 }
25432 }
25433
25434 /// Required. Identifier of the course.
25435 ///
25436 /// Sets the *course id* path property to the given value.
25437 ///
25438 /// Even though the property as already been set when instantiating this call,
25439 /// we provide this method for API completeness.
25440 pub fn course_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentDeleteCall<'a, C> {
25441 self._course_id = new_value.to_string();
25442 self
25443 }
25444 /// Optional. Deprecated, use `item_id` instead.
25445 ///
25446 /// Sets the *post id* path property to the given value.
25447 ///
25448 /// Even though the property as already been set when instantiating this call,
25449 /// we provide this method for API completeness.
25450 pub fn post_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentDeleteCall<'a, C> {
25451 self._post_id = new_value.to_string();
25452 self
25453 }
25454 /// Required. Identifier of the attachment.
25455 ///
25456 /// Sets the *attachment id* path property to the given value.
25457 ///
25458 /// Even though the property as already been set when instantiating this call,
25459 /// we provide this method for API completeness.
25460 pub fn attachment_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentDeleteCall<'a, C> {
25461 self._attachment_id = new_value.to_string();
25462 self
25463 }
25464 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
25465 ///
25466 /// Sets the *item id* query property to the given value.
25467 pub fn item_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentDeleteCall<'a, C> {
25468 self._item_id = Some(new_value.to_string());
25469 self
25470 }
25471 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25472 /// while executing the actual API request.
25473 ///
25474 /// ````text
25475 /// It should be used to handle progress information, and to implement a certain level of resilience.
25476 /// ````
25477 ///
25478 /// Sets the *delegate* property to the given value.
25479 pub fn delegate(
25480 mut self,
25481 new_value: &'a mut dyn common::Delegate,
25482 ) -> CoursePostAddOnAttachmentDeleteCall<'a, C> {
25483 self._delegate = Some(new_value);
25484 self
25485 }
25486
25487 /// Set any additional parameter of the query string used in the request.
25488 /// It should be used to set parameters which are not yet available through their own
25489 /// setters.
25490 ///
25491 /// Please note that this method must not be used to set any of the known parameters
25492 /// which have their own setter method. If done anyway, the request will fail.
25493 ///
25494 /// # Additional Parameters
25495 ///
25496 /// * *$.xgafv* (query-string) - V1 error format.
25497 /// * *access_token* (query-string) - OAuth access token.
25498 /// * *alt* (query-string) - Data format for response.
25499 /// * *callback* (query-string) - JSONP
25500 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25501 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
25502 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25503 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25504 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
25505 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25506 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25507 pub fn param<T>(mut self, name: T, value: T) -> CoursePostAddOnAttachmentDeleteCall<'a, C>
25508 where
25509 T: AsRef<str>,
25510 {
25511 self._additional_params
25512 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25513 self
25514 }
25515
25516 /// Identifies the authorization scope for the method you are building.
25517 ///
25518 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25519 /// [`Scope::AddonTeacher`].
25520 ///
25521 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25522 /// tokens for more than one scope.
25523 ///
25524 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25525 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25526 /// sufficient, a read-write scope will do as well.
25527 pub fn add_scope<St>(mut self, scope: St) -> CoursePostAddOnAttachmentDeleteCall<'a, C>
25528 where
25529 St: AsRef<str>,
25530 {
25531 self._scopes.insert(String::from(scope.as_ref()));
25532 self
25533 }
25534 /// Identifies the authorization scope(s) for the method you are building.
25535 ///
25536 /// See [`Self::add_scope()`] for details.
25537 pub fn add_scopes<I, St>(mut self, scopes: I) -> CoursePostAddOnAttachmentDeleteCall<'a, C>
25538 where
25539 I: IntoIterator<Item = St>,
25540 St: AsRef<str>,
25541 {
25542 self._scopes
25543 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25544 self
25545 }
25546
25547 /// Removes all scopes, and no default scope will be used either.
25548 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25549 /// for details).
25550 pub fn clear_scopes(mut self) -> CoursePostAddOnAttachmentDeleteCall<'a, C> {
25551 self._scopes.clear();
25552 self
25553 }
25554}
25555
25556/// Returns an add-on attachment. Requires the add-on requesting the attachment to be the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
25557///
25558/// A builder for the *posts.addOnAttachments.get* method supported by a *course* resource.
25559/// It is not used directly, but through a [`CourseMethods`] instance.
25560///
25561/// # Example
25562///
25563/// Instantiate a resource method builder
25564///
25565/// ```test_harness,no_run
25566/// # extern crate hyper;
25567/// # extern crate hyper_rustls;
25568/// # extern crate google_classroom1 as classroom1;
25569/// # async fn dox() {
25570/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25571///
25572/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25573/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25574/// # .with_native_roots()
25575/// # .unwrap()
25576/// # .https_only()
25577/// # .enable_http2()
25578/// # .build();
25579///
25580/// # let executor = hyper_util::rt::TokioExecutor::new();
25581/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25582/// # secret,
25583/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25584/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25585/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25586/// # ),
25587/// # ).build().await.unwrap();
25588///
25589/// # let client = hyper_util::client::legacy::Client::builder(
25590/// # hyper_util::rt::TokioExecutor::new()
25591/// # )
25592/// # .build(
25593/// # hyper_rustls::HttpsConnectorBuilder::new()
25594/// # .with_native_roots()
25595/// # .unwrap()
25596/// # .https_or_http()
25597/// # .enable_http2()
25598/// # .build()
25599/// # );
25600/// # let mut hub = Classroom::new(client, auth);
25601/// // You can configure optional parameters by calling the respective setters at will, and
25602/// // execute the final call using `doit()`.
25603/// // Values shown here are possibly random and not representative !
25604/// let result = hub.courses().posts_add_on_attachments_get("courseId", "postId", "attachmentId")
25605/// .item_id("rebum.")
25606/// .doit().await;
25607/// # }
25608/// ```
25609pub struct CoursePostAddOnAttachmentGetCall<'a, C>
25610where
25611 C: 'a,
25612{
25613 hub: &'a Classroom<C>,
25614 _course_id: String,
25615 _post_id: String,
25616 _attachment_id: String,
25617 _item_id: Option<String>,
25618 _delegate: Option<&'a mut dyn common::Delegate>,
25619 _additional_params: HashMap<String, String>,
25620 _scopes: BTreeSet<String>,
25621}
25622
25623impl<'a, C> common::CallBuilder for CoursePostAddOnAttachmentGetCall<'a, C> {}
25624
25625impl<'a, C> CoursePostAddOnAttachmentGetCall<'a, C>
25626where
25627 C: common::Connector,
25628{
25629 /// Perform the operation you have build so far.
25630 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
25631 use std::borrow::Cow;
25632 use std::io::{Read, Seek};
25633
25634 use common::{url::Params, ToParts};
25635 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25636
25637 let mut dd = common::DefaultDelegate;
25638 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25639 dlg.begin(common::MethodInfo {
25640 id: "classroom.courses.posts.addOnAttachments.get",
25641 http_method: hyper::Method::GET,
25642 });
25643
25644 for &field in ["alt", "courseId", "postId", "attachmentId", "itemId"].iter() {
25645 if self._additional_params.contains_key(field) {
25646 dlg.finished(false);
25647 return Err(common::Error::FieldClash(field));
25648 }
25649 }
25650
25651 let mut params = Params::with_capacity(6 + self._additional_params.len());
25652 params.push("courseId", self._course_id);
25653 params.push("postId", self._post_id);
25654 params.push("attachmentId", self._attachment_id);
25655 if let Some(value) = self._item_id.as_ref() {
25656 params.push("itemId", value);
25657 }
25658
25659 params.extend(self._additional_params.iter());
25660
25661 params.push("alt", "json");
25662 let mut url = self.hub._base_url.clone()
25663 + "v1/courses/{courseId}/posts/{postId}/addOnAttachments/{attachmentId}";
25664 if self._scopes.is_empty() {
25665 self._scopes
25666 .insert(Scope::AddonStudent.as_ref().to_string());
25667 }
25668
25669 #[allow(clippy::single_element_loop)]
25670 for &(find_this, param_name) in [
25671 ("{courseId}", "courseId"),
25672 ("{postId}", "postId"),
25673 ("{attachmentId}", "attachmentId"),
25674 ]
25675 .iter()
25676 {
25677 url = params.uri_replacement(url, param_name, find_this, false);
25678 }
25679 {
25680 let to_remove = ["attachmentId", "postId", "courseId"];
25681 params.remove_params(&to_remove);
25682 }
25683
25684 let url = params.parse_with_url(&url);
25685
25686 loop {
25687 let token = match self
25688 .hub
25689 .auth
25690 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25691 .await
25692 {
25693 Ok(token) => token,
25694 Err(e) => match dlg.token(e) {
25695 Ok(token) => token,
25696 Err(e) => {
25697 dlg.finished(false);
25698 return Err(common::Error::MissingToken(e));
25699 }
25700 },
25701 };
25702 let mut req_result = {
25703 let client = &self.hub.client;
25704 dlg.pre_request();
25705 let mut req_builder = hyper::Request::builder()
25706 .method(hyper::Method::GET)
25707 .uri(url.as_str())
25708 .header(USER_AGENT, self.hub._user_agent.clone());
25709
25710 if let Some(token) = token.as_ref() {
25711 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25712 }
25713
25714 let request = req_builder
25715 .header(CONTENT_LENGTH, 0_u64)
25716 .body(common::to_body::<String>(None));
25717
25718 client.request(request.unwrap()).await
25719 };
25720
25721 match req_result {
25722 Err(err) => {
25723 if let common::Retry::After(d) = dlg.http_error(&err) {
25724 sleep(d).await;
25725 continue;
25726 }
25727 dlg.finished(false);
25728 return Err(common::Error::HttpError(err));
25729 }
25730 Ok(res) => {
25731 let (mut parts, body) = res.into_parts();
25732 let mut body = common::Body::new(body);
25733 if !parts.status.is_success() {
25734 let bytes = common::to_bytes(body).await.unwrap_or_default();
25735 let error = serde_json::from_str(&common::to_string(&bytes));
25736 let response = common::to_response(parts, bytes.into());
25737
25738 if let common::Retry::After(d) =
25739 dlg.http_failure(&response, error.as_ref().ok())
25740 {
25741 sleep(d).await;
25742 continue;
25743 }
25744
25745 dlg.finished(false);
25746
25747 return Err(match error {
25748 Ok(value) => common::Error::BadRequest(value),
25749 _ => common::Error::Failure(response),
25750 });
25751 }
25752 let response = {
25753 let bytes = common::to_bytes(body).await.unwrap_or_default();
25754 let encoded = common::to_string(&bytes);
25755 match serde_json::from_str(&encoded) {
25756 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25757 Err(error) => {
25758 dlg.response_json_decode_error(&encoded, &error);
25759 return Err(common::Error::JsonDecodeError(
25760 encoded.to_string(),
25761 error,
25762 ));
25763 }
25764 }
25765 };
25766
25767 dlg.finished(true);
25768 return Ok(response);
25769 }
25770 }
25771 }
25772 }
25773
25774 /// Required. Identifier of the course.
25775 ///
25776 /// Sets the *course id* path property to the given value.
25777 ///
25778 /// Even though the property as already been set when instantiating this call,
25779 /// we provide this method for API completeness.
25780 pub fn course_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentGetCall<'a, C> {
25781 self._course_id = new_value.to_string();
25782 self
25783 }
25784 /// Optional. Deprecated, use `item_id` instead.
25785 ///
25786 /// Sets the *post id* path property to the given value.
25787 ///
25788 /// Even though the property as already been set when instantiating this call,
25789 /// we provide this method for API completeness.
25790 pub fn post_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentGetCall<'a, C> {
25791 self._post_id = new_value.to_string();
25792 self
25793 }
25794 /// Required. Identifier of the attachment.
25795 ///
25796 /// Sets the *attachment id* path property to the given value.
25797 ///
25798 /// Even though the property as already been set when instantiating this call,
25799 /// we provide this method for API completeness.
25800 pub fn attachment_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentGetCall<'a, C> {
25801 self._attachment_id = new_value.to_string();
25802 self
25803 }
25804 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
25805 ///
25806 /// Sets the *item id* query property to the given value.
25807 pub fn item_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentGetCall<'a, C> {
25808 self._item_id = Some(new_value.to_string());
25809 self
25810 }
25811 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25812 /// while executing the actual API request.
25813 ///
25814 /// ````text
25815 /// It should be used to handle progress information, and to implement a certain level of resilience.
25816 /// ````
25817 ///
25818 /// Sets the *delegate* property to the given value.
25819 pub fn delegate(
25820 mut self,
25821 new_value: &'a mut dyn common::Delegate,
25822 ) -> CoursePostAddOnAttachmentGetCall<'a, C> {
25823 self._delegate = Some(new_value);
25824 self
25825 }
25826
25827 /// Set any additional parameter of the query string used in the request.
25828 /// It should be used to set parameters which are not yet available through their own
25829 /// setters.
25830 ///
25831 /// Please note that this method must not be used to set any of the known parameters
25832 /// which have their own setter method. If done anyway, the request will fail.
25833 ///
25834 /// # Additional Parameters
25835 ///
25836 /// * *$.xgafv* (query-string) - V1 error format.
25837 /// * *access_token* (query-string) - OAuth access token.
25838 /// * *alt* (query-string) - Data format for response.
25839 /// * *callback* (query-string) - JSONP
25840 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25841 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
25842 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25843 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25844 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
25845 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25846 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25847 pub fn param<T>(mut self, name: T, value: T) -> CoursePostAddOnAttachmentGetCall<'a, C>
25848 where
25849 T: AsRef<str>,
25850 {
25851 self._additional_params
25852 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25853 self
25854 }
25855
25856 /// Identifies the authorization scope for the method you are building.
25857 ///
25858 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25859 /// [`Scope::AddonStudent`].
25860 ///
25861 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25862 /// tokens for more than one scope.
25863 ///
25864 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25865 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25866 /// sufficient, a read-write scope will do as well.
25867 pub fn add_scope<St>(mut self, scope: St) -> CoursePostAddOnAttachmentGetCall<'a, C>
25868 where
25869 St: AsRef<str>,
25870 {
25871 self._scopes.insert(String::from(scope.as_ref()));
25872 self
25873 }
25874 /// Identifies the authorization scope(s) for the method you are building.
25875 ///
25876 /// See [`Self::add_scope()`] for details.
25877 pub fn add_scopes<I, St>(mut self, scopes: I) -> CoursePostAddOnAttachmentGetCall<'a, C>
25878 where
25879 I: IntoIterator<Item = St>,
25880 St: AsRef<str>,
25881 {
25882 self._scopes
25883 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25884 self
25885 }
25886
25887 /// Removes all scopes, and no default scope will be used either.
25888 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25889 /// for details).
25890 pub fn clear_scopes(mut self) -> CoursePostAddOnAttachmentGetCall<'a, C> {
25891 self._scopes.clear();
25892 self
25893 }
25894}
25895
25896/// Returns all attachments created by an add-on under the post. Requires the add-on to have active attachments on the post or have permission to create new attachments on the post. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
25897///
25898/// A builder for the *posts.addOnAttachments.list* method supported by a *course* resource.
25899/// It is not used directly, but through a [`CourseMethods`] instance.
25900///
25901/// # Example
25902///
25903/// Instantiate a resource method builder
25904///
25905/// ```test_harness,no_run
25906/// # extern crate hyper;
25907/// # extern crate hyper_rustls;
25908/// # extern crate google_classroom1 as classroom1;
25909/// # async fn dox() {
25910/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25911///
25912/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25913/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25914/// # .with_native_roots()
25915/// # .unwrap()
25916/// # .https_only()
25917/// # .enable_http2()
25918/// # .build();
25919///
25920/// # let executor = hyper_util::rt::TokioExecutor::new();
25921/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25922/// # secret,
25923/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25924/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25925/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25926/// # ),
25927/// # ).build().await.unwrap();
25928///
25929/// # let client = hyper_util::client::legacy::Client::builder(
25930/// # hyper_util::rt::TokioExecutor::new()
25931/// # )
25932/// # .build(
25933/// # hyper_rustls::HttpsConnectorBuilder::new()
25934/// # .with_native_roots()
25935/// # .unwrap()
25936/// # .https_or_http()
25937/// # .enable_http2()
25938/// # .build()
25939/// # );
25940/// # let mut hub = Classroom::new(client, auth);
25941/// // You can configure optional parameters by calling the respective setters at will, and
25942/// // execute the final call using `doit()`.
25943/// // Values shown here are possibly random and not representative !
25944/// let result = hub.courses().posts_add_on_attachments_list("courseId", "postId")
25945/// .page_token("eos")
25946/// .page_size(-52)
25947/// .item_id("dolore")
25948/// .doit().await;
25949/// # }
25950/// ```
25951pub struct CoursePostAddOnAttachmentListCall<'a, C>
25952where
25953 C: 'a,
25954{
25955 hub: &'a Classroom<C>,
25956 _course_id: String,
25957 _post_id: String,
25958 _page_token: Option<String>,
25959 _page_size: Option<i32>,
25960 _item_id: Option<String>,
25961 _delegate: Option<&'a mut dyn common::Delegate>,
25962 _additional_params: HashMap<String, String>,
25963 _scopes: BTreeSet<String>,
25964}
25965
25966impl<'a, C> common::CallBuilder for CoursePostAddOnAttachmentListCall<'a, C> {}
25967
25968impl<'a, C> CoursePostAddOnAttachmentListCall<'a, C>
25969where
25970 C: common::Connector,
25971{
25972 /// Perform the operation you have build so far.
25973 pub async fn doit(
25974 mut self,
25975 ) -> common::Result<(common::Response, ListAddOnAttachmentsResponse)> {
25976 use std::borrow::Cow;
25977 use std::io::{Read, Seek};
25978
25979 use common::{url::Params, ToParts};
25980 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25981
25982 let mut dd = common::DefaultDelegate;
25983 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25984 dlg.begin(common::MethodInfo {
25985 id: "classroom.courses.posts.addOnAttachments.list",
25986 http_method: hyper::Method::GET,
25987 });
25988
25989 for &field in [
25990 "alt",
25991 "courseId",
25992 "postId",
25993 "pageToken",
25994 "pageSize",
25995 "itemId",
25996 ]
25997 .iter()
25998 {
25999 if self._additional_params.contains_key(field) {
26000 dlg.finished(false);
26001 return Err(common::Error::FieldClash(field));
26002 }
26003 }
26004
26005 let mut params = Params::with_capacity(7 + self._additional_params.len());
26006 params.push("courseId", self._course_id);
26007 params.push("postId", self._post_id);
26008 if let Some(value) = self._page_token.as_ref() {
26009 params.push("pageToken", value);
26010 }
26011 if let Some(value) = self._page_size.as_ref() {
26012 params.push("pageSize", value.to_string());
26013 }
26014 if let Some(value) = self._item_id.as_ref() {
26015 params.push("itemId", value);
26016 }
26017
26018 params.extend(self._additional_params.iter());
26019
26020 params.push("alt", "json");
26021 let mut url =
26022 self.hub._base_url.clone() + "v1/courses/{courseId}/posts/{postId}/addOnAttachments";
26023 if self._scopes.is_empty() {
26024 self._scopes
26025 .insert(Scope::AddonStudent.as_ref().to_string());
26026 }
26027
26028 #[allow(clippy::single_element_loop)]
26029 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{postId}", "postId")].iter()
26030 {
26031 url = params.uri_replacement(url, param_name, find_this, false);
26032 }
26033 {
26034 let to_remove = ["postId", "courseId"];
26035 params.remove_params(&to_remove);
26036 }
26037
26038 let url = params.parse_with_url(&url);
26039
26040 loop {
26041 let token = match self
26042 .hub
26043 .auth
26044 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26045 .await
26046 {
26047 Ok(token) => token,
26048 Err(e) => match dlg.token(e) {
26049 Ok(token) => token,
26050 Err(e) => {
26051 dlg.finished(false);
26052 return Err(common::Error::MissingToken(e));
26053 }
26054 },
26055 };
26056 let mut req_result = {
26057 let client = &self.hub.client;
26058 dlg.pre_request();
26059 let mut req_builder = hyper::Request::builder()
26060 .method(hyper::Method::GET)
26061 .uri(url.as_str())
26062 .header(USER_AGENT, self.hub._user_agent.clone());
26063
26064 if let Some(token) = token.as_ref() {
26065 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26066 }
26067
26068 let request = req_builder
26069 .header(CONTENT_LENGTH, 0_u64)
26070 .body(common::to_body::<String>(None));
26071
26072 client.request(request.unwrap()).await
26073 };
26074
26075 match req_result {
26076 Err(err) => {
26077 if let common::Retry::After(d) = dlg.http_error(&err) {
26078 sleep(d).await;
26079 continue;
26080 }
26081 dlg.finished(false);
26082 return Err(common::Error::HttpError(err));
26083 }
26084 Ok(res) => {
26085 let (mut parts, body) = res.into_parts();
26086 let mut body = common::Body::new(body);
26087 if !parts.status.is_success() {
26088 let bytes = common::to_bytes(body).await.unwrap_or_default();
26089 let error = serde_json::from_str(&common::to_string(&bytes));
26090 let response = common::to_response(parts, bytes.into());
26091
26092 if let common::Retry::After(d) =
26093 dlg.http_failure(&response, error.as_ref().ok())
26094 {
26095 sleep(d).await;
26096 continue;
26097 }
26098
26099 dlg.finished(false);
26100
26101 return Err(match error {
26102 Ok(value) => common::Error::BadRequest(value),
26103 _ => common::Error::Failure(response),
26104 });
26105 }
26106 let response = {
26107 let bytes = common::to_bytes(body).await.unwrap_or_default();
26108 let encoded = common::to_string(&bytes);
26109 match serde_json::from_str(&encoded) {
26110 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26111 Err(error) => {
26112 dlg.response_json_decode_error(&encoded, &error);
26113 return Err(common::Error::JsonDecodeError(
26114 encoded.to_string(),
26115 error,
26116 ));
26117 }
26118 }
26119 };
26120
26121 dlg.finished(true);
26122 return Ok(response);
26123 }
26124 }
26125 }
26126 }
26127
26128 /// Required. Identifier of the course.
26129 ///
26130 /// Sets the *course id* path property to the given value.
26131 ///
26132 /// Even though the property as already been set when instantiating this call,
26133 /// we provide this method for API completeness.
26134 pub fn course_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentListCall<'a, C> {
26135 self._course_id = new_value.to_string();
26136 self
26137 }
26138 /// Optional. Identifier of the post under the course whose attachments to enumerate. Deprecated, use `item_id` instead.
26139 ///
26140 /// Sets the *post id* path property to the given value.
26141 ///
26142 /// Even though the property as already been set when instantiating this call,
26143 /// we provide this method for API completeness.
26144 pub fn post_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentListCall<'a, C> {
26145 self._post_id = new_value.to_string();
26146 self
26147 }
26148 /// A page token, received from a previous `ListAddOnAttachments` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAddOnAttachments` must match the call that provided the page token.
26149 ///
26150 /// Sets the *page token* query property to the given value.
26151 pub fn page_token(mut self, new_value: &str) -> CoursePostAddOnAttachmentListCall<'a, C> {
26152 self._page_token = Some(new_value.to_string());
26153 self
26154 }
26155 /// The maximum number of attachments to return. The service may return fewer than this value. If unspecified, at most 20 attachments will be returned. The maximum value is 20; values above 20 will be coerced to 20.
26156 ///
26157 /// Sets the *page size* query property to the given value.
26158 pub fn page_size(mut self, new_value: i32) -> CoursePostAddOnAttachmentListCall<'a, C> {
26159 self._page_size = Some(new_value);
26160 self
26161 }
26162 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` whose attachments should be enumerated. This field is required, but is not marked as such while we are migrating from post_id.
26163 ///
26164 /// Sets the *item id* query property to the given value.
26165 pub fn item_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentListCall<'a, C> {
26166 self._item_id = Some(new_value.to_string());
26167 self
26168 }
26169 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26170 /// while executing the actual API request.
26171 ///
26172 /// ````text
26173 /// It should be used to handle progress information, and to implement a certain level of resilience.
26174 /// ````
26175 ///
26176 /// Sets the *delegate* property to the given value.
26177 pub fn delegate(
26178 mut self,
26179 new_value: &'a mut dyn common::Delegate,
26180 ) -> CoursePostAddOnAttachmentListCall<'a, C> {
26181 self._delegate = Some(new_value);
26182 self
26183 }
26184
26185 /// Set any additional parameter of the query string used in the request.
26186 /// It should be used to set parameters which are not yet available through their own
26187 /// setters.
26188 ///
26189 /// Please note that this method must not be used to set any of the known parameters
26190 /// which have their own setter method. If done anyway, the request will fail.
26191 ///
26192 /// # Additional Parameters
26193 ///
26194 /// * *$.xgafv* (query-string) - V1 error format.
26195 /// * *access_token* (query-string) - OAuth access token.
26196 /// * *alt* (query-string) - Data format for response.
26197 /// * *callback* (query-string) - JSONP
26198 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26199 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
26200 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26201 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26202 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
26203 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26204 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26205 pub fn param<T>(mut self, name: T, value: T) -> CoursePostAddOnAttachmentListCall<'a, C>
26206 where
26207 T: AsRef<str>,
26208 {
26209 self._additional_params
26210 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26211 self
26212 }
26213
26214 /// Identifies the authorization scope for the method you are building.
26215 ///
26216 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26217 /// [`Scope::AddonStudent`].
26218 ///
26219 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26220 /// tokens for more than one scope.
26221 ///
26222 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26223 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26224 /// sufficient, a read-write scope will do as well.
26225 pub fn add_scope<St>(mut self, scope: St) -> CoursePostAddOnAttachmentListCall<'a, C>
26226 where
26227 St: AsRef<str>,
26228 {
26229 self._scopes.insert(String::from(scope.as_ref()));
26230 self
26231 }
26232 /// Identifies the authorization scope(s) for the method you are building.
26233 ///
26234 /// See [`Self::add_scope()`] for details.
26235 pub fn add_scopes<I, St>(mut self, scopes: I) -> CoursePostAddOnAttachmentListCall<'a, C>
26236 where
26237 I: IntoIterator<Item = St>,
26238 St: AsRef<str>,
26239 {
26240 self._scopes
26241 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26242 self
26243 }
26244
26245 /// Removes all scopes, and no default scope will be used either.
26246 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26247 /// for details).
26248 pub fn clear_scopes(mut self) -> CoursePostAddOnAttachmentListCall<'a, C> {
26249 self._scopes.clear();
26250 self
26251 }
26252}
26253
26254/// Updates an add-on attachment. Requires the add-on to have been the original creator of the attachment. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
26255///
26256/// A builder for the *posts.addOnAttachments.patch* method supported by a *course* resource.
26257/// It is not used directly, but through a [`CourseMethods`] instance.
26258///
26259/// # Example
26260///
26261/// Instantiate a resource method builder
26262///
26263/// ```test_harness,no_run
26264/// # extern crate hyper;
26265/// # extern crate hyper_rustls;
26266/// # extern crate google_classroom1 as classroom1;
26267/// use classroom1::api::AddOnAttachment;
26268/// # async fn dox() {
26269/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26270///
26271/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26272/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26273/// # .with_native_roots()
26274/// # .unwrap()
26275/// # .https_only()
26276/// # .enable_http2()
26277/// # .build();
26278///
26279/// # let executor = hyper_util::rt::TokioExecutor::new();
26280/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26281/// # secret,
26282/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26283/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26284/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26285/// # ),
26286/// # ).build().await.unwrap();
26287///
26288/// # let client = hyper_util::client::legacy::Client::builder(
26289/// # hyper_util::rt::TokioExecutor::new()
26290/// # )
26291/// # .build(
26292/// # hyper_rustls::HttpsConnectorBuilder::new()
26293/// # .with_native_roots()
26294/// # .unwrap()
26295/// # .https_or_http()
26296/// # .enable_http2()
26297/// # .build()
26298/// # );
26299/// # let mut hub = Classroom::new(client, auth);
26300/// // As the method needs a request, you would usually fill it with the desired information
26301/// // into the respective structure. Some of the parts shown here might not be applicable !
26302/// // Values shown here are possibly random and not representative !
26303/// let mut req = AddOnAttachment::default();
26304///
26305/// // You can configure optional parameters by calling the respective setters at will, and
26306/// // execute the final call using `doit()`.
26307/// // Values shown here are possibly random and not representative !
26308/// let result = hub.courses().posts_add_on_attachments_patch(req, "courseId", "postId", "attachmentId")
26309/// .update_mask(FieldMask::new::<&str>(&[]))
26310/// .item_id("sit")
26311/// .doit().await;
26312/// # }
26313/// ```
26314pub struct CoursePostAddOnAttachmentPatchCall<'a, C>
26315where
26316 C: 'a,
26317{
26318 hub: &'a Classroom<C>,
26319 _request: AddOnAttachment,
26320 _course_id: String,
26321 _post_id: String,
26322 _attachment_id: String,
26323 _update_mask: Option<common::FieldMask>,
26324 _item_id: Option<String>,
26325 _delegate: Option<&'a mut dyn common::Delegate>,
26326 _additional_params: HashMap<String, String>,
26327 _scopes: BTreeSet<String>,
26328}
26329
26330impl<'a, C> common::CallBuilder for CoursePostAddOnAttachmentPatchCall<'a, C> {}
26331
26332impl<'a, C> CoursePostAddOnAttachmentPatchCall<'a, C>
26333where
26334 C: common::Connector,
26335{
26336 /// Perform the operation you have build so far.
26337 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnAttachment)> {
26338 use std::borrow::Cow;
26339 use std::io::{Read, Seek};
26340
26341 use common::{url::Params, ToParts};
26342 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26343
26344 let mut dd = common::DefaultDelegate;
26345 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26346 dlg.begin(common::MethodInfo {
26347 id: "classroom.courses.posts.addOnAttachments.patch",
26348 http_method: hyper::Method::PATCH,
26349 });
26350
26351 for &field in [
26352 "alt",
26353 "courseId",
26354 "postId",
26355 "attachmentId",
26356 "updateMask",
26357 "itemId",
26358 ]
26359 .iter()
26360 {
26361 if self._additional_params.contains_key(field) {
26362 dlg.finished(false);
26363 return Err(common::Error::FieldClash(field));
26364 }
26365 }
26366
26367 let mut params = Params::with_capacity(8 + self._additional_params.len());
26368 params.push("courseId", self._course_id);
26369 params.push("postId", self._post_id);
26370 params.push("attachmentId", self._attachment_id);
26371 if let Some(value) = self._update_mask.as_ref() {
26372 params.push("updateMask", value.to_string());
26373 }
26374 if let Some(value) = self._item_id.as_ref() {
26375 params.push("itemId", value);
26376 }
26377
26378 params.extend(self._additional_params.iter());
26379
26380 params.push("alt", "json");
26381 let mut url = self.hub._base_url.clone()
26382 + "v1/courses/{courseId}/posts/{postId}/addOnAttachments/{attachmentId}";
26383 if self._scopes.is_empty() {
26384 self._scopes
26385 .insert(Scope::AddonTeacher.as_ref().to_string());
26386 }
26387
26388 #[allow(clippy::single_element_loop)]
26389 for &(find_this, param_name) in [
26390 ("{courseId}", "courseId"),
26391 ("{postId}", "postId"),
26392 ("{attachmentId}", "attachmentId"),
26393 ]
26394 .iter()
26395 {
26396 url = params.uri_replacement(url, param_name, find_this, false);
26397 }
26398 {
26399 let to_remove = ["attachmentId", "postId", "courseId"];
26400 params.remove_params(&to_remove);
26401 }
26402
26403 let url = params.parse_with_url(&url);
26404
26405 let mut json_mime_type = mime::APPLICATION_JSON;
26406 let mut request_value_reader = {
26407 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26408 common::remove_json_null_values(&mut value);
26409 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26410 serde_json::to_writer(&mut dst, &value).unwrap();
26411 dst
26412 };
26413 let request_size = request_value_reader
26414 .seek(std::io::SeekFrom::End(0))
26415 .unwrap();
26416 request_value_reader
26417 .seek(std::io::SeekFrom::Start(0))
26418 .unwrap();
26419
26420 loop {
26421 let token = match self
26422 .hub
26423 .auth
26424 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26425 .await
26426 {
26427 Ok(token) => token,
26428 Err(e) => match dlg.token(e) {
26429 Ok(token) => token,
26430 Err(e) => {
26431 dlg.finished(false);
26432 return Err(common::Error::MissingToken(e));
26433 }
26434 },
26435 };
26436 request_value_reader
26437 .seek(std::io::SeekFrom::Start(0))
26438 .unwrap();
26439 let mut req_result = {
26440 let client = &self.hub.client;
26441 dlg.pre_request();
26442 let mut req_builder = hyper::Request::builder()
26443 .method(hyper::Method::PATCH)
26444 .uri(url.as_str())
26445 .header(USER_AGENT, self.hub._user_agent.clone());
26446
26447 if let Some(token) = token.as_ref() {
26448 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26449 }
26450
26451 let request = req_builder
26452 .header(CONTENT_TYPE, json_mime_type.to_string())
26453 .header(CONTENT_LENGTH, request_size as u64)
26454 .body(common::to_body(
26455 request_value_reader.get_ref().clone().into(),
26456 ));
26457
26458 client.request(request.unwrap()).await
26459 };
26460
26461 match req_result {
26462 Err(err) => {
26463 if let common::Retry::After(d) = dlg.http_error(&err) {
26464 sleep(d).await;
26465 continue;
26466 }
26467 dlg.finished(false);
26468 return Err(common::Error::HttpError(err));
26469 }
26470 Ok(res) => {
26471 let (mut parts, body) = res.into_parts();
26472 let mut body = common::Body::new(body);
26473 if !parts.status.is_success() {
26474 let bytes = common::to_bytes(body).await.unwrap_or_default();
26475 let error = serde_json::from_str(&common::to_string(&bytes));
26476 let response = common::to_response(parts, bytes.into());
26477
26478 if let common::Retry::After(d) =
26479 dlg.http_failure(&response, error.as_ref().ok())
26480 {
26481 sleep(d).await;
26482 continue;
26483 }
26484
26485 dlg.finished(false);
26486
26487 return Err(match error {
26488 Ok(value) => common::Error::BadRequest(value),
26489 _ => common::Error::Failure(response),
26490 });
26491 }
26492 let response = {
26493 let bytes = common::to_bytes(body).await.unwrap_or_default();
26494 let encoded = common::to_string(&bytes);
26495 match serde_json::from_str(&encoded) {
26496 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26497 Err(error) => {
26498 dlg.response_json_decode_error(&encoded, &error);
26499 return Err(common::Error::JsonDecodeError(
26500 encoded.to_string(),
26501 error,
26502 ));
26503 }
26504 }
26505 };
26506
26507 dlg.finished(true);
26508 return Ok(response);
26509 }
26510 }
26511 }
26512 }
26513
26514 ///
26515 /// Sets the *request* property to the given value.
26516 ///
26517 /// Even though the property as already been set when instantiating this call,
26518 /// we provide this method for API completeness.
26519 pub fn request(
26520 mut self,
26521 new_value: AddOnAttachment,
26522 ) -> CoursePostAddOnAttachmentPatchCall<'a, C> {
26523 self._request = new_value;
26524 self
26525 }
26526 /// Required. Identifier of the course.
26527 ///
26528 /// Sets the *course id* path property to the given value.
26529 ///
26530 /// Even though the property as already been set when instantiating this call,
26531 /// we provide this method for API completeness.
26532 pub fn course_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentPatchCall<'a, C> {
26533 self._course_id = new_value.to_string();
26534 self
26535 }
26536 /// Required. Identifier of the post under which the attachment is attached.
26537 ///
26538 /// Sets the *post id* path property to the given value.
26539 ///
26540 /// Even though the property as already been set when instantiating this call,
26541 /// we provide this method for API completeness.
26542 pub fn post_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentPatchCall<'a, C> {
26543 self._post_id = new_value.to_string();
26544 self
26545 }
26546 /// Required. Identifier of the attachment.
26547 ///
26548 /// Sets the *attachment id* path property to the given value.
26549 ///
26550 /// Even though the property as already been set when instantiating this call,
26551 /// we provide this method for API completeness.
26552 pub fn attachment_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentPatchCall<'a, C> {
26553 self._attachment_id = new_value.to_string();
26554 self
26555 }
26556 /// Required. Mask that identifies which fields on the attachment to update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the `AddOnAttachment` object. If a field that does not support empty values is included in the update mask and not set in the `AddOnAttachment` object, an `INVALID_ARGUMENT` error is returned. The following fields may be specified by teachers: * `title` * `teacher_view_uri` * `student_view_uri` * `student_work_review_uri` * `due_date` * `due_time` * `max_points`
26557 ///
26558 /// Sets the *update mask* query property to the given value.
26559 pub fn update_mask(
26560 mut self,
26561 new_value: common::FieldMask,
26562 ) -> CoursePostAddOnAttachmentPatchCall<'a, C> {
26563 self._update_mask = Some(new_value);
26564 self
26565 }
26566 /// Identifier of the post under which the attachment is attached.
26567 ///
26568 /// Sets the *item id* query property to the given value.
26569 pub fn item_id(mut self, new_value: &str) -> CoursePostAddOnAttachmentPatchCall<'a, C> {
26570 self._item_id = Some(new_value.to_string());
26571 self
26572 }
26573 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26574 /// while executing the actual API request.
26575 ///
26576 /// ````text
26577 /// It should be used to handle progress information, and to implement a certain level of resilience.
26578 /// ````
26579 ///
26580 /// Sets the *delegate* property to the given value.
26581 pub fn delegate(
26582 mut self,
26583 new_value: &'a mut dyn common::Delegate,
26584 ) -> CoursePostAddOnAttachmentPatchCall<'a, C> {
26585 self._delegate = Some(new_value);
26586 self
26587 }
26588
26589 /// Set any additional parameter of the query string used in the request.
26590 /// It should be used to set parameters which are not yet available through their own
26591 /// setters.
26592 ///
26593 /// Please note that this method must not be used to set any of the known parameters
26594 /// which have their own setter method. If done anyway, the request will fail.
26595 ///
26596 /// # Additional Parameters
26597 ///
26598 /// * *$.xgafv* (query-string) - V1 error format.
26599 /// * *access_token* (query-string) - OAuth access token.
26600 /// * *alt* (query-string) - Data format for response.
26601 /// * *callback* (query-string) - JSONP
26602 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26603 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
26604 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26605 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26606 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
26607 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26608 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26609 pub fn param<T>(mut self, name: T, value: T) -> CoursePostAddOnAttachmentPatchCall<'a, C>
26610 where
26611 T: AsRef<str>,
26612 {
26613 self._additional_params
26614 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26615 self
26616 }
26617
26618 /// Identifies the authorization scope for the method you are building.
26619 ///
26620 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26621 /// [`Scope::AddonTeacher`].
26622 ///
26623 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26624 /// tokens for more than one scope.
26625 ///
26626 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26627 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26628 /// sufficient, a read-write scope will do as well.
26629 pub fn add_scope<St>(mut self, scope: St) -> CoursePostAddOnAttachmentPatchCall<'a, C>
26630 where
26631 St: AsRef<str>,
26632 {
26633 self._scopes.insert(String::from(scope.as_ref()));
26634 self
26635 }
26636 /// Identifies the authorization scope(s) for the method you are building.
26637 ///
26638 /// See [`Self::add_scope()`] for details.
26639 pub fn add_scopes<I, St>(mut self, scopes: I) -> CoursePostAddOnAttachmentPatchCall<'a, C>
26640 where
26641 I: IntoIterator<Item = St>,
26642 St: AsRef<str>,
26643 {
26644 self._scopes
26645 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26646 self
26647 }
26648
26649 /// Removes all scopes, and no default scope will be used either.
26650 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26651 /// for details).
26652 pub fn clear_scopes(mut self) -> CoursePostAddOnAttachmentPatchCall<'a, C> {
26653 self._scopes.clear();
26654 self
26655 }
26656}
26657
26658/// Gets metadata for Classroom add-ons in the context of a specific post. To maintain the integrity of its own data and permissions model, an add-on should call this to validate query parameters and the requesting user's role whenever the add-on is opened in an [iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/iframes-overview). This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if one of the identified resources does not exist.
26659///
26660/// A builder for the *posts.getAddOnContext* method supported by a *course* resource.
26661/// It is not used directly, but through a [`CourseMethods`] instance.
26662///
26663/// # Example
26664///
26665/// Instantiate a resource method builder
26666///
26667/// ```test_harness,no_run
26668/// # extern crate hyper;
26669/// # extern crate hyper_rustls;
26670/// # extern crate google_classroom1 as classroom1;
26671/// # async fn dox() {
26672/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26673///
26674/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26675/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26676/// # .with_native_roots()
26677/// # .unwrap()
26678/// # .https_only()
26679/// # .enable_http2()
26680/// # .build();
26681///
26682/// # let executor = hyper_util::rt::TokioExecutor::new();
26683/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26684/// # secret,
26685/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26686/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26687/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26688/// # ),
26689/// # ).build().await.unwrap();
26690///
26691/// # let client = hyper_util::client::legacy::Client::builder(
26692/// # hyper_util::rt::TokioExecutor::new()
26693/// # )
26694/// # .build(
26695/// # hyper_rustls::HttpsConnectorBuilder::new()
26696/// # .with_native_roots()
26697/// # .unwrap()
26698/// # .https_or_http()
26699/// # .enable_http2()
26700/// # .build()
26701/// # );
26702/// # let mut hub = Classroom::new(client, auth);
26703/// // You can configure optional parameters by calling the respective setters at will, and
26704/// // execute the final call using `doit()`.
26705/// // Values shown here are possibly random and not representative !
26706/// let result = hub.courses().posts_get_add_on_context("courseId", "postId")
26707/// .item_id("sadipscing")
26708/// .attachment_id("ut")
26709/// .add_on_token("rebum.")
26710/// .doit().await;
26711/// # }
26712/// ```
26713pub struct CoursePostGetAddOnContextCall<'a, C>
26714where
26715 C: 'a,
26716{
26717 hub: &'a Classroom<C>,
26718 _course_id: String,
26719 _post_id: String,
26720 _item_id: Option<String>,
26721 _attachment_id: Option<String>,
26722 _add_on_token: Option<String>,
26723 _delegate: Option<&'a mut dyn common::Delegate>,
26724 _additional_params: HashMap<String, String>,
26725 _scopes: BTreeSet<String>,
26726}
26727
26728impl<'a, C> common::CallBuilder for CoursePostGetAddOnContextCall<'a, C> {}
26729
26730impl<'a, C> CoursePostGetAddOnContextCall<'a, C>
26731where
26732 C: common::Connector,
26733{
26734 /// Perform the operation you have build so far.
26735 pub async fn doit(mut self) -> common::Result<(common::Response, AddOnContext)> {
26736 use std::borrow::Cow;
26737 use std::io::{Read, Seek};
26738
26739 use common::{url::Params, ToParts};
26740 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26741
26742 let mut dd = common::DefaultDelegate;
26743 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26744 dlg.begin(common::MethodInfo {
26745 id: "classroom.courses.posts.getAddOnContext",
26746 http_method: hyper::Method::GET,
26747 });
26748
26749 for &field in [
26750 "alt",
26751 "courseId",
26752 "postId",
26753 "itemId",
26754 "attachmentId",
26755 "addOnToken",
26756 ]
26757 .iter()
26758 {
26759 if self._additional_params.contains_key(field) {
26760 dlg.finished(false);
26761 return Err(common::Error::FieldClash(field));
26762 }
26763 }
26764
26765 let mut params = Params::with_capacity(7 + self._additional_params.len());
26766 params.push("courseId", self._course_id);
26767 params.push("postId", self._post_id);
26768 if let Some(value) = self._item_id.as_ref() {
26769 params.push("itemId", value);
26770 }
26771 if let Some(value) = self._attachment_id.as_ref() {
26772 params.push("attachmentId", value);
26773 }
26774 if let Some(value) = self._add_on_token.as_ref() {
26775 params.push("addOnToken", value);
26776 }
26777
26778 params.extend(self._additional_params.iter());
26779
26780 params.push("alt", "json");
26781 let mut url =
26782 self.hub._base_url.clone() + "v1/courses/{courseId}/posts/{postId}/addOnContext";
26783 if self._scopes.is_empty() {
26784 self._scopes
26785 .insert(Scope::AddonStudent.as_ref().to_string());
26786 }
26787
26788 #[allow(clippy::single_element_loop)]
26789 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{postId}", "postId")].iter()
26790 {
26791 url = params.uri_replacement(url, param_name, find_this, false);
26792 }
26793 {
26794 let to_remove = ["postId", "courseId"];
26795 params.remove_params(&to_remove);
26796 }
26797
26798 let url = params.parse_with_url(&url);
26799
26800 loop {
26801 let token = match self
26802 .hub
26803 .auth
26804 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26805 .await
26806 {
26807 Ok(token) => token,
26808 Err(e) => match dlg.token(e) {
26809 Ok(token) => token,
26810 Err(e) => {
26811 dlg.finished(false);
26812 return Err(common::Error::MissingToken(e));
26813 }
26814 },
26815 };
26816 let mut req_result = {
26817 let client = &self.hub.client;
26818 dlg.pre_request();
26819 let mut req_builder = hyper::Request::builder()
26820 .method(hyper::Method::GET)
26821 .uri(url.as_str())
26822 .header(USER_AGENT, self.hub._user_agent.clone());
26823
26824 if let Some(token) = token.as_ref() {
26825 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26826 }
26827
26828 let request = req_builder
26829 .header(CONTENT_LENGTH, 0_u64)
26830 .body(common::to_body::<String>(None));
26831
26832 client.request(request.unwrap()).await
26833 };
26834
26835 match req_result {
26836 Err(err) => {
26837 if let common::Retry::After(d) = dlg.http_error(&err) {
26838 sleep(d).await;
26839 continue;
26840 }
26841 dlg.finished(false);
26842 return Err(common::Error::HttpError(err));
26843 }
26844 Ok(res) => {
26845 let (mut parts, body) = res.into_parts();
26846 let mut body = common::Body::new(body);
26847 if !parts.status.is_success() {
26848 let bytes = common::to_bytes(body).await.unwrap_or_default();
26849 let error = serde_json::from_str(&common::to_string(&bytes));
26850 let response = common::to_response(parts, bytes.into());
26851
26852 if let common::Retry::After(d) =
26853 dlg.http_failure(&response, error.as_ref().ok())
26854 {
26855 sleep(d).await;
26856 continue;
26857 }
26858
26859 dlg.finished(false);
26860
26861 return Err(match error {
26862 Ok(value) => common::Error::BadRequest(value),
26863 _ => common::Error::Failure(response),
26864 });
26865 }
26866 let response = {
26867 let bytes = common::to_bytes(body).await.unwrap_or_default();
26868 let encoded = common::to_string(&bytes);
26869 match serde_json::from_str(&encoded) {
26870 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26871 Err(error) => {
26872 dlg.response_json_decode_error(&encoded, &error);
26873 return Err(common::Error::JsonDecodeError(
26874 encoded.to_string(),
26875 error,
26876 ));
26877 }
26878 }
26879 };
26880
26881 dlg.finished(true);
26882 return Ok(response);
26883 }
26884 }
26885 }
26886 }
26887
26888 /// Required. Identifier of the course.
26889 ///
26890 /// Sets the *course id* path property to the given value.
26891 ///
26892 /// Even though the property as already been set when instantiating this call,
26893 /// we provide this method for API completeness.
26894 pub fn course_id(mut self, new_value: &str) -> CoursePostGetAddOnContextCall<'a, C> {
26895 self._course_id = new_value.to_string();
26896 self
26897 }
26898 /// Optional. Deprecated, use `item_id` instead.
26899 ///
26900 /// Sets the *post id* path property to the given value.
26901 ///
26902 /// Even though the property as already been set when instantiating this call,
26903 /// we provide this method for API completeness.
26904 pub fn post_id(mut self, new_value: &str) -> CoursePostGetAddOnContextCall<'a, C> {
26905 self._post_id = new_value.to_string();
26906 self
26907 }
26908 /// Identifier of the `Announcement`, `CourseWork`, or `CourseWorkMaterial` under which the attachment is attached. This field is required, but is not marked as such while we are migrating from post_id.
26909 ///
26910 /// Sets the *item id* query property to the given value.
26911 pub fn item_id(mut self, new_value: &str) -> CoursePostGetAddOnContextCall<'a, C> {
26912 self._item_id = Some(new_value.to_string());
26913 self
26914 }
26915 /// Optional. The identifier of the attachment. This field is required for all requests except when the user is in the [Attachment Discovery iframe](https://developers.google.com/workspace/classroom/add-ons/get-started/iframes/attachment-discovery-iframe).
26916 ///
26917 /// Sets the *attachment id* query property to the given value.
26918 pub fn attachment_id(mut self, new_value: &str) -> CoursePostGetAddOnContextCall<'a, C> {
26919 self._attachment_id = Some(new_value.to_string());
26920 self
26921 }
26922 /// Optional. Token that authorizes the request. The token is passed as a query parameter when the user is redirected from Classroom to the add-on's URL. The authorization token is required when neither of the following is true: * The add-on has attachments on the post. * The developer project issuing the request is the same project that created the post.
26923 ///
26924 /// Sets the *add on token* query property to the given value.
26925 pub fn add_on_token(mut self, new_value: &str) -> CoursePostGetAddOnContextCall<'a, C> {
26926 self._add_on_token = Some(new_value.to_string());
26927 self
26928 }
26929 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26930 /// while executing the actual API request.
26931 ///
26932 /// ````text
26933 /// It should be used to handle progress information, and to implement a certain level of resilience.
26934 /// ````
26935 ///
26936 /// Sets the *delegate* property to the given value.
26937 pub fn delegate(
26938 mut self,
26939 new_value: &'a mut dyn common::Delegate,
26940 ) -> CoursePostGetAddOnContextCall<'a, C> {
26941 self._delegate = Some(new_value);
26942 self
26943 }
26944
26945 /// Set any additional parameter of the query string used in the request.
26946 /// It should be used to set parameters which are not yet available through their own
26947 /// setters.
26948 ///
26949 /// Please note that this method must not be used to set any of the known parameters
26950 /// which have their own setter method. If done anyway, the request will fail.
26951 ///
26952 /// # Additional Parameters
26953 ///
26954 /// * *$.xgafv* (query-string) - V1 error format.
26955 /// * *access_token* (query-string) - OAuth access token.
26956 /// * *alt* (query-string) - Data format for response.
26957 /// * *callback* (query-string) - JSONP
26958 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26959 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
26960 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26961 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26962 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
26963 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26964 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26965 pub fn param<T>(mut self, name: T, value: T) -> CoursePostGetAddOnContextCall<'a, C>
26966 where
26967 T: AsRef<str>,
26968 {
26969 self._additional_params
26970 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26971 self
26972 }
26973
26974 /// Identifies the authorization scope for the method you are building.
26975 ///
26976 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26977 /// [`Scope::AddonStudent`].
26978 ///
26979 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26980 /// tokens for more than one scope.
26981 ///
26982 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26983 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26984 /// sufficient, a read-write scope will do as well.
26985 pub fn add_scope<St>(mut self, scope: St) -> CoursePostGetAddOnContextCall<'a, C>
26986 where
26987 St: AsRef<str>,
26988 {
26989 self._scopes.insert(String::from(scope.as_ref()));
26990 self
26991 }
26992 /// Identifies the authorization scope(s) for the method you are building.
26993 ///
26994 /// See [`Self::add_scope()`] for details.
26995 pub fn add_scopes<I, St>(mut self, scopes: I) -> CoursePostGetAddOnContextCall<'a, C>
26996 where
26997 I: IntoIterator<Item = St>,
26998 St: AsRef<str>,
26999 {
27000 self._scopes
27001 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27002 self
27003 }
27004
27005 /// Removes all scopes, and no default scope will be used either.
27006 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27007 /// for details).
27008 pub fn clear_scopes(mut self) -> CoursePostGetAddOnContextCall<'a, C> {
27009 self._scopes.clear();
27010 self
27011 }
27012}
27013
27014/// Adds a user as a student of a course. Domain administrators are permitted to [directly add](https://developers.google.com/workspace/classroom/guides/manage-users) users within their domain as students to courses within their domain. Students are permitted to add themselves to a course using an enrollment code. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create students in this course or for access errors. * `NOT_FOUND` if the requested course ID does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled, for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * UserGroupsMembershipLimitReached * InactiveCourseOwner * `ALREADY_EXISTS` if the user is already a student or teacher in the course.
27015///
27016/// A builder for the *students.create* method supported by a *course* resource.
27017/// It is not used directly, but through a [`CourseMethods`] instance.
27018///
27019/// # Example
27020///
27021/// Instantiate a resource method builder
27022///
27023/// ```test_harness,no_run
27024/// # extern crate hyper;
27025/// # extern crate hyper_rustls;
27026/// # extern crate google_classroom1 as classroom1;
27027/// use classroom1::api::Student;
27028/// # async fn dox() {
27029/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27030///
27031/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27032/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27033/// # .with_native_roots()
27034/// # .unwrap()
27035/// # .https_only()
27036/// # .enable_http2()
27037/// # .build();
27038///
27039/// # let executor = hyper_util::rt::TokioExecutor::new();
27040/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27041/// # secret,
27042/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27043/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27044/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27045/// # ),
27046/// # ).build().await.unwrap();
27047///
27048/// # let client = hyper_util::client::legacy::Client::builder(
27049/// # hyper_util::rt::TokioExecutor::new()
27050/// # )
27051/// # .build(
27052/// # hyper_rustls::HttpsConnectorBuilder::new()
27053/// # .with_native_roots()
27054/// # .unwrap()
27055/// # .https_or_http()
27056/// # .enable_http2()
27057/// # .build()
27058/// # );
27059/// # let mut hub = Classroom::new(client, auth);
27060/// // As the method needs a request, you would usually fill it with the desired information
27061/// // into the respective structure. Some of the parts shown here might not be applicable !
27062/// // Values shown here are possibly random and not representative !
27063/// let mut req = Student::default();
27064///
27065/// // You can configure optional parameters by calling the respective setters at will, and
27066/// // execute the final call using `doit()`.
27067/// // Values shown here are possibly random and not representative !
27068/// let result = hub.courses().students_create(req, "courseId")
27069/// .enrollment_code("kasd")
27070/// .doit().await;
27071/// # }
27072/// ```
27073pub struct CourseStudentCreateCall<'a, C>
27074where
27075 C: 'a,
27076{
27077 hub: &'a Classroom<C>,
27078 _request: Student,
27079 _course_id: String,
27080 _enrollment_code: Option<String>,
27081 _delegate: Option<&'a mut dyn common::Delegate>,
27082 _additional_params: HashMap<String, String>,
27083 _scopes: BTreeSet<String>,
27084}
27085
27086impl<'a, C> common::CallBuilder for CourseStudentCreateCall<'a, C> {}
27087
27088impl<'a, C> CourseStudentCreateCall<'a, C>
27089where
27090 C: common::Connector,
27091{
27092 /// Perform the operation you have build so far.
27093 pub async fn doit(mut self) -> common::Result<(common::Response, Student)> {
27094 use std::borrow::Cow;
27095 use std::io::{Read, Seek};
27096
27097 use common::{url::Params, ToParts};
27098 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27099
27100 let mut dd = common::DefaultDelegate;
27101 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27102 dlg.begin(common::MethodInfo {
27103 id: "classroom.courses.students.create",
27104 http_method: hyper::Method::POST,
27105 });
27106
27107 for &field in ["alt", "courseId", "enrollmentCode"].iter() {
27108 if self._additional_params.contains_key(field) {
27109 dlg.finished(false);
27110 return Err(common::Error::FieldClash(field));
27111 }
27112 }
27113
27114 let mut params = Params::with_capacity(5 + self._additional_params.len());
27115 params.push("courseId", self._course_id);
27116 if let Some(value) = self._enrollment_code.as_ref() {
27117 params.push("enrollmentCode", value);
27118 }
27119
27120 params.extend(self._additional_params.iter());
27121
27122 params.push("alt", "json");
27123 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/students";
27124 if self._scopes.is_empty() {
27125 self._scopes
27126 .insert(Scope::ProfileEmail.as_ref().to_string());
27127 }
27128
27129 #[allow(clippy::single_element_loop)]
27130 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
27131 url = params.uri_replacement(url, param_name, find_this, false);
27132 }
27133 {
27134 let to_remove = ["courseId"];
27135 params.remove_params(&to_remove);
27136 }
27137
27138 let url = params.parse_with_url(&url);
27139
27140 let mut json_mime_type = mime::APPLICATION_JSON;
27141 let mut request_value_reader = {
27142 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27143 common::remove_json_null_values(&mut value);
27144 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27145 serde_json::to_writer(&mut dst, &value).unwrap();
27146 dst
27147 };
27148 let request_size = request_value_reader
27149 .seek(std::io::SeekFrom::End(0))
27150 .unwrap();
27151 request_value_reader
27152 .seek(std::io::SeekFrom::Start(0))
27153 .unwrap();
27154
27155 loop {
27156 let token = match self
27157 .hub
27158 .auth
27159 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27160 .await
27161 {
27162 Ok(token) => token,
27163 Err(e) => match dlg.token(e) {
27164 Ok(token) => token,
27165 Err(e) => {
27166 dlg.finished(false);
27167 return Err(common::Error::MissingToken(e));
27168 }
27169 },
27170 };
27171 request_value_reader
27172 .seek(std::io::SeekFrom::Start(0))
27173 .unwrap();
27174 let mut req_result = {
27175 let client = &self.hub.client;
27176 dlg.pre_request();
27177 let mut req_builder = hyper::Request::builder()
27178 .method(hyper::Method::POST)
27179 .uri(url.as_str())
27180 .header(USER_AGENT, self.hub._user_agent.clone());
27181
27182 if let Some(token) = token.as_ref() {
27183 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27184 }
27185
27186 let request = req_builder
27187 .header(CONTENT_TYPE, json_mime_type.to_string())
27188 .header(CONTENT_LENGTH, request_size as u64)
27189 .body(common::to_body(
27190 request_value_reader.get_ref().clone().into(),
27191 ));
27192
27193 client.request(request.unwrap()).await
27194 };
27195
27196 match req_result {
27197 Err(err) => {
27198 if let common::Retry::After(d) = dlg.http_error(&err) {
27199 sleep(d).await;
27200 continue;
27201 }
27202 dlg.finished(false);
27203 return Err(common::Error::HttpError(err));
27204 }
27205 Ok(res) => {
27206 let (mut parts, body) = res.into_parts();
27207 let mut body = common::Body::new(body);
27208 if !parts.status.is_success() {
27209 let bytes = common::to_bytes(body).await.unwrap_or_default();
27210 let error = serde_json::from_str(&common::to_string(&bytes));
27211 let response = common::to_response(parts, bytes.into());
27212
27213 if let common::Retry::After(d) =
27214 dlg.http_failure(&response, error.as_ref().ok())
27215 {
27216 sleep(d).await;
27217 continue;
27218 }
27219
27220 dlg.finished(false);
27221
27222 return Err(match error {
27223 Ok(value) => common::Error::BadRequest(value),
27224 _ => common::Error::Failure(response),
27225 });
27226 }
27227 let response = {
27228 let bytes = common::to_bytes(body).await.unwrap_or_default();
27229 let encoded = common::to_string(&bytes);
27230 match serde_json::from_str(&encoded) {
27231 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27232 Err(error) => {
27233 dlg.response_json_decode_error(&encoded, &error);
27234 return Err(common::Error::JsonDecodeError(
27235 encoded.to_string(),
27236 error,
27237 ));
27238 }
27239 }
27240 };
27241
27242 dlg.finished(true);
27243 return Ok(response);
27244 }
27245 }
27246 }
27247 }
27248
27249 ///
27250 /// Sets the *request* property to the given value.
27251 ///
27252 /// Even though the property as already been set when instantiating this call,
27253 /// we provide this method for API completeness.
27254 pub fn request(mut self, new_value: Student) -> CourseStudentCreateCall<'a, C> {
27255 self._request = new_value;
27256 self
27257 }
27258 /// Identifier of the course to create the student in. This identifier can be either the Classroom-assigned identifier or an alias.
27259 ///
27260 /// Sets the *course id* path property to the given value.
27261 ///
27262 /// Even though the property as already been set when instantiating this call,
27263 /// we provide this method for API completeness.
27264 pub fn course_id(mut self, new_value: &str) -> CourseStudentCreateCall<'a, C> {
27265 self._course_id = new_value.to_string();
27266 self
27267 }
27268 /// Enrollment code of the course to create the student in. This code is required if userId corresponds to the requesting user; it may be omitted if the requesting user has administrative permissions to create students for any user.
27269 ///
27270 /// Sets the *enrollment code* query property to the given value.
27271 pub fn enrollment_code(mut self, new_value: &str) -> CourseStudentCreateCall<'a, C> {
27272 self._enrollment_code = Some(new_value.to_string());
27273 self
27274 }
27275 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27276 /// while executing the actual API request.
27277 ///
27278 /// ````text
27279 /// It should be used to handle progress information, and to implement a certain level of resilience.
27280 /// ````
27281 ///
27282 /// Sets the *delegate* property to the given value.
27283 pub fn delegate(
27284 mut self,
27285 new_value: &'a mut dyn common::Delegate,
27286 ) -> CourseStudentCreateCall<'a, C> {
27287 self._delegate = Some(new_value);
27288 self
27289 }
27290
27291 /// Set any additional parameter of the query string used in the request.
27292 /// It should be used to set parameters which are not yet available through their own
27293 /// setters.
27294 ///
27295 /// Please note that this method must not be used to set any of the known parameters
27296 /// which have their own setter method. If done anyway, the request will fail.
27297 ///
27298 /// # Additional Parameters
27299 ///
27300 /// * *$.xgafv* (query-string) - V1 error format.
27301 /// * *access_token* (query-string) - OAuth access token.
27302 /// * *alt* (query-string) - Data format for response.
27303 /// * *callback* (query-string) - JSONP
27304 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27305 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
27306 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27307 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27308 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
27309 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27310 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27311 pub fn param<T>(mut self, name: T, value: T) -> CourseStudentCreateCall<'a, C>
27312 where
27313 T: AsRef<str>,
27314 {
27315 self._additional_params
27316 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27317 self
27318 }
27319
27320 /// Identifies the authorization scope for the method you are building.
27321 ///
27322 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27323 /// [`Scope::ProfileEmail`].
27324 ///
27325 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27326 /// tokens for more than one scope.
27327 ///
27328 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27329 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27330 /// sufficient, a read-write scope will do as well.
27331 pub fn add_scope<St>(mut self, scope: St) -> CourseStudentCreateCall<'a, C>
27332 where
27333 St: AsRef<str>,
27334 {
27335 self._scopes.insert(String::from(scope.as_ref()));
27336 self
27337 }
27338 /// Identifies the authorization scope(s) for the method you are building.
27339 ///
27340 /// See [`Self::add_scope()`] for details.
27341 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseStudentCreateCall<'a, C>
27342 where
27343 I: IntoIterator<Item = St>,
27344 St: AsRef<str>,
27345 {
27346 self._scopes
27347 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27348 self
27349 }
27350
27351 /// Removes all scopes, and no default scope will be used either.
27352 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27353 /// for details).
27354 pub fn clear_scopes(mut self) -> CourseStudentCreateCall<'a, C> {
27355 self._scopes.clear();
27356 self
27357 }
27358}
27359
27360/// Deletes a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist.
27361///
27362/// A builder for the *students.delete* method supported by a *course* resource.
27363/// It is not used directly, but through a [`CourseMethods`] instance.
27364///
27365/// # Example
27366///
27367/// Instantiate a resource method builder
27368///
27369/// ```test_harness,no_run
27370/// # extern crate hyper;
27371/// # extern crate hyper_rustls;
27372/// # extern crate google_classroom1 as classroom1;
27373/// # async fn dox() {
27374/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27375///
27376/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27377/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27378/// # .with_native_roots()
27379/// # .unwrap()
27380/// # .https_only()
27381/// # .enable_http2()
27382/// # .build();
27383///
27384/// # let executor = hyper_util::rt::TokioExecutor::new();
27385/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27386/// # secret,
27387/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27388/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27389/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27390/// # ),
27391/// # ).build().await.unwrap();
27392///
27393/// # let client = hyper_util::client::legacy::Client::builder(
27394/// # hyper_util::rt::TokioExecutor::new()
27395/// # )
27396/// # .build(
27397/// # hyper_rustls::HttpsConnectorBuilder::new()
27398/// # .with_native_roots()
27399/// # .unwrap()
27400/// # .https_or_http()
27401/// # .enable_http2()
27402/// # .build()
27403/// # );
27404/// # let mut hub = Classroom::new(client, auth);
27405/// // You can configure optional parameters by calling the respective setters at will, and
27406/// // execute the final call using `doit()`.
27407/// // Values shown here are possibly random and not representative !
27408/// let result = hub.courses().students_delete("courseId", "userId")
27409/// .doit().await;
27410/// # }
27411/// ```
27412pub struct CourseStudentDeleteCall<'a, C>
27413where
27414 C: 'a,
27415{
27416 hub: &'a Classroom<C>,
27417 _course_id: String,
27418 _user_id: String,
27419 _delegate: Option<&'a mut dyn common::Delegate>,
27420 _additional_params: HashMap<String, String>,
27421 _scopes: BTreeSet<String>,
27422}
27423
27424impl<'a, C> common::CallBuilder for CourseStudentDeleteCall<'a, C> {}
27425
27426impl<'a, C> CourseStudentDeleteCall<'a, C>
27427where
27428 C: common::Connector,
27429{
27430 /// Perform the operation you have build so far.
27431 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
27432 use std::borrow::Cow;
27433 use std::io::{Read, Seek};
27434
27435 use common::{url::Params, ToParts};
27436 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27437
27438 let mut dd = common::DefaultDelegate;
27439 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27440 dlg.begin(common::MethodInfo {
27441 id: "classroom.courses.students.delete",
27442 http_method: hyper::Method::DELETE,
27443 });
27444
27445 for &field in ["alt", "courseId", "userId"].iter() {
27446 if self._additional_params.contains_key(field) {
27447 dlg.finished(false);
27448 return Err(common::Error::FieldClash(field));
27449 }
27450 }
27451
27452 let mut params = Params::with_capacity(4 + self._additional_params.len());
27453 params.push("courseId", self._course_id);
27454 params.push("userId", self._user_id);
27455
27456 params.extend(self._additional_params.iter());
27457
27458 params.push("alt", "json");
27459 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/students/{userId}";
27460 if self._scopes.is_empty() {
27461 self._scopes.insert(Scope::Roster.as_ref().to_string());
27462 }
27463
27464 #[allow(clippy::single_element_loop)]
27465 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{userId}", "userId")].iter()
27466 {
27467 url = params.uri_replacement(url, param_name, find_this, false);
27468 }
27469 {
27470 let to_remove = ["userId", "courseId"];
27471 params.remove_params(&to_remove);
27472 }
27473
27474 let url = params.parse_with_url(&url);
27475
27476 loop {
27477 let token = match self
27478 .hub
27479 .auth
27480 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27481 .await
27482 {
27483 Ok(token) => token,
27484 Err(e) => match dlg.token(e) {
27485 Ok(token) => token,
27486 Err(e) => {
27487 dlg.finished(false);
27488 return Err(common::Error::MissingToken(e));
27489 }
27490 },
27491 };
27492 let mut req_result = {
27493 let client = &self.hub.client;
27494 dlg.pre_request();
27495 let mut req_builder = hyper::Request::builder()
27496 .method(hyper::Method::DELETE)
27497 .uri(url.as_str())
27498 .header(USER_AGENT, self.hub._user_agent.clone());
27499
27500 if let Some(token) = token.as_ref() {
27501 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27502 }
27503
27504 let request = req_builder
27505 .header(CONTENT_LENGTH, 0_u64)
27506 .body(common::to_body::<String>(None));
27507
27508 client.request(request.unwrap()).await
27509 };
27510
27511 match req_result {
27512 Err(err) => {
27513 if let common::Retry::After(d) = dlg.http_error(&err) {
27514 sleep(d).await;
27515 continue;
27516 }
27517 dlg.finished(false);
27518 return Err(common::Error::HttpError(err));
27519 }
27520 Ok(res) => {
27521 let (mut parts, body) = res.into_parts();
27522 let mut body = common::Body::new(body);
27523 if !parts.status.is_success() {
27524 let bytes = common::to_bytes(body).await.unwrap_or_default();
27525 let error = serde_json::from_str(&common::to_string(&bytes));
27526 let response = common::to_response(parts, bytes.into());
27527
27528 if let common::Retry::After(d) =
27529 dlg.http_failure(&response, error.as_ref().ok())
27530 {
27531 sleep(d).await;
27532 continue;
27533 }
27534
27535 dlg.finished(false);
27536
27537 return Err(match error {
27538 Ok(value) => common::Error::BadRequest(value),
27539 _ => common::Error::Failure(response),
27540 });
27541 }
27542 let response = {
27543 let bytes = common::to_bytes(body).await.unwrap_or_default();
27544 let encoded = common::to_string(&bytes);
27545 match serde_json::from_str(&encoded) {
27546 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27547 Err(error) => {
27548 dlg.response_json_decode_error(&encoded, &error);
27549 return Err(common::Error::JsonDecodeError(
27550 encoded.to_string(),
27551 error,
27552 ));
27553 }
27554 }
27555 };
27556
27557 dlg.finished(true);
27558 return Ok(response);
27559 }
27560 }
27561 }
27562 }
27563
27564 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
27565 ///
27566 /// Sets the *course id* path property to the given value.
27567 ///
27568 /// Even though the property as already been set when instantiating this call,
27569 /// we provide this method for API completeness.
27570 pub fn course_id(mut self, new_value: &str) -> CourseStudentDeleteCall<'a, C> {
27571 self._course_id = new_value.to_string();
27572 self
27573 }
27574 /// Identifier of the student to delete. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
27575 ///
27576 /// Sets the *user id* path property to the given value.
27577 ///
27578 /// Even though the property as already been set when instantiating this call,
27579 /// we provide this method for API completeness.
27580 pub fn user_id(mut self, new_value: &str) -> CourseStudentDeleteCall<'a, C> {
27581 self._user_id = new_value.to_string();
27582 self
27583 }
27584 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27585 /// while executing the actual API request.
27586 ///
27587 /// ````text
27588 /// It should be used to handle progress information, and to implement a certain level of resilience.
27589 /// ````
27590 ///
27591 /// Sets the *delegate* property to the given value.
27592 pub fn delegate(
27593 mut self,
27594 new_value: &'a mut dyn common::Delegate,
27595 ) -> CourseStudentDeleteCall<'a, C> {
27596 self._delegate = Some(new_value);
27597 self
27598 }
27599
27600 /// Set any additional parameter of the query string used in the request.
27601 /// It should be used to set parameters which are not yet available through their own
27602 /// setters.
27603 ///
27604 /// Please note that this method must not be used to set any of the known parameters
27605 /// which have their own setter method. If done anyway, the request will fail.
27606 ///
27607 /// # Additional Parameters
27608 ///
27609 /// * *$.xgafv* (query-string) - V1 error format.
27610 /// * *access_token* (query-string) - OAuth access token.
27611 /// * *alt* (query-string) - Data format for response.
27612 /// * *callback* (query-string) - JSONP
27613 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27614 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
27615 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27616 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27617 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
27618 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27619 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27620 pub fn param<T>(mut self, name: T, value: T) -> CourseStudentDeleteCall<'a, C>
27621 where
27622 T: AsRef<str>,
27623 {
27624 self._additional_params
27625 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27626 self
27627 }
27628
27629 /// Identifies the authorization scope for the method you are building.
27630 ///
27631 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27632 /// [`Scope::Roster`].
27633 ///
27634 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27635 /// tokens for more than one scope.
27636 ///
27637 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27638 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27639 /// sufficient, a read-write scope will do as well.
27640 pub fn add_scope<St>(mut self, scope: St) -> CourseStudentDeleteCall<'a, C>
27641 where
27642 St: AsRef<str>,
27643 {
27644 self._scopes.insert(String::from(scope.as_ref()));
27645 self
27646 }
27647 /// Identifies the authorization scope(s) for the method you are building.
27648 ///
27649 /// See [`Self::add_scope()`] for details.
27650 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseStudentDeleteCall<'a, C>
27651 where
27652 I: IntoIterator<Item = St>,
27653 St: AsRef<str>,
27654 {
27655 self._scopes
27656 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27657 self
27658 }
27659
27660 /// Removes all scopes, and no default scope will be used either.
27661 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27662 /// for details).
27663 pub fn clear_scopes(mut self) -> CourseStudentDeleteCall<'a, C> {
27664 self._scopes.clear();
27665 self
27666 }
27667}
27668
27669/// Returns a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist.
27670///
27671/// A builder for the *students.get* method supported by a *course* resource.
27672/// It is not used directly, but through a [`CourseMethods`] instance.
27673///
27674/// # Example
27675///
27676/// Instantiate a resource method builder
27677///
27678/// ```test_harness,no_run
27679/// # extern crate hyper;
27680/// # extern crate hyper_rustls;
27681/// # extern crate google_classroom1 as classroom1;
27682/// # async fn dox() {
27683/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27684///
27685/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27686/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27687/// # .with_native_roots()
27688/// # .unwrap()
27689/// # .https_only()
27690/// # .enable_http2()
27691/// # .build();
27692///
27693/// # let executor = hyper_util::rt::TokioExecutor::new();
27694/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27695/// # secret,
27696/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27697/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27698/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27699/// # ),
27700/// # ).build().await.unwrap();
27701///
27702/// # let client = hyper_util::client::legacy::Client::builder(
27703/// # hyper_util::rt::TokioExecutor::new()
27704/// # )
27705/// # .build(
27706/// # hyper_rustls::HttpsConnectorBuilder::new()
27707/// # .with_native_roots()
27708/// # .unwrap()
27709/// # .https_or_http()
27710/// # .enable_http2()
27711/// # .build()
27712/// # );
27713/// # let mut hub = Classroom::new(client, auth);
27714/// // You can configure optional parameters by calling the respective setters at will, and
27715/// // execute the final call using `doit()`.
27716/// // Values shown here are possibly random and not representative !
27717/// let result = hub.courses().students_get("courseId", "userId")
27718/// .doit().await;
27719/// # }
27720/// ```
27721pub struct CourseStudentGetCall<'a, C>
27722where
27723 C: 'a,
27724{
27725 hub: &'a Classroom<C>,
27726 _course_id: String,
27727 _user_id: String,
27728 _delegate: Option<&'a mut dyn common::Delegate>,
27729 _additional_params: HashMap<String, String>,
27730 _scopes: BTreeSet<String>,
27731}
27732
27733impl<'a, C> common::CallBuilder for CourseStudentGetCall<'a, C> {}
27734
27735impl<'a, C> CourseStudentGetCall<'a, C>
27736where
27737 C: common::Connector,
27738{
27739 /// Perform the operation you have build so far.
27740 pub async fn doit(mut self) -> common::Result<(common::Response, Student)> {
27741 use std::borrow::Cow;
27742 use std::io::{Read, Seek};
27743
27744 use common::{url::Params, ToParts};
27745 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27746
27747 let mut dd = common::DefaultDelegate;
27748 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27749 dlg.begin(common::MethodInfo {
27750 id: "classroom.courses.students.get",
27751 http_method: hyper::Method::GET,
27752 });
27753
27754 for &field in ["alt", "courseId", "userId"].iter() {
27755 if self._additional_params.contains_key(field) {
27756 dlg.finished(false);
27757 return Err(common::Error::FieldClash(field));
27758 }
27759 }
27760
27761 let mut params = Params::with_capacity(4 + self._additional_params.len());
27762 params.push("courseId", self._course_id);
27763 params.push("userId", self._user_id);
27764
27765 params.extend(self._additional_params.iter());
27766
27767 params.push("alt", "json");
27768 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/students/{userId}";
27769 if self._scopes.is_empty() {
27770 self._scopes
27771 .insert(Scope::RosterReadonly.as_ref().to_string());
27772 }
27773
27774 #[allow(clippy::single_element_loop)]
27775 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{userId}", "userId")].iter()
27776 {
27777 url = params.uri_replacement(url, param_name, find_this, false);
27778 }
27779 {
27780 let to_remove = ["userId", "courseId"];
27781 params.remove_params(&to_remove);
27782 }
27783
27784 let url = params.parse_with_url(&url);
27785
27786 loop {
27787 let token = match self
27788 .hub
27789 .auth
27790 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27791 .await
27792 {
27793 Ok(token) => token,
27794 Err(e) => match dlg.token(e) {
27795 Ok(token) => token,
27796 Err(e) => {
27797 dlg.finished(false);
27798 return Err(common::Error::MissingToken(e));
27799 }
27800 },
27801 };
27802 let mut req_result = {
27803 let client = &self.hub.client;
27804 dlg.pre_request();
27805 let mut req_builder = hyper::Request::builder()
27806 .method(hyper::Method::GET)
27807 .uri(url.as_str())
27808 .header(USER_AGENT, self.hub._user_agent.clone());
27809
27810 if let Some(token) = token.as_ref() {
27811 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27812 }
27813
27814 let request = req_builder
27815 .header(CONTENT_LENGTH, 0_u64)
27816 .body(common::to_body::<String>(None));
27817
27818 client.request(request.unwrap()).await
27819 };
27820
27821 match req_result {
27822 Err(err) => {
27823 if let common::Retry::After(d) = dlg.http_error(&err) {
27824 sleep(d).await;
27825 continue;
27826 }
27827 dlg.finished(false);
27828 return Err(common::Error::HttpError(err));
27829 }
27830 Ok(res) => {
27831 let (mut parts, body) = res.into_parts();
27832 let mut body = common::Body::new(body);
27833 if !parts.status.is_success() {
27834 let bytes = common::to_bytes(body).await.unwrap_or_default();
27835 let error = serde_json::from_str(&common::to_string(&bytes));
27836 let response = common::to_response(parts, bytes.into());
27837
27838 if let common::Retry::After(d) =
27839 dlg.http_failure(&response, error.as_ref().ok())
27840 {
27841 sleep(d).await;
27842 continue;
27843 }
27844
27845 dlg.finished(false);
27846
27847 return Err(match error {
27848 Ok(value) => common::Error::BadRequest(value),
27849 _ => common::Error::Failure(response),
27850 });
27851 }
27852 let response = {
27853 let bytes = common::to_bytes(body).await.unwrap_or_default();
27854 let encoded = common::to_string(&bytes);
27855 match serde_json::from_str(&encoded) {
27856 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27857 Err(error) => {
27858 dlg.response_json_decode_error(&encoded, &error);
27859 return Err(common::Error::JsonDecodeError(
27860 encoded.to_string(),
27861 error,
27862 ));
27863 }
27864 }
27865 };
27866
27867 dlg.finished(true);
27868 return Ok(response);
27869 }
27870 }
27871 }
27872 }
27873
27874 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
27875 ///
27876 /// Sets the *course id* path property to the given value.
27877 ///
27878 /// Even though the property as already been set when instantiating this call,
27879 /// we provide this method for API completeness.
27880 pub fn course_id(mut self, new_value: &str) -> CourseStudentGetCall<'a, C> {
27881 self._course_id = new_value.to_string();
27882 self
27883 }
27884 /// Identifier of the student to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
27885 ///
27886 /// Sets the *user id* path property to the given value.
27887 ///
27888 /// Even though the property as already been set when instantiating this call,
27889 /// we provide this method for API completeness.
27890 pub fn user_id(mut self, new_value: &str) -> CourseStudentGetCall<'a, C> {
27891 self._user_id = new_value.to_string();
27892 self
27893 }
27894 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27895 /// while executing the actual API request.
27896 ///
27897 /// ````text
27898 /// It should be used to handle progress information, and to implement a certain level of resilience.
27899 /// ````
27900 ///
27901 /// Sets the *delegate* property to the given value.
27902 pub fn delegate(
27903 mut self,
27904 new_value: &'a mut dyn common::Delegate,
27905 ) -> CourseStudentGetCall<'a, C> {
27906 self._delegate = Some(new_value);
27907 self
27908 }
27909
27910 /// Set any additional parameter of the query string used in the request.
27911 /// It should be used to set parameters which are not yet available through their own
27912 /// setters.
27913 ///
27914 /// Please note that this method must not be used to set any of the known parameters
27915 /// which have their own setter method. If done anyway, the request will fail.
27916 ///
27917 /// # Additional Parameters
27918 ///
27919 /// * *$.xgafv* (query-string) - V1 error format.
27920 /// * *access_token* (query-string) - OAuth access token.
27921 /// * *alt* (query-string) - Data format for response.
27922 /// * *callback* (query-string) - JSONP
27923 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27924 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
27925 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27926 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27927 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
27928 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27929 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27930 pub fn param<T>(mut self, name: T, value: T) -> CourseStudentGetCall<'a, C>
27931 where
27932 T: AsRef<str>,
27933 {
27934 self._additional_params
27935 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27936 self
27937 }
27938
27939 /// Identifies the authorization scope for the method you are building.
27940 ///
27941 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27942 /// [`Scope::RosterReadonly`].
27943 ///
27944 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27945 /// tokens for more than one scope.
27946 ///
27947 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27948 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27949 /// sufficient, a read-write scope will do as well.
27950 pub fn add_scope<St>(mut self, scope: St) -> CourseStudentGetCall<'a, C>
27951 where
27952 St: AsRef<str>,
27953 {
27954 self._scopes.insert(String::from(scope.as_ref()));
27955 self
27956 }
27957 /// Identifies the authorization scope(s) for the method you are building.
27958 ///
27959 /// See [`Self::add_scope()`] for details.
27960 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseStudentGetCall<'a, C>
27961 where
27962 I: IntoIterator<Item = St>,
27963 St: AsRef<str>,
27964 {
27965 self._scopes
27966 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27967 self
27968 }
27969
27970 /// Removes all scopes, and no default scope will be used either.
27971 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27972 /// for details).
27973 pub fn clear_scopes(mut self) -> CourseStudentGetCall<'a, C> {
27974 self._scopes.clear();
27975 self
27976 }
27977}
27978
27979/// Returns a list of students of this course that the requester is permitted to view. This method returns the following error codes: * `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for access errors.
27980///
27981/// A builder for the *students.list* method supported by a *course* resource.
27982/// It is not used directly, but through a [`CourseMethods`] instance.
27983///
27984/// # Example
27985///
27986/// Instantiate a resource method builder
27987///
27988/// ```test_harness,no_run
27989/// # extern crate hyper;
27990/// # extern crate hyper_rustls;
27991/// # extern crate google_classroom1 as classroom1;
27992/// # async fn dox() {
27993/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27994///
27995/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27996/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27997/// # .with_native_roots()
27998/// # .unwrap()
27999/// # .https_only()
28000/// # .enable_http2()
28001/// # .build();
28002///
28003/// # let executor = hyper_util::rt::TokioExecutor::new();
28004/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28005/// # secret,
28006/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28007/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28008/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28009/// # ),
28010/// # ).build().await.unwrap();
28011///
28012/// # let client = hyper_util::client::legacy::Client::builder(
28013/// # hyper_util::rt::TokioExecutor::new()
28014/// # )
28015/// # .build(
28016/// # hyper_rustls::HttpsConnectorBuilder::new()
28017/// # .with_native_roots()
28018/// # .unwrap()
28019/// # .https_or_http()
28020/// # .enable_http2()
28021/// # .build()
28022/// # );
28023/// # let mut hub = Classroom::new(client, auth);
28024/// // You can configure optional parameters by calling the respective setters at will, and
28025/// // execute the final call using `doit()`.
28026/// // Values shown here are possibly random and not representative !
28027/// let result = hub.courses().students_list("courseId")
28028/// .page_token("magna")
28029/// .page_size(-59)
28030/// .doit().await;
28031/// # }
28032/// ```
28033pub struct CourseStudentListCall<'a, C>
28034where
28035 C: 'a,
28036{
28037 hub: &'a Classroom<C>,
28038 _course_id: String,
28039 _page_token: Option<String>,
28040 _page_size: Option<i32>,
28041 _delegate: Option<&'a mut dyn common::Delegate>,
28042 _additional_params: HashMap<String, String>,
28043 _scopes: BTreeSet<String>,
28044}
28045
28046impl<'a, C> common::CallBuilder for CourseStudentListCall<'a, C> {}
28047
28048impl<'a, C> CourseStudentListCall<'a, C>
28049where
28050 C: common::Connector,
28051{
28052 /// Perform the operation you have build so far.
28053 pub async fn doit(mut self) -> common::Result<(common::Response, ListStudentsResponse)> {
28054 use std::borrow::Cow;
28055 use std::io::{Read, Seek};
28056
28057 use common::{url::Params, ToParts};
28058 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28059
28060 let mut dd = common::DefaultDelegate;
28061 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28062 dlg.begin(common::MethodInfo {
28063 id: "classroom.courses.students.list",
28064 http_method: hyper::Method::GET,
28065 });
28066
28067 for &field in ["alt", "courseId", "pageToken", "pageSize"].iter() {
28068 if self._additional_params.contains_key(field) {
28069 dlg.finished(false);
28070 return Err(common::Error::FieldClash(field));
28071 }
28072 }
28073
28074 let mut params = Params::with_capacity(5 + self._additional_params.len());
28075 params.push("courseId", self._course_id);
28076 if let Some(value) = self._page_token.as_ref() {
28077 params.push("pageToken", value);
28078 }
28079 if let Some(value) = self._page_size.as_ref() {
28080 params.push("pageSize", value.to_string());
28081 }
28082
28083 params.extend(self._additional_params.iter());
28084
28085 params.push("alt", "json");
28086 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/students";
28087 if self._scopes.is_empty() {
28088 self._scopes
28089 .insert(Scope::RosterReadonly.as_ref().to_string());
28090 }
28091
28092 #[allow(clippy::single_element_loop)]
28093 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
28094 url = params.uri_replacement(url, param_name, find_this, false);
28095 }
28096 {
28097 let to_remove = ["courseId"];
28098 params.remove_params(&to_remove);
28099 }
28100
28101 let url = params.parse_with_url(&url);
28102
28103 loop {
28104 let token = match self
28105 .hub
28106 .auth
28107 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28108 .await
28109 {
28110 Ok(token) => token,
28111 Err(e) => match dlg.token(e) {
28112 Ok(token) => token,
28113 Err(e) => {
28114 dlg.finished(false);
28115 return Err(common::Error::MissingToken(e));
28116 }
28117 },
28118 };
28119 let mut req_result = {
28120 let client = &self.hub.client;
28121 dlg.pre_request();
28122 let mut req_builder = hyper::Request::builder()
28123 .method(hyper::Method::GET)
28124 .uri(url.as_str())
28125 .header(USER_AGENT, self.hub._user_agent.clone());
28126
28127 if let Some(token) = token.as_ref() {
28128 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28129 }
28130
28131 let request = req_builder
28132 .header(CONTENT_LENGTH, 0_u64)
28133 .body(common::to_body::<String>(None));
28134
28135 client.request(request.unwrap()).await
28136 };
28137
28138 match req_result {
28139 Err(err) => {
28140 if let common::Retry::After(d) = dlg.http_error(&err) {
28141 sleep(d).await;
28142 continue;
28143 }
28144 dlg.finished(false);
28145 return Err(common::Error::HttpError(err));
28146 }
28147 Ok(res) => {
28148 let (mut parts, body) = res.into_parts();
28149 let mut body = common::Body::new(body);
28150 if !parts.status.is_success() {
28151 let bytes = common::to_bytes(body).await.unwrap_or_default();
28152 let error = serde_json::from_str(&common::to_string(&bytes));
28153 let response = common::to_response(parts, bytes.into());
28154
28155 if let common::Retry::After(d) =
28156 dlg.http_failure(&response, error.as_ref().ok())
28157 {
28158 sleep(d).await;
28159 continue;
28160 }
28161
28162 dlg.finished(false);
28163
28164 return Err(match error {
28165 Ok(value) => common::Error::BadRequest(value),
28166 _ => common::Error::Failure(response),
28167 });
28168 }
28169 let response = {
28170 let bytes = common::to_bytes(body).await.unwrap_or_default();
28171 let encoded = common::to_string(&bytes);
28172 match serde_json::from_str(&encoded) {
28173 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28174 Err(error) => {
28175 dlg.response_json_decode_error(&encoded, &error);
28176 return Err(common::Error::JsonDecodeError(
28177 encoded.to_string(),
28178 error,
28179 ));
28180 }
28181 }
28182 };
28183
28184 dlg.finished(true);
28185 return Ok(response);
28186 }
28187 }
28188 }
28189 }
28190
28191 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
28192 ///
28193 /// Sets the *course id* path property to the given value.
28194 ///
28195 /// Even though the property as already been set when instantiating this call,
28196 /// we provide this method for API completeness.
28197 pub fn course_id(mut self, new_value: &str) -> CourseStudentListCall<'a, C> {
28198 self._course_id = new_value.to_string();
28199 self
28200 }
28201 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
28202 ///
28203 /// Sets the *page token* query property to the given value.
28204 pub fn page_token(mut self, new_value: &str) -> CourseStudentListCall<'a, C> {
28205 self._page_token = Some(new_value.to_string());
28206 self
28207 }
28208 /// Maximum number of items to return. The default is 30 if unspecified or `0`. The server may return fewer than the specified number of results.
28209 ///
28210 /// Sets the *page size* query property to the given value.
28211 pub fn page_size(mut self, new_value: i32) -> CourseStudentListCall<'a, C> {
28212 self._page_size = Some(new_value);
28213 self
28214 }
28215 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28216 /// while executing the actual API request.
28217 ///
28218 /// ````text
28219 /// It should be used to handle progress information, and to implement a certain level of resilience.
28220 /// ````
28221 ///
28222 /// Sets the *delegate* property to the given value.
28223 pub fn delegate(
28224 mut self,
28225 new_value: &'a mut dyn common::Delegate,
28226 ) -> CourseStudentListCall<'a, C> {
28227 self._delegate = Some(new_value);
28228 self
28229 }
28230
28231 /// Set any additional parameter of the query string used in the request.
28232 /// It should be used to set parameters which are not yet available through their own
28233 /// setters.
28234 ///
28235 /// Please note that this method must not be used to set any of the known parameters
28236 /// which have their own setter method. If done anyway, the request will fail.
28237 ///
28238 /// # Additional Parameters
28239 ///
28240 /// * *$.xgafv* (query-string) - V1 error format.
28241 /// * *access_token* (query-string) - OAuth access token.
28242 /// * *alt* (query-string) - Data format for response.
28243 /// * *callback* (query-string) - JSONP
28244 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28245 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
28246 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28247 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28248 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
28249 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28250 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28251 pub fn param<T>(mut self, name: T, value: T) -> CourseStudentListCall<'a, C>
28252 where
28253 T: AsRef<str>,
28254 {
28255 self._additional_params
28256 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28257 self
28258 }
28259
28260 /// Identifies the authorization scope for the method you are building.
28261 ///
28262 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28263 /// [`Scope::RosterReadonly`].
28264 ///
28265 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28266 /// tokens for more than one scope.
28267 ///
28268 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28269 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28270 /// sufficient, a read-write scope will do as well.
28271 pub fn add_scope<St>(mut self, scope: St) -> CourseStudentListCall<'a, C>
28272 where
28273 St: AsRef<str>,
28274 {
28275 self._scopes.insert(String::from(scope.as_ref()));
28276 self
28277 }
28278 /// Identifies the authorization scope(s) for the method you are building.
28279 ///
28280 /// See [`Self::add_scope()`] for details.
28281 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseStudentListCall<'a, C>
28282 where
28283 I: IntoIterator<Item = St>,
28284 St: AsRef<str>,
28285 {
28286 self._scopes
28287 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28288 self
28289 }
28290
28291 /// Removes all scopes, and no default scope will be used either.
28292 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28293 /// for details).
28294 pub fn clear_scopes(mut self) -> CourseStudentListCall<'a, C> {
28295 self._scopes.clear();
28296 self
28297 }
28298}
28299
28300/// Creates a teacher of a course. Domain administrators are permitted to [directly add](https://developers.google.com/workspace/classroom/guides/manage-users) users within their domain as teachers to courses within their domain. Non-admin users should send an Invitation instead. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create teachers in this course or for access errors. * `NOT_FOUND` if the requested course ID does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled, for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * CourseTeacherLimitReached * UserGroupsMembershipLimitReached * InactiveCourseOwner * `ALREADY_EXISTS` if the user is already a teacher or student in the course.
28301///
28302/// A builder for the *teachers.create* method supported by a *course* resource.
28303/// It is not used directly, but through a [`CourseMethods`] instance.
28304///
28305/// # Example
28306///
28307/// Instantiate a resource method builder
28308///
28309/// ```test_harness,no_run
28310/// # extern crate hyper;
28311/// # extern crate hyper_rustls;
28312/// # extern crate google_classroom1 as classroom1;
28313/// use classroom1::api::Teacher;
28314/// # async fn dox() {
28315/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28316///
28317/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28318/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28319/// # .with_native_roots()
28320/// # .unwrap()
28321/// # .https_only()
28322/// # .enable_http2()
28323/// # .build();
28324///
28325/// # let executor = hyper_util::rt::TokioExecutor::new();
28326/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28327/// # secret,
28328/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28329/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28330/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28331/// # ),
28332/// # ).build().await.unwrap();
28333///
28334/// # let client = hyper_util::client::legacy::Client::builder(
28335/// # hyper_util::rt::TokioExecutor::new()
28336/// # )
28337/// # .build(
28338/// # hyper_rustls::HttpsConnectorBuilder::new()
28339/// # .with_native_roots()
28340/// # .unwrap()
28341/// # .https_or_http()
28342/// # .enable_http2()
28343/// # .build()
28344/// # );
28345/// # let mut hub = Classroom::new(client, auth);
28346/// // As the method needs a request, you would usually fill it with the desired information
28347/// // into the respective structure. Some of the parts shown here might not be applicable !
28348/// // Values shown here are possibly random and not representative !
28349/// let mut req = Teacher::default();
28350///
28351/// // You can configure optional parameters by calling the respective setters at will, and
28352/// // execute the final call using `doit()`.
28353/// // Values shown here are possibly random and not representative !
28354/// let result = hub.courses().teachers_create(req, "courseId")
28355/// .doit().await;
28356/// # }
28357/// ```
28358pub struct CourseTeacherCreateCall<'a, C>
28359where
28360 C: 'a,
28361{
28362 hub: &'a Classroom<C>,
28363 _request: Teacher,
28364 _course_id: String,
28365 _delegate: Option<&'a mut dyn common::Delegate>,
28366 _additional_params: HashMap<String, String>,
28367 _scopes: BTreeSet<String>,
28368}
28369
28370impl<'a, C> common::CallBuilder for CourseTeacherCreateCall<'a, C> {}
28371
28372impl<'a, C> CourseTeacherCreateCall<'a, C>
28373where
28374 C: common::Connector,
28375{
28376 /// Perform the operation you have build so far.
28377 pub async fn doit(mut self) -> common::Result<(common::Response, Teacher)> {
28378 use std::borrow::Cow;
28379 use std::io::{Read, Seek};
28380
28381 use common::{url::Params, ToParts};
28382 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28383
28384 let mut dd = common::DefaultDelegate;
28385 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28386 dlg.begin(common::MethodInfo {
28387 id: "classroom.courses.teachers.create",
28388 http_method: hyper::Method::POST,
28389 });
28390
28391 for &field in ["alt", "courseId"].iter() {
28392 if self._additional_params.contains_key(field) {
28393 dlg.finished(false);
28394 return Err(common::Error::FieldClash(field));
28395 }
28396 }
28397
28398 let mut params = Params::with_capacity(4 + self._additional_params.len());
28399 params.push("courseId", self._course_id);
28400
28401 params.extend(self._additional_params.iter());
28402
28403 params.push("alt", "json");
28404 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/teachers";
28405 if self._scopes.is_empty() {
28406 self._scopes
28407 .insert(Scope::ProfileEmail.as_ref().to_string());
28408 }
28409
28410 #[allow(clippy::single_element_loop)]
28411 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
28412 url = params.uri_replacement(url, param_name, find_this, false);
28413 }
28414 {
28415 let to_remove = ["courseId"];
28416 params.remove_params(&to_remove);
28417 }
28418
28419 let url = params.parse_with_url(&url);
28420
28421 let mut json_mime_type = mime::APPLICATION_JSON;
28422 let mut request_value_reader = {
28423 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28424 common::remove_json_null_values(&mut value);
28425 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28426 serde_json::to_writer(&mut dst, &value).unwrap();
28427 dst
28428 };
28429 let request_size = request_value_reader
28430 .seek(std::io::SeekFrom::End(0))
28431 .unwrap();
28432 request_value_reader
28433 .seek(std::io::SeekFrom::Start(0))
28434 .unwrap();
28435
28436 loop {
28437 let token = match self
28438 .hub
28439 .auth
28440 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28441 .await
28442 {
28443 Ok(token) => token,
28444 Err(e) => match dlg.token(e) {
28445 Ok(token) => token,
28446 Err(e) => {
28447 dlg.finished(false);
28448 return Err(common::Error::MissingToken(e));
28449 }
28450 },
28451 };
28452 request_value_reader
28453 .seek(std::io::SeekFrom::Start(0))
28454 .unwrap();
28455 let mut req_result = {
28456 let client = &self.hub.client;
28457 dlg.pre_request();
28458 let mut req_builder = hyper::Request::builder()
28459 .method(hyper::Method::POST)
28460 .uri(url.as_str())
28461 .header(USER_AGENT, self.hub._user_agent.clone());
28462
28463 if let Some(token) = token.as_ref() {
28464 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28465 }
28466
28467 let request = req_builder
28468 .header(CONTENT_TYPE, json_mime_type.to_string())
28469 .header(CONTENT_LENGTH, request_size as u64)
28470 .body(common::to_body(
28471 request_value_reader.get_ref().clone().into(),
28472 ));
28473
28474 client.request(request.unwrap()).await
28475 };
28476
28477 match req_result {
28478 Err(err) => {
28479 if let common::Retry::After(d) = dlg.http_error(&err) {
28480 sleep(d).await;
28481 continue;
28482 }
28483 dlg.finished(false);
28484 return Err(common::Error::HttpError(err));
28485 }
28486 Ok(res) => {
28487 let (mut parts, body) = res.into_parts();
28488 let mut body = common::Body::new(body);
28489 if !parts.status.is_success() {
28490 let bytes = common::to_bytes(body).await.unwrap_or_default();
28491 let error = serde_json::from_str(&common::to_string(&bytes));
28492 let response = common::to_response(parts, bytes.into());
28493
28494 if let common::Retry::After(d) =
28495 dlg.http_failure(&response, error.as_ref().ok())
28496 {
28497 sleep(d).await;
28498 continue;
28499 }
28500
28501 dlg.finished(false);
28502
28503 return Err(match error {
28504 Ok(value) => common::Error::BadRequest(value),
28505 _ => common::Error::Failure(response),
28506 });
28507 }
28508 let response = {
28509 let bytes = common::to_bytes(body).await.unwrap_or_default();
28510 let encoded = common::to_string(&bytes);
28511 match serde_json::from_str(&encoded) {
28512 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28513 Err(error) => {
28514 dlg.response_json_decode_error(&encoded, &error);
28515 return Err(common::Error::JsonDecodeError(
28516 encoded.to_string(),
28517 error,
28518 ));
28519 }
28520 }
28521 };
28522
28523 dlg.finished(true);
28524 return Ok(response);
28525 }
28526 }
28527 }
28528 }
28529
28530 ///
28531 /// Sets the *request* property to the given value.
28532 ///
28533 /// Even though the property as already been set when instantiating this call,
28534 /// we provide this method for API completeness.
28535 pub fn request(mut self, new_value: Teacher) -> CourseTeacherCreateCall<'a, C> {
28536 self._request = new_value;
28537 self
28538 }
28539 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
28540 ///
28541 /// Sets the *course id* path property to the given value.
28542 ///
28543 /// Even though the property as already been set when instantiating this call,
28544 /// we provide this method for API completeness.
28545 pub fn course_id(mut self, new_value: &str) -> CourseTeacherCreateCall<'a, C> {
28546 self._course_id = new_value.to_string();
28547 self
28548 }
28549 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28550 /// while executing the actual API request.
28551 ///
28552 /// ````text
28553 /// It should be used to handle progress information, and to implement a certain level of resilience.
28554 /// ````
28555 ///
28556 /// Sets the *delegate* property to the given value.
28557 pub fn delegate(
28558 mut self,
28559 new_value: &'a mut dyn common::Delegate,
28560 ) -> CourseTeacherCreateCall<'a, C> {
28561 self._delegate = Some(new_value);
28562 self
28563 }
28564
28565 /// Set any additional parameter of the query string used in the request.
28566 /// It should be used to set parameters which are not yet available through their own
28567 /// setters.
28568 ///
28569 /// Please note that this method must not be used to set any of the known parameters
28570 /// which have their own setter method. If done anyway, the request will fail.
28571 ///
28572 /// # Additional Parameters
28573 ///
28574 /// * *$.xgafv* (query-string) - V1 error format.
28575 /// * *access_token* (query-string) - OAuth access token.
28576 /// * *alt* (query-string) - Data format for response.
28577 /// * *callback* (query-string) - JSONP
28578 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28579 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
28580 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28581 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28582 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
28583 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28584 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28585 pub fn param<T>(mut self, name: T, value: T) -> CourseTeacherCreateCall<'a, C>
28586 where
28587 T: AsRef<str>,
28588 {
28589 self._additional_params
28590 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28591 self
28592 }
28593
28594 /// Identifies the authorization scope for the method you are building.
28595 ///
28596 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28597 /// [`Scope::ProfileEmail`].
28598 ///
28599 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28600 /// tokens for more than one scope.
28601 ///
28602 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28603 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28604 /// sufficient, a read-write scope will do as well.
28605 pub fn add_scope<St>(mut self, scope: St) -> CourseTeacherCreateCall<'a, C>
28606 where
28607 St: AsRef<str>,
28608 {
28609 self._scopes.insert(String::from(scope.as_ref()));
28610 self
28611 }
28612 /// Identifies the authorization scope(s) for the method you are building.
28613 ///
28614 /// See [`Self::add_scope()`] for details.
28615 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseTeacherCreateCall<'a, C>
28616 where
28617 I: IntoIterator<Item = St>,
28618 St: AsRef<str>,
28619 {
28620 self._scopes
28621 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28622 self
28623 }
28624
28625 /// Removes all scopes, and no default scope will be used either.
28626 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28627 /// for details).
28628 pub fn clear_scopes(mut self) -> CourseTeacherCreateCall<'a, C> {
28629 self._scopes.clear();
28630 self
28631 }
28632}
28633
28634/// Removes the specified teacher from the specified course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete teachers of this course or for access errors. * `NOT_FOUND` if no teacher of this course has the requested ID or if the course does not exist. * `FAILED_PRECONDITION` if the requested ID belongs to the primary teacher of this course. * `FAILED_PRECONDITION` if the requested ID belongs to the owner of the course Drive folder. * `FAILED_PRECONDITION` if the course no longer has an active owner.
28635///
28636/// A builder for the *teachers.delete* method supported by a *course* resource.
28637/// It is not used directly, but through a [`CourseMethods`] instance.
28638///
28639/// # Example
28640///
28641/// Instantiate a resource method builder
28642///
28643/// ```test_harness,no_run
28644/// # extern crate hyper;
28645/// # extern crate hyper_rustls;
28646/// # extern crate google_classroom1 as classroom1;
28647/// # async fn dox() {
28648/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28649///
28650/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28651/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28652/// # .with_native_roots()
28653/// # .unwrap()
28654/// # .https_only()
28655/// # .enable_http2()
28656/// # .build();
28657///
28658/// # let executor = hyper_util::rt::TokioExecutor::new();
28659/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28660/// # secret,
28661/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28662/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28663/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28664/// # ),
28665/// # ).build().await.unwrap();
28666///
28667/// # let client = hyper_util::client::legacy::Client::builder(
28668/// # hyper_util::rt::TokioExecutor::new()
28669/// # )
28670/// # .build(
28671/// # hyper_rustls::HttpsConnectorBuilder::new()
28672/// # .with_native_roots()
28673/// # .unwrap()
28674/// # .https_or_http()
28675/// # .enable_http2()
28676/// # .build()
28677/// # );
28678/// # let mut hub = Classroom::new(client, auth);
28679/// // You can configure optional parameters by calling the respective setters at will, and
28680/// // execute the final call using `doit()`.
28681/// // Values shown here are possibly random and not representative !
28682/// let result = hub.courses().teachers_delete("courseId", "userId")
28683/// .doit().await;
28684/// # }
28685/// ```
28686pub struct CourseTeacherDeleteCall<'a, C>
28687where
28688 C: 'a,
28689{
28690 hub: &'a Classroom<C>,
28691 _course_id: String,
28692 _user_id: String,
28693 _delegate: Option<&'a mut dyn common::Delegate>,
28694 _additional_params: HashMap<String, String>,
28695 _scopes: BTreeSet<String>,
28696}
28697
28698impl<'a, C> common::CallBuilder for CourseTeacherDeleteCall<'a, C> {}
28699
28700impl<'a, C> CourseTeacherDeleteCall<'a, C>
28701where
28702 C: common::Connector,
28703{
28704 /// Perform the operation you have build so far.
28705 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
28706 use std::borrow::Cow;
28707 use std::io::{Read, Seek};
28708
28709 use common::{url::Params, ToParts};
28710 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28711
28712 let mut dd = common::DefaultDelegate;
28713 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28714 dlg.begin(common::MethodInfo {
28715 id: "classroom.courses.teachers.delete",
28716 http_method: hyper::Method::DELETE,
28717 });
28718
28719 for &field in ["alt", "courseId", "userId"].iter() {
28720 if self._additional_params.contains_key(field) {
28721 dlg.finished(false);
28722 return Err(common::Error::FieldClash(field));
28723 }
28724 }
28725
28726 let mut params = Params::with_capacity(4 + self._additional_params.len());
28727 params.push("courseId", self._course_id);
28728 params.push("userId", self._user_id);
28729
28730 params.extend(self._additional_params.iter());
28731
28732 params.push("alt", "json");
28733 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/teachers/{userId}";
28734 if self._scopes.is_empty() {
28735 self._scopes.insert(Scope::Roster.as_ref().to_string());
28736 }
28737
28738 #[allow(clippy::single_element_loop)]
28739 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{userId}", "userId")].iter()
28740 {
28741 url = params.uri_replacement(url, param_name, find_this, false);
28742 }
28743 {
28744 let to_remove = ["userId", "courseId"];
28745 params.remove_params(&to_remove);
28746 }
28747
28748 let url = params.parse_with_url(&url);
28749
28750 loop {
28751 let token = match self
28752 .hub
28753 .auth
28754 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28755 .await
28756 {
28757 Ok(token) => token,
28758 Err(e) => match dlg.token(e) {
28759 Ok(token) => token,
28760 Err(e) => {
28761 dlg.finished(false);
28762 return Err(common::Error::MissingToken(e));
28763 }
28764 },
28765 };
28766 let mut req_result = {
28767 let client = &self.hub.client;
28768 dlg.pre_request();
28769 let mut req_builder = hyper::Request::builder()
28770 .method(hyper::Method::DELETE)
28771 .uri(url.as_str())
28772 .header(USER_AGENT, self.hub._user_agent.clone());
28773
28774 if let Some(token) = token.as_ref() {
28775 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28776 }
28777
28778 let request = req_builder
28779 .header(CONTENT_LENGTH, 0_u64)
28780 .body(common::to_body::<String>(None));
28781
28782 client.request(request.unwrap()).await
28783 };
28784
28785 match req_result {
28786 Err(err) => {
28787 if let common::Retry::After(d) = dlg.http_error(&err) {
28788 sleep(d).await;
28789 continue;
28790 }
28791 dlg.finished(false);
28792 return Err(common::Error::HttpError(err));
28793 }
28794 Ok(res) => {
28795 let (mut parts, body) = res.into_parts();
28796 let mut body = common::Body::new(body);
28797 if !parts.status.is_success() {
28798 let bytes = common::to_bytes(body).await.unwrap_or_default();
28799 let error = serde_json::from_str(&common::to_string(&bytes));
28800 let response = common::to_response(parts, bytes.into());
28801
28802 if let common::Retry::After(d) =
28803 dlg.http_failure(&response, error.as_ref().ok())
28804 {
28805 sleep(d).await;
28806 continue;
28807 }
28808
28809 dlg.finished(false);
28810
28811 return Err(match error {
28812 Ok(value) => common::Error::BadRequest(value),
28813 _ => common::Error::Failure(response),
28814 });
28815 }
28816 let response = {
28817 let bytes = common::to_bytes(body).await.unwrap_or_default();
28818 let encoded = common::to_string(&bytes);
28819 match serde_json::from_str(&encoded) {
28820 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28821 Err(error) => {
28822 dlg.response_json_decode_error(&encoded, &error);
28823 return Err(common::Error::JsonDecodeError(
28824 encoded.to_string(),
28825 error,
28826 ));
28827 }
28828 }
28829 };
28830
28831 dlg.finished(true);
28832 return Ok(response);
28833 }
28834 }
28835 }
28836 }
28837
28838 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
28839 ///
28840 /// Sets the *course id* path property to the given value.
28841 ///
28842 /// Even though the property as already been set when instantiating this call,
28843 /// we provide this method for API completeness.
28844 pub fn course_id(mut self, new_value: &str) -> CourseTeacherDeleteCall<'a, C> {
28845 self._course_id = new_value.to_string();
28846 self
28847 }
28848 /// Identifier of the teacher to delete. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
28849 ///
28850 /// Sets the *user id* path property to the given value.
28851 ///
28852 /// Even though the property as already been set when instantiating this call,
28853 /// we provide this method for API completeness.
28854 pub fn user_id(mut self, new_value: &str) -> CourseTeacherDeleteCall<'a, C> {
28855 self._user_id = new_value.to_string();
28856 self
28857 }
28858 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28859 /// while executing the actual API request.
28860 ///
28861 /// ````text
28862 /// It should be used to handle progress information, and to implement a certain level of resilience.
28863 /// ````
28864 ///
28865 /// Sets the *delegate* property to the given value.
28866 pub fn delegate(
28867 mut self,
28868 new_value: &'a mut dyn common::Delegate,
28869 ) -> CourseTeacherDeleteCall<'a, C> {
28870 self._delegate = Some(new_value);
28871 self
28872 }
28873
28874 /// Set any additional parameter of the query string used in the request.
28875 /// It should be used to set parameters which are not yet available through their own
28876 /// setters.
28877 ///
28878 /// Please note that this method must not be used to set any of the known parameters
28879 /// which have their own setter method. If done anyway, the request will fail.
28880 ///
28881 /// # Additional Parameters
28882 ///
28883 /// * *$.xgafv* (query-string) - V1 error format.
28884 /// * *access_token* (query-string) - OAuth access token.
28885 /// * *alt* (query-string) - Data format for response.
28886 /// * *callback* (query-string) - JSONP
28887 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28888 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
28889 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28890 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28891 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
28892 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28893 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28894 pub fn param<T>(mut self, name: T, value: T) -> CourseTeacherDeleteCall<'a, C>
28895 where
28896 T: AsRef<str>,
28897 {
28898 self._additional_params
28899 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28900 self
28901 }
28902
28903 /// Identifies the authorization scope for the method you are building.
28904 ///
28905 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28906 /// [`Scope::Roster`].
28907 ///
28908 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28909 /// tokens for more than one scope.
28910 ///
28911 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28912 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28913 /// sufficient, a read-write scope will do as well.
28914 pub fn add_scope<St>(mut self, scope: St) -> CourseTeacherDeleteCall<'a, C>
28915 where
28916 St: AsRef<str>,
28917 {
28918 self._scopes.insert(String::from(scope.as_ref()));
28919 self
28920 }
28921 /// Identifies the authorization scope(s) for the method you are building.
28922 ///
28923 /// See [`Self::add_scope()`] for details.
28924 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseTeacherDeleteCall<'a, C>
28925 where
28926 I: IntoIterator<Item = St>,
28927 St: AsRef<str>,
28928 {
28929 self._scopes
28930 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28931 self
28932 }
28933
28934 /// Removes all scopes, and no default scope will be used either.
28935 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28936 /// for details).
28937 pub fn clear_scopes(mut self) -> CourseTeacherDeleteCall<'a, C> {
28938 self._scopes.clear();
28939 self
28940 }
28941}
28942
28943/// Returns a teacher of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view teachers of this course or for access errors. * `NOT_FOUND` if no teacher of this course has the requested ID or if the course does not exist.
28944///
28945/// A builder for the *teachers.get* method supported by a *course* resource.
28946/// It is not used directly, but through a [`CourseMethods`] instance.
28947///
28948/// # Example
28949///
28950/// Instantiate a resource method builder
28951///
28952/// ```test_harness,no_run
28953/// # extern crate hyper;
28954/// # extern crate hyper_rustls;
28955/// # extern crate google_classroom1 as classroom1;
28956/// # async fn dox() {
28957/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28958///
28959/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28960/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28961/// # .with_native_roots()
28962/// # .unwrap()
28963/// # .https_only()
28964/// # .enable_http2()
28965/// # .build();
28966///
28967/// # let executor = hyper_util::rt::TokioExecutor::new();
28968/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28969/// # secret,
28970/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28971/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28972/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28973/// # ),
28974/// # ).build().await.unwrap();
28975///
28976/// # let client = hyper_util::client::legacy::Client::builder(
28977/// # hyper_util::rt::TokioExecutor::new()
28978/// # )
28979/// # .build(
28980/// # hyper_rustls::HttpsConnectorBuilder::new()
28981/// # .with_native_roots()
28982/// # .unwrap()
28983/// # .https_or_http()
28984/// # .enable_http2()
28985/// # .build()
28986/// # );
28987/// # let mut hub = Classroom::new(client, auth);
28988/// // You can configure optional parameters by calling the respective setters at will, and
28989/// // execute the final call using `doit()`.
28990/// // Values shown here are possibly random and not representative !
28991/// let result = hub.courses().teachers_get("courseId", "userId")
28992/// .doit().await;
28993/// # }
28994/// ```
28995pub struct CourseTeacherGetCall<'a, C>
28996where
28997 C: 'a,
28998{
28999 hub: &'a Classroom<C>,
29000 _course_id: String,
29001 _user_id: String,
29002 _delegate: Option<&'a mut dyn common::Delegate>,
29003 _additional_params: HashMap<String, String>,
29004 _scopes: BTreeSet<String>,
29005}
29006
29007impl<'a, C> common::CallBuilder for CourseTeacherGetCall<'a, C> {}
29008
29009impl<'a, C> CourseTeacherGetCall<'a, C>
29010where
29011 C: common::Connector,
29012{
29013 /// Perform the operation you have build so far.
29014 pub async fn doit(mut self) -> common::Result<(common::Response, Teacher)> {
29015 use std::borrow::Cow;
29016 use std::io::{Read, Seek};
29017
29018 use common::{url::Params, ToParts};
29019 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29020
29021 let mut dd = common::DefaultDelegate;
29022 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29023 dlg.begin(common::MethodInfo {
29024 id: "classroom.courses.teachers.get",
29025 http_method: hyper::Method::GET,
29026 });
29027
29028 for &field in ["alt", "courseId", "userId"].iter() {
29029 if self._additional_params.contains_key(field) {
29030 dlg.finished(false);
29031 return Err(common::Error::FieldClash(field));
29032 }
29033 }
29034
29035 let mut params = Params::with_capacity(4 + self._additional_params.len());
29036 params.push("courseId", self._course_id);
29037 params.push("userId", self._user_id);
29038
29039 params.extend(self._additional_params.iter());
29040
29041 params.push("alt", "json");
29042 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/teachers/{userId}";
29043 if self._scopes.is_empty() {
29044 self._scopes
29045 .insert(Scope::RosterReadonly.as_ref().to_string());
29046 }
29047
29048 #[allow(clippy::single_element_loop)]
29049 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{userId}", "userId")].iter()
29050 {
29051 url = params.uri_replacement(url, param_name, find_this, false);
29052 }
29053 {
29054 let to_remove = ["userId", "courseId"];
29055 params.remove_params(&to_remove);
29056 }
29057
29058 let url = params.parse_with_url(&url);
29059
29060 loop {
29061 let token = match self
29062 .hub
29063 .auth
29064 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29065 .await
29066 {
29067 Ok(token) => token,
29068 Err(e) => match dlg.token(e) {
29069 Ok(token) => token,
29070 Err(e) => {
29071 dlg.finished(false);
29072 return Err(common::Error::MissingToken(e));
29073 }
29074 },
29075 };
29076 let mut req_result = {
29077 let client = &self.hub.client;
29078 dlg.pre_request();
29079 let mut req_builder = hyper::Request::builder()
29080 .method(hyper::Method::GET)
29081 .uri(url.as_str())
29082 .header(USER_AGENT, self.hub._user_agent.clone());
29083
29084 if let Some(token) = token.as_ref() {
29085 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29086 }
29087
29088 let request = req_builder
29089 .header(CONTENT_LENGTH, 0_u64)
29090 .body(common::to_body::<String>(None));
29091
29092 client.request(request.unwrap()).await
29093 };
29094
29095 match req_result {
29096 Err(err) => {
29097 if let common::Retry::After(d) = dlg.http_error(&err) {
29098 sleep(d).await;
29099 continue;
29100 }
29101 dlg.finished(false);
29102 return Err(common::Error::HttpError(err));
29103 }
29104 Ok(res) => {
29105 let (mut parts, body) = res.into_parts();
29106 let mut body = common::Body::new(body);
29107 if !parts.status.is_success() {
29108 let bytes = common::to_bytes(body).await.unwrap_or_default();
29109 let error = serde_json::from_str(&common::to_string(&bytes));
29110 let response = common::to_response(parts, bytes.into());
29111
29112 if let common::Retry::After(d) =
29113 dlg.http_failure(&response, error.as_ref().ok())
29114 {
29115 sleep(d).await;
29116 continue;
29117 }
29118
29119 dlg.finished(false);
29120
29121 return Err(match error {
29122 Ok(value) => common::Error::BadRequest(value),
29123 _ => common::Error::Failure(response),
29124 });
29125 }
29126 let response = {
29127 let bytes = common::to_bytes(body).await.unwrap_or_default();
29128 let encoded = common::to_string(&bytes);
29129 match serde_json::from_str(&encoded) {
29130 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29131 Err(error) => {
29132 dlg.response_json_decode_error(&encoded, &error);
29133 return Err(common::Error::JsonDecodeError(
29134 encoded.to_string(),
29135 error,
29136 ));
29137 }
29138 }
29139 };
29140
29141 dlg.finished(true);
29142 return Ok(response);
29143 }
29144 }
29145 }
29146 }
29147
29148 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
29149 ///
29150 /// Sets the *course id* path property to the given value.
29151 ///
29152 /// Even though the property as already been set when instantiating this call,
29153 /// we provide this method for API completeness.
29154 pub fn course_id(mut self, new_value: &str) -> CourseTeacherGetCall<'a, C> {
29155 self._course_id = new_value.to_string();
29156 self
29157 }
29158 /// Identifier of the teacher to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
29159 ///
29160 /// Sets the *user id* path property to the given value.
29161 ///
29162 /// Even though the property as already been set when instantiating this call,
29163 /// we provide this method for API completeness.
29164 pub fn user_id(mut self, new_value: &str) -> CourseTeacherGetCall<'a, C> {
29165 self._user_id = new_value.to_string();
29166 self
29167 }
29168 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29169 /// while executing the actual API request.
29170 ///
29171 /// ````text
29172 /// It should be used to handle progress information, and to implement a certain level of resilience.
29173 /// ````
29174 ///
29175 /// Sets the *delegate* property to the given value.
29176 pub fn delegate(
29177 mut self,
29178 new_value: &'a mut dyn common::Delegate,
29179 ) -> CourseTeacherGetCall<'a, C> {
29180 self._delegate = Some(new_value);
29181 self
29182 }
29183
29184 /// Set any additional parameter of the query string used in the request.
29185 /// It should be used to set parameters which are not yet available through their own
29186 /// setters.
29187 ///
29188 /// Please note that this method must not be used to set any of the known parameters
29189 /// which have their own setter method. If done anyway, the request will fail.
29190 ///
29191 /// # Additional Parameters
29192 ///
29193 /// * *$.xgafv* (query-string) - V1 error format.
29194 /// * *access_token* (query-string) - OAuth access token.
29195 /// * *alt* (query-string) - Data format for response.
29196 /// * *callback* (query-string) - JSONP
29197 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29198 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
29199 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29200 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29201 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
29202 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29203 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29204 pub fn param<T>(mut self, name: T, value: T) -> CourseTeacherGetCall<'a, C>
29205 where
29206 T: AsRef<str>,
29207 {
29208 self._additional_params
29209 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29210 self
29211 }
29212
29213 /// Identifies the authorization scope for the method you are building.
29214 ///
29215 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29216 /// [`Scope::RosterReadonly`].
29217 ///
29218 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29219 /// tokens for more than one scope.
29220 ///
29221 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29222 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29223 /// sufficient, a read-write scope will do as well.
29224 pub fn add_scope<St>(mut self, scope: St) -> CourseTeacherGetCall<'a, C>
29225 where
29226 St: AsRef<str>,
29227 {
29228 self._scopes.insert(String::from(scope.as_ref()));
29229 self
29230 }
29231 /// Identifies the authorization scope(s) for the method you are building.
29232 ///
29233 /// See [`Self::add_scope()`] for details.
29234 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseTeacherGetCall<'a, C>
29235 where
29236 I: IntoIterator<Item = St>,
29237 St: AsRef<str>,
29238 {
29239 self._scopes
29240 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29241 self
29242 }
29243
29244 /// Removes all scopes, and no default scope will be used either.
29245 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29246 /// for details).
29247 pub fn clear_scopes(mut self) -> CourseTeacherGetCall<'a, C> {
29248 self._scopes.clear();
29249 self
29250 }
29251}
29252
29253/// Returns a list of teachers of this course that the requester is permitted to view. This method returns the following error codes: * `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for access errors.
29254///
29255/// A builder for the *teachers.list* method supported by a *course* resource.
29256/// It is not used directly, but through a [`CourseMethods`] instance.
29257///
29258/// # Example
29259///
29260/// Instantiate a resource method builder
29261///
29262/// ```test_harness,no_run
29263/// # extern crate hyper;
29264/// # extern crate hyper_rustls;
29265/// # extern crate google_classroom1 as classroom1;
29266/// # async fn dox() {
29267/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29268///
29269/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29270/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29271/// # .with_native_roots()
29272/// # .unwrap()
29273/// # .https_only()
29274/// # .enable_http2()
29275/// # .build();
29276///
29277/// # let executor = hyper_util::rt::TokioExecutor::new();
29278/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29279/// # secret,
29280/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29281/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29282/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29283/// # ),
29284/// # ).build().await.unwrap();
29285///
29286/// # let client = hyper_util::client::legacy::Client::builder(
29287/// # hyper_util::rt::TokioExecutor::new()
29288/// # )
29289/// # .build(
29290/// # hyper_rustls::HttpsConnectorBuilder::new()
29291/// # .with_native_roots()
29292/// # .unwrap()
29293/// # .https_or_http()
29294/// # .enable_http2()
29295/// # .build()
29296/// # );
29297/// # let mut hub = Classroom::new(client, auth);
29298/// // You can configure optional parameters by calling the respective setters at will, and
29299/// // execute the final call using `doit()`.
29300/// // Values shown here are possibly random and not representative !
29301/// let result = hub.courses().teachers_list("courseId")
29302/// .page_token("ut")
29303/// .page_size(-3)
29304/// .doit().await;
29305/// # }
29306/// ```
29307pub struct CourseTeacherListCall<'a, C>
29308where
29309 C: 'a,
29310{
29311 hub: &'a Classroom<C>,
29312 _course_id: String,
29313 _page_token: Option<String>,
29314 _page_size: Option<i32>,
29315 _delegate: Option<&'a mut dyn common::Delegate>,
29316 _additional_params: HashMap<String, String>,
29317 _scopes: BTreeSet<String>,
29318}
29319
29320impl<'a, C> common::CallBuilder for CourseTeacherListCall<'a, C> {}
29321
29322impl<'a, C> CourseTeacherListCall<'a, C>
29323where
29324 C: common::Connector,
29325{
29326 /// Perform the operation you have build so far.
29327 pub async fn doit(mut self) -> common::Result<(common::Response, ListTeachersResponse)> {
29328 use std::borrow::Cow;
29329 use std::io::{Read, Seek};
29330
29331 use common::{url::Params, ToParts};
29332 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29333
29334 let mut dd = common::DefaultDelegate;
29335 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29336 dlg.begin(common::MethodInfo {
29337 id: "classroom.courses.teachers.list",
29338 http_method: hyper::Method::GET,
29339 });
29340
29341 for &field in ["alt", "courseId", "pageToken", "pageSize"].iter() {
29342 if self._additional_params.contains_key(field) {
29343 dlg.finished(false);
29344 return Err(common::Error::FieldClash(field));
29345 }
29346 }
29347
29348 let mut params = Params::with_capacity(5 + self._additional_params.len());
29349 params.push("courseId", self._course_id);
29350 if let Some(value) = self._page_token.as_ref() {
29351 params.push("pageToken", value);
29352 }
29353 if let Some(value) = self._page_size.as_ref() {
29354 params.push("pageSize", value.to_string());
29355 }
29356
29357 params.extend(self._additional_params.iter());
29358
29359 params.push("alt", "json");
29360 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/teachers";
29361 if self._scopes.is_empty() {
29362 self._scopes
29363 .insert(Scope::RosterReadonly.as_ref().to_string());
29364 }
29365
29366 #[allow(clippy::single_element_loop)]
29367 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
29368 url = params.uri_replacement(url, param_name, find_this, false);
29369 }
29370 {
29371 let to_remove = ["courseId"];
29372 params.remove_params(&to_remove);
29373 }
29374
29375 let url = params.parse_with_url(&url);
29376
29377 loop {
29378 let token = match self
29379 .hub
29380 .auth
29381 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29382 .await
29383 {
29384 Ok(token) => token,
29385 Err(e) => match dlg.token(e) {
29386 Ok(token) => token,
29387 Err(e) => {
29388 dlg.finished(false);
29389 return Err(common::Error::MissingToken(e));
29390 }
29391 },
29392 };
29393 let mut req_result = {
29394 let client = &self.hub.client;
29395 dlg.pre_request();
29396 let mut req_builder = hyper::Request::builder()
29397 .method(hyper::Method::GET)
29398 .uri(url.as_str())
29399 .header(USER_AGENT, self.hub._user_agent.clone());
29400
29401 if let Some(token) = token.as_ref() {
29402 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29403 }
29404
29405 let request = req_builder
29406 .header(CONTENT_LENGTH, 0_u64)
29407 .body(common::to_body::<String>(None));
29408
29409 client.request(request.unwrap()).await
29410 };
29411
29412 match req_result {
29413 Err(err) => {
29414 if let common::Retry::After(d) = dlg.http_error(&err) {
29415 sleep(d).await;
29416 continue;
29417 }
29418 dlg.finished(false);
29419 return Err(common::Error::HttpError(err));
29420 }
29421 Ok(res) => {
29422 let (mut parts, body) = res.into_parts();
29423 let mut body = common::Body::new(body);
29424 if !parts.status.is_success() {
29425 let bytes = common::to_bytes(body).await.unwrap_or_default();
29426 let error = serde_json::from_str(&common::to_string(&bytes));
29427 let response = common::to_response(parts, bytes.into());
29428
29429 if let common::Retry::After(d) =
29430 dlg.http_failure(&response, error.as_ref().ok())
29431 {
29432 sleep(d).await;
29433 continue;
29434 }
29435
29436 dlg.finished(false);
29437
29438 return Err(match error {
29439 Ok(value) => common::Error::BadRequest(value),
29440 _ => common::Error::Failure(response),
29441 });
29442 }
29443 let response = {
29444 let bytes = common::to_bytes(body).await.unwrap_or_default();
29445 let encoded = common::to_string(&bytes);
29446 match serde_json::from_str(&encoded) {
29447 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29448 Err(error) => {
29449 dlg.response_json_decode_error(&encoded, &error);
29450 return Err(common::Error::JsonDecodeError(
29451 encoded.to_string(),
29452 error,
29453 ));
29454 }
29455 }
29456 };
29457
29458 dlg.finished(true);
29459 return Ok(response);
29460 }
29461 }
29462 }
29463 }
29464
29465 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
29466 ///
29467 /// Sets the *course id* path property to the given value.
29468 ///
29469 /// Even though the property as already been set when instantiating this call,
29470 /// we provide this method for API completeness.
29471 pub fn course_id(mut self, new_value: &str) -> CourseTeacherListCall<'a, C> {
29472 self._course_id = new_value.to_string();
29473 self
29474 }
29475 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
29476 ///
29477 /// Sets the *page token* query property to the given value.
29478 pub fn page_token(mut self, new_value: &str) -> CourseTeacherListCall<'a, C> {
29479 self._page_token = Some(new_value.to_string());
29480 self
29481 }
29482 /// Maximum number of items to return. The default is 30 if unspecified or `0`. The server may return fewer than the specified number of results.
29483 ///
29484 /// Sets the *page size* query property to the given value.
29485 pub fn page_size(mut self, new_value: i32) -> CourseTeacherListCall<'a, C> {
29486 self._page_size = Some(new_value);
29487 self
29488 }
29489 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29490 /// while executing the actual API request.
29491 ///
29492 /// ````text
29493 /// It should be used to handle progress information, and to implement a certain level of resilience.
29494 /// ````
29495 ///
29496 /// Sets the *delegate* property to the given value.
29497 pub fn delegate(
29498 mut self,
29499 new_value: &'a mut dyn common::Delegate,
29500 ) -> CourseTeacherListCall<'a, C> {
29501 self._delegate = Some(new_value);
29502 self
29503 }
29504
29505 /// Set any additional parameter of the query string used in the request.
29506 /// It should be used to set parameters which are not yet available through their own
29507 /// setters.
29508 ///
29509 /// Please note that this method must not be used to set any of the known parameters
29510 /// which have their own setter method. If done anyway, the request will fail.
29511 ///
29512 /// # Additional Parameters
29513 ///
29514 /// * *$.xgafv* (query-string) - V1 error format.
29515 /// * *access_token* (query-string) - OAuth access token.
29516 /// * *alt* (query-string) - Data format for response.
29517 /// * *callback* (query-string) - JSONP
29518 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29519 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
29520 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29521 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29522 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
29523 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29524 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29525 pub fn param<T>(mut self, name: T, value: T) -> CourseTeacherListCall<'a, C>
29526 where
29527 T: AsRef<str>,
29528 {
29529 self._additional_params
29530 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29531 self
29532 }
29533
29534 /// Identifies the authorization scope for the method you are building.
29535 ///
29536 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29537 /// [`Scope::RosterReadonly`].
29538 ///
29539 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29540 /// tokens for more than one scope.
29541 ///
29542 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29543 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29544 /// sufficient, a read-write scope will do as well.
29545 pub fn add_scope<St>(mut self, scope: St) -> CourseTeacherListCall<'a, C>
29546 where
29547 St: AsRef<str>,
29548 {
29549 self._scopes.insert(String::from(scope.as_ref()));
29550 self
29551 }
29552 /// Identifies the authorization scope(s) for the method you are building.
29553 ///
29554 /// See [`Self::add_scope()`] for details.
29555 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseTeacherListCall<'a, C>
29556 where
29557 I: IntoIterator<Item = St>,
29558 St: AsRef<str>,
29559 {
29560 self._scopes
29561 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29562 self
29563 }
29564
29565 /// Removes all scopes, and no default scope will be used either.
29566 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29567 /// for details).
29568 pub fn clear_scopes(mut self) -> CourseTeacherListCall<'a, C> {
29569 self._scopes.clear();
29570 self
29571 }
29572}
29573
29574/// Creates a topic. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course, create a topic in the requested course, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `ALREADY_EXISTS` if there exists a topic in the course with the same name. * `FAILED_PRECONDITION` for the following request error: * CourseTopicLimitReached * `NOT_FOUND` if the requested course does not exist.
29575///
29576/// A builder for the *topics.create* method supported by a *course* resource.
29577/// It is not used directly, but through a [`CourseMethods`] instance.
29578///
29579/// # Example
29580///
29581/// Instantiate a resource method builder
29582///
29583/// ```test_harness,no_run
29584/// # extern crate hyper;
29585/// # extern crate hyper_rustls;
29586/// # extern crate google_classroom1 as classroom1;
29587/// use classroom1::api::Topic;
29588/// # async fn dox() {
29589/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29590///
29591/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29592/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29593/// # .with_native_roots()
29594/// # .unwrap()
29595/// # .https_only()
29596/// # .enable_http2()
29597/// # .build();
29598///
29599/// # let executor = hyper_util::rt::TokioExecutor::new();
29600/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29601/// # secret,
29602/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29603/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29604/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29605/// # ),
29606/// # ).build().await.unwrap();
29607///
29608/// # let client = hyper_util::client::legacy::Client::builder(
29609/// # hyper_util::rt::TokioExecutor::new()
29610/// # )
29611/// # .build(
29612/// # hyper_rustls::HttpsConnectorBuilder::new()
29613/// # .with_native_roots()
29614/// # .unwrap()
29615/// # .https_or_http()
29616/// # .enable_http2()
29617/// # .build()
29618/// # );
29619/// # let mut hub = Classroom::new(client, auth);
29620/// // As the method needs a request, you would usually fill it with the desired information
29621/// // into the respective structure. Some of the parts shown here might not be applicable !
29622/// // Values shown here are possibly random and not representative !
29623/// let mut req = Topic::default();
29624///
29625/// // You can configure optional parameters by calling the respective setters at will, and
29626/// // execute the final call using `doit()`.
29627/// // Values shown here are possibly random and not representative !
29628/// let result = hub.courses().topics_create(req, "courseId")
29629/// .doit().await;
29630/// # }
29631/// ```
29632pub struct CourseTopicCreateCall<'a, C>
29633where
29634 C: 'a,
29635{
29636 hub: &'a Classroom<C>,
29637 _request: Topic,
29638 _course_id: String,
29639 _delegate: Option<&'a mut dyn common::Delegate>,
29640 _additional_params: HashMap<String, String>,
29641 _scopes: BTreeSet<String>,
29642}
29643
29644impl<'a, C> common::CallBuilder for CourseTopicCreateCall<'a, C> {}
29645
29646impl<'a, C> CourseTopicCreateCall<'a, C>
29647where
29648 C: common::Connector,
29649{
29650 /// Perform the operation you have build so far.
29651 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
29652 use std::borrow::Cow;
29653 use std::io::{Read, Seek};
29654
29655 use common::{url::Params, ToParts};
29656 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29657
29658 let mut dd = common::DefaultDelegate;
29659 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29660 dlg.begin(common::MethodInfo {
29661 id: "classroom.courses.topics.create",
29662 http_method: hyper::Method::POST,
29663 });
29664
29665 for &field in ["alt", "courseId"].iter() {
29666 if self._additional_params.contains_key(field) {
29667 dlg.finished(false);
29668 return Err(common::Error::FieldClash(field));
29669 }
29670 }
29671
29672 let mut params = Params::with_capacity(4 + self._additional_params.len());
29673 params.push("courseId", self._course_id);
29674
29675 params.extend(self._additional_params.iter());
29676
29677 params.push("alt", "json");
29678 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/topics";
29679 if self._scopes.is_empty() {
29680 self._scopes.insert(Scope::Topic.as_ref().to_string());
29681 }
29682
29683 #[allow(clippy::single_element_loop)]
29684 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
29685 url = params.uri_replacement(url, param_name, find_this, false);
29686 }
29687 {
29688 let to_remove = ["courseId"];
29689 params.remove_params(&to_remove);
29690 }
29691
29692 let url = params.parse_with_url(&url);
29693
29694 let mut json_mime_type = mime::APPLICATION_JSON;
29695 let mut request_value_reader = {
29696 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29697 common::remove_json_null_values(&mut value);
29698 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29699 serde_json::to_writer(&mut dst, &value).unwrap();
29700 dst
29701 };
29702 let request_size = request_value_reader
29703 .seek(std::io::SeekFrom::End(0))
29704 .unwrap();
29705 request_value_reader
29706 .seek(std::io::SeekFrom::Start(0))
29707 .unwrap();
29708
29709 loop {
29710 let token = match self
29711 .hub
29712 .auth
29713 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29714 .await
29715 {
29716 Ok(token) => token,
29717 Err(e) => match dlg.token(e) {
29718 Ok(token) => token,
29719 Err(e) => {
29720 dlg.finished(false);
29721 return Err(common::Error::MissingToken(e));
29722 }
29723 },
29724 };
29725 request_value_reader
29726 .seek(std::io::SeekFrom::Start(0))
29727 .unwrap();
29728 let mut req_result = {
29729 let client = &self.hub.client;
29730 dlg.pre_request();
29731 let mut req_builder = hyper::Request::builder()
29732 .method(hyper::Method::POST)
29733 .uri(url.as_str())
29734 .header(USER_AGENT, self.hub._user_agent.clone());
29735
29736 if let Some(token) = token.as_ref() {
29737 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29738 }
29739
29740 let request = req_builder
29741 .header(CONTENT_TYPE, json_mime_type.to_string())
29742 .header(CONTENT_LENGTH, request_size as u64)
29743 .body(common::to_body(
29744 request_value_reader.get_ref().clone().into(),
29745 ));
29746
29747 client.request(request.unwrap()).await
29748 };
29749
29750 match req_result {
29751 Err(err) => {
29752 if let common::Retry::After(d) = dlg.http_error(&err) {
29753 sleep(d).await;
29754 continue;
29755 }
29756 dlg.finished(false);
29757 return Err(common::Error::HttpError(err));
29758 }
29759 Ok(res) => {
29760 let (mut parts, body) = res.into_parts();
29761 let mut body = common::Body::new(body);
29762 if !parts.status.is_success() {
29763 let bytes = common::to_bytes(body).await.unwrap_or_default();
29764 let error = serde_json::from_str(&common::to_string(&bytes));
29765 let response = common::to_response(parts, bytes.into());
29766
29767 if let common::Retry::After(d) =
29768 dlg.http_failure(&response, error.as_ref().ok())
29769 {
29770 sleep(d).await;
29771 continue;
29772 }
29773
29774 dlg.finished(false);
29775
29776 return Err(match error {
29777 Ok(value) => common::Error::BadRequest(value),
29778 _ => common::Error::Failure(response),
29779 });
29780 }
29781 let response = {
29782 let bytes = common::to_bytes(body).await.unwrap_or_default();
29783 let encoded = common::to_string(&bytes);
29784 match serde_json::from_str(&encoded) {
29785 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29786 Err(error) => {
29787 dlg.response_json_decode_error(&encoded, &error);
29788 return Err(common::Error::JsonDecodeError(
29789 encoded.to_string(),
29790 error,
29791 ));
29792 }
29793 }
29794 };
29795
29796 dlg.finished(true);
29797 return Ok(response);
29798 }
29799 }
29800 }
29801 }
29802
29803 ///
29804 /// Sets the *request* property to the given value.
29805 ///
29806 /// Even though the property as already been set when instantiating this call,
29807 /// we provide this method for API completeness.
29808 pub fn request(mut self, new_value: Topic) -> CourseTopicCreateCall<'a, C> {
29809 self._request = new_value;
29810 self
29811 }
29812 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
29813 ///
29814 /// Sets the *course id* path property to the given value.
29815 ///
29816 /// Even though the property as already been set when instantiating this call,
29817 /// we provide this method for API completeness.
29818 pub fn course_id(mut self, new_value: &str) -> CourseTopicCreateCall<'a, C> {
29819 self._course_id = new_value.to_string();
29820 self
29821 }
29822 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29823 /// while executing the actual API request.
29824 ///
29825 /// ````text
29826 /// It should be used to handle progress information, and to implement a certain level of resilience.
29827 /// ````
29828 ///
29829 /// Sets the *delegate* property to the given value.
29830 pub fn delegate(
29831 mut self,
29832 new_value: &'a mut dyn common::Delegate,
29833 ) -> CourseTopicCreateCall<'a, C> {
29834 self._delegate = Some(new_value);
29835 self
29836 }
29837
29838 /// Set any additional parameter of the query string used in the request.
29839 /// It should be used to set parameters which are not yet available through their own
29840 /// setters.
29841 ///
29842 /// Please note that this method must not be used to set any of the known parameters
29843 /// which have their own setter method. If done anyway, the request will fail.
29844 ///
29845 /// # Additional Parameters
29846 ///
29847 /// * *$.xgafv* (query-string) - V1 error format.
29848 /// * *access_token* (query-string) - OAuth access token.
29849 /// * *alt* (query-string) - Data format for response.
29850 /// * *callback* (query-string) - JSONP
29851 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29852 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
29853 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29854 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29855 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
29856 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29857 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29858 pub fn param<T>(mut self, name: T, value: T) -> CourseTopicCreateCall<'a, C>
29859 where
29860 T: AsRef<str>,
29861 {
29862 self._additional_params
29863 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29864 self
29865 }
29866
29867 /// Identifies the authorization scope for the method you are building.
29868 ///
29869 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29870 /// [`Scope::Topic`].
29871 ///
29872 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29873 /// tokens for more than one scope.
29874 ///
29875 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29876 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29877 /// sufficient, a read-write scope will do as well.
29878 pub fn add_scope<St>(mut self, scope: St) -> CourseTopicCreateCall<'a, C>
29879 where
29880 St: AsRef<str>,
29881 {
29882 self._scopes.insert(String::from(scope.as_ref()));
29883 self
29884 }
29885 /// Identifies the authorization scope(s) for the method you are building.
29886 ///
29887 /// See [`Self::add_scope()`] for details.
29888 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseTopicCreateCall<'a, C>
29889 where
29890 I: IntoIterator<Item = St>,
29891 St: AsRef<str>,
29892 {
29893 self._scopes
29894 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29895 self
29896 }
29897
29898 /// Removes all scopes, and no default scope will be used either.
29899 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29900 /// for details).
29901 pub fn clear_scopes(mut self) -> CourseTopicCreateCall<'a, C> {
29902 self._scopes.clear();
29903 self
29904 }
29905}
29906
29907/// Deletes a topic. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not allowed to delete the requested topic or for access errors. * `FAILED_PRECONDITION` if the requested topic has already been deleted. * `NOT_FOUND` if no course or topic exists with the requested ID.
29908///
29909/// A builder for the *topics.delete* method supported by a *course* resource.
29910/// It is not used directly, but through a [`CourseMethods`] instance.
29911///
29912/// # Example
29913///
29914/// Instantiate a resource method builder
29915///
29916/// ```test_harness,no_run
29917/// # extern crate hyper;
29918/// # extern crate hyper_rustls;
29919/// # extern crate google_classroom1 as classroom1;
29920/// # async fn dox() {
29921/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29922///
29923/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29924/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29925/// # .with_native_roots()
29926/// # .unwrap()
29927/// # .https_only()
29928/// # .enable_http2()
29929/// # .build();
29930///
29931/// # let executor = hyper_util::rt::TokioExecutor::new();
29932/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29933/// # secret,
29934/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29935/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29936/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29937/// # ),
29938/// # ).build().await.unwrap();
29939///
29940/// # let client = hyper_util::client::legacy::Client::builder(
29941/// # hyper_util::rt::TokioExecutor::new()
29942/// # )
29943/// # .build(
29944/// # hyper_rustls::HttpsConnectorBuilder::new()
29945/// # .with_native_roots()
29946/// # .unwrap()
29947/// # .https_or_http()
29948/// # .enable_http2()
29949/// # .build()
29950/// # );
29951/// # let mut hub = Classroom::new(client, auth);
29952/// // You can configure optional parameters by calling the respective setters at will, and
29953/// // execute the final call using `doit()`.
29954/// // Values shown here are possibly random and not representative !
29955/// let result = hub.courses().topics_delete("courseId", "id")
29956/// .doit().await;
29957/// # }
29958/// ```
29959pub struct CourseTopicDeleteCall<'a, C>
29960where
29961 C: 'a,
29962{
29963 hub: &'a Classroom<C>,
29964 _course_id: String,
29965 _id: String,
29966 _delegate: Option<&'a mut dyn common::Delegate>,
29967 _additional_params: HashMap<String, String>,
29968 _scopes: BTreeSet<String>,
29969}
29970
29971impl<'a, C> common::CallBuilder for CourseTopicDeleteCall<'a, C> {}
29972
29973impl<'a, C> CourseTopicDeleteCall<'a, C>
29974where
29975 C: common::Connector,
29976{
29977 /// Perform the operation you have build so far.
29978 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
29979 use std::borrow::Cow;
29980 use std::io::{Read, Seek};
29981
29982 use common::{url::Params, ToParts};
29983 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29984
29985 let mut dd = common::DefaultDelegate;
29986 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29987 dlg.begin(common::MethodInfo {
29988 id: "classroom.courses.topics.delete",
29989 http_method: hyper::Method::DELETE,
29990 });
29991
29992 for &field in ["alt", "courseId", "id"].iter() {
29993 if self._additional_params.contains_key(field) {
29994 dlg.finished(false);
29995 return Err(common::Error::FieldClash(field));
29996 }
29997 }
29998
29999 let mut params = Params::with_capacity(4 + self._additional_params.len());
30000 params.push("courseId", self._course_id);
30001 params.push("id", self._id);
30002
30003 params.extend(self._additional_params.iter());
30004
30005 params.push("alt", "json");
30006 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/topics/{id}";
30007 if self._scopes.is_empty() {
30008 self._scopes.insert(Scope::Topic.as_ref().to_string());
30009 }
30010
30011 #[allow(clippy::single_element_loop)]
30012 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
30013 url = params.uri_replacement(url, param_name, find_this, false);
30014 }
30015 {
30016 let to_remove = ["id", "courseId"];
30017 params.remove_params(&to_remove);
30018 }
30019
30020 let url = params.parse_with_url(&url);
30021
30022 loop {
30023 let token = match self
30024 .hub
30025 .auth
30026 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30027 .await
30028 {
30029 Ok(token) => token,
30030 Err(e) => match dlg.token(e) {
30031 Ok(token) => token,
30032 Err(e) => {
30033 dlg.finished(false);
30034 return Err(common::Error::MissingToken(e));
30035 }
30036 },
30037 };
30038 let mut req_result = {
30039 let client = &self.hub.client;
30040 dlg.pre_request();
30041 let mut req_builder = hyper::Request::builder()
30042 .method(hyper::Method::DELETE)
30043 .uri(url.as_str())
30044 .header(USER_AGENT, self.hub._user_agent.clone());
30045
30046 if let Some(token) = token.as_ref() {
30047 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30048 }
30049
30050 let request = req_builder
30051 .header(CONTENT_LENGTH, 0_u64)
30052 .body(common::to_body::<String>(None));
30053
30054 client.request(request.unwrap()).await
30055 };
30056
30057 match req_result {
30058 Err(err) => {
30059 if let common::Retry::After(d) = dlg.http_error(&err) {
30060 sleep(d).await;
30061 continue;
30062 }
30063 dlg.finished(false);
30064 return Err(common::Error::HttpError(err));
30065 }
30066 Ok(res) => {
30067 let (mut parts, body) = res.into_parts();
30068 let mut body = common::Body::new(body);
30069 if !parts.status.is_success() {
30070 let bytes = common::to_bytes(body).await.unwrap_or_default();
30071 let error = serde_json::from_str(&common::to_string(&bytes));
30072 let response = common::to_response(parts, bytes.into());
30073
30074 if let common::Retry::After(d) =
30075 dlg.http_failure(&response, error.as_ref().ok())
30076 {
30077 sleep(d).await;
30078 continue;
30079 }
30080
30081 dlg.finished(false);
30082
30083 return Err(match error {
30084 Ok(value) => common::Error::BadRequest(value),
30085 _ => common::Error::Failure(response),
30086 });
30087 }
30088 let response = {
30089 let bytes = common::to_bytes(body).await.unwrap_or_default();
30090 let encoded = common::to_string(&bytes);
30091 match serde_json::from_str(&encoded) {
30092 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30093 Err(error) => {
30094 dlg.response_json_decode_error(&encoded, &error);
30095 return Err(common::Error::JsonDecodeError(
30096 encoded.to_string(),
30097 error,
30098 ));
30099 }
30100 }
30101 };
30102
30103 dlg.finished(true);
30104 return Ok(response);
30105 }
30106 }
30107 }
30108 }
30109
30110 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
30111 ///
30112 /// Sets the *course id* path property to the given value.
30113 ///
30114 /// Even though the property as already been set when instantiating this call,
30115 /// we provide this method for API completeness.
30116 pub fn course_id(mut self, new_value: &str) -> CourseTopicDeleteCall<'a, C> {
30117 self._course_id = new_value.to_string();
30118 self
30119 }
30120 /// Identifier of the topic to delete.
30121 ///
30122 /// Sets the *id* path property to the given value.
30123 ///
30124 /// Even though the property as already been set when instantiating this call,
30125 /// we provide this method for API completeness.
30126 pub fn id(mut self, new_value: &str) -> CourseTopicDeleteCall<'a, C> {
30127 self._id = new_value.to_string();
30128 self
30129 }
30130 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30131 /// while executing the actual API request.
30132 ///
30133 /// ````text
30134 /// It should be used to handle progress information, and to implement a certain level of resilience.
30135 /// ````
30136 ///
30137 /// Sets the *delegate* property to the given value.
30138 pub fn delegate(
30139 mut self,
30140 new_value: &'a mut dyn common::Delegate,
30141 ) -> CourseTopicDeleteCall<'a, C> {
30142 self._delegate = Some(new_value);
30143 self
30144 }
30145
30146 /// Set any additional parameter of the query string used in the request.
30147 /// It should be used to set parameters which are not yet available through their own
30148 /// setters.
30149 ///
30150 /// Please note that this method must not be used to set any of the known parameters
30151 /// which have their own setter method. If done anyway, the request will fail.
30152 ///
30153 /// # Additional Parameters
30154 ///
30155 /// * *$.xgafv* (query-string) - V1 error format.
30156 /// * *access_token* (query-string) - OAuth access token.
30157 /// * *alt* (query-string) - Data format for response.
30158 /// * *callback* (query-string) - JSONP
30159 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30160 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
30161 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30162 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30163 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
30164 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30165 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30166 pub fn param<T>(mut self, name: T, value: T) -> CourseTopicDeleteCall<'a, C>
30167 where
30168 T: AsRef<str>,
30169 {
30170 self._additional_params
30171 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30172 self
30173 }
30174
30175 /// Identifies the authorization scope for the method you are building.
30176 ///
30177 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30178 /// [`Scope::Topic`].
30179 ///
30180 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30181 /// tokens for more than one scope.
30182 ///
30183 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30184 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30185 /// sufficient, a read-write scope will do as well.
30186 pub fn add_scope<St>(mut self, scope: St) -> CourseTopicDeleteCall<'a, C>
30187 where
30188 St: AsRef<str>,
30189 {
30190 self._scopes.insert(String::from(scope.as_ref()));
30191 self
30192 }
30193 /// Identifies the authorization scope(s) for the method you are building.
30194 ///
30195 /// See [`Self::add_scope()`] for details.
30196 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseTopicDeleteCall<'a, C>
30197 where
30198 I: IntoIterator<Item = St>,
30199 St: AsRef<str>,
30200 {
30201 self._scopes
30202 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30203 self
30204 }
30205
30206 /// Removes all scopes, and no default scope will be used either.
30207 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30208 /// for details).
30209 pub fn clear_scopes(mut self) -> CourseTopicDeleteCall<'a, C> {
30210 self._scopes.clear();
30211 self
30212 }
30213}
30214
30215/// Returns a topic. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or topic, or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course or topic does not exist.
30216///
30217/// A builder for the *topics.get* method supported by a *course* resource.
30218/// It is not used directly, but through a [`CourseMethods`] instance.
30219///
30220/// # Example
30221///
30222/// Instantiate a resource method builder
30223///
30224/// ```test_harness,no_run
30225/// # extern crate hyper;
30226/// # extern crate hyper_rustls;
30227/// # extern crate google_classroom1 as classroom1;
30228/// # async fn dox() {
30229/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30230///
30231/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30232/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30233/// # .with_native_roots()
30234/// # .unwrap()
30235/// # .https_only()
30236/// # .enable_http2()
30237/// # .build();
30238///
30239/// # let executor = hyper_util::rt::TokioExecutor::new();
30240/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30241/// # secret,
30242/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30243/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30244/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30245/// # ),
30246/// # ).build().await.unwrap();
30247///
30248/// # let client = hyper_util::client::legacy::Client::builder(
30249/// # hyper_util::rt::TokioExecutor::new()
30250/// # )
30251/// # .build(
30252/// # hyper_rustls::HttpsConnectorBuilder::new()
30253/// # .with_native_roots()
30254/// # .unwrap()
30255/// # .https_or_http()
30256/// # .enable_http2()
30257/// # .build()
30258/// # );
30259/// # let mut hub = Classroom::new(client, auth);
30260/// // You can configure optional parameters by calling the respective setters at will, and
30261/// // execute the final call using `doit()`.
30262/// // Values shown here are possibly random and not representative !
30263/// let result = hub.courses().topics_get("courseId", "id")
30264/// .doit().await;
30265/// # }
30266/// ```
30267pub struct CourseTopicGetCall<'a, C>
30268where
30269 C: 'a,
30270{
30271 hub: &'a Classroom<C>,
30272 _course_id: String,
30273 _id: String,
30274 _delegate: Option<&'a mut dyn common::Delegate>,
30275 _additional_params: HashMap<String, String>,
30276 _scopes: BTreeSet<String>,
30277}
30278
30279impl<'a, C> common::CallBuilder for CourseTopicGetCall<'a, C> {}
30280
30281impl<'a, C> CourseTopicGetCall<'a, C>
30282where
30283 C: common::Connector,
30284{
30285 /// Perform the operation you have build so far.
30286 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
30287 use std::borrow::Cow;
30288 use std::io::{Read, Seek};
30289
30290 use common::{url::Params, ToParts};
30291 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30292
30293 let mut dd = common::DefaultDelegate;
30294 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30295 dlg.begin(common::MethodInfo {
30296 id: "classroom.courses.topics.get",
30297 http_method: hyper::Method::GET,
30298 });
30299
30300 for &field in ["alt", "courseId", "id"].iter() {
30301 if self._additional_params.contains_key(field) {
30302 dlg.finished(false);
30303 return Err(common::Error::FieldClash(field));
30304 }
30305 }
30306
30307 let mut params = Params::with_capacity(4 + self._additional_params.len());
30308 params.push("courseId", self._course_id);
30309 params.push("id", self._id);
30310
30311 params.extend(self._additional_params.iter());
30312
30313 params.push("alt", "json");
30314 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/topics/{id}";
30315 if self._scopes.is_empty() {
30316 self._scopes
30317 .insert(Scope::TopicReadonly.as_ref().to_string());
30318 }
30319
30320 #[allow(clippy::single_element_loop)]
30321 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
30322 url = params.uri_replacement(url, param_name, find_this, false);
30323 }
30324 {
30325 let to_remove = ["id", "courseId"];
30326 params.remove_params(&to_remove);
30327 }
30328
30329 let url = params.parse_with_url(&url);
30330
30331 loop {
30332 let token = match self
30333 .hub
30334 .auth
30335 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30336 .await
30337 {
30338 Ok(token) => token,
30339 Err(e) => match dlg.token(e) {
30340 Ok(token) => token,
30341 Err(e) => {
30342 dlg.finished(false);
30343 return Err(common::Error::MissingToken(e));
30344 }
30345 },
30346 };
30347 let mut req_result = {
30348 let client = &self.hub.client;
30349 dlg.pre_request();
30350 let mut req_builder = hyper::Request::builder()
30351 .method(hyper::Method::GET)
30352 .uri(url.as_str())
30353 .header(USER_AGENT, self.hub._user_agent.clone());
30354
30355 if let Some(token) = token.as_ref() {
30356 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30357 }
30358
30359 let request = req_builder
30360 .header(CONTENT_LENGTH, 0_u64)
30361 .body(common::to_body::<String>(None));
30362
30363 client.request(request.unwrap()).await
30364 };
30365
30366 match req_result {
30367 Err(err) => {
30368 if let common::Retry::After(d) = dlg.http_error(&err) {
30369 sleep(d).await;
30370 continue;
30371 }
30372 dlg.finished(false);
30373 return Err(common::Error::HttpError(err));
30374 }
30375 Ok(res) => {
30376 let (mut parts, body) = res.into_parts();
30377 let mut body = common::Body::new(body);
30378 if !parts.status.is_success() {
30379 let bytes = common::to_bytes(body).await.unwrap_or_default();
30380 let error = serde_json::from_str(&common::to_string(&bytes));
30381 let response = common::to_response(parts, bytes.into());
30382
30383 if let common::Retry::After(d) =
30384 dlg.http_failure(&response, error.as_ref().ok())
30385 {
30386 sleep(d).await;
30387 continue;
30388 }
30389
30390 dlg.finished(false);
30391
30392 return Err(match error {
30393 Ok(value) => common::Error::BadRequest(value),
30394 _ => common::Error::Failure(response),
30395 });
30396 }
30397 let response = {
30398 let bytes = common::to_bytes(body).await.unwrap_or_default();
30399 let encoded = common::to_string(&bytes);
30400 match serde_json::from_str(&encoded) {
30401 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30402 Err(error) => {
30403 dlg.response_json_decode_error(&encoded, &error);
30404 return Err(common::Error::JsonDecodeError(
30405 encoded.to_string(),
30406 error,
30407 ));
30408 }
30409 }
30410 };
30411
30412 dlg.finished(true);
30413 return Ok(response);
30414 }
30415 }
30416 }
30417 }
30418
30419 /// Identifier of the course.
30420 ///
30421 /// Sets the *course id* path property to the given value.
30422 ///
30423 /// Even though the property as already been set when instantiating this call,
30424 /// we provide this method for API completeness.
30425 pub fn course_id(mut self, new_value: &str) -> CourseTopicGetCall<'a, C> {
30426 self._course_id = new_value.to_string();
30427 self
30428 }
30429 /// Identifier of the topic.
30430 ///
30431 /// Sets the *id* path property to the given value.
30432 ///
30433 /// Even though the property as already been set when instantiating this call,
30434 /// we provide this method for API completeness.
30435 pub fn id(mut self, new_value: &str) -> CourseTopicGetCall<'a, C> {
30436 self._id = new_value.to_string();
30437 self
30438 }
30439 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30440 /// while executing the actual API request.
30441 ///
30442 /// ````text
30443 /// It should be used to handle progress information, and to implement a certain level of resilience.
30444 /// ````
30445 ///
30446 /// Sets the *delegate* property to the given value.
30447 pub fn delegate(
30448 mut self,
30449 new_value: &'a mut dyn common::Delegate,
30450 ) -> CourseTopicGetCall<'a, C> {
30451 self._delegate = Some(new_value);
30452 self
30453 }
30454
30455 /// Set any additional parameter of the query string used in the request.
30456 /// It should be used to set parameters which are not yet available through their own
30457 /// setters.
30458 ///
30459 /// Please note that this method must not be used to set any of the known parameters
30460 /// which have their own setter method. If done anyway, the request will fail.
30461 ///
30462 /// # Additional Parameters
30463 ///
30464 /// * *$.xgafv* (query-string) - V1 error format.
30465 /// * *access_token* (query-string) - OAuth access token.
30466 /// * *alt* (query-string) - Data format for response.
30467 /// * *callback* (query-string) - JSONP
30468 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30469 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
30470 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30471 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30472 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
30473 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30474 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30475 pub fn param<T>(mut self, name: T, value: T) -> CourseTopicGetCall<'a, C>
30476 where
30477 T: AsRef<str>,
30478 {
30479 self._additional_params
30480 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30481 self
30482 }
30483
30484 /// Identifies the authorization scope for the method you are building.
30485 ///
30486 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30487 /// [`Scope::TopicReadonly`].
30488 ///
30489 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30490 /// tokens for more than one scope.
30491 ///
30492 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30493 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30494 /// sufficient, a read-write scope will do as well.
30495 pub fn add_scope<St>(mut self, scope: St) -> CourseTopicGetCall<'a, C>
30496 where
30497 St: AsRef<str>,
30498 {
30499 self._scopes.insert(String::from(scope.as_ref()));
30500 self
30501 }
30502 /// Identifies the authorization scope(s) for the method you are building.
30503 ///
30504 /// See [`Self::add_scope()`] for details.
30505 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseTopicGetCall<'a, C>
30506 where
30507 I: IntoIterator<Item = St>,
30508 St: AsRef<str>,
30509 {
30510 self._scopes
30511 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30512 self
30513 }
30514
30515 /// Removes all scopes, and no default scope will be used either.
30516 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30517 /// for details).
30518 pub fn clear_scopes(mut self) -> CourseTopicGetCall<'a, C> {
30519 self._scopes.clear();
30520 self
30521 }
30522}
30523
30524/// Returns the list of topics that the requester is permitted to view. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
30525///
30526/// A builder for the *topics.list* method supported by a *course* resource.
30527/// It is not used directly, but through a [`CourseMethods`] instance.
30528///
30529/// # Example
30530///
30531/// Instantiate a resource method builder
30532///
30533/// ```test_harness,no_run
30534/// # extern crate hyper;
30535/// # extern crate hyper_rustls;
30536/// # extern crate google_classroom1 as classroom1;
30537/// # async fn dox() {
30538/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30539///
30540/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30541/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30542/// # .with_native_roots()
30543/// # .unwrap()
30544/// # .https_only()
30545/// # .enable_http2()
30546/// # .build();
30547///
30548/// # let executor = hyper_util::rt::TokioExecutor::new();
30549/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30550/// # secret,
30551/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30552/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30553/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30554/// # ),
30555/// # ).build().await.unwrap();
30556///
30557/// # let client = hyper_util::client::legacy::Client::builder(
30558/// # hyper_util::rt::TokioExecutor::new()
30559/// # )
30560/// # .build(
30561/// # hyper_rustls::HttpsConnectorBuilder::new()
30562/// # .with_native_roots()
30563/// # .unwrap()
30564/// # .https_or_http()
30565/// # .enable_http2()
30566/// # .build()
30567/// # );
30568/// # let mut hub = Classroom::new(client, auth);
30569/// // You can configure optional parameters by calling the respective setters at will, and
30570/// // execute the final call using `doit()`.
30571/// // Values shown here are possibly random and not representative !
30572/// let result = hub.courses().topics_list("courseId")
30573/// .page_token("invidunt")
30574/// .page_size(-64)
30575/// .doit().await;
30576/// # }
30577/// ```
30578pub struct CourseTopicListCall<'a, C>
30579where
30580 C: 'a,
30581{
30582 hub: &'a Classroom<C>,
30583 _course_id: String,
30584 _page_token: Option<String>,
30585 _page_size: Option<i32>,
30586 _delegate: Option<&'a mut dyn common::Delegate>,
30587 _additional_params: HashMap<String, String>,
30588 _scopes: BTreeSet<String>,
30589}
30590
30591impl<'a, C> common::CallBuilder for CourseTopicListCall<'a, C> {}
30592
30593impl<'a, C> CourseTopicListCall<'a, C>
30594where
30595 C: common::Connector,
30596{
30597 /// Perform the operation you have build so far.
30598 pub async fn doit(mut self) -> common::Result<(common::Response, ListTopicResponse)> {
30599 use std::borrow::Cow;
30600 use std::io::{Read, Seek};
30601
30602 use common::{url::Params, ToParts};
30603 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30604
30605 let mut dd = common::DefaultDelegate;
30606 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30607 dlg.begin(common::MethodInfo {
30608 id: "classroom.courses.topics.list",
30609 http_method: hyper::Method::GET,
30610 });
30611
30612 for &field in ["alt", "courseId", "pageToken", "pageSize"].iter() {
30613 if self._additional_params.contains_key(field) {
30614 dlg.finished(false);
30615 return Err(common::Error::FieldClash(field));
30616 }
30617 }
30618
30619 let mut params = Params::with_capacity(5 + self._additional_params.len());
30620 params.push("courseId", self._course_id);
30621 if let Some(value) = self._page_token.as_ref() {
30622 params.push("pageToken", value);
30623 }
30624 if let Some(value) = self._page_size.as_ref() {
30625 params.push("pageSize", value.to_string());
30626 }
30627
30628 params.extend(self._additional_params.iter());
30629
30630 params.push("alt", "json");
30631 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/topics";
30632 if self._scopes.is_empty() {
30633 self._scopes
30634 .insert(Scope::TopicReadonly.as_ref().to_string());
30635 }
30636
30637 #[allow(clippy::single_element_loop)]
30638 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
30639 url = params.uri_replacement(url, param_name, find_this, false);
30640 }
30641 {
30642 let to_remove = ["courseId"];
30643 params.remove_params(&to_remove);
30644 }
30645
30646 let url = params.parse_with_url(&url);
30647
30648 loop {
30649 let token = match self
30650 .hub
30651 .auth
30652 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30653 .await
30654 {
30655 Ok(token) => token,
30656 Err(e) => match dlg.token(e) {
30657 Ok(token) => token,
30658 Err(e) => {
30659 dlg.finished(false);
30660 return Err(common::Error::MissingToken(e));
30661 }
30662 },
30663 };
30664 let mut req_result = {
30665 let client = &self.hub.client;
30666 dlg.pre_request();
30667 let mut req_builder = hyper::Request::builder()
30668 .method(hyper::Method::GET)
30669 .uri(url.as_str())
30670 .header(USER_AGENT, self.hub._user_agent.clone());
30671
30672 if let Some(token) = token.as_ref() {
30673 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30674 }
30675
30676 let request = req_builder
30677 .header(CONTENT_LENGTH, 0_u64)
30678 .body(common::to_body::<String>(None));
30679
30680 client.request(request.unwrap()).await
30681 };
30682
30683 match req_result {
30684 Err(err) => {
30685 if let common::Retry::After(d) = dlg.http_error(&err) {
30686 sleep(d).await;
30687 continue;
30688 }
30689 dlg.finished(false);
30690 return Err(common::Error::HttpError(err));
30691 }
30692 Ok(res) => {
30693 let (mut parts, body) = res.into_parts();
30694 let mut body = common::Body::new(body);
30695 if !parts.status.is_success() {
30696 let bytes = common::to_bytes(body).await.unwrap_or_default();
30697 let error = serde_json::from_str(&common::to_string(&bytes));
30698 let response = common::to_response(parts, bytes.into());
30699
30700 if let common::Retry::After(d) =
30701 dlg.http_failure(&response, error.as_ref().ok())
30702 {
30703 sleep(d).await;
30704 continue;
30705 }
30706
30707 dlg.finished(false);
30708
30709 return Err(match error {
30710 Ok(value) => common::Error::BadRequest(value),
30711 _ => common::Error::Failure(response),
30712 });
30713 }
30714 let response = {
30715 let bytes = common::to_bytes(body).await.unwrap_or_default();
30716 let encoded = common::to_string(&bytes);
30717 match serde_json::from_str(&encoded) {
30718 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30719 Err(error) => {
30720 dlg.response_json_decode_error(&encoded, &error);
30721 return Err(common::Error::JsonDecodeError(
30722 encoded.to_string(),
30723 error,
30724 ));
30725 }
30726 }
30727 };
30728
30729 dlg.finished(true);
30730 return Ok(response);
30731 }
30732 }
30733 }
30734 }
30735
30736 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
30737 ///
30738 /// Sets the *course id* path property to the given value.
30739 ///
30740 /// Even though the property as already been set when instantiating this call,
30741 /// we provide this method for API completeness.
30742 pub fn course_id(mut self, new_value: &str) -> CourseTopicListCall<'a, C> {
30743 self._course_id = new_value.to_string();
30744 self
30745 }
30746 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
30747 ///
30748 /// Sets the *page token* query property to the given value.
30749 pub fn page_token(mut self, new_value: &str) -> CourseTopicListCall<'a, C> {
30750 self._page_token = Some(new_value.to_string());
30751 self
30752 }
30753 /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.
30754 ///
30755 /// Sets the *page size* query property to the given value.
30756 pub fn page_size(mut self, new_value: i32) -> CourseTopicListCall<'a, C> {
30757 self._page_size = Some(new_value);
30758 self
30759 }
30760 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30761 /// while executing the actual API request.
30762 ///
30763 /// ````text
30764 /// It should be used to handle progress information, and to implement a certain level of resilience.
30765 /// ````
30766 ///
30767 /// Sets the *delegate* property to the given value.
30768 pub fn delegate(
30769 mut self,
30770 new_value: &'a mut dyn common::Delegate,
30771 ) -> CourseTopicListCall<'a, C> {
30772 self._delegate = Some(new_value);
30773 self
30774 }
30775
30776 /// Set any additional parameter of the query string used in the request.
30777 /// It should be used to set parameters which are not yet available through their own
30778 /// setters.
30779 ///
30780 /// Please note that this method must not be used to set any of the known parameters
30781 /// which have their own setter method. If done anyway, the request will fail.
30782 ///
30783 /// # Additional Parameters
30784 ///
30785 /// * *$.xgafv* (query-string) - V1 error format.
30786 /// * *access_token* (query-string) - OAuth access token.
30787 /// * *alt* (query-string) - Data format for response.
30788 /// * *callback* (query-string) - JSONP
30789 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30790 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
30791 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30792 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30793 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
30794 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30795 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30796 pub fn param<T>(mut self, name: T, value: T) -> CourseTopicListCall<'a, C>
30797 where
30798 T: AsRef<str>,
30799 {
30800 self._additional_params
30801 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30802 self
30803 }
30804
30805 /// Identifies the authorization scope for the method you are building.
30806 ///
30807 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30808 /// [`Scope::TopicReadonly`].
30809 ///
30810 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30811 /// tokens for more than one scope.
30812 ///
30813 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30814 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30815 /// sufficient, a read-write scope will do as well.
30816 pub fn add_scope<St>(mut self, scope: St) -> CourseTopicListCall<'a, C>
30817 where
30818 St: AsRef<str>,
30819 {
30820 self._scopes.insert(String::from(scope.as_ref()));
30821 self
30822 }
30823 /// Identifies the authorization scope(s) for the method you are building.
30824 ///
30825 /// See [`Self::add_scope()`] for details.
30826 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseTopicListCall<'a, C>
30827 where
30828 I: IntoIterator<Item = St>,
30829 St: AsRef<str>,
30830 {
30831 self._scopes
30832 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30833 self
30834 }
30835
30836 /// Removes all scopes, and no default scope will be used either.
30837 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30838 /// for details).
30839 pub fn clear_scopes(mut self) -> CourseTopicListCall<'a, C> {
30840 self._scopes.clear();
30841 self
30842 }
30843}
30844
30845/// Updates one or more fields of a topic. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting developer project did not create the corresponding topic or for access errors. * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if there exists a topic in the course with the same name. * `NOT_FOUND` if the requested course or topic does not exist
30846///
30847/// A builder for the *topics.patch* method supported by a *course* resource.
30848/// It is not used directly, but through a [`CourseMethods`] instance.
30849///
30850/// # Example
30851///
30852/// Instantiate a resource method builder
30853///
30854/// ```test_harness,no_run
30855/// # extern crate hyper;
30856/// # extern crate hyper_rustls;
30857/// # extern crate google_classroom1 as classroom1;
30858/// use classroom1::api::Topic;
30859/// # async fn dox() {
30860/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30861///
30862/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30863/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30864/// # .with_native_roots()
30865/// # .unwrap()
30866/// # .https_only()
30867/// # .enable_http2()
30868/// # .build();
30869///
30870/// # let executor = hyper_util::rt::TokioExecutor::new();
30871/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30872/// # secret,
30873/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30874/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30875/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30876/// # ),
30877/// # ).build().await.unwrap();
30878///
30879/// # let client = hyper_util::client::legacy::Client::builder(
30880/// # hyper_util::rt::TokioExecutor::new()
30881/// # )
30882/// # .build(
30883/// # hyper_rustls::HttpsConnectorBuilder::new()
30884/// # .with_native_roots()
30885/// # .unwrap()
30886/// # .https_or_http()
30887/// # .enable_http2()
30888/// # .build()
30889/// # );
30890/// # let mut hub = Classroom::new(client, auth);
30891/// // As the method needs a request, you would usually fill it with the desired information
30892/// // into the respective structure. Some of the parts shown here might not be applicable !
30893/// // Values shown here are possibly random and not representative !
30894/// let mut req = Topic::default();
30895///
30896/// // You can configure optional parameters by calling the respective setters at will, and
30897/// // execute the final call using `doit()`.
30898/// // Values shown here are possibly random and not representative !
30899/// let result = hub.courses().topics_patch(req, "courseId", "id")
30900/// .update_mask(FieldMask::new::<&str>(&[]))
30901/// .doit().await;
30902/// # }
30903/// ```
30904pub struct CourseTopicPatchCall<'a, C>
30905where
30906 C: 'a,
30907{
30908 hub: &'a Classroom<C>,
30909 _request: Topic,
30910 _course_id: String,
30911 _id: String,
30912 _update_mask: Option<common::FieldMask>,
30913 _delegate: Option<&'a mut dyn common::Delegate>,
30914 _additional_params: HashMap<String, String>,
30915 _scopes: BTreeSet<String>,
30916}
30917
30918impl<'a, C> common::CallBuilder for CourseTopicPatchCall<'a, C> {}
30919
30920impl<'a, C> CourseTopicPatchCall<'a, C>
30921where
30922 C: common::Connector,
30923{
30924 /// Perform the operation you have build so far.
30925 pub async fn doit(mut self) -> common::Result<(common::Response, Topic)> {
30926 use std::borrow::Cow;
30927 use std::io::{Read, Seek};
30928
30929 use common::{url::Params, ToParts};
30930 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30931
30932 let mut dd = common::DefaultDelegate;
30933 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30934 dlg.begin(common::MethodInfo {
30935 id: "classroom.courses.topics.patch",
30936 http_method: hyper::Method::PATCH,
30937 });
30938
30939 for &field in ["alt", "courseId", "id", "updateMask"].iter() {
30940 if self._additional_params.contains_key(field) {
30941 dlg.finished(false);
30942 return Err(common::Error::FieldClash(field));
30943 }
30944 }
30945
30946 let mut params = Params::with_capacity(6 + self._additional_params.len());
30947 params.push("courseId", self._course_id);
30948 params.push("id", self._id);
30949 if let Some(value) = self._update_mask.as_ref() {
30950 params.push("updateMask", value.to_string());
30951 }
30952
30953 params.extend(self._additional_params.iter());
30954
30955 params.push("alt", "json");
30956 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/topics/{id}";
30957 if self._scopes.is_empty() {
30958 self._scopes.insert(Scope::Topic.as_ref().to_string());
30959 }
30960
30961 #[allow(clippy::single_element_loop)]
30962 for &(find_this, param_name) in [("{courseId}", "courseId"), ("{id}", "id")].iter() {
30963 url = params.uri_replacement(url, param_name, find_this, false);
30964 }
30965 {
30966 let to_remove = ["id", "courseId"];
30967 params.remove_params(&to_remove);
30968 }
30969
30970 let url = params.parse_with_url(&url);
30971
30972 let mut json_mime_type = mime::APPLICATION_JSON;
30973 let mut request_value_reader = {
30974 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30975 common::remove_json_null_values(&mut value);
30976 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30977 serde_json::to_writer(&mut dst, &value).unwrap();
30978 dst
30979 };
30980 let request_size = request_value_reader
30981 .seek(std::io::SeekFrom::End(0))
30982 .unwrap();
30983 request_value_reader
30984 .seek(std::io::SeekFrom::Start(0))
30985 .unwrap();
30986
30987 loop {
30988 let token = match self
30989 .hub
30990 .auth
30991 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30992 .await
30993 {
30994 Ok(token) => token,
30995 Err(e) => match dlg.token(e) {
30996 Ok(token) => token,
30997 Err(e) => {
30998 dlg.finished(false);
30999 return Err(common::Error::MissingToken(e));
31000 }
31001 },
31002 };
31003 request_value_reader
31004 .seek(std::io::SeekFrom::Start(0))
31005 .unwrap();
31006 let mut req_result = {
31007 let client = &self.hub.client;
31008 dlg.pre_request();
31009 let mut req_builder = hyper::Request::builder()
31010 .method(hyper::Method::PATCH)
31011 .uri(url.as_str())
31012 .header(USER_AGENT, self.hub._user_agent.clone());
31013
31014 if let Some(token) = token.as_ref() {
31015 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31016 }
31017
31018 let request = req_builder
31019 .header(CONTENT_TYPE, json_mime_type.to_string())
31020 .header(CONTENT_LENGTH, request_size as u64)
31021 .body(common::to_body(
31022 request_value_reader.get_ref().clone().into(),
31023 ));
31024
31025 client.request(request.unwrap()).await
31026 };
31027
31028 match req_result {
31029 Err(err) => {
31030 if let common::Retry::After(d) = dlg.http_error(&err) {
31031 sleep(d).await;
31032 continue;
31033 }
31034 dlg.finished(false);
31035 return Err(common::Error::HttpError(err));
31036 }
31037 Ok(res) => {
31038 let (mut parts, body) = res.into_parts();
31039 let mut body = common::Body::new(body);
31040 if !parts.status.is_success() {
31041 let bytes = common::to_bytes(body).await.unwrap_or_default();
31042 let error = serde_json::from_str(&common::to_string(&bytes));
31043 let response = common::to_response(parts, bytes.into());
31044
31045 if let common::Retry::After(d) =
31046 dlg.http_failure(&response, error.as_ref().ok())
31047 {
31048 sleep(d).await;
31049 continue;
31050 }
31051
31052 dlg.finished(false);
31053
31054 return Err(match error {
31055 Ok(value) => common::Error::BadRequest(value),
31056 _ => common::Error::Failure(response),
31057 });
31058 }
31059 let response = {
31060 let bytes = common::to_bytes(body).await.unwrap_or_default();
31061 let encoded = common::to_string(&bytes);
31062 match serde_json::from_str(&encoded) {
31063 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31064 Err(error) => {
31065 dlg.response_json_decode_error(&encoded, &error);
31066 return Err(common::Error::JsonDecodeError(
31067 encoded.to_string(),
31068 error,
31069 ));
31070 }
31071 }
31072 };
31073
31074 dlg.finished(true);
31075 return Ok(response);
31076 }
31077 }
31078 }
31079 }
31080
31081 ///
31082 /// Sets the *request* property to the given value.
31083 ///
31084 /// Even though the property as already been set when instantiating this call,
31085 /// we provide this method for API completeness.
31086 pub fn request(mut self, new_value: Topic) -> CourseTopicPatchCall<'a, C> {
31087 self._request = new_value;
31088 self
31089 }
31090 /// Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.
31091 ///
31092 /// Sets the *course id* path property to the given value.
31093 ///
31094 /// Even though the property as already been set when instantiating this call,
31095 /// we provide this method for API completeness.
31096 pub fn course_id(mut self, new_value: &str) -> CourseTopicPatchCall<'a, C> {
31097 self._course_id = new_value.to_string();
31098 self
31099 }
31100 /// Identifier of the topic.
31101 ///
31102 /// Sets the *id* path property to the given value.
31103 ///
31104 /// Even though the property as already been set when instantiating this call,
31105 /// we provide this method for API completeness.
31106 pub fn id(mut self, new_value: &str) -> CourseTopicPatchCall<'a, C> {
31107 self._id = new_value.to_string();
31108 self
31109 }
31110 /// Mask that identifies which fields on the topic to update. This field is required to do an update. The update fails if invalid fields are specified. If a field supports empty values, it can be cleared by specifying it in the update mask and not in the Topic object. If a field that does not support empty values is included in the update mask and not set in the Topic object, an `INVALID_ARGUMENT` error is returned. The following fields may be specified: * `name`
31111 ///
31112 /// Sets the *update mask* query property to the given value.
31113 pub fn update_mask(mut self, new_value: common::FieldMask) -> CourseTopicPatchCall<'a, C> {
31114 self._update_mask = Some(new_value);
31115 self
31116 }
31117 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31118 /// while executing the actual API request.
31119 ///
31120 /// ````text
31121 /// It should be used to handle progress information, and to implement a certain level of resilience.
31122 /// ````
31123 ///
31124 /// Sets the *delegate* property to the given value.
31125 pub fn delegate(
31126 mut self,
31127 new_value: &'a mut dyn common::Delegate,
31128 ) -> CourseTopicPatchCall<'a, C> {
31129 self._delegate = Some(new_value);
31130 self
31131 }
31132
31133 /// Set any additional parameter of the query string used in the request.
31134 /// It should be used to set parameters which are not yet available through their own
31135 /// setters.
31136 ///
31137 /// Please note that this method must not be used to set any of the known parameters
31138 /// which have their own setter method. If done anyway, the request will fail.
31139 ///
31140 /// # Additional Parameters
31141 ///
31142 /// * *$.xgafv* (query-string) - V1 error format.
31143 /// * *access_token* (query-string) - OAuth access token.
31144 /// * *alt* (query-string) - Data format for response.
31145 /// * *callback* (query-string) - JSONP
31146 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31147 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
31148 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31149 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31150 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
31151 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31152 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31153 pub fn param<T>(mut self, name: T, value: T) -> CourseTopicPatchCall<'a, C>
31154 where
31155 T: AsRef<str>,
31156 {
31157 self._additional_params
31158 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31159 self
31160 }
31161
31162 /// Identifies the authorization scope for the method you are building.
31163 ///
31164 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31165 /// [`Scope::Topic`].
31166 ///
31167 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31168 /// tokens for more than one scope.
31169 ///
31170 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31171 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31172 /// sufficient, a read-write scope will do as well.
31173 pub fn add_scope<St>(mut self, scope: St) -> CourseTopicPatchCall<'a, C>
31174 where
31175 St: AsRef<str>,
31176 {
31177 self._scopes.insert(String::from(scope.as_ref()));
31178 self
31179 }
31180 /// Identifies the authorization scope(s) for the method you are building.
31181 ///
31182 /// See [`Self::add_scope()`] for details.
31183 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseTopicPatchCall<'a, C>
31184 where
31185 I: IntoIterator<Item = St>,
31186 St: AsRef<str>,
31187 {
31188 self._scopes
31189 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31190 self
31191 }
31192
31193 /// Removes all scopes, and no default scope will be used either.
31194 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31195 /// for details).
31196 pub fn clear_scopes(mut self) -> CourseTopicPatchCall<'a, C> {
31197 self._scopes.clear();
31198 self
31199 }
31200}
31201
31202/// Creates a course. The user specified in `ownerId` is the owner of the created course and added as a teacher. A non-admin requesting user can only create a course with themselves as the owner. Domain admins can create courses owned by any user within their domain. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create courses or for access errors. * `NOT_FOUND` if the primary teacher is not a valid user. * `FAILED_PRECONDITION` if the course owner's account is disabled or for the following request errors: * UserCannotOwnCourse * UserGroupsMembershipLimitReached * CourseTitleCannotContainUrl * `ALREADY_EXISTS` if an alias was specified in the `id` and already exists.
31203///
31204/// A builder for the *create* method supported by a *course* resource.
31205/// It is not used directly, but through a [`CourseMethods`] instance.
31206///
31207/// # Example
31208///
31209/// Instantiate a resource method builder
31210///
31211/// ```test_harness,no_run
31212/// # extern crate hyper;
31213/// # extern crate hyper_rustls;
31214/// # extern crate google_classroom1 as classroom1;
31215/// use classroom1::api::Course;
31216/// # async fn dox() {
31217/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31218///
31219/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31220/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31221/// # .with_native_roots()
31222/// # .unwrap()
31223/// # .https_only()
31224/// # .enable_http2()
31225/// # .build();
31226///
31227/// # let executor = hyper_util::rt::TokioExecutor::new();
31228/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31229/// # secret,
31230/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31231/// # yup_oauth2::client::CustomHyperClientBuilder::from(
31232/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
31233/// # ),
31234/// # ).build().await.unwrap();
31235///
31236/// # let client = hyper_util::client::legacy::Client::builder(
31237/// # hyper_util::rt::TokioExecutor::new()
31238/// # )
31239/// # .build(
31240/// # hyper_rustls::HttpsConnectorBuilder::new()
31241/// # .with_native_roots()
31242/// # .unwrap()
31243/// # .https_or_http()
31244/// # .enable_http2()
31245/// # .build()
31246/// # );
31247/// # let mut hub = Classroom::new(client, auth);
31248/// // As the method needs a request, you would usually fill it with the desired information
31249/// // into the respective structure. Some of the parts shown here might not be applicable !
31250/// // Values shown here are possibly random and not representative !
31251/// let mut req = Course::default();
31252///
31253/// // You can configure optional parameters by calling the respective setters at will, and
31254/// // execute the final call using `doit()`.
31255/// // Values shown here are possibly random and not representative !
31256/// let result = hub.courses().create(req)
31257/// .doit().await;
31258/// # }
31259/// ```
31260pub struct CourseCreateCall<'a, C>
31261where
31262 C: 'a,
31263{
31264 hub: &'a Classroom<C>,
31265 _request: Course,
31266 _delegate: Option<&'a mut dyn common::Delegate>,
31267 _additional_params: HashMap<String, String>,
31268 _scopes: BTreeSet<String>,
31269}
31270
31271impl<'a, C> common::CallBuilder for CourseCreateCall<'a, C> {}
31272
31273impl<'a, C> CourseCreateCall<'a, C>
31274where
31275 C: common::Connector,
31276{
31277 /// Perform the operation you have build so far.
31278 pub async fn doit(mut self) -> common::Result<(common::Response, Course)> {
31279 use std::borrow::Cow;
31280 use std::io::{Read, Seek};
31281
31282 use common::{url::Params, ToParts};
31283 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31284
31285 let mut dd = common::DefaultDelegate;
31286 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31287 dlg.begin(common::MethodInfo {
31288 id: "classroom.courses.create",
31289 http_method: hyper::Method::POST,
31290 });
31291
31292 for &field in ["alt"].iter() {
31293 if self._additional_params.contains_key(field) {
31294 dlg.finished(false);
31295 return Err(common::Error::FieldClash(field));
31296 }
31297 }
31298
31299 let mut params = Params::with_capacity(3 + self._additional_params.len());
31300
31301 params.extend(self._additional_params.iter());
31302
31303 params.push("alt", "json");
31304 let mut url = self.hub._base_url.clone() + "v1/courses";
31305 if self._scopes.is_empty() {
31306 self._scopes.insert(Scope::Course.as_ref().to_string());
31307 }
31308
31309 let url = params.parse_with_url(&url);
31310
31311 let mut json_mime_type = mime::APPLICATION_JSON;
31312 let mut request_value_reader = {
31313 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31314 common::remove_json_null_values(&mut value);
31315 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31316 serde_json::to_writer(&mut dst, &value).unwrap();
31317 dst
31318 };
31319 let request_size = request_value_reader
31320 .seek(std::io::SeekFrom::End(0))
31321 .unwrap();
31322 request_value_reader
31323 .seek(std::io::SeekFrom::Start(0))
31324 .unwrap();
31325
31326 loop {
31327 let token = match self
31328 .hub
31329 .auth
31330 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31331 .await
31332 {
31333 Ok(token) => token,
31334 Err(e) => match dlg.token(e) {
31335 Ok(token) => token,
31336 Err(e) => {
31337 dlg.finished(false);
31338 return Err(common::Error::MissingToken(e));
31339 }
31340 },
31341 };
31342 request_value_reader
31343 .seek(std::io::SeekFrom::Start(0))
31344 .unwrap();
31345 let mut req_result = {
31346 let client = &self.hub.client;
31347 dlg.pre_request();
31348 let mut req_builder = hyper::Request::builder()
31349 .method(hyper::Method::POST)
31350 .uri(url.as_str())
31351 .header(USER_AGENT, self.hub._user_agent.clone());
31352
31353 if let Some(token) = token.as_ref() {
31354 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31355 }
31356
31357 let request = req_builder
31358 .header(CONTENT_TYPE, json_mime_type.to_string())
31359 .header(CONTENT_LENGTH, request_size as u64)
31360 .body(common::to_body(
31361 request_value_reader.get_ref().clone().into(),
31362 ));
31363
31364 client.request(request.unwrap()).await
31365 };
31366
31367 match req_result {
31368 Err(err) => {
31369 if let common::Retry::After(d) = dlg.http_error(&err) {
31370 sleep(d).await;
31371 continue;
31372 }
31373 dlg.finished(false);
31374 return Err(common::Error::HttpError(err));
31375 }
31376 Ok(res) => {
31377 let (mut parts, body) = res.into_parts();
31378 let mut body = common::Body::new(body);
31379 if !parts.status.is_success() {
31380 let bytes = common::to_bytes(body).await.unwrap_or_default();
31381 let error = serde_json::from_str(&common::to_string(&bytes));
31382 let response = common::to_response(parts, bytes.into());
31383
31384 if let common::Retry::After(d) =
31385 dlg.http_failure(&response, error.as_ref().ok())
31386 {
31387 sleep(d).await;
31388 continue;
31389 }
31390
31391 dlg.finished(false);
31392
31393 return Err(match error {
31394 Ok(value) => common::Error::BadRequest(value),
31395 _ => common::Error::Failure(response),
31396 });
31397 }
31398 let response = {
31399 let bytes = common::to_bytes(body).await.unwrap_or_default();
31400 let encoded = common::to_string(&bytes);
31401 match serde_json::from_str(&encoded) {
31402 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31403 Err(error) => {
31404 dlg.response_json_decode_error(&encoded, &error);
31405 return Err(common::Error::JsonDecodeError(
31406 encoded.to_string(),
31407 error,
31408 ));
31409 }
31410 }
31411 };
31412
31413 dlg.finished(true);
31414 return Ok(response);
31415 }
31416 }
31417 }
31418 }
31419
31420 ///
31421 /// Sets the *request* property to the given value.
31422 ///
31423 /// Even though the property as already been set when instantiating this call,
31424 /// we provide this method for API completeness.
31425 pub fn request(mut self, new_value: Course) -> CourseCreateCall<'a, C> {
31426 self._request = new_value;
31427 self
31428 }
31429 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31430 /// while executing the actual API request.
31431 ///
31432 /// ````text
31433 /// It should be used to handle progress information, and to implement a certain level of resilience.
31434 /// ````
31435 ///
31436 /// Sets the *delegate* property to the given value.
31437 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CourseCreateCall<'a, C> {
31438 self._delegate = Some(new_value);
31439 self
31440 }
31441
31442 /// Set any additional parameter of the query string used in the request.
31443 /// It should be used to set parameters which are not yet available through their own
31444 /// setters.
31445 ///
31446 /// Please note that this method must not be used to set any of the known parameters
31447 /// which have their own setter method. If done anyway, the request will fail.
31448 ///
31449 /// # Additional Parameters
31450 ///
31451 /// * *$.xgafv* (query-string) - V1 error format.
31452 /// * *access_token* (query-string) - OAuth access token.
31453 /// * *alt* (query-string) - Data format for response.
31454 /// * *callback* (query-string) - JSONP
31455 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31456 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
31457 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31458 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31459 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
31460 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31461 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31462 pub fn param<T>(mut self, name: T, value: T) -> CourseCreateCall<'a, C>
31463 where
31464 T: AsRef<str>,
31465 {
31466 self._additional_params
31467 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31468 self
31469 }
31470
31471 /// Identifies the authorization scope for the method you are building.
31472 ///
31473 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31474 /// [`Scope::Course`].
31475 ///
31476 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31477 /// tokens for more than one scope.
31478 ///
31479 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31480 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31481 /// sufficient, a read-write scope will do as well.
31482 pub fn add_scope<St>(mut self, scope: St) -> CourseCreateCall<'a, C>
31483 where
31484 St: AsRef<str>,
31485 {
31486 self._scopes.insert(String::from(scope.as_ref()));
31487 self
31488 }
31489 /// Identifies the authorization scope(s) for the method you are building.
31490 ///
31491 /// See [`Self::add_scope()`] for details.
31492 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseCreateCall<'a, C>
31493 where
31494 I: IntoIterator<Item = St>,
31495 St: AsRef<str>,
31496 {
31497 self._scopes
31498 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31499 self
31500 }
31501
31502 /// Removes all scopes, and no default scope will be used either.
31503 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31504 /// for details).
31505 pub fn clear_scopes(mut self) -> CourseCreateCall<'a, C> {
31506 self._scopes.clear();
31507 self
31508 }
31509}
31510
31511/// Deletes a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID.
31512///
31513/// A builder for the *delete* method supported by a *course* resource.
31514/// It is not used directly, but through a [`CourseMethods`] instance.
31515///
31516/// # Example
31517///
31518/// Instantiate a resource method builder
31519///
31520/// ```test_harness,no_run
31521/// # extern crate hyper;
31522/// # extern crate hyper_rustls;
31523/// # extern crate google_classroom1 as classroom1;
31524/// # async fn dox() {
31525/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31526///
31527/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31528/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31529/// # .with_native_roots()
31530/// # .unwrap()
31531/// # .https_only()
31532/// # .enable_http2()
31533/// # .build();
31534///
31535/// # let executor = hyper_util::rt::TokioExecutor::new();
31536/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31537/// # secret,
31538/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31539/// # yup_oauth2::client::CustomHyperClientBuilder::from(
31540/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
31541/// # ),
31542/// # ).build().await.unwrap();
31543///
31544/// # let client = hyper_util::client::legacy::Client::builder(
31545/// # hyper_util::rt::TokioExecutor::new()
31546/// # )
31547/// # .build(
31548/// # hyper_rustls::HttpsConnectorBuilder::new()
31549/// # .with_native_roots()
31550/// # .unwrap()
31551/// # .https_or_http()
31552/// # .enable_http2()
31553/// # .build()
31554/// # );
31555/// # let mut hub = Classroom::new(client, auth);
31556/// // You can configure optional parameters by calling the respective setters at will, and
31557/// // execute the final call using `doit()`.
31558/// // Values shown here are possibly random and not representative !
31559/// let result = hub.courses().delete("id")
31560/// .doit().await;
31561/// # }
31562/// ```
31563pub struct CourseDeleteCall<'a, C>
31564where
31565 C: 'a,
31566{
31567 hub: &'a Classroom<C>,
31568 _id: String,
31569 _delegate: Option<&'a mut dyn common::Delegate>,
31570 _additional_params: HashMap<String, String>,
31571 _scopes: BTreeSet<String>,
31572}
31573
31574impl<'a, C> common::CallBuilder for CourseDeleteCall<'a, C> {}
31575
31576impl<'a, C> CourseDeleteCall<'a, C>
31577where
31578 C: common::Connector,
31579{
31580 /// Perform the operation you have build so far.
31581 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
31582 use std::borrow::Cow;
31583 use std::io::{Read, Seek};
31584
31585 use common::{url::Params, ToParts};
31586 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31587
31588 let mut dd = common::DefaultDelegate;
31589 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31590 dlg.begin(common::MethodInfo {
31591 id: "classroom.courses.delete",
31592 http_method: hyper::Method::DELETE,
31593 });
31594
31595 for &field in ["alt", "id"].iter() {
31596 if self._additional_params.contains_key(field) {
31597 dlg.finished(false);
31598 return Err(common::Error::FieldClash(field));
31599 }
31600 }
31601
31602 let mut params = Params::with_capacity(3 + self._additional_params.len());
31603 params.push("id", self._id);
31604
31605 params.extend(self._additional_params.iter());
31606
31607 params.push("alt", "json");
31608 let mut url = self.hub._base_url.clone() + "v1/courses/{id}";
31609 if self._scopes.is_empty() {
31610 self._scopes.insert(Scope::Course.as_ref().to_string());
31611 }
31612
31613 #[allow(clippy::single_element_loop)]
31614 for &(find_this, param_name) in [("{id}", "id")].iter() {
31615 url = params.uri_replacement(url, param_name, find_this, false);
31616 }
31617 {
31618 let to_remove = ["id"];
31619 params.remove_params(&to_remove);
31620 }
31621
31622 let url = params.parse_with_url(&url);
31623
31624 loop {
31625 let token = match self
31626 .hub
31627 .auth
31628 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31629 .await
31630 {
31631 Ok(token) => token,
31632 Err(e) => match dlg.token(e) {
31633 Ok(token) => token,
31634 Err(e) => {
31635 dlg.finished(false);
31636 return Err(common::Error::MissingToken(e));
31637 }
31638 },
31639 };
31640 let mut req_result = {
31641 let client = &self.hub.client;
31642 dlg.pre_request();
31643 let mut req_builder = hyper::Request::builder()
31644 .method(hyper::Method::DELETE)
31645 .uri(url.as_str())
31646 .header(USER_AGENT, self.hub._user_agent.clone());
31647
31648 if let Some(token) = token.as_ref() {
31649 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31650 }
31651
31652 let request = req_builder
31653 .header(CONTENT_LENGTH, 0_u64)
31654 .body(common::to_body::<String>(None));
31655
31656 client.request(request.unwrap()).await
31657 };
31658
31659 match req_result {
31660 Err(err) => {
31661 if let common::Retry::After(d) = dlg.http_error(&err) {
31662 sleep(d).await;
31663 continue;
31664 }
31665 dlg.finished(false);
31666 return Err(common::Error::HttpError(err));
31667 }
31668 Ok(res) => {
31669 let (mut parts, body) = res.into_parts();
31670 let mut body = common::Body::new(body);
31671 if !parts.status.is_success() {
31672 let bytes = common::to_bytes(body).await.unwrap_or_default();
31673 let error = serde_json::from_str(&common::to_string(&bytes));
31674 let response = common::to_response(parts, bytes.into());
31675
31676 if let common::Retry::After(d) =
31677 dlg.http_failure(&response, error.as_ref().ok())
31678 {
31679 sleep(d).await;
31680 continue;
31681 }
31682
31683 dlg.finished(false);
31684
31685 return Err(match error {
31686 Ok(value) => common::Error::BadRequest(value),
31687 _ => common::Error::Failure(response),
31688 });
31689 }
31690 let response = {
31691 let bytes = common::to_bytes(body).await.unwrap_or_default();
31692 let encoded = common::to_string(&bytes);
31693 match serde_json::from_str(&encoded) {
31694 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31695 Err(error) => {
31696 dlg.response_json_decode_error(&encoded, &error);
31697 return Err(common::Error::JsonDecodeError(
31698 encoded.to_string(),
31699 error,
31700 ));
31701 }
31702 }
31703 };
31704
31705 dlg.finished(true);
31706 return Ok(response);
31707 }
31708 }
31709 }
31710 }
31711
31712 /// Identifier of the course to delete. This identifier can be either the Classroom-assigned identifier or an alias.
31713 ///
31714 /// Sets the *id* path property to the given value.
31715 ///
31716 /// Even though the property as already been set when instantiating this call,
31717 /// we provide this method for API completeness.
31718 pub fn id(mut self, new_value: &str) -> CourseDeleteCall<'a, C> {
31719 self._id = new_value.to_string();
31720 self
31721 }
31722 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31723 /// while executing the actual API request.
31724 ///
31725 /// ````text
31726 /// It should be used to handle progress information, and to implement a certain level of resilience.
31727 /// ````
31728 ///
31729 /// Sets the *delegate* property to the given value.
31730 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CourseDeleteCall<'a, C> {
31731 self._delegate = Some(new_value);
31732 self
31733 }
31734
31735 /// Set any additional parameter of the query string used in the request.
31736 /// It should be used to set parameters which are not yet available through their own
31737 /// setters.
31738 ///
31739 /// Please note that this method must not be used to set any of the known parameters
31740 /// which have their own setter method. If done anyway, the request will fail.
31741 ///
31742 /// # Additional Parameters
31743 ///
31744 /// * *$.xgafv* (query-string) - V1 error format.
31745 /// * *access_token* (query-string) - OAuth access token.
31746 /// * *alt* (query-string) - Data format for response.
31747 /// * *callback* (query-string) - JSONP
31748 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31749 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
31750 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31751 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31752 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
31753 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31754 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31755 pub fn param<T>(mut self, name: T, value: T) -> CourseDeleteCall<'a, C>
31756 where
31757 T: AsRef<str>,
31758 {
31759 self._additional_params
31760 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31761 self
31762 }
31763
31764 /// Identifies the authorization scope for the method you are building.
31765 ///
31766 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31767 /// [`Scope::Course`].
31768 ///
31769 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31770 /// tokens for more than one scope.
31771 ///
31772 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31773 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31774 /// sufficient, a read-write scope will do as well.
31775 pub fn add_scope<St>(mut self, scope: St) -> CourseDeleteCall<'a, C>
31776 where
31777 St: AsRef<str>,
31778 {
31779 self._scopes.insert(String::from(scope.as_ref()));
31780 self
31781 }
31782 /// Identifies the authorization scope(s) for the method you are building.
31783 ///
31784 /// See [`Self::add_scope()`] for details.
31785 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseDeleteCall<'a, C>
31786 where
31787 I: IntoIterator<Item = St>,
31788 St: AsRef<str>,
31789 {
31790 self._scopes
31791 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31792 self
31793 }
31794
31795 /// Removes all scopes, and no default scope will be used either.
31796 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31797 /// for details).
31798 pub fn clear_scopes(mut self) -> CourseDeleteCall<'a, C> {
31799 self._scopes.clear();
31800 self
31801 }
31802}
31803
31804/// Returns a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID.
31805///
31806/// A builder for the *get* method supported by a *course* resource.
31807/// It is not used directly, but through a [`CourseMethods`] instance.
31808///
31809/// # Example
31810///
31811/// Instantiate a resource method builder
31812///
31813/// ```test_harness,no_run
31814/// # extern crate hyper;
31815/// # extern crate hyper_rustls;
31816/// # extern crate google_classroom1 as classroom1;
31817/// # async fn dox() {
31818/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31819///
31820/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31821/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31822/// # .with_native_roots()
31823/// # .unwrap()
31824/// # .https_only()
31825/// # .enable_http2()
31826/// # .build();
31827///
31828/// # let executor = hyper_util::rt::TokioExecutor::new();
31829/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31830/// # secret,
31831/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31832/// # yup_oauth2::client::CustomHyperClientBuilder::from(
31833/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
31834/// # ),
31835/// # ).build().await.unwrap();
31836///
31837/// # let client = hyper_util::client::legacy::Client::builder(
31838/// # hyper_util::rt::TokioExecutor::new()
31839/// # )
31840/// # .build(
31841/// # hyper_rustls::HttpsConnectorBuilder::new()
31842/// # .with_native_roots()
31843/// # .unwrap()
31844/// # .https_or_http()
31845/// # .enable_http2()
31846/// # .build()
31847/// # );
31848/// # let mut hub = Classroom::new(client, auth);
31849/// // You can configure optional parameters by calling the respective setters at will, and
31850/// // execute the final call using `doit()`.
31851/// // Values shown here are possibly random and not representative !
31852/// let result = hub.courses().get("id")
31853/// .doit().await;
31854/// # }
31855/// ```
31856pub struct CourseGetCall<'a, C>
31857where
31858 C: 'a,
31859{
31860 hub: &'a Classroom<C>,
31861 _id: String,
31862 _delegate: Option<&'a mut dyn common::Delegate>,
31863 _additional_params: HashMap<String, String>,
31864 _scopes: BTreeSet<String>,
31865}
31866
31867impl<'a, C> common::CallBuilder for CourseGetCall<'a, C> {}
31868
31869impl<'a, C> CourseGetCall<'a, C>
31870where
31871 C: common::Connector,
31872{
31873 /// Perform the operation you have build so far.
31874 pub async fn doit(mut self) -> common::Result<(common::Response, Course)> {
31875 use std::borrow::Cow;
31876 use std::io::{Read, Seek};
31877
31878 use common::{url::Params, ToParts};
31879 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31880
31881 let mut dd = common::DefaultDelegate;
31882 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31883 dlg.begin(common::MethodInfo {
31884 id: "classroom.courses.get",
31885 http_method: hyper::Method::GET,
31886 });
31887
31888 for &field in ["alt", "id"].iter() {
31889 if self._additional_params.contains_key(field) {
31890 dlg.finished(false);
31891 return Err(common::Error::FieldClash(field));
31892 }
31893 }
31894
31895 let mut params = Params::with_capacity(3 + self._additional_params.len());
31896 params.push("id", self._id);
31897
31898 params.extend(self._additional_params.iter());
31899
31900 params.push("alt", "json");
31901 let mut url = self.hub._base_url.clone() + "v1/courses/{id}";
31902 if self._scopes.is_empty() {
31903 self._scopes
31904 .insert(Scope::CourseReadonly.as_ref().to_string());
31905 }
31906
31907 #[allow(clippy::single_element_loop)]
31908 for &(find_this, param_name) in [("{id}", "id")].iter() {
31909 url = params.uri_replacement(url, param_name, find_this, false);
31910 }
31911 {
31912 let to_remove = ["id"];
31913 params.remove_params(&to_remove);
31914 }
31915
31916 let url = params.parse_with_url(&url);
31917
31918 loop {
31919 let token = match self
31920 .hub
31921 .auth
31922 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31923 .await
31924 {
31925 Ok(token) => token,
31926 Err(e) => match dlg.token(e) {
31927 Ok(token) => token,
31928 Err(e) => {
31929 dlg.finished(false);
31930 return Err(common::Error::MissingToken(e));
31931 }
31932 },
31933 };
31934 let mut req_result = {
31935 let client = &self.hub.client;
31936 dlg.pre_request();
31937 let mut req_builder = hyper::Request::builder()
31938 .method(hyper::Method::GET)
31939 .uri(url.as_str())
31940 .header(USER_AGENT, self.hub._user_agent.clone());
31941
31942 if let Some(token) = token.as_ref() {
31943 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31944 }
31945
31946 let request = req_builder
31947 .header(CONTENT_LENGTH, 0_u64)
31948 .body(common::to_body::<String>(None));
31949
31950 client.request(request.unwrap()).await
31951 };
31952
31953 match req_result {
31954 Err(err) => {
31955 if let common::Retry::After(d) = dlg.http_error(&err) {
31956 sleep(d).await;
31957 continue;
31958 }
31959 dlg.finished(false);
31960 return Err(common::Error::HttpError(err));
31961 }
31962 Ok(res) => {
31963 let (mut parts, body) = res.into_parts();
31964 let mut body = common::Body::new(body);
31965 if !parts.status.is_success() {
31966 let bytes = common::to_bytes(body).await.unwrap_or_default();
31967 let error = serde_json::from_str(&common::to_string(&bytes));
31968 let response = common::to_response(parts, bytes.into());
31969
31970 if let common::Retry::After(d) =
31971 dlg.http_failure(&response, error.as_ref().ok())
31972 {
31973 sleep(d).await;
31974 continue;
31975 }
31976
31977 dlg.finished(false);
31978
31979 return Err(match error {
31980 Ok(value) => common::Error::BadRequest(value),
31981 _ => common::Error::Failure(response),
31982 });
31983 }
31984 let response = {
31985 let bytes = common::to_bytes(body).await.unwrap_or_default();
31986 let encoded = common::to_string(&bytes);
31987 match serde_json::from_str(&encoded) {
31988 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31989 Err(error) => {
31990 dlg.response_json_decode_error(&encoded, &error);
31991 return Err(common::Error::JsonDecodeError(
31992 encoded.to_string(),
31993 error,
31994 ));
31995 }
31996 }
31997 };
31998
31999 dlg.finished(true);
32000 return Ok(response);
32001 }
32002 }
32003 }
32004 }
32005
32006 /// Identifier of the course to return. This identifier can be either the Classroom-assigned identifier or an alias.
32007 ///
32008 /// Sets the *id* path property to the given value.
32009 ///
32010 /// Even though the property as already been set when instantiating this call,
32011 /// we provide this method for API completeness.
32012 pub fn id(mut self, new_value: &str) -> CourseGetCall<'a, C> {
32013 self._id = new_value.to_string();
32014 self
32015 }
32016 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32017 /// while executing the actual API request.
32018 ///
32019 /// ````text
32020 /// It should be used to handle progress information, and to implement a certain level of resilience.
32021 /// ````
32022 ///
32023 /// Sets the *delegate* property to the given value.
32024 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CourseGetCall<'a, C> {
32025 self._delegate = Some(new_value);
32026 self
32027 }
32028
32029 /// Set any additional parameter of the query string used in the request.
32030 /// It should be used to set parameters which are not yet available through their own
32031 /// setters.
32032 ///
32033 /// Please note that this method must not be used to set any of the known parameters
32034 /// which have their own setter method. If done anyway, the request will fail.
32035 ///
32036 /// # Additional Parameters
32037 ///
32038 /// * *$.xgafv* (query-string) - V1 error format.
32039 /// * *access_token* (query-string) - OAuth access token.
32040 /// * *alt* (query-string) - Data format for response.
32041 /// * *callback* (query-string) - JSONP
32042 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32043 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
32044 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32045 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32046 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
32047 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32048 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32049 pub fn param<T>(mut self, name: T, value: T) -> CourseGetCall<'a, C>
32050 where
32051 T: AsRef<str>,
32052 {
32053 self._additional_params
32054 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32055 self
32056 }
32057
32058 /// Identifies the authorization scope for the method you are building.
32059 ///
32060 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32061 /// [`Scope::CourseReadonly`].
32062 ///
32063 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32064 /// tokens for more than one scope.
32065 ///
32066 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32067 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32068 /// sufficient, a read-write scope will do as well.
32069 pub fn add_scope<St>(mut self, scope: St) -> CourseGetCall<'a, C>
32070 where
32071 St: AsRef<str>,
32072 {
32073 self._scopes.insert(String::from(scope.as_ref()));
32074 self
32075 }
32076 /// Identifies the authorization scope(s) for the method you are building.
32077 ///
32078 /// See [`Self::add_scope()`] for details.
32079 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseGetCall<'a, C>
32080 where
32081 I: IntoIterator<Item = St>,
32082 St: AsRef<str>,
32083 {
32084 self._scopes
32085 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32086 self
32087 }
32088
32089 /// Removes all scopes, and no default scope will be used either.
32090 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32091 /// for details).
32092 pub fn clear_scopes(mut self) -> CourseGetCall<'a, C> {
32093 self._scopes.clear();
32094 self
32095 }
32096}
32097
32098/// Returns the grading period settings in a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user isn't permitted to access the grading period settings in the requested course or for access errors. * `NOT_FOUND` if the requested course does not exist.
32099///
32100/// A builder for the *getGradingPeriodSettings* method supported by a *course* resource.
32101/// It is not used directly, but through a [`CourseMethods`] instance.
32102///
32103/// # Example
32104///
32105/// Instantiate a resource method builder
32106///
32107/// ```test_harness,no_run
32108/// # extern crate hyper;
32109/// # extern crate hyper_rustls;
32110/// # extern crate google_classroom1 as classroom1;
32111/// # async fn dox() {
32112/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32113///
32114/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32115/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32116/// # .with_native_roots()
32117/// # .unwrap()
32118/// # .https_only()
32119/// # .enable_http2()
32120/// # .build();
32121///
32122/// # let executor = hyper_util::rt::TokioExecutor::new();
32123/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32124/// # secret,
32125/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32126/// # yup_oauth2::client::CustomHyperClientBuilder::from(
32127/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
32128/// # ),
32129/// # ).build().await.unwrap();
32130///
32131/// # let client = hyper_util::client::legacy::Client::builder(
32132/// # hyper_util::rt::TokioExecutor::new()
32133/// # )
32134/// # .build(
32135/// # hyper_rustls::HttpsConnectorBuilder::new()
32136/// # .with_native_roots()
32137/// # .unwrap()
32138/// # .https_or_http()
32139/// # .enable_http2()
32140/// # .build()
32141/// # );
32142/// # let mut hub = Classroom::new(client, auth);
32143/// // You can configure optional parameters by calling the respective setters at will, and
32144/// // execute the final call using `doit()`.
32145/// // Values shown here are possibly random and not representative !
32146/// let result = hub.courses().get_grading_period_settings("courseId")
32147/// .doit().await;
32148/// # }
32149/// ```
32150pub struct CourseGetGradingPeriodSettingCall<'a, C>
32151where
32152 C: 'a,
32153{
32154 hub: &'a Classroom<C>,
32155 _course_id: String,
32156 _delegate: Option<&'a mut dyn common::Delegate>,
32157 _additional_params: HashMap<String, String>,
32158 _scopes: BTreeSet<String>,
32159}
32160
32161impl<'a, C> common::CallBuilder for CourseGetGradingPeriodSettingCall<'a, C> {}
32162
32163impl<'a, C> CourseGetGradingPeriodSettingCall<'a, C>
32164where
32165 C: common::Connector,
32166{
32167 /// Perform the operation you have build so far.
32168 pub async fn doit(mut self) -> common::Result<(common::Response, GradingPeriodSettings)> {
32169 use std::borrow::Cow;
32170 use std::io::{Read, Seek};
32171
32172 use common::{url::Params, ToParts};
32173 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32174
32175 let mut dd = common::DefaultDelegate;
32176 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32177 dlg.begin(common::MethodInfo {
32178 id: "classroom.courses.getGradingPeriodSettings",
32179 http_method: hyper::Method::GET,
32180 });
32181
32182 for &field in ["alt", "courseId"].iter() {
32183 if self._additional_params.contains_key(field) {
32184 dlg.finished(false);
32185 return Err(common::Error::FieldClash(field));
32186 }
32187 }
32188
32189 let mut params = Params::with_capacity(3 + self._additional_params.len());
32190 params.push("courseId", self._course_id);
32191
32192 params.extend(self._additional_params.iter());
32193
32194 params.push("alt", "json");
32195 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/gradingPeriodSettings";
32196 if self._scopes.is_empty() {
32197 self._scopes
32198 .insert(Scope::CourseReadonly.as_ref().to_string());
32199 }
32200
32201 #[allow(clippy::single_element_loop)]
32202 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
32203 url = params.uri_replacement(url, param_name, find_this, false);
32204 }
32205 {
32206 let to_remove = ["courseId"];
32207 params.remove_params(&to_remove);
32208 }
32209
32210 let url = params.parse_with_url(&url);
32211
32212 loop {
32213 let token = match self
32214 .hub
32215 .auth
32216 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32217 .await
32218 {
32219 Ok(token) => token,
32220 Err(e) => match dlg.token(e) {
32221 Ok(token) => token,
32222 Err(e) => {
32223 dlg.finished(false);
32224 return Err(common::Error::MissingToken(e));
32225 }
32226 },
32227 };
32228 let mut req_result = {
32229 let client = &self.hub.client;
32230 dlg.pre_request();
32231 let mut req_builder = hyper::Request::builder()
32232 .method(hyper::Method::GET)
32233 .uri(url.as_str())
32234 .header(USER_AGENT, self.hub._user_agent.clone());
32235
32236 if let Some(token) = token.as_ref() {
32237 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32238 }
32239
32240 let request = req_builder
32241 .header(CONTENT_LENGTH, 0_u64)
32242 .body(common::to_body::<String>(None));
32243
32244 client.request(request.unwrap()).await
32245 };
32246
32247 match req_result {
32248 Err(err) => {
32249 if let common::Retry::After(d) = dlg.http_error(&err) {
32250 sleep(d).await;
32251 continue;
32252 }
32253 dlg.finished(false);
32254 return Err(common::Error::HttpError(err));
32255 }
32256 Ok(res) => {
32257 let (mut parts, body) = res.into_parts();
32258 let mut body = common::Body::new(body);
32259 if !parts.status.is_success() {
32260 let bytes = common::to_bytes(body).await.unwrap_or_default();
32261 let error = serde_json::from_str(&common::to_string(&bytes));
32262 let response = common::to_response(parts, bytes.into());
32263
32264 if let common::Retry::After(d) =
32265 dlg.http_failure(&response, error.as_ref().ok())
32266 {
32267 sleep(d).await;
32268 continue;
32269 }
32270
32271 dlg.finished(false);
32272
32273 return Err(match error {
32274 Ok(value) => common::Error::BadRequest(value),
32275 _ => common::Error::Failure(response),
32276 });
32277 }
32278 let response = {
32279 let bytes = common::to_bytes(body).await.unwrap_or_default();
32280 let encoded = common::to_string(&bytes);
32281 match serde_json::from_str(&encoded) {
32282 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32283 Err(error) => {
32284 dlg.response_json_decode_error(&encoded, &error);
32285 return Err(common::Error::JsonDecodeError(
32286 encoded.to_string(),
32287 error,
32288 ));
32289 }
32290 }
32291 };
32292
32293 dlg.finished(true);
32294 return Ok(response);
32295 }
32296 }
32297 }
32298 }
32299
32300 /// Required. The identifier of the course.
32301 ///
32302 /// Sets the *course id* path property to the given value.
32303 ///
32304 /// Even though the property as already been set when instantiating this call,
32305 /// we provide this method for API completeness.
32306 pub fn course_id(mut self, new_value: &str) -> CourseGetGradingPeriodSettingCall<'a, C> {
32307 self._course_id = new_value.to_string();
32308 self
32309 }
32310 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32311 /// while executing the actual API request.
32312 ///
32313 /// ````text
32314 /// It should be used to handle progress information, and to implement a certain level of resilience.
32315 /// ````
32316 ///
32317 /// Sets the *delegate* property to the given value.
32318 pub fn delegate(
32319 mut self,
32320 new_value: &'a mut dyn common::Delegate,
32321 ) -> CourseGetGradingPeriodSettingCall<'a, C> {
32322 self._delegate = Some(new_value);
32323 self
32324 }
32325
32326 /// Set any additional parameter of the query string used in the request.
32327 /// It should be used to set parameters which are not yet available through their own
32328 /// setters.
32329 ///
32330 /// Please note that this method must not be used to set any of the known parameters
32331 /// which have their own setter method. If done anyway, the request will fail.
32332 ///
32333 /// # Additional Parameters
32334 ///
32335 /// * *$.xgafv* (query-string) - V1 error format.
32336 /// * *access_token* (query-string) - OAuth access token.
32337 /// * *alt* (query-string) - Data format for response.
32338 /// * *callback* (query-string) - JSONP
32339 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32340 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
32341 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32342 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32343 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
32344 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32345 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32346 pub fn param<T>(mut self, name: T, value: T) -> CourseGetGradingPeriodSettingCall<'a, C>
32347 where
32348 T: AsRef<str>,
32349 {
32350 self._additional_params
32351 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32352 self
32353 }
32354
32355 /// Identifies the authorization scope for the method you are building.
32356 ///
32357 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32358 /// [`Scope::CourseReadonly`].
32359 ///
32360 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32361 /// tokens for more than one scope.
32362 ///
32363 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32364 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32365 /// sufficient, a read-write scope will do as well.
32366 pub fn add_scope<St>(mut self, scope: St) -> CourseGetGradingPeriodSettingCall<'a, C>
32367 where
32368 St: AsRef<str>,
32369 {
32370 self._scopes.insert(String::from(scope.as_ref()));
32371 self
32372 }
32373 /// Identifies the authorization scope(s) for the method you are building.
32374 ///
32375 /// See [`Self::add_scope()`] for details.
32376 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseGetGradingPeriodSettingCall<'a, C>
32377 where
32378 I: IntoIterator<Item = St>,
32379 St: AsRef<str>,
32380 {
32381 self._scopes
32382 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32383 self
32384 }
32385
32386 /// Removes all scopes, and no default scope will be used either.
32387 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32388 /// for details).
32389 pub fn clear_scopes(mut self) -> CourseGetGradingPeriodSettingCall<'a, C> {
32390 self._scopes.clear();
32391 self
32392 }
32393}
32394
32395/// Returns a list of courses that the requesting user is permitted to view, restricted to those that match the request. Returned courses are ordered by creation time, with the most recently created coming first. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the query argument is malformed. * `NOT_FOUND` if any users specified in the query arguments do not exist.
32396///
32397/// A builder for the *list* method supported by a *course* resource.
32398/// It is not used directly, but through a [`CourseMethods`] instance.
32399///
32400/// # Example
32401///
32402/// Instantiate a resource method builder
32403///
32404/// ```test_harness,no_run
32405/// # extern crate hyper;
32406/// # extern crate hyper_rustls;
32407/// # extern crate google_classroom1 as classroom1;
32408/// # async fn dox() {
32409/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32410///
32411/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32412/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32413/// # .with_native_roots()
32414/// # .unwrap()
32415/// # .https_only()
32416/// # .enable_http2()
32417/// # .build();
32418///
32419/// # let executor = hyper_util::rt::TokioExecutor::new();
32420/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32421/// # secret,
32422/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32423/// # yup_oauth2::client::CustomHyperClientBuilder::from(
32424/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
32425/// # ),
32426/// # ).build().await.unwrap();
32427///
32428/// # let client = hyper_util::client::legacy::Client::builder(
32429/// # hyper_util::rt::TokioExecutor::new()
32430/// # )
32431/// # .build(
32432/// # hyper_rustls::HttpsConnectorBuilder::new()
32433/// # .with_native_roots()
32434/// # .unwrap()
32435/// # .https_or_http()
32436/// # .enable_http2()
32437/// # .build()
32438/// # );
32439/// # let mut hub = Classroom::new(client, auth);
32440/// // You can configure optional parameters by calling the respective setters at will, and
32441/// // execute the final call using `doit()`.
32442/// // Values shown here are possibly random and not representative !
32443/// let result = hub.courses().list()
32444/// .teacher_id("et")
32445/// .student_id("sanctus")
32446/// .page_token("accusam")
32447/// .page_size(-39)
32448/// .add_course_states("sed")
32449/// .doit().await;
32450/// # }
32451/// ```
32452pub struct CourseListCall<'a, C>
32453where
32454 C: 'a,
32455{
32456 hub: &'a Classroom<C>,
32457 _teacher_id: Option<String>,
32458 _student_id: Option<String>,
32459 _page_token: Option<String>,
32460 _page_size: Option<i32>,
32461 _course_states: Vec<String>,
32462 _delegate: Option<&'a mut dyn common::Delegate>,
32463 _additional_params: HashMap<String, String>,
32464 _scopes: BTreeSet<String>,
32465}
32466
32467impl<'a, C> common::CallBuilder for CourseListCall<'a, C> {}
32468
32469impl<'a, C> CourseListCall<'a, C>
32470where
32471 C: common::Connector,
32472{
32473 /// Perform the operation you have build so far.
32474 pub async fn doit(mut self) -> common::Result<(common::Response, ListCoursesResponse)> {
32475 use std::borrow::Cow;
32476 use std::io::{Read, Seek};
32477
32478 use common::{url::Params, ToParts};
32479 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32480
32481 let mut dd = common::DefaultDelegate;
32482 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32483 dlg.begin(common::MethodInfo {
32484 id: "classroom.courses.list",
32485 http_method: hyper::Method::GET,
32486 });
32487
32488 for &field in [
32489 "alt",
32490 "teacherId",
32491 "studentId",
32492 "pageToken",
32493 "pageSize",
32494 "courseStates",
32495 ]
32496 .iter()
32497 {
32498 if self._additional_params.contains_key(field) {
32499 dlg.finished(false);
32500 return Err(common::Error::FieldClash(field));
32501 }
32502 }
32503
32504 let mut params = Params::with_capacity(7 + self._additional_params.len());
32505 if let Some(value) = self._teacher_id.as_ref() {
32506 params.push("teacherId", value);
32507 }
32508 if let Some(value) = self._student_id.as_ref() {
32509 params.push("studentId", value);
32510 }
32511 if let Some(value) = self._page_token.as_ref() {
32512 params.push("pageToken", value);
32513 }
32514 if let Some(value) = self._page_size.as_ref() {
32515 params.push("pageSize", value.to_string());
32516 }
32517 if !self._course_states.is_empty() {
32518 for f in self._course_states.iter() {
32519 params.push("courseStates", f);
32520 }
32521 }
32522
32523 params.extend(self._additional_params.iter());
32524
32525 params.push("alt", "json");
32526 let mut url = self.hub._base_url.clone() + "v1/courses";
32527 if self._scopes.is_empty() {
32528 self._scopes
32529 .insert(Scope::CourseReadonly.as_ref().to_string());
32530 }
32531
32532 let url = params.parse_with_url(&url);
32533
32534 loop {
32535 let token = match self
32536 .hub
32537 .auth
32538 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32539 .await
32540 {
32541 Ok(token) => token,
32542 Err(e) => match dlg.token(e) {
32543 Ok(token) => token,
32544 Err(e) => {
32545 dlg.finished(false);
32546 return Err(common::Error::MissingToken(e));
32547 }
32548 },
32549 };
32550 let mut req_result = {
32551 let client = &self.hub.client;
32552 dlg.pre_request();
32553 let mut req_builder = hyper::Request::builder()
32554 .method(hyper::Method::GET)
32555 .uri(url.as_str())
32556 .header(USER_AGENT, self.hub._user_agent.clone());
32557
32558 if let Some(token) = token.as_ref() {
32559 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32560 }
32561
32562 let request = req_builder
32563 .header(CONTENT_LENGTH, 0_u64)
32564 .body(common::to_body::<String>(None));
32565
32566 client.request(request.unwrap()).await
32567 };
32568
32569 match req_result {
32570 Err(err) => {
32571 if let common::Retry::After(d) = dlg.http_error(&err) {
32572 sleep(d).await;
32573 continue;
32574 }
32575 dlg.finished(false);
32576 return Err(common::Error::HttpError(err));
32577 }
32578 Ok(res) => {
32579 let (mut parts, body) = res.into_parts();
32580 let mut body = common::Body::new(body);
32581 if !parts.status.is_success() {
32582 let bytes = common::to_bytes(body).await.unwrap_or_default();
32583 let error = serde_json::from_str(&common::to_string(&bytes));
32584 let response = common::to_response(parts, bytes.into());
32585
32586 if let common::Retry::After(d) =
32587 dlg.http_failure(&response, error.as_ref().ok())
32588 {
32589 sleep(d).await;
32590 continue;
32591 }
32592
32593 dlg.finished(false);
32594
32595 return Err(match error {
32596 Ok(value) => common::Error::BadRequest(value),
32597 _ => common::Error::Failure(response),
32598 });
32599 }
32600 let response = {
32601 let bytes = common::to_bytes(body).await.unwrap_or_default();
32602 let encoded = common::to_string(&bytes);
32603 match serde_json::from_str(&encoded) {
32604 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32605 Err(error) => {
32606 dlg.response_json_decode_error(&encoded, &error);
32607 return Err(common::Error::JsonDecodeError(
32608 encoded.to_string(),
32609 error,
32610 ));
32611 }
32612 }
32613 };
32614
32615 dlg.finished(true);
32616 return Ok(response);
32617 }
32618 }
32619 }
32620 }
32621
32622 /// Restricts returned courses to those having a teacher with the specified identifier. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
32623 ///
32624 /// Sets the *teacher id* query property to the given value.
32625 pub fn teacher_id(mut self, new_value: &str) -> CourseListCall<'a, C> {
32626 self._teacher_id = Some(new_value.to_string());
32627 self
32628 }
32629 /// Restricts returned courses to those having a student with the specified identifier. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
32630 ///
32631 /// Sets the *student id* query property to the given value.
32632 pub fn student_id(mut self, new_value: &str) -> CourseListCall<'a, C> {
32633 self._student_id = Some(new_value.to_string());
32634 self
32635 }
32636 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
32637 ///
32638 /// Sets the *page token* query property to the given value.
32639 pub fn page_token(mut self, new_value: &str) -> CourseListCall<'a, C> {
32640 self._page_token = Some(new_value.to_string());
32641 self
32642 }
32643 /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.
32644 ///
32645 /// Sets the *page size* query property to the given value.
32646 pub fn page_size(mut self, new_value: i32) -> CourseListCall<'a, C> {
32647 self._page_size = Some(new_value);
32648 self
32649 }
32650 /// Restricts returned courses to those in one of the specified states The default value is ACTIVE, ARCHIVED, PROVISIONED, DECLINED.
32651 ///
32652 /// Append the given value to the *course states* query property.
32653 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
32654 pub fn add_course_states(mut self, new_value: &str) -> CourseListCall<'a, C> {
32655 self._course_states.push(new_value.to_string());
32656 self
32657 }
32658 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32659 /// while executing the actual API request.
32660 ///
32661 /// ````text
32662 /// It should be used to handle progress information, and to implement a certain level of resilience.
32663 /// ````
32664 ///
32665 /// Sets the *delegate* property to the given value.
32666 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CourseListCall<'a, C> {
32667 self._delegate = Some(new_value);
32668 self
32669 }
32670
32671 /// Set any additional parameter of the query string used in the request.
32672 /// It should be used to set parameters which are not yet available through their own
32673 /// setters.
32674 ///
32675 /// Please note that this method must not be used to set any of the known parameters
32676 /// which have their own setter method. If done anyway, the request will fail.
32677 ///
32678 /// # Additional Parameters
32679 ///
32680 /// * *$.xgafv* (query-string) - V1 error format.
32681 /// * *access_token* (query-string) - OAuth access token.
32682 /// * *alt* (query-string) - Data format for response.
32683 /// * *callback* (query-string) - JSONP
32684 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32685 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
32686 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32687 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32688 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
32689 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32690 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32691 pub fn param<T>(mut self, name: T, value: T) -> CourseListCall<'a, C>
32692 where
32693 T: AsRef<str>,
32694 {
32695 self._additional_params
32696 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32697 self
32698 }
32699
32700 /// Identifies the authorization scope for the method you are building.
32701 ///
32702 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32703 /// [`Scope::CourseReadonly`].
32704 ///
32705 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32706 /// tokens for more than one scope.
32707 ///
32708 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32709 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32710 /// sufficient, a read-write scope will do as well.
32711 pub fn add_scope<St>(mut self, scope: St) -> CourseListCall<'a, C>
32712 where
32713 St: AsRef<str>,
32714 {
32715 self._scopes.insert(String::from(scope.as_ref()));
32716 self
32717 }
32718 /// Identifies the authorization scope(s) for the method you are building.
32719 ///
32720 /// See [`Self::add_scope()`] for details.
32721 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseListCall<'a, C>
32722 where
32723 I: IntoIterator<Item = St>,
32724 St: AsRef<str>,
32725 {
32726 self._scopes
32727 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32728 self
32729 }
32730
32731 /// Removes all scopes, and no default scope will be used either.
32732 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32733 /// for details).
32734 pub fn clear_scopes(mut self) -> CourseListCall<'a, C> {
32735 self._scopes.clear();
32736 self
32737 }
32738}
32739
32740/// Updates one or more fields in a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID. * `INVALID_ARGUMENT` if invalid fields are specified in the update mask or if no update mask is supplied. * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable * InactiveCourseOwner * IneligibleOwner * CourseTitleCannotContainUrl
32741///
32742/// A builder for the *patch* method supported by a *course* resource.
32743/// It is not used directly, but through a [`CourseMethods`] instance.
32744///
32745/// # Example
32746///
32747/// Instantiate a resource method builder
32748///
32749/// ```test_harness,no_run
32750/// # extern crate hyper;
32751/// # extern crate hyper_rustls;
32752/// # extern crate google_classroom1 as classroom1;
32753/// use classroom1::api::Course;
32754/// # async fn dox() {
32755/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32756///
32757/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32758/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32759/// # .with_native_roots()
32760/// # .unwrap()
32761/// # .https_only()
32762/// # .enable_http2()
32763/// # .build();
32764///
32765/// # let executor = hyper_util::rt::TokioExecutor::new();
32766/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32767/// # secret,
32768/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32769/// # yup_oauth2::client::CustomHyperClientBuilder::from(
32770/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
32771/// # ),
32772/// # ).build().await.unwrap();
32773///
32774/// # let client = hyper_util::client::legacy::Client::builder(
32775/// # hyper_util::rt::TokioExecutor::new()
32776/// # )
32777/// # .build(
32778/// # hyper_rustls::HttpsConnectorBuilder::new()
32779/// # .with_native_roots()
32780/// # .unwrap()
32781/// # .https_or_http()
32782/// # .enable_http2()
32783/// # .build()
32784/// # );
32785/// # let mut hub = Classroom::new(client, auth);
32786/// // As the method needs a request, you would usually fill it with the desired information
32787/// // into the respective structure. Some of the parts shown here might not be applicable !
32788/// // Values shown here are possibly random and not representative !
32789/// let mut req = Course::default();
32790///
32791/// // You can configure optional parameters by calling the respective setters at will, and
32792/// // execute the final call using `doit()`.
32793/// // Values shown here are possibly random and not representative !
32794/// let result = hub.courses().patch(req, "id")
32795/// .update_mask(FieldMask::new::<&str>(&[]))
32796/// .doit().await;
32797/// # }
32798/// ```
32799pub struct CoursePatchCall<'a, C>
32800where
32801 C: 'a,
32802{
32803 hub: &'a Classroom<C>,
32804 _request: Course,
32805 _id: String,
32806 _update_mask: Option<common::FieldMask>,
32807 _delegate: Option<&'a mut dyn common::Delegate>,
32808 _additional_params: HashMap<String, String>,
32809 _scopes: BTreeSet<String>,
32810}
32811
32812impl<'a, C> common::CallBuilder for CoursePatchCall<'a, C> {}
32813
32814impl<'a, C> CoursePatchCall<'a, C>
32815where
32816 C: common::Connector,
32817{
32818 /// Perform the operation you have build so far.
32819 pub async fn doit(mut self) -> common::Result<(common::Response, Course)> {
32820 use std::borrow::Cow;
32821 use std::io::{Read, Seek};
32822
32823 use common::{url::Params, ToParts};
32824 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32825
32826 let mut dd = common::DefaultDelegate;
32827 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32828 dlg.begin(common::MethodInfo {
32829 id: "classroom.courses.patch",
32830 http_method: hyper::Method::PATCH,
32831 });
32832
32833 for &field in ["alt", "id", "updateMask"].iter() {
32834 if self._additional_params.contains_key(field) {
32835 dlg.finished(false);
32836 return Err(common::Error::FieldClash(field));
32837 }
32838 }
32839
32840 let mut params = Params::with_capacity(5 + self._additional_params.len());
32841 params.push("id", self._id);
32842 if let Some(value) = self._update_mask.as_ref() {
32843 params.push("updateMask", value.to_string());
32844 }
32845
32846 params.extend(self._additional_params.iter());
32847
32848 params.push("alt", "json");
32849 let mut url = self.hub._base_url.clone() + "v1/courses/{id}";
32850 if self._scopes.is_empty() {
32851 self._scopes.insert(Scope::Course.as_ref().to_string());
32852 }
32853
32854 #[allow(clippy::single_element_loop)]
32855 for &(find_this, param_name) in [("{id}", "id")].iter() {
32856 url = params.uri_replacement(url, param_name, find_this, false);
32857 }
32858 {
32859 let to_remove = ["id"];
32860 params.remove_params(&to_remove);
32861 }
32862
32863 let url = params.parse_with_url(&url);
32864
32865 let mut json_mime_type = mime::APPLICATION_JSON;
32866 let mut request_value_reader = {
32867 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32868 common::remove_json_null_values(&mut value);
32869 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32870 serde_json::to_writer(&mut dst, &value).unwrap();
32871 dst
32872 };
32873 let request_size = request_value_reader
32874 .seek(std::io::SeekFrom::End(0))
32875 .unwrap();
32876 request_value_reader
32877 .seek(std::io::SeekFrom::Start(0))
32878 .unwrap();
32879
32880 loop {
32881 let token = match self
32882 .hub
32883 .auth
32884 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32885 .await
32886 {
32887 Ok(token) => token,
32888 Err(e) => match dlg.token(e) {
32889 Ok(token) => token,
32890 Err(e) => {
32891 dlg.finished(false);
32892 return Err(common::Error::MissingToken(e));
32893 }
32894 },
32895 };
32896 request_value_reader
32897 .seek(std::io::SeekFrom::Start(0))
32898 .unwrap();
32899 let mut req_result = {
32900 let client = &self.hub.client;
32901 dlg.pre_request();
32902 let mut req_builder = hyper::Request::builder()
32903 .method(hyper::Method::PATCH)
32904 .uri(url.as_str())
32905 .header(USER_AGENT, self.hub._user_agent.clone());
32906
32907 if let Some(token) = token.as_ref() {
32908 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32909 }
32910
32911 let request = req_builder
32912 .header(CONTENT_TYPE, json_mime_type.to_string())
32913 .header(CONTENT_LENGTH, request_size as u64)
32914 .body(common::to_body(
32915 request_value_reader.get_ref().clone().into(),
32916 ));
32917
32918 client.request(request.unwrap()).await
32919 };
32920
32921 match req_result {
32922 Err(err) => {
32923 if let common::Retry::After(d) = dlg.http_error(&err) {
32924 sleep(d).await;
32925 continue;
32926 }
32927 dlg.finished(false);
32928 return Err(common::Error::HttpError(err));
32929 }
32930 Ok(res) => {
32931 let (mut parts, body) = res.into_parts();
32932 let mut body = common::Body::new(body);
32933 if !parts.status.is_success() {
32934 let bytes = common::to_bytes(body).await.unwrap_or_default();
32935 let error = serde_json::from_str(&common::to_string(&bytes));
32936 let response = common::to_response(parts, bytes.into());
32937
32938 if let common::Retry::After(d) =
32939 dlg.http_failure(&response, error.as_ref().ok())
32940 {
32941 sleep(d).await;
32942 continue;
32943 }
32944
32945 dlg.finished(false);
32946
32947 return Err(match error {
32948 Ok(value) => common::Error::BadRequest(value),
32949 _ => common::Error::Failure(response),
32950 });
32951 }
32952 let response = {
32953 let bytes = common::to_bytes(body).await.unwrap_or_default();
32954 let encoded = common::to_string(&bytes);
32955 match serde_json::from_str(&encoded) {
32956 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32957 Err(error) => {
32958 dlg.response_json_decode_error(&encoded, &error);
32959 return Err(common::Error::JsonDecodeError(
32960 encoded.to_string(),
32961 error,
32962 ));
32963 }
32964 }
32965 };
32966
32967 dlg.finished(true);
32968 return Ok(response);
32969 }
32970 }
32971 }
32972 }
32973
32974 ///
32975 /// Sets the *request* property to the given value.
32976 ///
32977 /// Even though the property as already been set when instantiating this call,
32978 /// we provide this method for API completeness.
32979 pub fn request(mut self, new_value: Course) -> CoursePatchCall<'a, C> {
32980 self._request = new_value;
32981 self
32982 }
32983 /// Identifier of the course to update. This identifier can be either the Classroom-assigned identifier or an alias.
32984 ///
32985 /// Sets the *id* path property to the given value.
32986 ///
32987 /// Even though the property as already been set when instantiating this call,
32988 /// we provide this method for API completeness.
32989 pub fn id(mut self, new_value: &str) -> CoursePatchCall<'a, C> {
32990 self._id = new_value.to_string();
32991 self
32992 }
32993 /// Mask that identifies which fields on the course to update. This field is required to do an update. The update will fail if invalid fields are specified. The following fields are valid: * `courseState` * `description` * `descriptionHeading` * `name` * `ownerId` * `room` * `section` * `subject` Note: patches to ownerId are treated as being effective immediately, but in practice it may take some time for the ownership transfer of all affected resources to complete. When set in a query parameter, this field should be specified as `updateMask=,,...`
32994 ///
32995 /// Sets the *update mask* query property to the given value.
32996 pub fn update_mask(mut self, new_value: common::FieldMask) -> CoursePatchCall<'a, C> {
32997 self._update_mask = Some(new_value);
32998 self
32999 }
33000 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33001 /// while executing the actual API request.
33002 ///
33003 /// ````text
33004 /// It should be used to handle progress information, and to implement a certain level of resilience.
33005 /// ````
33006 ///
33007 /// Sets the *delegate* property to the given value.
33008 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CoursePatchCall<'a, C> {
33009 self._delegate = Some(new_value);
33010 self
33011 }
33012
33013 /// Set any additional parameter of the query string used in the request.
33014 /// It should be used to set parameters which are not yet available through their own
33015 /// setters.
33016 ///
33017 /// Please note that this method must not be used to set any of the known parameters
33018 /// which have their own setter method. If done anyway, the request will fail.
33019 ///
33020 /// # Additional Parameters
33021 ///
33022 /// * *$.xgafv* (query-string) - V1 error format.
33023 /// * *access_token* (query-string) - OAuth access token.
33024 /// * *alt* (query-string) - Data format for response.
33025 /// * *callback* (query-string) - JSONP
33026 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33027 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
33028 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33029 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33030 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
33031 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33032 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33033 pub fn param<T>(mut self, name: T, value: T) -> CoursePatchCall<'a, C>
33034 where
33035 T: AsRef<str>,
33036 {
33037 self._additional_params
33038 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33039 self
33040 }
33041
33042 /// Identifies the authorization scope for the method you are building.
33043 ///
33044 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33045 /// [`Scope::Course`].
33046 ///
33047 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33048 /// tokens for more than one scope.
33049 ///
33050 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33051 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33052 /// sufficient, a read-write scope will do as well.
33053 pub fn add_scope<St>(mut self, scope: St) -> CoursePatchCall<'a, C>
33054 where
33055 St: AsRef<str>,
33056 {
33057 self._scopes.insert(String::from(scope.as_ref()));
33058 self
33059 }
33060 /// Identifies the authorization scope(s) for the method you are building.
33061 ///
33062 /// See [`Self::add_scope()`] for details.
33063 pub fn add_scopes<I, St>(mut self, scopes: I) -> CoursePatchCall<'a, C>
33064 where
33065 I: IntoIterator<Item = St>,
33066 St: AsRef<str>,
33067 {
33068 self._scopes
33069 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33070 self
33071 }
33072
33073 /// Removes all scopes, and no default scope will be used either.
33074 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33075 /// for details).
33076 pub fn clear_scopes(mut self) -> CoursePatchCall<'a, C> {
33077 self._scopes.clear();
33078 self
33079 }
33080}
33081
33082/// Updates a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID. * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable * CourseTitleCannotContainUrl
33083///
33084/// A builder for the *update* method supported by a *course* resource.
33085/// It is not used directly, but through a [`CourseMethods`] instance.
33086///
33087/// # Example
33088///
33089/// Instantiate a resource method builder
33090///
33091/// ```test_harness,no_run
33092/// # extern crate hyper;
33093/// # extern crate hyper_rustls;
33094/// # extern crate google_classroom1 as classroom1;
33095/// use classroom1::api::Course;
33096/// # async fn dox() {
33097/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33098///
33099/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33100/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33101/// # .with_native_roots()
33102/// # .unwrap()
33103/// # .https_only()
33104/// # .enable_http2()
33105/// # .build();
33106///
33107/// # let executor = hyper_util::rt::TokioExecutor::new();
33108/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33109/// # secret,
33110/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33111/// # yup_oauth2::client::CustomHyperClientBuilder::from(
33112/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
33113/// # ),
33114/// # ).build().await.unwrap();
33115///
33116/// # let client = hyper_util::client::legacy::Client::builder(
33117/// # hyper_util::rt::TokioExecutor::new()
33118/// # )
33119/// # .build(
33120/// # hyper_rustls::HttpsConnectorBuilder::new()
33121/// # .with_native_roots()
33122/// # .unwrap()
33123/// # .https_or_http()
33124/// # .enable_http2()
33125/// # .build()
33126/// # );
33127/// # let mut hub = Classroom::new(client, auth);
33128/// // As the method needs a request, you would usually fill it with the desired information
33129/// // into the respective structure. Some of the parts shown here might not be applicable !
33130/// // Values shown here are possibly random and not representative !
33131/// let mut req = Course::default();
33132///
33133/// // You can configure optional parameters by calling the respective setters at will, and
33134/// // execute the final call using `doit()`.
33135/// // Values shown here are possibly random and not representative !
33136/// let result = hub.courses().update(req, "id")
33137/// .doit().await;
33138/// # }
33139/// ```
33140pub struct CourseUpdateCall<'a, C>
33141where
33142 C: 'a,
33143{
33144 hub: &'a Classroom<C>,
33145 _request: Course,
33146 _id: String,
33147 _delegate: Option<&'a mut dyn common::Delegate>,
33148 _additional_params: HashMap<String, String>,
33149 _scopes: BTreeSet<String>,
33150}
33151
33152impl<'a, C> common::CallBuilder for CourseUpdateCall<'a, C> {}
33153
33154impl<'a, C> CourseUpdateCall<'a, C>
33155where
33156 C: common::Connector,
33157{
33158 /// Perform the operation you have build so far.
33159 pub async fn doit(mut self) -> common::Result<(common::Response, Course)> {
33160 use std::borrow::Cow;
33161 use std::io::{Read, Seek};
33162
33163 use common::{url::Params, ToParts};
33164 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33165
33166 let mut dd = common::DefaultDelegate;
33167 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33168 dlg.begin(common::MethodInfo {
33169 id: "classroom.courses.update",
33170 http_method: hyper::Method::PUT,
33171 });
33172
33173 for &field in ["alt", "id"].iter() {
33174 if self._additional_params.contains_key(field) {
33175 dlg.finished(false);
33176 return Err(common::Error::FieldClash(field));
33177 }
33178 }
33179
33180 let mut params = Params::with_capacity(4 + self._additional_params.len());
33181 params.push("id", self._id);
33182
33183 params.extend(self._additional_params.iter());
33184
33185 params.push("alt", "json");
33186 let mut url = self.hub._base_url.clone() + "v1/courses/{id}";
33187 if self._scopes.is_empty() {
33188 self._scopes.insert(Scope::Course.as_ref().to_string());
33189 }
33190
33191 #[allow(clippy::single_element_loop)]
33192 for &(find_this, param_name) in [("{id}", "id")].iter() {
33193 url = params.uri_replacement(url, param_name, find_this, false);
33194 }
33195 {
33196 let to_remove = ["id"];
33197 params.remove_params(&to_remove);
33198 }
33199
33200 let url = params.parse_with_url(&url);
33201
33202 let mut json_mime_type = mime::APPLICATION_JSON;
33203 let mut request_value_reader = {
33204 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33205 common::remove_json_null_values(&mut value);
33206 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33207 serde_json::to_writer(&mut dst, &value).unwrap();
33208 dst
33209 };
33210 let request_size = request_value_reader
33211 .seek(std::io::SeekFrom::End(0))
33212 .unwrap();
33213 request_value_reader
33214 .seek(std::io::SeekFrom::Start(0))
33215 .unwrap();
33216
33217 loop {
33218 let token = match self
33219 .hub
33220 .auth
33221 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33222 .await
33223 {
33224 Ok(token) => token,
33225 Err(e) => match dlg.token(e) {
33226 Ok(token) => token,
33227 Err(e) => {
33228 dlg.finished(false);
33229 return Err(common::Error::MissingToken(e));
33230 }
33231 },
33232 };
33233 request_value_reader
33234 .seek(std::io::SeekFrom::Start(0))
33235 .unwrap();
33236 let mut req_result = {
33237 let client = &self.hub.client;
33238 dlg.pre_request();
33239 let mut req_builder = hyper::Request::builder()
33240 .method(hyper::Method::PUT)
33241 .uri(url.as_str())
33242 .header(USER_AGENT, self.hub._user_agent.clone());
33243
33244 if let Some(token) = token.as_ref() {
33245 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33246 }
33247
33248 let request = req_builder
33249 .header(CONTENT_TYPE, json_mime_type.to_string())
33250 .header(CONTENT_LENGTH, request_size as u64)
33251 .body(common::to_body(
33252 request_value_reader.get_ref().clone().into(),
33253 ));
33254
33255 client.request(request.unwrap()).await
33256 };
33257
33258 match req_result {
33259 Err(err) => {
33260 if let common::Retry::After(d) = dlg.http_error(&err) {
33261 sleep(d).await;
33262 continue;
33263 }
33264 dlg.finished(false);
33265 return Err(common::Error::HttpError(err));
33266 }
33267 Ok(res) => {
33268 let (mut parts, body) = res.into_parts();
33269 let mut body = common::Body::new(body);
33270 if !parts.status.is_success() {
33271 let bytes = common::to_bytes(body).await.unwrap_or_default();
33272 let error = serde_json::from_str(&common::to_string(&bytes));
33273 let response = common::to_response(parts, bytes.into());
33274
33275 if let common::Retry::After(d) =
33276 dlg.http_failure(&response, error.as_ref().ok())
33277 {
33278 sleep(d).await;
33279 continue;
33280 }
33281
33282 dlg.finished(false);
33283
33284 return Err(match error {
33285 Ok(value) => common::Error::BadRequest(value),
33286 _ => common::Error::Failure(response),
33287 });
33288 }
33289 let response = {
33290 let bytes = common::to_bytes(body).await.unwrap_or_default();
33291 let encoded = common::to_string(&bytes);
33292 match serde_json::from_str(&encoded) {
33293 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33294 Err(error) => {
33295 dlg.response_json_decode_error(&encoded, &error);
33296 return Err(common::Error::JsonDecodeError(
33297 encoded.to_string(),
33298 error,
33299 ));
33300 }
33301 }
33302 };
33303
33304 dlg.finished(true);
33305 return Ok(response);
33306 }
33307 }
33308 }
33309 }
33310
33311 ///
33312 /// Sets the *request* property to the given value.
33313 ///
33314 /// Even though the property as already been set when instantiating this call,
33315 /// we provide this method for API completeness.
33316 pub fn request(mut self, new_value: Course) -> CourseUpdateCall<'a, C> {
33317 self._request = new_value;
33318 self
33319 }
33320 /// Identifier of the course to update. This identifier can be either the Classroom-assigned identifier or an alias.
33321 ///
33322 /// Sets the *id* path property to the given value.
33323 ///
33324 /// Even though the property as already been set when instantiating this call,
33325 /// we provide this method for API completeness.
33326 pub fn id(mut self, new_value: &str) -> CourseUpdateCall<'a, C> {
33327 self._id = new_value.to_string();
33328 self
33329 }
33330 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33331 /// while executing the actual API request.
33332 ///
33333 /// ````text
33334 /// It should be used to handle progress information, and to implement a certain level of resilience.
33335 /// ````
33336 ///
33337 /// Sets the *delegate* property to the given value.
33338 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CourseUpdateCall<'a, C> {
33339 self._delegate = Some(new_value);
33340 self
33341 }
33342
33343 /// Set any additional parameter of the query string used in the request.
33344 /// It should be used to set parameters which are not yet available through their own
33345 /// setters.
33346 ///
33347 /// Please note that this method must not be used to set any of the known parameters
33348 /// which have their own setter method. If done anyway, the request will fail.
33349 ///
33350 /// # Additional Parameters
33351 ///
33352 /// * *$.xgafv* (query-string) - V1 error format.
33353 /// * *access_token* (query-string) - OAuth access token.
33354 /// * *alt* (query-string) - Data format for response.
33355 /// * *callback* (query-string) - JSONP
33356 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33357 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
33358 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33359 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33360 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
33361 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33362 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33363 pub fn param<T>(mut self, name: T, value: T) -> CourseUpdateCall<'a, C>
33364 where
33365 T: AsRef<str>,
33366 {
33367 self._additional_params
33368 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33369 self
33370 }
33371
33372 /// Identifies the authorization scope for the method you are building.
33373 ///
33374 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33375 /// [`Scope::Course`].
33376 ///
33377 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33378 /// tokens for more than one scope.
33379 ///
33380 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33381 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33382 /// sufficient, a read-write scope will do as well.
33383 pub fn add_scope<St>(mut self, scope: St) -> CourseUpdateCall<'a, C>
33384 where
33385 St: AsRef<str>,
33386 {
33387 self._scopes.insert(String::from(scope.as_ref()));
33388 self
33389 }
33390 /// Identifies the authorization scope(s) for the method you are building.
33391 ///
33392 /// See [`Self::add_scope()`] for details.
33393 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseUpdateCall<'a, C>
33394 where
33395 I: IntoIterator<Item = St>,
33396 St: AsRef<str>,
33397 {
33398 self._scopes
33399 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33400 self
33401 }
33402
33403 /// Removes all scopes, and no default scope will be used either.
33404 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33405 /// for details).
33406 pub fn clear_scopes(mut self) -> CourseUpdateCall<'a, C> {
33407 self._scopes.clear();
33408 self
33409 }
33410}
33411
33412/// Updates grading period settings of a course. Individual grading periods can be added, removed, or modified using this method. The requesting user and course owner must be eligible to modify Grading Periods. For details, see [licensing requirements](https://developers.google.com/workspace/classroom/grading-periods/manage-grading-periods#licensing_requirements). This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the grading period settings in a course or for access errors: * UserIneligibleToUpdateGradingPeriodSettings * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if the requested course does not exist.
33413///
33414/// A builder for the *updateGradingPeriodSettings* method supported by a *course* resource.
33415/// It is not used directly, but through a [`CourseMethods`] instance.
33416///
33417/// # Example
33418///
33419/// Instantiate a resource method builder
33420///
33421/// ```test_harness,no_run
33422/// # extern crate hyper;
33423/// # extern crate hyper_rustls;
33424/// # extern crate google_classroom1 as classroom1;
33425/// use classroom1::api::GradingPeriodSettings;
33426/// # async fn dox() {
33427/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33428///
33429/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33430/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33431/// # .with_native_roots()
33432/// # .unwrap()
33433/// # .https_only()
33434/// # .enable_http2()
33435/// # .build();
33436///
33437/// # let executor = hyper_util::rt::TokioExecutor::new();
33438/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33439/// # secret,
33440/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33441/// # yup_oauth2::client::CustomHyperClientBuilder::from(
33442/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
33443/// # ),
33444/// # ).build().await.unwrap();
33445///
33446/// # let client = hyper_util::client::legacy::Client::builder(
33447/// # hyper_util::rt::TokioExecutor::new()
33448/// # )
33449/// # .build(
33450/// # hyper_rustls::HttpsConnectorBuilder::new()
33451/// # .with_native_roots()
33452/// # .unwrap()
33453/// # .https_or_http()
33454/// # .enable_http2()
33455/// # .build()
33456/// # );
33457/// # let mut hub = Classroom::new(client, auth);
33458/// // As the method needs a request, you would usually fill it with the desired information
33459/// // into the respective structure. Some of the parts shown here might not be applicable !
33460/// // Values shown here are possibly random and not representative !
33461/// let mut req = GradingPeriodSettings::default();
33462///
33463/// // You can configure optional parameters by calling the respective setters at will, and
33464/// // execute the final call using `doit()`.
33465/// // Values shown here are possibly random and not representative !
33466/// let result = hub.courses().update_grading_period_settings(req, "courseId")
33467/// .update_mask(FieldMask::new::<&str>(&[]))
33468/// .doit().await;
33469/// # }
33470/// ```
33471pub struct CourseUpdateGradingPeriodSettingCall<'a, C>
33472where
33473 C: 'a,
33474{
33475 hub: &'a Classroom<C>,
33476 _request: GradingPeriodSettings,
33477 _course_id: String,
33478 _update_mask: Option<common::FieldMask>,
33479 _delegate: Option<&'a mut dyn common::Delegate>,
33480 _additional_params: HashMap<String, String>,
33481 _scopes: BTreeSet<String>,
33482}
33483
33484impl<'a, C> common::CallBuilder for CourseUpdateGradingPeriodSettingCall<'a, C> {}
33485
33486impl<'a, C> CourseUpdateGradingPeriodSettingCall<'a, C>
33487where
33488 C: common::Connector,
33489{
33490 /// Perform the operation you have build so far.
33491 pub async fn doit(mut self) -> common::Result<(common::Response, GradingPeriodSettings)> {
33492 use std::borrow::Cow;
33493 use std::io::{Read, Seek};
33494
33495 use common::{url::Params, ToParts};
33496 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33497
33498 let mut dd = common::DefaultDelegate;
33499 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33500 dlg.begin(common::MethodInfo {
33501 id: "classroom.courses.updateGradingPeriodSettings",
33502 http_method: hyper::Method::PATCH,
33503 });
33504
33505 for &field in ["alt", "courseId", "updateMask"].iter() {
33506 if self._additional_params.contains_key(field) {
33507 dlg.finished(false);
33508 return Err(common::Error::FieldClash(field));
33509 }
33510 }
33511
33512 let mut params = Params::with_capacity(5 + self._additional_params.len());
33513 params.push("courseId", self._course_id);
33514 if let Some(value) = self._update_mask.as_ref() {
33515 params.push("updateMask", value.to_string());
33516 }
33517
33518 params.extend(self._additional_params.iter());
33519
33520 params.push("alt", "json");
33521 let mut url = self.hub._base_url.clone() + "v1/courses/{courseId}/gradingPeriodSettings";
33522 if self._scopes.is_empty() {
33523 self._scopes.insert(Scope::Course.as_ref().to_string());
33524 }
33525
33526 #[allow(clippy::single_element_loop)]
33527 for &(find_this, param_name) in [("{courseId}", "courseId")].iter() {
33528 url = params.uri_replacement(url, param_name, find_this, false);
33529 }
33530 {
33531 let to_remove = ["courseId"];
33532 params.remove_params(&to_remove);
33533 }
33534
33535 let url = params.parse_with_url(&url);
33536
33537 let mut json_mime_type = mime::APPLICATION_JSON;
33538 let mut request_value_reader = {
33539 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33540 common::remove_json_null_values(&mut value);
33541 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33542 serde_json::to_writer(&mut dst, &value).unwrap();
33543 dst
33544 };
33545 let request_size = request_value_reader
33546 .seek(std::io::SeekFrom::End(0))
33547 .unwrap();
33548 request_value_reader
33549 .seek(std::io::SeekFrom::Start(0))
33550 .unwrap();
33551
33552 loop {
33553 let token = match self
33554 .hub
33555 .auth
33556 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33557 .await
33558 {
33559 Ok(token) => token,
33560 Err(e) => match dlg.token(e) {
33561 Ok(token) => token,
33562 Err(e) => {
33563 dlg.finished(false);
33564 return Err(common::Error::MissingToken(e));
33565 }
33566 },
33567 };
33568 request_value_reader
33569 .seek(std::io::SeekFrom::Start(0))
33570 .unwrap();
33571 let mut req_result = {
33572 let client = &self.hub.client;
33573 dlg.pre_request();
33574 let mut req_builder = hyper::Request::builder()
33575 .method(hyper::Method::PATCH)
33576 .uri(url.as_str())
33577 .header(USER_AGENT, self.hub._user_agent.clone());
33578
33579 if let Some(token) = token.as_ref() {
33580 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33581 }
33582
33583 let request = req_builder
33584 .header(CONTENT_TYPE, json_mime_type.to_string())
33585 .header(CONTENT_LENGTH, request_size as u64)
33586 .body(common::to_body(
33587 request_value_reader.get_ref().clone().into(),
33588 ));
33589
33590 client.request(request.unwrap()).await
33591 };
33592
33593 match req_result {
33594 Err(err) => {
33595 if let common::Retry::After(d) = dlg.http_error(&err) {
33596 sleep(d).await;
33597 continue;
33598 }
33599 dlg.finished(false);
33600 return Err(common::Error::HttpError(err));
33601 }
33602 Ok(res) => {
33603 let (mut parts, body) = res.into_parts();
33604 let mut body = common::Body::new(body);
33605 if !parts.status.is_success() {
33606 let bytes = common::to_bytes(body).await.unwrap_or_default();
33607 let error = serde_json::from_str(&common::to_string(&bytes));
33608 let response = common::to_response(parts, bytes.into());
33609
33610 if let common::Retry::After(d) =
33611 dlg.http_failure(&response, error.as_ref().ok())
33612 {
33613 sleep(d).await;
33614 continue;
33615 }
33616
33617 dlg.finished(false);
33618
33619 return Err(match error {
33620 Ok(value) => common::Error::BadRequest(value),
33621 _ => common::Error::Failure(response),
33622 });
33623 }
33624 let response = {
33625 let bytes = common::to_bytes(body).await.unwrap_or_default();
33626 let encoded = common::to_string(&bytes);
33627 match serde_json::from_str(&encoded) {
33628 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33629 Err(error) => {
33630 dlg.response_json_decode_error(&encoded, &error);
33631 return Err(common::Error::JsonDecodeError(
33632 encoded.to_string(),
33633 error,
33634 ));
33635 }
33636 }
33637 };
33638
33639 dlg.finished(true);
33640 return Ok(response);
33641 }
33642 }
33643 }
33644 }
33645
33646 ///
33647 /// Sets the *request* property to the given value.
33648 ///
33649 /// Even though the property as already been set when instantiating this call,
33650 /// we provide this method for API completeness.
33651 pub fn request(
33652 mut self,
33653 new_value: GradingPeriodSettings,
33654 ) -> CourseUpdateGradingPeriodSettingCall<'a, C> {
33655 self._request = new_value;
33656 self
33657 }
33658 /// Required. The identifier of the course.
33659 ///
33660 /// Sets the *course id* path property to the given value.
33661 ///
33662 /// Even though the property as already been set when instantiating this call,
33663 /// we provide this method for API completeness.
33664 pub fn course_id(mut self, new_value: &str) -> CourseUpdateGradingPeriodSettingCall<'a, C> {
33665 self._course_id = new_value.to_string();
33666 self
33667 }
33668 /// Mask that identifies which fields in the GradingPeriodSettings to update. The GradingPeriodSettings `grading_periods` list will be fully replaced by the grading periods specified in the update request. For example: * Grading periods included in the list without an ID are considered additions, and a new ID will be assigned when the request is made. * Grading periods that currently exist, but are missing from the request will be considered deletions. * Grading periods with an existing ID and modified data are considered edits. Unmodified data will be left as is. * Grading periods included with an unknown ID will result in an error. The following fields may be specified: * `grading_periods` * `apply_to_existing_coursework`
33669 ///
33670 /// Sets the *update mask* query property to the given value.
33671 pub fn update_mask(
33672 mut self,
33673 new_value: common::FieldMask,
33674 ) -> CourseUpdateGradingPeriodSettingCall<'a, C> {
33675 self._update_mask = Some(new_value);
33676 self
33677 }
33678 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33679 /// while executing the actual API request.
33680 ///
33681 /// ````text
33682 /// It should be used to handle progress information, and to implement a certain level of resilience.
33683 /// ````
33684 ///
33685 /// Sets the *delegate* property to the given value.
33686 pub fn delegate(
33687 mut self,
33688 new_value: &'a mut dyn common::Delegate,
33689 ) -> CourseUpdateGradingPeriodSettingCall<'a, C> {
33690 self._delegate = Some(new_value);
33691 self
33692 }
33693
33694 /// Set any additional parameter of the query string used in the request.
33695 /// It should be used to set parameters which are not yet available through their own
33696 /// setters.
33697 ///
33698 /// Please note that this method must not be used to set any of the known parameters
33699 /// which have their own setter method. If done anyway, the request will fail.
33700 ///
33701 /// # Additional Parameters
33702 ///
33703 /// * *$.xgafv* (query-string) - V1 error format.
33704 /// * *access_token* (query-string) - OAuth access token.
33705 /// * *alt* (query-string) - Data format for response.
33706 /// * *callback* (query-string) - JSONP
33707 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33708 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
33709 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33710 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33711 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
33712 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33713 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33714 pub fn param<T>(mut self, name: T, value: T) -> CourseUpdateGradingPeriodSettingCall<'a, C>
33715 where
33716 T: AsRef<str>,
33717 {
33718 self._additional_params
33719 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33720 self
33721 }
33722
33723 /// Identifies the authorization scope for the method you are building.
33724 ///
33725 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33726 /// [`Scope::Course`].
33727 ///
33728 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33729 /// tokens for more than one scope.
33730 ///
33731 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33732 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33733 /// sufficient, a read-write scope will do as well.
33734 pub fn add_scope<St>(mut self, scope: St) -> CourseUpdateGradingPeriodSettingCall<'a, C>
33735 where
33736 St: AsRef<str>,
33737 {
33738 self._scopes.insert(String::from(scope.as_ref()));
33739 self
33740 }
33741 /// Identifies the authorization scope(s) for the method you are building.
33742 ///
33743 /// See [`Self::add_scope()`] for details.
33744 pub fn add_scopes<I, St>(mut self, scopes: I) -> CourseUpdateGradingPeriodSettingCall<'a, C>
33745 where
33746 I: IntoIterator<Item = St>,
33747 St: AsRef<str>,
33748 {
33749 self._scopes
33750 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33751 self
33752 }
33753
33754 /// Removes all scopes, and no default scope will be used either.
33755 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33756 /// for details).
33757 pub fn clear_scopes(mut self) -> CourseUpdateGradingPeriodSettingCall<'a, C> {
33758 self._scopes.clear();
33759 self
33760 }
33761}
33762
33763/// Accepts an invitation, removing it and adding the invited user to the teachers or students (as appropriate) of the specified course. Only the invited user may accept an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to accept the requested invitation or for access errors. * `FAILED_PRECONDITION` for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * CourseTeacherLimitReached * UserGroupsMembershipLimitReached * `NOT_FOUND` if no invitation exists with the requested ID.
33764///
33765/// A builder for the *accept* method supported by a *invitation* resource.
33766/// It is not used directly, but through a [`InvitationMethods`] instance.
33767///
33768/// # Example
33769///
33770/// Instantiate a resource method builder
33771///
33772/// ```test_harness,no_run
33773/// # extern crate hyper;
33774/// # extern crate hyper_rustls;
33775/// # extern crate google_classroom1 as classroom1;
33776/// # async fn dox() {
33777/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33778///
33779/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33780/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33781/// # .with_native_roots()
33782/// # .unwrap()
33783/// # .https_only()
33784/// # .enable_http2()
33785/// # .build();
33786///
33787/// # let executor = hyper_util::rt::TokioExecutor::new();
33788/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33789/// # secret,
33790/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33791/// # yup_oauth2::client::CustomHyperClientBuilder::from(
33792/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
33793/// # ),
33794/// # ).build().await.unwrap();
33795///
33796/// # let client = hyper_util::client::legacy::Client::builder(
33797/// # hyper_util::rt::TokioExecutor::new()
33798/// # )
33799/// # .build(
33800/// # hyper_rustls::HttpsConnectorBuilder::new()
33801/// # .with_native_roots()
33802/// # .unwrap()
33803/// # .https_or_http()
33804/// # .enable_http2()
33805/// # .build()
33806/// # );
33807/// # let mut hub = Classroom::new(client, auth);
33808/// // You can configure optional parameters by calling the respective setters at will, and
33809/// // execute the final call using `doit()`.
33810/// // Values shown here are possibly random and not representative !
33811/// let result = hub.invitations().accept("id")
33812/// .doit().await;
33813/// # }
33814/// ```
33815pub struct InvitationAcceptCall<'a, C>
33816where
33817 C: 'a,
33818{
33819 hub: &'a Classroom<C>,
33820 _id: String,
33821 _delegate: Option<&'a mut dyn common::Delegate>,
33822 _additional_params: HashMap<String, String>,
33823 _scopes: BTreeSet<String>,
33824}
33825
33826impl<'a, C> common::CallBuilder for InvitationAcceptCall<'a, C> {}
33827
33828impl<'a, C> InvitationAcceptCall<'a, C>
33829where
33830 C: common::Connector,
33831{
33832 /// Perform the operation you have build so far.
33833 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
33834 use std::borrow::Cow;
33835 use std::io::{Read, Seek};
33836
33837 use common::{url::Params, ToParts};
33838 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33839
33840 let mut dd = common::DefaultDelegate;
33841 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33842 dlg.begin(common::MethodInfo {
33843 id: "classroom.invitations.accept",
33844 http_method: hyper::Method::POST,
33845 });
33846
33847 for &field in ["alt", "id"].iter() {
33848 if self._additional_params.contains_key(field) {
33849 dlg.finished(false);
33850 return Err(common::Error::FieldClash(field));
33851 }
33852 }
33853
33854 let mut params = Params::with_capacity(3 + self._additional_params.len());
33855 params.push("id", self._id);
33856
33857 params.extend(self._additional_params.iter());
33858
33859 params.push("alt", "json");
33860 let mut url = self.hub._base_url.clone() + "v1/invitations/{id}:accept";
33861 if self._scopes.is_empty() {
33862 self._scopes.insert(Scope::Roster.as_ref().to_string());
33863 }
33864
33865 #[allow(clippy::single_element_loop)]
33866 for &(find_this, param_name) in [("{id}", "id")].iter() {
33867 url = params.uri_replacement(url, param_name, find_this, false);
33868 }
33869 {
33870 let to_remove = ["id"];
33871 params.remove_params(&to_remove);
33872 }
33873
33874 let url = params.parse_with_url(&url);
33875
33876 loop {
33877 let token = match self
33878 .hub
33879 .auth
33880 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33881 .await
33882 {
33883 Ok(token) => token,
33884 Err(e) => match dlg.token(e) {
33885 Ok(token) => token,
33886 Err(e) => {
33887 dlg.finished(false);
33888 return Err(common::Error::MissingToken(e));
33889 }
33890 },
33891 };
33892 let mut req_result = {
33893 let client = &self.hub.client;
33894 dlg.pre_request();
33895 let mut req_builder = hyper::Request::builder()
33896 .method(hyper::Method::POST)
33897 .uri(url.as_str())
33898 .header(USER_AGENT, self.hub._user_agent.clone());
33899
33900 if let Some(token) = token.as_ref() {
33901 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33902 }
33903
33904 let request = req_builder
33905 .header(CONTENT_LENGTH, 0_u64)
33906 .body(common::to_body::<String>(None));
33907
33908 client.request(request.unwrap()).await
33909 };
33910
33911 match req_result {
33912 Err(err) => {
33913 if let common::Retry::After(d) = dlg.http_error(&err) {
33914 sleep(d).await;
33915 continue;
33916 }
33917 dlg.finished(false);
33918 return Err(common::Error::HttpError(err));
33919 }
33920 Ok(res) => {
33921 let (mut parts, body) = res.into_parts();
33922 let mut body = common::Body::new(body);
33923 if !parts.status.is_success() {
33924 let bytes = common::to_bytes(body).await.unwrap_or_default();
33925 let error = serde_json::from_str(&common::to_string(&bytes));
33926 let response = common::to_response(parts, bytes.into());
33927
33928 if let common::Retry::After(d) =
33929 dlg.http_failure(&response, error.as_ref().ok())
33930 {
33931 sleep(d).await;
33932 continue;
33933 }
33934
33935 dlg.finished(false);
33936
33937 return Err(match error {
33938 Ok(value) => common::Error::BadRequest(value),
33939 _ => common::Error::Failure(response),
33940 });
33941 }
33942 let response = {
33943 let bytes = common::to_bytes(body).await.unwrap_or_default();
33944 let encoded = common::to_string(&bytes);
33945 match serde_json::from_str(&encoded) {
33946 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33947 Err(error) => {
33948 dlg.response_json_decode_error(&encoded, &error);
33949 return Err(common::Error::JsonDecodeError(
33950 encoded.to_string(),
33951 error,
33952 ));
33953 }
33954 }
33955 };
33956
33957 dlg.finished(true);
33958 return Ok(response);
33959 }
33960 }
33961 }
33962 }
33963
33964 /// Identifier of the invitation to accept.
33965 ///
33966 /// Sets the *id* path property to the given value.
33967 ///
33968 /// Even though the property as already been set when instantiating this call,
33969 /// we provide this method for API completeness.
33970 pub fn id(mut self, new_value: &str) -> InvitationAcceptCall<'a, C> {
33971 self._id = new_value.to_string();
33972 self
33973 }
33974 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33975 /// while executing the actual API request.
33976 ///
33977 /// ````text
33978 /// It should be used to handle progress information, and to implement a certain level of resilience.
33979 /// ````
33980 ///
33981 /// Sets the *delegate* property to the given value.
33982 pub fn delegate(
33983 mut self,
33984 new_value: &'a mut dyn common::Delegate,
33985 ) -> InvitationAcceptCall<'a, C> {
33986 self._delegate = Some(new_value);
33987 self
33988 }
33989
33990 /// Set any additional parameter of the query string used in the request.
33991 /// It should be used to set parameters which are not yet available through their own
33992 /// setters.
33993 ///
33994 /// Please note that this method must not be used to set any of the known parameters
33995 /// which have their own setter method. If done anyway, the request will fail.
33996 ///
33997 /// # Additional Parameters
33998 ///
33999 /// * *$.xgafv* (query-string) - V1 error format.
34000 /// * *access_token* (query-string) - OAuth access token.
34001 /// * *alt* (query-string) - Data format for response.
34002 /// * *callback* (query-string) - JSONP
34003 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34004 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
34005 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34006 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34007 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
34008 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34009 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34010 pub fn param<T>(mut self, name: T, value: T) -> InvitationAcceptCall<'a, C>
34011 where
34012 T: AsRef<str>,
34013 {
34014 self._additional_params
34015 .insert(name.as_ref().to_string(), value.as_ref().to_string());
34016 self
34017 }
34018
34019 /// Identifies the authorization scope for the method you are building.
34020 ///
34021 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34022 /// [`Scope::Roster`].
34023 ///
34024 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34025 /// tokens for more than one scope.
34026 ///
34027 /// Usually there is more than one suitable scope to authorize an operation, some of which may
34028 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34029 /// sufficient, a read-write scope will do as well.
34030 pub fn add_scope<St>(mut self, scope: St) -> InvitationAcceptCall<'a, C>
34031 where
34032 St: AsRef<str>,
34033 {
34034 self._scopes.insert(String::from(scope.as_ref()));
34035 self
34036 }
34037 /// Identifies the authorization scope(s) for the method you are building.
34038 ///
34039 /// See [`Self::add_scope()`] for details.
34040 pub fn add_scopes<I, St>(mut self, scopes: I) -> InvitationAcceptCall<'a, C>
34041 where
34042 I: IntoIterator<Item = St>,
34043 St: AsRef<str>,
34044 {
34045 self._scopes
34046 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34047 self
34048 }
34049
34050 /// Removes all scopes, and no default scope will be used either.
34051 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34052 /// for details).
34053 pub fn clear_scopes(mut self) -> InvitationAcceptCall<'a, C> {
34054 self._scopes.clear();
34055 self
34056 }
34057}
34058
34059/// Creates an invitation. Only one invitation for a user and course may exist at a time. Delete and re-create an invitation to make changes. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create invitations for this course or for access errors. * `NOT_FOUND` if the course or the user does not exist. * `FAILED_PRECONDITION`: * if the requested user's account is disabled. * if the user already has this role or a role with greater permissions. * for the following request errors: * IneligibleOwner * `ALREADY_EXISTS` if an invitation for the specified user and course already exists.
34060///
34061/// A builder for the *create* method supported by a *invitation* resource.
34062/// It is not used directly, but through a [`InvitationMethods`] instance.
34063///
34064/// # Example
34065///
34066/// Instantiate a resource method builder
34067///
34068/// ```test_harness,no_run
34069/// # extern crate hyper;
34070/// # extern crate hyper_rustls;
34071/// # extern crate google_classroom1 as classroom1;
34072/// use classroom1::api::Invitation;
34073/// # async fn dox() {
34074/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34075///
34076/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34077/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34078/// # .with_native_roots()
34079/// # .unwrap()
34080/// # .https_only()
34081/// # .enable_http2()
34082/// # .build();
34083///
34084/// # let executor = hyper_util::rt::TokioExecutor::new();
34085/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34086/// # secret,
34087/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34088/// # yup_oauth2::client::CustomHyperClientBuilder::from(
34089/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
34090/// # ),
34091/// # ).build().await.unwrap();
34092///
34093/// # let client = hyper_util::client::legacy::Client::builder(
34094/// # hyper_util::rt::TokioExecutor::new()
34095/// # )
34096/// # .build(
34097/// # hyper_rustls::HttpsConnectorBuilder::new()
34098/// # .with_native_roots()
34099/// # .unwrap()
34100/// # .https_or_http()
34101/// # .enable_http2()
34102/// # .build()
34103/// # );
34104/// # let mut hub = Classroom::new(client, auth);
34105/// // As the method needs a request, you would usually fill it with the desired information
34106/// // into the respective structure. Some of the parts shown here might not be applicable !
34107/// // Values shown here are possibly random and not representative !
34108/// let mut req = Invitation::default();
34109///
34110/// // You can configure optional parameters by calling the respective setters at will, and
34111/// // execute the final call using `doit()`.
34112/// // Values shown here are possibly random and not representative !
34113/// let result = hub.invitations().create(req)
34114/// .doit().await;
34115/// # }
34116/// ```
34117pub struct InvitationCreateCall<'a, C>
34118where
34119 C: 'a,
34120{
34121 hub: &'a Classroom<C>,
34122 _request: Invitation,
34123 _delegate: Option<&'a mut dyn common::Delegate>,
34124 _additional_params: HashMap<String, String>,
34125 _scopes: BTreeSet<String>,
34126}
34127
34128impl<'a, C> common::CallBuilder for InvitationCreateCall<'a, C> {}
34129
34130impl<'a, C> InvitationCreateCall<'a, C>
34131where
34132 C: common::Connector,
34133{
34134 /// Perform the operation you have build so far.
34135 pub async fn doit(mut self) -> common::Result<(common::Response, Invitation)> {
34136 use std::borrow::Cow;
34137 use std::io::{Read, Seek};
34138
34139 use common::{url::Params, ToParts};
34140 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34141
34142 let mut dd = common::DefaultDelegate;
34143 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34144 dlg.begin(common::MethodInfo {
34145 id: "classroom.invitations.create",
34146 http_method: hyper::Method::POST,
34147 });
34148
34149 for &field in ["alt"].iter() {
34150 if self._additional_params.contains_key(field) {
34151 dlg.finished(false);
34152 return Err(common::Error::FieldClash(field));
34153 }
34154 }
34155
34156 let mut params = Params::with_capacity(3 + self._additional_params.len());
34157
34158 params.extend(self._additional_params.iter());
34159
34160 params.push("alt", "json");
34161 let mut url = self.hub._base_url.clone() + "v1/invitations";
34162 if self._scopes.is_empty() {
34163 self._scopes.insert(Scope::Roster.as_ref().to_string());
34164 }
34165
34166 let url = params.parse_with_url(&url);
34167
34168 let mut json_mime_type = mime::APPLICATION_JSON;
34169 let mut request_value_reader = {
34170 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
34171 common::remove_json_null_values(&mut value);
34172 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
34173 serde_json::to_writer(&mut dst, &value).unwrap();
34174 dst
34175 };
34176 let request_size = request_value_reader
34177 .seek(std::io::SeekFrom::End(0))
34178 .unwrap();
34179 request_value_reader
34180 .seek(std::io::SeekFrom::Start(0))
34181 .unwrap();
34182
34183 loop {
34184 let token = match self
34185 .hub
34186 .auth
34187 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34188 .await
34189 {
34190 Ok(token) => token,
34191 Err(e) => match dlg.token(e) {
34192 Ok(token) => token,
34193 Err(e) => {
34194 dlg.finished(false);
34195 return Err(common::Error::MissingToken(e));
34196 }
34197 },
34198 };
34199 request_value_reader
34200 .seek(std::io::SeekFrom::Start(0))
34201 .unwrap();
34202 let mut req_result = {
34203 let client = &self.hub.client;
34204 dlg.pre_request();
34205 let mut req_builder = hyper::Request::builder()
34206 .method(hyper::Method::POST)
34207 .uri(url.as_str())
34208 .header(USER_AGENT, self.hub._user_agent.clone());
34209
34210 if let Some(token) = token.as_ref() {
34211 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34212 }
34213
34214 let request = req_builder
34215 .header(CONTENT_TYPE, json_mime_type.to_string())
34216 .header(CONTENT_LENGTH, request_size as u64)
34217 .body(common::to_body(
34218 request_value_reader.get_ref().clone().into(),
34219 ));
34220
34221 client.request(request.unwrap()).await
34222 };
34223
34224 match req_result {
34225 Err(err) => {
34226 if let common::Retry::After(d) = dlg.http_error(&err) {
34227 sleep(d).await;
34228 continue;
34229 }
34230 dlg.finished(false);
34231 return Err(common::Error::HttpError(err));
34232 }
34233 Ok(res) => {
34234 let (mut parts, body) = res.into_parts();
34235 let mut body = common::Body::new(body);
34236 if !parts.status.is_success() {
34237 let bytes = common::to_bytes(body).await.unwrap_or_default();
34238 let error = serde_json::from_str(&common::to_string(&bytes));
34239 let response = common::to_response(parts, bytes.into());
34240
34241 if let common::Retry::After(d) =
34242 dlg.http_failure(&response, error.as_ref().ok())
34243 {
34244 sleep(d).await;
34245 continue;
34246 }
34247
34248 dlg.finished(false);
34249
34250 return Err(match error {
34251 Ok(value) => common::Error::BadRequest(value),
34252 _ => common::Error::Failure(response),
34253 });
34254 }
34255 let response = {
34256 let bytes = common::to_bytes(body).await.unwrap_or_default();
34257 let encoded = common::to_string(&bytes);
34258 match serde_json::from_str(&encoded) {
34259 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34260 Err(error) => {
34261 dlg.response_json_decode_error(&encoded, &error);
34262 return Err(common::Error::JsonDecodeError(
34263 encoded.to_string(),
34264 error,
34265 ));
34266 }
34267 }
34268 };
34269
34270 dlg.finished(true);
34271 return Ok(response);
34272 }
34273 }
34274 }
34275 }
34276
34277 ///
34278 /// Sets the *request* property to the given value.
34279 ///
34280 /// Even though the property as already been set when instantiating this call,
34281 /// we provide this method for API completeness.
34282 pub fn request(mut self, new_value: Invitation) -> InvitationCreateCall<'a, C> {
34283 self._request = new_value;
34284 self
34285 }
34286 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34287 /// while executing the actual API request.
34288 ///
34289 /// ````text
34290 /// It should be used to handle progress information, and to implement a certain level of resilience.
34291 /// ````
34292 ///
34293 /// Sets the *delegate* property to the given value.
34294 pub fn delegate(
34295 mut self,
34296 new_value: &'a mut dyn common::Delegate,
34297 ) -> InvitationCreateCall<'a, C> {
34298 self._delegate = Some(new_value);
34299 self
34300 }
34301
34302 /// Set any additional parameter of the query string used in the request.
34303 /// It should be used to set parameters which are not yet available through their own
34304 /// setters.
34305 ///
34306 /// Please note that this method must not be used to set any of the known parameters
34307 /// which have their own setter method. If done anyway, the request will fail.
34308 ///
34309 /// # Additional Parameters
34310 ///
34311 /// * *$.xgafv* (query-string) - V1 error format.
34312 /// * *access_token* (query-string) - OAuth access token.
34313 /// * *alt* (query-string) - Data format for response.
34314 /// * *callback* (query-string) - JSONP
34315 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34316 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
34317 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34318 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34319 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
34320 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34321 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34322 pub fn param<T>(mut self, name: T, value: T) -> InvitationCreateCall<'a, C>
34323 where
34324 T: AsRef<str>,
34325 {
34326 self._additional_params
34327 .insert(name.as_ref().to_string(), value.as_ref().to_string());
34328 self
34329 }
34330
34331 /// Identifies the authorization scope for the method you are building.
34332 ///
34333 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34334 /// [`Scope::Roster`].
34335 ///
34336 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34337 /// tokens for more than one scope.
34338 ///
34339 /// Usually there is more than one suitable scope to authorize an operation, some of which may
34340 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34341 /// sufficient, a read-write scope will do as well.
34342 pub fn add_scope<St>(mut self, scope: St) -> InvitationCreateCall<'a, C>
34343 where
34344 St: AsRef<str>,
34345 {
34346 self._scopes.insert(String::from(scope.as_ref()));
34347 self
34348 }
34349 /// Identifies the authorization scope(s) for the method you are building.
34350 ///
34351 /// See [`Self::add_scope()`] for details.
34352 pub fn add_scopes<I, St>(mut self, scopes: I) -> InvitationCreateCall<'a, C>
34353 where
34354 I: IntoIterator<Item = St>,
34355 St: AsRef<str>,
34356 {
34357 self._scopes
34358 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34359 self
34360 }
34361
34362 /// Removes all scopes, and no default scope will be used either.
34363 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34364 /// for details).
34365 pub fn clear_scopes(mut self) -> InvitationCreateCall<'a, C> {
34366 self._scopes.clear();
34367 self
34368 }
34369}
34370
34371/// Deletes an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete the requested invitation or for access errors. * `NOT_FOUND` if no invitation exists with the requested ID.
34372///
34373/// A builder for the *delete* method supported by a *invitation* resource.
34374/// It is not used directly, but through a [`InvitationMethods`] instance.
34375///
34376/// # Example
34377///
34378/// Instantiate a resource method builder
34379///
34380/// ```test_harness,no_run
34381/// # extern crate hyper;
34382/// # extern crate hyper_rustls;
34383/// # extern crate google_classroom1 as classroom1;
34384/// # async fn dox() {
34385/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34386///
34387/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34388/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34389/// # .with_native_roots()
34390/// # .unwrap()
34391/// # .https_only()
34392/// # .enable_http2()
34393/// # .build();
34394///
34395/// # let executor = hyper_util::rt::TokioExecutor::new();
34396/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34397/// # secret,
34398/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34399/// # yup_oauth2::client::CustomHyperClientBuilder::from(
34400/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
34401/// # ),
34402/// # ).build().await.unwrap();
34403///
34404/// # let client = hyper_util::client::legacy::Client::builder(
34405/// # hyper_util::rt::TokioExecutor::new()
34406/// # )
34407/// # .build(
34408/// # hyper_rustls::HttpsConnectorBuilder::new()
34409/// # .with_native_roots()
34410/// # .unwrap()
34411/// # .https_or_http()
34412/// # .enable_http2()
34413/// # .build()
34414/// # );
34415/// # let mut hub = Classroom::new(client, auth);
34416/// // You can configure optional parameters by calling the respective setters at will, and
34417/// // execute the final call using `doit()`.
34418/// // Values shown here are possibly random and not representative !
34419/// let result = hub.invitations().delete("id")
34420/// .doit().await;
34421/// # }
34422/// ```
34423pub struct InvitationDeleteCall<'a, C>
34424where
34425 C: 'a,
34426{
34427 hub: &'a Classroom<C>,
34428 _id: String,
34429 _delegate: Option<&'a mut dyn common::Delegate>,
34430 _additional_params: HashMap<String, String>,
34431 _scopes: BTreeSet<String>,
34432}
34433
34434impl<'a, C> common::CallBuilder for InvitationDeleteCall<'a, C> {}
34435
34436impl<'a, C> InvitationDeleteCall<'a, C>
34437where
34438 C: common::Connector,
34439{
34440 /// Perform the operation you have build so far.
34441 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
34442 use std::borrow::Cow;
34443 use std::io::{Read, Seek};
34444
34445 use common::{url::Params, ToParts};
34446 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34447
34448 let mut dd = common::DefaultDelegate;
34449 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34450 dlg.begin(common::MethodInfo {
34451 id: "classroom.invitations.delete",
34452 http_method: hyper::Method::DELETE,
34453 });
34454
34455 for &field in ["alt", "id"].iter() {
34456 if self._additional_params.contains_key(field) {
34457 dlg.finished(false);
34458 return Err(common::Error::FieldClash(field));
34459 }
34460 }
34461
34462 let mut params = Params::with_capacity(3 + self._additional_params.len());
34463 params.push("id", self._id);
34464
34465 params.extend(self._additional_params.iter());
34466
34467 params.push("alt", "json");
34468 let mut url = self.hub._base_url.clone() + "v1/invitations/{id}";
34469 if self._scopes.is_empty() {
34470 self._scopes.insert(Scope::Roster.as_ref().to_string());
34471 }
34472
34473 #[allow(clippy::single_element_loop)]
34474 for &(find_this, param_name) in [("{id}", "id")].iter() {
34475 url = params.uri_replacement(url, param_name, find_this, false);
34476 }
34477 {
34478 let to_remove = ["id"];
34479 params.remove_params(&to_remove);
34480 }
34481
34482 let url = params.parse_with_url(&url);
34483
34484 loop {
34485 let token = match self
34486 .hub
34487 .auth
34488 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34489 .await
34490 {
34491 Ok(token) => token,
34492 Err(e) => match dlg.token(e) {
34493 Ok(token) => token,
34494 Err(e) => {
34495 dlg.finished(false);
34496 return Err(common::Error::MissingToken(e));
34497 }
34498 },
34499 };
34500 let mut req_result = {
34501 let client = &self.hub.client;
34502 dlg.pre_request();
34503 let mut req_builder = hyper::Request::builder()
34504 .method(hyper::Method::DELETE)
34505 .uri(url.as_str())
34506 .header(USER_AGENT, self.hub._user_agent.clone());
34507
34508 if let Some(token) = token.as_ref() {
34509 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34510 }
34511
34512 let request = req_builder
34513 .header(CONTENT_LENGTH, 0_u64)
34514 .body(common::to_body::<String>(None));
34515
34516 client.request(request.unwrap()).await
34517 };
34518
34519 match req_result {
34520 Err(err) => {
34521 if let common::Retry::After(d) = dlg.http_error(&err) {
34522 sleep(d).await;
34523 continue;
34524 }
34525 dlg.finished(false);
34526 return Err(common::Error::HttpError(err));
34527 }
34528 Ok(res) => {
34529 let (mut parts, body) = res.into_parts();
34530 let mut body = common::Body::new(body);
34531 if !parts.status.is_success() {
34532 let bytes = common::to_bytes(body).await.unwrap_or_default();
34533 let error = serde_json::from_str(&common::to_string(&bytes));
34534 let response = common::to_response(parts, bytes.into());
34535
34536 if let common::Retry::After(d) =
34537 dlg.http_failure(&response, error.as_ref().ok())
34538 {
34539 sleep(d).await;
34540 continue;
34541 }
34542
34543 dlg.finished(false);
34544
34545 return Err(match error {
34546 Ok(value) => common::Error::BadRequest(value),
34547 _ => common::Error::Failure(response),
34548 });
34549 }
34550 let response = {
34551 let bytes = common::to_bytes(body).await.unwrap_or_default();
34552 let encoded = common::to_string(&bytes);
34553 match serde_json::from_str(&encoded) {
34554 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34555 Err(error) => {
34556 dlg.response_json_decode_error(&encoded, &error);
34557 return Err(common::Error::JsonDecodeError(
34558 encoded.to_string(),
34559 error,
34560 ));
34561 }
34562 }
34563 };
34564
34565 dlg.finished(true);
34566 return Ok(response);
34567 }
34568 }
34569 }
34570 }
34571
34572 /// Identifier of the invitation to delete.
34573 ///
34574 /// Sets the *id* path property to the given value.
34575 ///
34576 /// Even though the property as already been set when instantiating this call,
34577 /// we provide this method for API completeness.
34578 pub fn id(mut self, new_value: &str) -> InvitationDeleteCall<'a, C> {
34579 self._id = new_value.to_string();
34580 self
34581 }
34582 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34583 /// while executing the actual API request.
34584 ///
34585 /// ````text
34586 /// It should be used to handle progress information, and to implement a certain level of resilience.
34587 /// ````
34588 ///
34589 /// Sets the *delegate* property to the given value.
34590 pub fn delegate(
34591 mut self,
34592 new_value: &'a mut dyn common::Delegate,
34593 ) -> InvitationDeleteCall<'a, C> {
34594 self._delegate = Some(new_value);
34595 self
34596 }
34597
34598 /// Set any additional parameter of the query string used in the request.
34599 /// It should be used to set parameters which are not yet available through their own
34600 /// setters.
34601 ///
34602 /// Please note that this method must not be used to set any of the known parameters
34603 /// which have their own setter method. If done anyway, the request will fail.
34604 ///
34605 /// # Additional Parameters
34606 ///
34607 /// * *$.xgafv* (query-string) - V1 error format.
34608 /// * *access_token* (query-string) - OAuth access token.
34609 /// * *alt* (query-string) - Data format for response.
34610 /// * *callback* (query-string) - JSONP
34611 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34612 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
34613 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34614 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34615 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
34616 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34617 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34618 pub fn param<T>(mut self, name: T, value: T) -> InvitationDeleteCall<'a, C>
34619 where
34620 T: AsRef<str>,
34621 {
34622 self._additional_params
34623 .insert(name.as_ref().to_string(), value.as_ref().to_string());
34624 self
34625 }
34626
34627 /// Identifies the authorization scope for the method you are building.
34628 ///
34629 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34630 /// [`Scope::Roster`].
34631 ///
34632 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34633 /// tokens for more than one scope.
34634 ///
34635 /// Usually there is more than one suitable scope to authorize an operation, some of which may
34636 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34637 /// sufficient, a read-write scope will do as well.
34638 pub fn add_scope<St>(mut self, scope: St) -> InvitationDeleteCall<'a, C>
34639 where
34640 St: AsRef<str>,
34641 {
34642 self._scopes.insert(String::from(scope.as_ref()));
34643 self
34644 }
34645 /// Identifies the authorization scope(s) for the method you are building.
34646 ///
34647 /// See [`Self::add_scope()`] for details.
34648 pub fn add_scopes<I, St>(mut self, scopes: I) -> InvitationDeleteCall<'a, C>
34649 where
34650 I: IntoIterator<Item = St>,
34651 St: AsRef<str>,
34652 {
34653 self._scopes
34654 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34655 self
34656 }
34657
34658 /// Removes all scopes, and no default scope will be used either.
34659 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34660 /// for details).
34661 pub fn clear_scopes(mut self) -> InvitationDeleteCall<'a, C> {
34662 self._scopes.clear();
34663 self
34664 }
34665}
34666
34667/// Returns an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view the requested invitation or for access errors. * `NOT_FOUND` if no invitation exists with the requested ID.
34668///
34669/// A builder for the *get* method supported by a *invitation* resource.
34670/// It is not used directly, but through a [`InvitationMethods`] instance.
34671///
34672/// # Example
34673///
34674/// Instantiate a resource method builder
34675///
34676/// ```test_harness,no_run
34677/// # extern crate hyper;
34678/// # extern crate hyper_rustls;
34679/// # extern crate google_classroom1 as classroom1;
34680/// # async fn dox() {
34681/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34682///
34683/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34684/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34685/// # .with_native_roots()
34686/// # .unwrap()
34687/// # .https_only()
34688/// # .enable_http2()
34689/// # .build();
34690///
34691/// # let executor = hyper_util::rt::TokioExecutor::new();
34692/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34693/// # secret,
34694/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34695/// # yup_oauth2::client::CustomHyperClientBuilder::from(
34696/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
34697/// # ),
34698/// # ).build().await.unwrap();
34699///
34700/// # let client = hyper_util::client::legacy::Client::builder(
34701/// # hyper_util::rt::TokioExecutor::new()
34702/// # )
34703/// # .build(
34704/// # hyper_rustls::HttpsConnectorBuilder::new()
34705/// # .with_native_roots()
34706/// # .unwrap()
34707/// # .https_or_http()
34708/// # .enable_http2()
34709/// # .build()
34710/// # );
34711/// # let mut hub = Classroom::new(client, auth);
34712/// // You can configure optional parameters by calling the respective setters at will, and
34713/// // execute the final call using `doit()`.
34714/// // Values shown here are possibly random and not representative !
34715/// let result = hub.invitations().get("id")
34716/// .doit().await;
34717/// # }
34718/// ```
34719pub struct InvitationGetCall<'a, C>
34720where
34721 C: 'a,
34722{
34723 hub: &'a Classroom<C>,
34724 _id: String,
34725 _delegate: Option<&'a mut dyn common::Delegate>,
34726 _additional_params: HashMap<String, String>,
34727 _scopes: BTreeSet<String>,
34728}
34729
34730impl<'a, C> common::CallBuilder for InvitationGetCall<'a, C> {}
34731
34732impl<'a, C> InvitationGetCall<'a, C>
34733where
34734 C: common::Connector,
34735{
34736 /// Perform the operation you have build so far.
34737 pub async fn doit(mut self) -> common::Result<(common::Response, Invitation)> {
34738 use std::borrow::Cow;
34739 use std::io::{Read, Seek};
34740
34741 use common::{url::Params, ToParts};
34742 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34743
34744 let mut dd = common::DefaultDelegate;
34745 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34746 dlg.begin(common::MethodInfo {
34747 id: "classroom.invitations.get",
34748 http_method: hyper::Method::GET,
34749 });
34750
34751 for &field in ["alt", "id"].iter() {
34752 if self._additional_params.contains_key(field) {
34753 dlg.finished(false);
34754 return Err(common::Error::FieldClash(field));
34755 }
34756 }
34757
34758 let mut params = Params::with_capacity(3 + self._additional_params.len());
34759 params.push("id", self._id);
34760
34761 params.extend(self._additional_params.iter());
34762
34763 params.push("alt", "json");
34764 let mut url = self.hub._base_url.clone() + "v1/invitations/{id}";
34765 if self._scopes.is_empty() {
34766 self._scopes
34767 .insert(Scope::RosterReadonly.as_ref().to_string());
34768 }
34769
34770 #[allow(clippy::single_element_loop)]
34771 for &(find_this, param_name) in [("{id}", "id")].iter() {
34772 url = params.uri_replacement(url, param_name, find_this, false);
34773 }
34774 {
34775 let to_remove = ["id"];
34776 params.remove_params(&to_remove);
34777 }
34778
34779 let url = params.parse_with_url(&url);
34780
34781 loop {
34782 let token = match self
34783 .hub
34784 .auth
34785 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34786 .await
34787 {
34788 Ok(token) => token,
34789 Err(e) => match dlg.token(e) {
34790 Ok(token) => token,
34791 Err(e) => {
34792 dlg.finished(false);
34793 return Err(common::Error::MissingToken(e));
34794 }
34795 },
34796 };
34797 let mut req_result = {
34798 let client = &self.hub.client;
34799 dlg.pre_request();
34800 let mut req_builder = hyper::Request::builder()
34801 .method(hyper::Method::GET)
34802 .uri(url.as_str())
34803 .header(USER_AGENT, self.hub._user_agent.clone());
34804
34805 if let Some(token) = token.as_ref() {
34806 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34807 }
34808
34809 let request = req_builder
34810 .header(CONTENT_LENGTH, 0_u64)
34811 .body(common::to_body::<String>(None));
34812
34813 client.request(request.unwrap()).await
34814 };
34815
34816 match req_result {
34817 Err(err) => {
34818 if let common::Retry::After(d) = dlg.http_error(&err) {
34819 sleep(d).await;
34820 continue;
34821 }
34822 dlg.finished(false);
34823 return Err(common::Error::HttpError(err));
34824 }
34825 Ok(res) => {
34826 let (mut parts, body) = res.into_parts();
34827 let mut body = common::Body::new(body);
34828 if !parts.status.is_success() {
34829 let bytes = common::to_bytes(body).await.unwrap_or_default();
34830 let error = serde_json::from_str(&common::to_string(&bytes));
34831 let response = common::to_response(parts, bytes.into());
34832
34833 if let common::Retry::After(d) =
34834 dlg.http_failure(&response, error.as_ref().ok())
34835 {
34836 sleep(d).await;
34837 continue;
34838 }
34839
34840 dlg.finished(false);
34841
34842 return Err(match error {
34843 Ok(value) => common::Error::BadRequest(value),
34844 _ => common::Error::Failure(response),
34845 });
34846 }
34847 let response = {
34848 let bytes = common::to_bytes(body).await.unwrap_or_default();
34849 let encoded = common::to_string(&bytes);
34850 match serde_json::from_str(&encoded) {
34851 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34852 Err(error) => {
34853 dlg.response_json_decode_error(&encoded, &error);
34854 return Err(common::Error::JsonDecodeError(
34855 encoded.to_string(),
34856 error,
34857 ));
34858 }
34859 }
34860 };
34861
34862 dlg.finished(true);
34863 return Ok(response);
34864 }
34865 }
34866 }
34867 }
34868
34869 /// Identifier of the invitation to return.
34870 ///
34871 /// Sets the *id* path property to the given value.
34872 ///
34873 /// Even though the property as already been set when instantiating this call,
34874 /// we provide this method for API completeness.
34875 pub fn id(mut self, new_value: &str) -> InvitationGetCall<'a, C> {
34876 self._id = new_value.to_string();
34877 self
34878 }
34879 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34880 /// while executing the actual API request.
34881 ///
34882 /// ````text
34883 /// It should be used to handle progress information, and to implement a certain level of resilience.
34884 /// ````
34885 ///
34886 /// Sets the *delegate* property to the given value.
34887 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> InvitationGetCall<'a, C> {
34888 self._delegate = Some(new_value);
34889 self
34890 }
34891
34892 /// Set any additional parameter of the query string used in the request.
34893 /// It should be used to set parameters which are not yet available through their own
34894 /// setters.
34895 ///
34896 /// Please note that this method must not be used to set any of the known parameters
34897 /// which have their own setter method. If done anyway, the request will fail.
34898 ///
34899 /// # Additional Parameters
34900 ///
34901 /// * *$.xgafv* (query-string) - V1 error format.
34902 /// * *access_token* (query-string) - OAuth access token.
34903 /// * *alt* (query-string) - Data format for response.
34904 /// * *callback* (query-string) - JSONP
34905 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34906 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
34907 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34908 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34909 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
34910 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34911 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34912 pub fn param<T>(mut self, name: T, value: T) -> InvitationGetCall<'a, C>
34913 where
34914 T: AsRef<str>,
34915 {
34916 self._additional_params
34917 .insert(name.as_ref().to_string(), value.as_ref().to_string());
34918 self
34919 }
34920
34921 /// Identifies the authorization scope for the method you are building.
34922 ///
34923 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34924 /// [`Scope::RosterReadonly`].
34925 ///
34926 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34927 /// tokens for more than one scope.
34928 ///
34929 /// Usually there is more than one suitable scope to authorize an operation, some of which may
34930 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34931 /// sufficient, a read-write scope will do as well.
34932 pub fn add_scope<St>(mut self, scope: St) -> InvitationGetCall<'a, C>
34933 where
34934 St: AsRef<str>,
34935 {
34936 self._scopes.insert(String::from(scope.as_ref()));
34937 self
34938 }
34939 /// Identifies the authorization scope(s) for the method you are building.
34940 ///
34941 /// See [`Self::add_scope()`] for details.
34942 pub fn add_scopes<I, St>(mut self, scopes: I) -> InvitationGetCall<'a, C>
34943 where
34944 I: IntoIterator<Item = St>,
34945 St: AsRef<str>,
34946 {
34947 self._scopes
34948 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34949 self
34950 }
34951
34952 /// Removes all scopes, and no default scope will be used either.
34953 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34954 /// for details).
34955 pub fn clear_scopes(mut self) -> InvitationGetCall<'a, C> {
34956 self._scopes.clear();
34957 self
34958 }
34959}
34960
34961/// Returns a list of invitations that the requesting user is permitted to view, restricted to those that match the list request. *Note:* At least one of `user_id` or `course_id` must be supplied. Both fields can be supplied. This method returns the following error codes: * `PERMISSION_DENIED` for access errors.
34962///
34963/// A builder for the *list* method supported by a *invitation* resource.
34964/// It is not used directly, but through a [`InvitationMethods`] instance.
34965///
34966/// # Example
34967///
34968/// Instantiate a resource method builder
34969///
34970/// ```test_harness,no_run
34971/// # extern crate hyper;
34972/// # extern crate hyper_rustls;
34973/// # extern crate google_classroom1 as classroom1;
34974/// # async fn dox() {
34975/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34976///
34977/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34978/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34979/// # .with_native_roots()
34980/// # .unwrap()
34981/// # .https_only()
34982/// # .enable_http2()
34983/// # .build();
34984///
34985/// # let executor = hyper_util::rt::TokioExecutor::new();
34986/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34987/// # secret,
34988/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34989/// # yup_oauth2::client::CustomHyperClientBuilder::from(
34990/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
34991/// # ),
34992/// # ).build().await.unwrap();
34993///
34994/// # let client = hyper_util::client::legacy::Client::builder(
34995/// # hyper_util::rt::TokioExecutor::new()
34996/// # )
34997/// # .build(
34998/// # hyper_rustls::HttpsConnectorBuilder::new()
34999/// # .with_native_roots()
35000/// # .unwrap()
35001/// # .https_or_http()
35002/// # .enable_http2()
35003/// # .build()
35004/// # );
35005/// # let mut hub = Classroom::new(client, auth);
35006/// // You can configure optional parameters by calling the respective setters at will, and
35007/// // execute the final call using `doit()`.
35008/// // Values shown here are possibly random and not representative !
35009/// let result = hub.invitations().list()
35010/// .user_id("justo")
35011/// .page_token("ipsum")
35012/// .page_size(-73)
35013/// .course_id("dolores")
35014/// .doit().await;
35015/// # }
35016/// ```
35017pub struct InvitationListCall<'a, C>
35018where
35019 C: 'a,
35020{
35021 hub: &'a Classroom<C>,
35022 _user_id: Option<String>,
35023 _page_token: Option<String>,
35024 _page_size: Option<i32>,
35025 _course_id: Option<String>,
35026 _delegate: Option<&'a mut dyn common::Delegate>,
35027 _additional_params: HashMap<String, String>,
35028 _scopes: BTreeSet<String>,
35029}
35030
35031impl<'a, C> common::CallBuilder for InvitationListCall<'a, C> {}
35032
35033impl<'a, C> InvitationListCall<'a, C>
35034where
35035 C: common::Connector,
35036{
35037 /// Perform the operation you have build so far.
35038 pub async fn doit(mut self) -> common::Result<(common::Response, ListInvitationsResponse)> {
35039 use std::borrow::Cow;
35040 use std::io::{Read, Seek};
35041
35042 use common::{url::Params, ToParts};
35043 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35044
35045 let mut dd = common::DefaultDelegate;
35046 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35047 dlg.begin(common::MethodInfo {
35048 id: "classroom.invitations.list",
35049 http_method: hyper::Method::GET,
35050 });
35051
35052 for &field in ["alt", "userId", "pageToken", "pageSize", "courseId"].iter() {
35053 if self._additional_params.contains_key(field) {
35054 dlg.finished(false);
35055 return Err(common::Error::FieldClash(field));
35056 }
35057 }
35058
35059 let mut params = Params::with_capacity(6 + self._additional_params.len());
35060 if let Some(value) = self._user_id.as_ref() {
35061 params.push("userId", value);
35062 }
35063 if let Some(value) = self._page_token.as_ref() {
35064 params.push("pageToken", value);
35065 }
35066 if let Some(value) = self._page_size.as_ref() {
35067 params.push("pageSize", value.to_string());
35068 }
35069 if let Some(value) = self._course_id.as_ref() {
35070 params.push("courseId", value);
35071 }
35072
35073 params.extend(self._additional_params.iter());
35074
35075 params.push("alt", "json");
35076 let mut url = self.hub._base_url.clone() + "v1/invitations";
35077 if self._scopes.is_empty() {
35078 self._scopes
35079 .insert(Scope::RosterReadonly.as_ref().to_string());
35080 }
35081
35082 let url = params.parse_with_url(&url);
35083
35084 loop {
35085 let token = match self
35086 .hub
35087 .auth
35088 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35089 .await
35090 {
35091 Ok(token) => token,
35092 Err(e) => match dlg.token(e) {
35093 Ok(token) => token,
35094 Err(e) => {
35095 dlg.finished(false);
35096 return Err(common::Error::MissingToken(e));
35097 }
35098 },
35099 };
35100 let mut req_result = {
35101 let client = &self.hub.client;
35102 dlg.pre_request();
35103 let mut req_builder = hyper::Request::builder()
35104 .method(hyper::Method::GET)
35105 .uri(url.as_str())
35106 .header(USER_AGENT, self.hub._user_agent.clone());
35107
35108 if let Some(token) = token.as_ref() {
35109 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35110 }
35111
35112 let request = req_builder
35113 .header(CONTENT_LENGTH, 0_u64)
35114 .body(common::to_body::<String>(None));
35115
35116 client.request(request.unwrap()).await
35117 };
35118
35119 match req_result {
35120 Err(err) => {
35121 if let common::Retry::After(d) = dlg.http_error(&err) {
35122 sleep(d).await;
35123 continue;
35124 }
35125 dlg.finished(false);
35126 return Err(common::Error::HttpError(err));
35127 }
35128 Ok(res) => {
35129 let (mut parts, body) = res.into_parts();
35130 let mut body = common::Body::new(body);
35131 if !parts.status.is_success() {
35132 let bytes = common::to_bytes(body).await.unwrap_or_default();
35133 let error = serde_json::from_str(&common::to_string(&bytes));
35134 let response = common::to_response(parts, bytes.into());
35135
35136 if let common::Retry::After(d) =
35137 dlg.http_failure(&response, error.as_ref().ok())
35138 {
35139 sleep(d).await;
35140 continue;
35141 }
35142
35143 dlg.finished(false);
35144
35145 return Err(match error {
35146 Ok(value) => common::Error::BadRequest(value),
35147 _ => common::Error::Failure(response),
35148 });
35149 }
35150 let response = {
35151 let bytes = common::to_bytes(body).await.unwrap_or_default();
35152 let encoded = common::to_string(&bytes);
35153 match serde_json::from_str(&encoded) {
35154 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35155 Err(error) => {
35156 dlg.response_json_decode_error(&encoded, &error);
35157 return Err(common::Error::JsonDecodeError(
35158 encoded.to_string(),
35159 error,
35160 ));
35161 }
35162 }
35163 };
35164
35165 dlg.finished(true);
35166 return Ok(response);
35167 }
35168 }
35169 }
35170 }
35171
35172 /// Restricts returned invitations to those for a specific user. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
35173 ///
35174 /// Sets the *user id* query property to the given value.
35175 pub fn user_id(mut self, new_value: &str) -> InvitationListCall<'a, C> {
35176 self._user_id = Some(new_value.to_string());
35177 self
35178 }
35179 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
35180 ///
35181 /// Sets the *page token* query property to the given value.
35182 pub fn page_token(mut self, new_value: &str) -> InvitationListCall<'a, C> {
35183 self._page_token = Some(new_value.to_string());
35184 self
35185 }
35186 /// Maximum number of items to return. The default is 500 if unspecified or `0`. The server may return fewer than the specified number of results.
35187 ///
35188 /// Sets the *page size* query property to the given value.
35189 pub fn page_size(mut self, new_value: i32) -> InvitationListCall<'a, C> {
35190 self._page_size = Some(new_value);
35191 self
35192 }
35193 /// Restricts returned invitations to those for a course with the specified identifier.
35194 ///
35195 /// Sets the *course id* query property to the given value.
35196 pub fn course_id(mut self, new_value: &str) -> InvitationListCall<'a, C> {
35197 self._course_id = Some(new_value.to_string());
35198 self
35199 }
35200 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35201 /// while executing the actual API request.
35202 ///
35203 /// ````text
35204 /// It should be used to handle progress information, and to implement a certain level of resilience.
35205 /// ````
35206 ///
35207 /// Sets the *delegate* property to the given value.
35208 pub fn delegate(
35209 mut self,
35210 new_value: &'a mut dyn common::Delegate,
35211 ) -> InvitationListCall<'a, C> {
35212 self._delegate = Some(new_value);
35213 self
35214 }
35215
35216 /// Set any additional parameter of the query string used in the request.
35217 /// It should be used to set parameters which are not yet available through their own
35218 /// setters.
35219 ///
35220 /// Please note that this method must not be used to set any of the known parameters
35221 /// which have their own setter method. If done anyway, the request will fail.
35222 ///
35223 /// # Additional Parameters
35224 ///
35225 /// * *$.xgafv* (query-string) - V1 error format.
35226 /// * *access_token* (query-string) - OAuth access token.
35227 /// * *alt* (query-string) - Data format for response.
35228 /// * *callback* (query-string) - JSONP
35229 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35230 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
35231 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35232 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35233 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
35234 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
35235 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
35236 pub fn param<T>(mut self, name: T, value: T) -> InvitationListCall<'a, C>
35237 where
35238 T: AsRef<str>,
35239 {
35240 self._additional_params
35241 .insert(name.as_ref().to_string(), value.as_ref().to_string());
35242 self
35243 }
35244
35245 /// Identifies the authorization scope for the method you are building.
35246 ///
35247 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35248 /// [`Scope::RosterReadonly`].
35249 ///
35250 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35251 /// tokens for more than one scope.
35252 ///
35253 /// Usually there is more than one suitable scope to authorize an operation, some of which may
35254 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35255 /// sufficient, a read-write scope will do as well.
35256 pub fn add_scope<St>(mut self, scope: St) -> InvitationListCall<'a, C>
35257 where
35258 St: AsRef<str>,
35259 {
35260 self._scopes.insert(String::from(scope.as_ref()));
35261 self
35262 }
35263 /// Identifies the authorization scope(s) for the method you are building.
35264 ///
35265 /// See [`Self::add_scope()`] for details.
35266 pub fn add_scopes<I, St>(mut self, scopes: I) -> InvitationListCall<'a, C>
35267 where
35268 I: IntoIterator<Item = St>,
35269 St: AsRef<str>,
35270 {
35271 self._scopes
35272 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35273 self
35274 }
35275
35276 /// Removes all scopes, and no default scope will be used either.
35277 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35278 /// for details).
35279 pub fn clear_scopes(mut self) -> InvitationListCall<'a, C> {
35280 self._scopes.clear();
35281 self
35282 }
35283}
35284
35285/// Creates a `Registration`, causing Classroom to start sending notifications from the provided `feed` to the destination provided in `cloudPubSubTopic`. Returns the created `Registration`. Currently, this will be the same as the argument, but with server-assigned fields such as `expiry_time` and `id` filled in. Note that any value specified for the `expiry_time` or `id` fields will be ignored. While Classroom may validate the `cloudPubSubTopic` and return errors on a best effort basis, it is the caller's responsibility to ensure that it exists and that Classroom has permission to publish to it. This method may return the following error codes: * `PERMISSION_DENIED` if: * the authenticated user does not have permission to receive notifications from the requested field; or * the current user has not granted access to the current Cloud project with the appropriate scope for the requested feed. Note that domain-wide delegation of authority is not currently supported for this purpose. If the request has the appropriate scope, but no grant exists, a Request Errors is returned. * another access error is encountered. * `INVALID_ARGUMENT` if: * no `cloudPubsubTopic` is specified, or the specified `cloudPubsubTopic` is not valid; or * no `feed` is specified, or the specified `feed` is not valid. * `NOT_FOUND` if: * the specified `feed` cannot be located, or the requesting user does not have permission to determine whether or not it exists; or * the specified `cloudPubsubTopic` cannot be located, or Classroom has not been granted permission to publish to it.
35286///
35287/// A builder for the *create* method supported by a *registration* resource.
35288/// It is not used directly, but through a [`RegistrationMethods`] instance.
35289///
35290/// # Example
35291///
35292/// Instantiate a resource method builder
35293///
35294/// ```test_harness,no_run
35295/// # extern crate hyper;
35296/// # extern crate hyper_rustls;
35297/// # extern crate google_classroom1 as classroom1;
35298/// use classroom1::api::Registration;
35299/// # async fn dox() {
35300/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35301///
35302/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35303/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
35304/// # .with_native_roots()
35305/// # .unwrap()
35306/// # .https_only()
35307/// # .enable_http2()
35308/// # .build();
35309///
35310/// # let executor = hyper_util::rt::TokioExecutor::new();
35311/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
35312/// # secret,
35313/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35314/// # yup_oauth2::client::CustomHyperClientBuilder::from(
35315/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
35316/// # ),
35317/// # ).build().await.unwrap();
35318///
35319/// # let client = hyper_util::client::legacy::Client::builder(
35320/// # hyper_util::rt::TokioExecutor::new()
35321/// # )
35322/// # .build(
35323/// # hyper_rustls::HttpsConnectorBuilder::new()
35324/// # .with_native_roots()
35325/// # .unwrap()
35326/// # .https_or_http()
35327/// # .enable_http2()
35328/// # .build()
35329/// # );
35330/// # let mut hub = Classroom::new(client, auth);
35331/// // As the method needs a request, you would usually fill it with the desired information
35332/// // into the respective structure. Some of the parts shown here might not be applicable !
35333/// // Values shown here are possibly random and not representative !
35334/// let mut req = Registration::default();
35335///
35336/// // You can configure optional parameters by calling the respective setters at will, and
35337/// // execute the final call using `doit()`.
35338/// // Values shown here are possibly random and not representative !
35339/// let result = hub.registrations().create(req)
35340/// .doit().await;
35341/// # }
35342/// ```
35343pub struct RegistrationCreateCall<'a, C>
35344where
35345 C: 'a,
35346{
35347 hub: &'a Classroom<C>,
35348 _request: Registration,
35349 _delegate: Option<&'a mut dyn common::Delegate>,
35350 _additional_params: HashMap<String, String>,
35351 _scopes: BTreeSet<String>,
35352}
35353
35354impl<'a, C> common::CallBuilder for RegistrationCreateCall<'a, C> {}
35355
35356impl<'a, C> RegistrationCreateCall<'a, C>
35357where
35358 C: common::Connector,
35359{
35360 /// Perform the operation you have build so far.
35361 pub async fn doit(mut self) -> common::Result<(common::Response, Registration)> {
35362 use std::borrow::Cow;
35363 use std::io::{Read, Seek};
35364
35365 use common::{url::Params, ToParts};
35366 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35367
35368 let mut dd = common::DefaultDelegate;
35369 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35370 dlg.begin(common::MethodInfo {
35371 id: "classroom.registrations.create",
35372 http_method: hyper::Method::POST,
35373 });
35374
35375 for &field in ["alt"].iter() {
35376 if self._additional_params.contains_key(field) {
35377 dlg.finished(false);
35378 return Err(common::Error::FieldClash(field));
35379 }
35380 }
35381
35382 let mut params = Params::with_capacity(3 + self._additional_params.len());
35383
35384 params.extend(self._additional_params.iter());
35385
35386 params.push("alt", "json");
35387 let mut url = self.hub._base_url.clone() + "v1/registrations";
35388 if self._scopes.is_empty() {
35389 self._scopes
35390 .insert(Scope::PushNotification.as_ref().to_string());
35391 }
35392
35393 let url = params.parse_with_url(&url);
35394
35395 let mut json_mime_type = mime::APPLICATION_JSON;
35396 let mut request_value_reader = {
35397 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
35398 common::remove_json_null_values(&mut value);
35399 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
35400 serde_json::to_writer(&mut dst, &value).unwrap();
35401 dst
35402 };
35403 let request_size = request_value_reader
35404 .seek(std::io::SeekFrom::End(0))
35405 .unwrap();
35406 request_value_reader
35407 .seek(std::io::SeekFrom::Start(0))
35408 .unwrap();
35409
35410 loop {
35411 let token = match self
35412 .hub
35413 .auth
35414 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35415 .await
35416 {
35417 Ok(token) => token,
35418 Err(e) => match dlg.token(e) {
35419 Ok(token) => token,
35420 Err(e) => {
35421 dlg.finished(false);
35422 return Err(common::Error::MissingToken(e));
35423 }
35424 },
35425 };
35426 request_value_reader
35427 .seek(std::io::SeekFrom::Start(0))
35428 .unwrap();
35429 let mut req_result = {
35430 let client = &self.hub.client;
35431 dlg.pre_request();
35432 let mut req_builder = hyper::Request::builder()
35433 .method(hyper::Method::POST)
35434 .uri(url.as_str())
35435 .header(USER_AGENT, self.hub._user_agent.clone());
35436
35437 if let Some(token) = token.as_ref() {
35438 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35439 }
35440
35441 let request = req_builder
35442 .header(CONTENT_TYPE, json_mime_type.to_string())
35443 .header(CONTENT_LENGTH, request_size as u64)
35444 .body(common::to_body(
35445 request_value_reader.get_ref().clone().into(),
35446 ));
35447
35448 client.request(request.unwrap()).await
35449 };
35450
35451 match req_result {
35452 Err(err) => {
35453 if let common::Retry::After(d) = dlg.http_error(&err) {
35454 sleep(d).await;
35455 continue;
35456 }
35457 dlg.finished(false);
35458 return Err(common::Error::HttpError(err));
35459 }
35460 Ok(res) => {
35461 let (mut parts, body) = res.into_parts();
35462 let mut body = common::Body::new(body);
35463 if !parts.status.is_success() {
35464 let bytes = common::to_bytes(body).await.unwrap_or_default();
35465 let error = serde_json::from_str(&common::to_string(&bytes));
35466 let response = common::to_response(parts, bytes.into());
35467
35468 if let common::Retry::After(d) =
35469 dlg.http_failure(&response, error.as_ref().ok())
35470 {
35471 sleep(d).await;
35472 continue;
35473 }
35474
35475 dlg.finished(false);
35476
35477 return Err(match error {
35478 Ok(value) => common::Error::BadRequest(value),
35479 _ => common::Error::Failure(response),
35480 });
35481 }
35482 let response = {
35483 let bytes = common::to_bytes(body).await.unwrap_or_default();
35484 let encoded = common::to_string(&bytes);
35485 match serde_json::from_str(&encoded) {
35486 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35487 Err(error) => {
35488 dlg.response_json_decode_error(&encoded, &error);
35489 return Err(common::Error::JsonDecodeError(
35490 encoded.to_string(),
35491 error,
35492 ));
35493 }
35494 }
35495 };
35496
35497 dlg.finished(true);
35498 return Ok(response);
35499 }
35500 }
35501 }
35502 }
35503
35504 ///
35505 /// Sets the *request* property to the given value.
35506 ///
35507 /// Even though the property as already been set when instantiating this call,
35508 /// we provide this method for API completeness.
35509 pub fn request(mut self, new_value: Registration) -> RegistrationCreateCall<'a, C> {
35510 self._request = new_value;
35511 self
35512 }
35513 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35514 /// while executing the actual API request.
35515 ///
35516 /// ````text
35517 /// It should be used to handle progress information, and to implement a certain level of resilience.
35518 /// ````
35519 ///
35520 /// Sets the *delegate* property to the given value.
35521 pub fn delegate(
35522 mut self,
35523 new_value: &'a mut dyn common::Delegate,
35524 ) -> RegistrationCreateCall<'a, C> {
35525 self._delegate = Some(new_value);
35526 self
35527 }
35528
35529 /// Set any additional parameter of the query string used in the request.
35530 /// It should be used to set parameters which are not yet available through their own
35531 /// setters.
35532 ///
35533 /// Please note that this method must not be used to set any of the known parameters
35534 /// which have their own setter method. If done anyway, the request will fail.
35535 ///
35536 /// # Additional Parameters
35537 ///
35538 /// * *$.xgafv* (query-string) - V1 error format.
35539 /// * *access_token* (query-string) - OAuth access token.
35540 /// * *alt* (query-string) - Data format for response.
35541 /// * *callback* (query-string) - JSONP
35542 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35543 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
35544 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35545 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35546 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
35547 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
35548 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
35549 pub fn param<T>(mut self, name: T, value: T) -> RegistrationCreateCall<'a, C>
35550 where
35551 T: AsRef<str>,
35552 {
35553 self._additional_params
35554 .insert(name.as_ref().to_string(), value.as_ref().to_string());
35555 self
35556 }
35557
35558 /// Identifies the authorization scope for the method you are building.
35559 ///
35560 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35561 /// [`Scope::PushNotification`].
35562 ///
35563 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35564 /// tokens for more than one scope.
35565 ///
35566 /// Usually there is more than one suitable scope to authorize an operation, some of which may
35567 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35568 /// sufficient, a read-write scope will do as well.
35569 pub fn add_scope<St>(mut self, scope: St) -> RegistrationCreateCall<'a, C>
35570 where
35571 St: AsRef<str>,
35572 {
35573 self._scopes.insert(String::from(scope.as_ref()));
35574 self
35575 }
35576 /// Identifies the authorization scope(s) for the method you are building.
35577 ///
35578 /// See [`Self::add_scope()`] for details.
35579 pub fn add_scopes<I, St>(mut self, scopes: I) -> RegistrationCreateCall<'a, C>
35580 where
35581 I: IntoIterator<Item = St>,
35582 St: AsRef<str>,
35583 {
35584 self._scopes
35585 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35586 self
35587 }
35588
35589 /// Removes all scopes, and no default scope will be used either.
35590 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35591 /// for details).
35592 pub fn clear_scopes(mut self) -> RegistrationCreateCall<'a, C> {
35593 self._scopes.clear();
35594 self
35595 }
35596}
35597
35598/// Deletes a `Registration`, causing Classroom to stop sending notifications for that `Registration`.
35599///
35600/// A builder for the *delete* method supported by a *registration* resource.
35601/// It is not used directly, but through a [`RegistrationMethods`] instance.
35602///
35603/// # Example
35604///
35605/// Instantiate a resource method builder
35606///
35607/// ```test_harness,no_run
35608/// # extern crate hyper;
35609/// # extern crate hyper_rustls;
35610/// # extern crate google_classroom1 as classroom1;
35611/// # async fn dox() {
35612/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35613///
35614/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35615/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
35616/// # .with_native_roots()
35617/// # .unwrap()
35618/// # .https_only()
35619/// # .enable_http2()
35620/// # .build();
35621///
35622/// # let executor = hyper_util::rt::TokioExecutor::new();
35623/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
35624/// # secret,
35625/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35626/// # yup_oauth2::client::CustomHyperClientBuilder::from(
35627/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
35628/// # ),
35629/// # ).build().await.unwrap();
35630///
35631/// # let client = hyper_util::client::legacy::Client::builder(
35632/// # hyper_util::rt::TokioExecutor::new()
35633/// # )
35634/// # .build(
35635/// # hyper_rustls::HttpsConnectorBuilder::new()
35636/// # .with_native_roots()
35637/// # .unwrap()
35638/// # .https_or_http()
35639/// # .enable_http2()
35640/// # .build()
35641/// # );
35642/// # let mut hub = Classroom::new(client, auth);
35643/// // You can configure optional parameters by calling the respective setters at will, and
35644/// // execute the final call using `doit()`.
35645/// // Values shown here are possibly random and not representative !
35646/// let result = hub.registrations().delete("registrationId")
35647/// .doit().await;
35648/// # }
35649/// ```
35650pub struct RegistrationDeleteCall<'a, C>
35651where
35652 C: 'a,
35653{
35654 hub: &'a Classroom<C>,
35655 _registration_id: String,
35656 _delegate: Option<&'a mut dyn common::Delegate>,
35657 _additional_params: HashMap<String, String>,
35658 _scopes: BTreeSet<String>,
35659}
35660
35661impl<'a, C> common::CallBuilder for RegistrationDeleteCall<'a, C> {}
35662
35663impl<'a, C> RegistrationDeleteCall<'a, C>
35664where
35665 C: common::Connector,
35666{
35667 /// Perform the operation you have build so far.
35668 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
35669 use std::borrow::Cow;
35670 use std::io::{Read, Seek};
35671
35672 use common::{url::Params, ToParts};
35673 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35674
35675 let mut dd = common::DefaultDelegate;
35676 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35677 dlg.begin(common::MethodInfo {
35678 id: "classroom.registrations.delete",
35679 http_method: hyper::Method::DELETE,
35680 });
35681
35682 for &field in ["alt", "registrationId"].iter() {
35683 if self._additional_params.contains_key(field) {
35684 dlg.finished(false);
35685 return Err(common::Error::FieldClash(field));
35686 }
35687 }
35688
35689 let mut params = Params::with_capacity(3 + self._additional_params.len());
35690 params.push("registrationId", self._registration_id);
35691
35692 params.extend(self._additional_params.iter());
35693
35694 params.push("alt", "json");
35695 let mut url = self.hub._base_url.clone() + "v1/registrations/{registrationId}";
35696 if self._scopes.is_empty() {
35697 self._scopes
35698 .insert(Scope::PushNotification.as_ref().to_string());
35699 }
35700
35701 #[allow(clippy::single_element_loop)]
35702 for &(find_this, param_name) in [("{registrationId}", "registrationId")].iter() {
35703 url = params.uri_replacement(url, param_name, find_this, false);
35704 }
35705 {
35706 let to_remove = ["registrationId"];
35707 params.remove_params(&to_remove);
35708 }
35709
35710 let url = params.parse_with_url(&url);
35711
35712 loop {
35713 let token = match self
35714 .hub
35715 .auth
35716 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35717 .await
35718 {
35719 Ok(token) => token,
35720 Err(e) => match dlg.token(e) {
35721 Ok(token) => token,
35722 Err(e) => {
35723 dlg.finished(false);
35724 return Err(common::Error::MissingToken(e));
35725 }
35726 },
35727 };
35728 let mut req_result = {
35729 let client = &self.hub.client;
35730 dlg.pre_request();
35731 let mut req_builder = hyper::Request::builder()
35732 .method(hyper::Method::DELETE)
35733 .uri(url.as_str())
35734 .header(USER_AGENT, self.hub._user_agent.clone());
35735
35736 if let Some(token) = token.as_ref() {
35737 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35738 }
35739
35740 let request = req_builder
35741 .header(CONTENT_LENGTH, 0_u64)
35742 .body(common::to_body::<String>(None));
35743
35744 client.request(request.unwrap()).await
35745 };
35746
35747 match req_result {
35748 Err(err) => {
35749 if let common::Retry::After(d) = dlg.http_error(&err) {
35750 sleep(d).await;
35751 continue;
35752 }
35753 dlg.finished(false);
35754 return Err(common::Error::HttpError(err));
35755 }
35756 Ok(res) => {
35757 let (mut parts, body) = res.into_parts();
35758 let mut body = common::Body::new(body);
35759 if !parts.status.is_success() {
35760 let bytes = common::to_bytes(body).await.unwrap_or_default();
35761 let error = serde_json::from_str(&common::to_string(&bytes));
35762 let response = common::to_response(parts, bytes.into());
35763
35764 if let common::Retry::After(d) =
35765 dlg.http_failure(&response, error.as_ref().ok())
35766 {
35767 sleep(d).await;
35768 continue;
35769 }
35770
35771 dlg.finished(false);
35772
35773 return Err(match error {
35774 Ok(value) => common::Error::BadRequest(value),
35775 _ => common::Error::Failure(response),
35776 });
35777 }
35778 let response = {
35779 let bytes = common::to_bytes(body).await.unwrap_or_default();
35780 let encoded = common::to_string(&bytes);
35781 match serde_json::from_str(&encoded) {
35782 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35783 Err(error) => {
35784 dlg.response_json_decode_error(&encoded, &error);
35785 return Err(common::Error::JsonDecodeError(
35786 encoded.to_string(),
35787 error,
35788 ));
35789 }
35790 }
35791 };
35792
35793 dlg.finished(true);
35794 return Ok(response);
35795 }
35796 }
35797 }
35798 }
35799
35800 /// The `registration_id` of the `Registration` to be deleted.
35801 ///
35802 /// Sets the *registration id* path property to the given value.
35803 ///
35804 /// Even though the property as already been set when instantiating this call,
35805 /// we provide this method for API completeness.
35806 pub fn registration_id(mut self, new_value: &str) -> RegistrationDeleteCall<'a, C> {
35807 self._registration_id = new_value.to_string();
35808 self
35809 }
35810 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35811 /// while executing the actual API request.
35812 ///
35813 /// ````text
35814 /// It should be used to handle progress information, and to implement a certain level of resilience.
35815 /// ````
35816 ///
35817 /// Sets the *delegate* property to the given value.
35818 pub fn delegate(
35819 mut self,
35820 new_value: &'a mut dyn common::Delegate,
35821 ) -> RegistrationDeleteCall<'a, C> {
35822 self._delegate = Some(new_value);
35823 self
35824 }
35825
35826 /// Set any additional parameter of the query string used in the request.
35827 /// It should be used to set parameters which are not yet available through their own
35828 /// setters.
35829 ///
35830 /// Please note that this method must not be used to set any of the known parameters
35831 /// which have their own setter method. If done anyway, the request will fail.
35832 ///
35833 /// # Additional Parameters
35834 ///
35835 /// * *$.xgafv* (query-string) - V1 error format.
35836 /// * *access_token* (query-string) - OAuth access token.
35837 /// * *alt* (query-string) - Data format for response.
35838 /// * *callback* (query-string) - JSONP
35839 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35840 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
35841 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35842 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35843 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
35844 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
35845 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
35846 pub fn param<T>(mut self, name: T, value: T) -> RegistrationDeleteCall<'a, C>
35847 where
35848 T: AsRef<str>,
35849 {
35850 self._additional_params
35851 .insert(name.as_ref().to_string(), value.as_ref().to_string());
35852 self
35853 }
35854
35855 /// Identifies the authorization scope for the method you are building.
35856 ///
35857 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35858 /// [`Scope::PushNotification`].
35859 ///
35860 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35861 /// tokens for more than one scope.
35862 ///
35863 /// Usually there is more than one suitable scope to authorize an operation, some of which may
35864 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35865 /// sufficient, a read-write scope will do as well.
35866 pub fn add_scope<St>(mut self, scope: St) -> RegistrationDeleteCall<'a, C>
35867 where
35868 St: AsRef<str>,
35869 {
35870 self._scopes.insert(String::from(scope.as_ref()));
35871 self
35872 }
35873 /// Identifies the authorization scope(s) for the method you are building.
35874 ///
35875 /// See [`Self::add_scope()`] for details.
35876 pub fn add_scopes<I, St>(mut self, scopes: I) -> RegistrationDeleteCall<'a, C>
35877 where
35878 I: IntoIterator<Item = St>,
35879 St: AsRef<str>,
35880 {
35881 self._scopes
35882 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35883 self
35884 }
35885
35886 /// Removes all scopes, and no default scope will be used either.
35887 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35888 /// for details).
35889 pub fn clear_scopes(mut self) -> RegistrationDeleteCall<'a, C> {
35890 self._scopes.clear();
35891 self
35892 }
35893}
35894
35895/// Creates a guardian invitation, and sends an email to the guardian asking them to confirm that they are the student's guardian. Once the guardian accepts the invitation, their `state` will change to `COMPLETED` and they will start receiving guardian notifications. A `Guardian` resource will also be created to represent the active guardian. The request object must have the `student_id` and `invited_email_address` fields set. Failing to set these fields, or setting any other fields in the request, will result in an error. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if the guardian in question has already rejected too many requests for that student, if guardians are not enabled for the domain in question, or for other access errors. * `RESOURCE_EXHAUSTED` if the student or guardian has exceeded the guardian link limit. * `INVALID_ARGUMENT` if the guardian email address is not valid (for example, if it is too long), or if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API). This error will also be returned if read-only fields are set, or if the `state` field is set to to a value other than `PENDING`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student. * `ALREADY_EXISTS` if there is already a pending guardian invitation for the student and `invited_email_address` provided, or if the provided `invited_email_address` matches the Google account of an existing `Guardian` for this user.
35896///
35897/// A builder for the *guardianInvitations.create* method supported by a *userProfile* resource.
35898/// It is not used directly, but through a [`UserProfileMethods`] instance.
35899///
35900/// # Example
35901///
35902/// Instantiate a resource method builder
35903///
35904/// ```test_harness,no_run
35905/// # extern crate hyper;
35906/// # extern crate hyper_rustls;
35907/// # extern crate google_classroom1 as classroom1;
35908/// use classroom1::api::GuardianInvitation;
35909/// # async fn dox() {
35910/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35911///
35912/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35913/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
35914/// # .with_native_roots()
35915/// # .unwrap()
35916/// # .https_only()
35917/// # .enable_http2()
35918/// # .build();
35919///
35920/// # let executor = hyper_util::rt::TokioExecutor::new();
35921/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
35922/// # secret,
35923/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35924/// # yup_oauth2::client::CustomHyperClientBuilder::from(
35925/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
35926/// # ),
35927/// # ).build().await.unwrap();
35928///
35929/// # let client = hyper_util::client::legacy::Client::builder(
35930/// # hyper_util::rt::TokioExecutor::new()
35931/// # )
35932/// # .build(
35933/// # hyper_rustls::HttpsConnectorBuilder::new()
35934/// # .with_native_roots()
35935/// # .unwrap()
35936/// # .https_or_http()
35937/// # .enable_http2()
35938/// # .build()
35939/// # );
35940/// # let mut hub = Classroom::new(client, auth);
35941/// // As the method needs a request, you would usually fill it with the desired information
35942/// // into the respective structure. Some of the parts shown here might not be applicable !
35943/// // Values shown here are possibly random and not representative !
35944/// let mut req = GuardianInvitation::default();
35945///
35946/// // You can configure optional parameters by calling the respective setters at will, and
35947/// // execute the final call using `doit()`.
35948/// // Values shown here are possibly random and not representative !
35949/// let result = hub.user_profiles().guardian_invitations_create(req, "studentId")
35950/// .doit().await;
35951/// # }
35952/// ```
35953pub struct UserProfileGuardianInvitationCreateCall<'a, C>
35954where
35955 C: 'a,
35956{
35957 hub: &'a Classroom<C>,
35958 _request: GuardianInvitation,
35959 _student_id: String,
35960 _delegate: Option<&'a mut dyn common::Delegate>,
35961 _additional_params: HashMap<String, String>,
35962 _scopes: BTreeSet<String>,
35963}
35964
35965impl<'a, C> common::CallBuilder for UserProfileGuardianInvitationCreateCall<'a, C> {}
35966
35967impl<'a, C> UserProfileGuardianInvitationCreateCall<'a, C>
35968where
35969 C: common::Connector,
35970{
35971 /// Perform the operation you have build so far.
35972 pub async fn doit(mut self) -> common::Result<(common::Response, GuardianInvitation)> {
35973 use std::borrow::Cow;
35974 use std::io::{Read, Seek};
35975
35976 use common::{url::Params, ToParts};
35977 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35978
35979 let mut dd = common::DefaultDelegate;
35980 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35981 dlg.begin(common::MethodInfo {
35982 id: "classroom.userProfiles.guardianInvitations.create",
35983 http_method: hyper::Method::POST,
35984 });
35985
35986 for &field in ["alt", "studentId"].iter() {
35987 if self._additional_params.contains_key(field) {
35988 dlg.finished(false);
35989 return Err(common::Error::FieldClash(field));
35990 }
35991 }
35992
35993 let mut params = Params::with_capacity(4 + self._additional_params.len());
35994 params.push("studentId", self._student_id);
35995
35996 params.extend(self._additional_params.iter());
35997
35998 params.push("alt", "json");
35999 let mut url =
36000 self.hub._base_url.clone() + "v1/userProfiles/{studentId}/guardianInvitations";
36001 if self._scopes.is_empty() {
36002 self._scopes
36003 .insert(Scope::GuardianlinkStudent.as_ref().to_string());
36004 }
36005
36006 #[allow(clippy::single_element_loop)]
36007 for &(find_this, param_name) in [("{studentId}", "studentId")].iter() {
36008 url = params.uri_replacement(url, param_name, find_this, false);
36009 }
36010 {
36011 let to_remove = ["studentId"];
36012 params.remove_params(&to_remove);
36013 }
36014
36015 let url = params.parse_with_url(&url);
36016
36017 let mut json_mime_type = mime::APPLICATION_JSON;
36018 let mut request_value_reader = {
36019 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
36020 common::remove_json_null_values(&mut value);
36021 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
36022 serde_json::to_writer(&mut dst, &value).unwrap();
36023 dst
36024 };
36025 let request_size = request_value_reader
36026 .seek(std::io::SeekFrom::End(0))
36027 .unwrap();
36028 request_value_reader
36029 .seek(std::io::SeekFrom::Start(0))
36030 .unwrap();
36031
36032 loop {
36033 let token = match self
36034 .hub
36035 .auth
36036 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36037 .await
36038 {
36039 Ok(token) => token,
36040 Err(e) => match dlg.token(e) {
36041 Ok(token) => token,
36042 Err(e) => {
36043 dlg.finished(false);
36044 return Err(common::Error::MissingToken(e));
36045 }
36046 },
36047 };
36048 request_value_reader
36049 .seek(std::io::SeekFrom::Start(0))
36050 .unwrap();
36051 let mut req_result = {
36052 let client = &self.hub.client;
36053 dlg.pre_request();
36054 let mut req_builder = hyper::Request::builder()
36055 .method(hyper::Method::POST)
36056 .uri(url.as_str())
36057 .header(USER_AGENT, self.hub._user_agent.clone());
36058
36059 if let Some(token) = token.as_ref() {
36060 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36061 }
36062
36063 let request = req_builder
36064 .header(CONTENT_TYPE, json_mime_type.to_string())
36065 .header(CONTENT_LENGTH, request_size as u64)
36066 .body(common::to_body(
36067 request_value_reader.get_ref().clone().into(),
36068 ));
36069
36070 client.request(request.unwrap()).await
36071 };
36072
36073 match req_result {
36074 Err(err) => {
36075 if let common::Retry::After(d) = dlg.http_error(&err) {
36076 sleep(d).await;
36077 continue;
36078 }
36079 dlg.finished(false);
36080 return Err(common::Error::HttpError(err));
36081 }
36082 Ok(res) => {
36083 let (mut parts, body) = res.into_parts();
36084 let mut body = common::Body::new(body);
36085 if !parts.status.is_success() {
36086 let bytes = common::to_bytes(body).await.unwrap_or_default();
36087 let error = serde_json::from_str(&common::to_string(&bytes));
36088 let response = common::to_response(parts, bytes.into());
36089
36090 if let common::Retry::After(d) =
36091 dlg.http_failure(&response, error.as_ref().ok())
36092 {
36093 sleep(d).await;
36094 continue;
36095 }
36096
36097 dlg.finished(false);
36098
36099 return Err(match error {
36100 Ok(value) => common::Error::BadRequest(value),
36101 _ => common::Error::Failure(response),
36102 });
36103 }
36104 let response = {
36105 let bytes = common::to_bytes(body).await.unwrap_or_default();
36106 let encoded = common::to_string(&bytes);
36107 match serde_json::from_str(&encoded) {
36108 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36109 Err(error) => {
36110 dlg.response_json_decode_error(&encoded, &error);
36111 return Err(common::Error::JsonDecodeError(
36112 encoded.to_string(),
36113 error,
36114 ));
36115 }
36116 }
36117 };
36118
36119 dlg.finished(true);
36120 return Ok(response);
36121 }
36122 }
36123 }
36124 }
36125
36126 ///
36127 /// Sets the *request* property to the given value.
36128 ///
36129 /// Even though the property as already been set when instantiating this call,
36130 /// we provide this method for API completeness.
36131 pub fn request(
36132 mut self,
36133 new_value: GuardianInvitation,
36134 ) -> UserProfileGuardianInvitationCreateCall<'a, C> {
36135 self._request = new_value;
36136 self
36137 }
36138 /// ID of the student (in standard format)
36139 ///
36140 /// Sets the *student id* path property to the given value.
36141 ///
36142 /// Even though the property as already been set when instantiating this call,
36143 /// we provide this method for API completeness.
36144 pub fn student_id(mut self, new_value: &str) -> UserProfileGuardianInvitationCreateCall<'a, C> {
36145 self._student_id = new_value.to_string();
36146 self
36147 }
36148 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36149 /// while executing the actual API request.
36150 ///
36151 /// ````text
36152 /// It should be used to handle progress information, and to implement a certain level of resilience.
36153 /// ````
36154 ///
36155 /// Sets the *delegate* property to the given value.
36156 pub fn delegate(
36157 mut self,
36158 new_value: &'a mut dyn common::Delegate,
36159 ) -> UserProfileGuardianInvitationCreateCall<'a, C> {
36160 self._delegate = Some(new_value);
36161 self
36162 }
36163
36164 /// Set any additional parameter of the query string used in the request.
36165 /// It should be used to set parameters which are not yet available through their own
36166 /// setters.
36167 ///
36168 /// Please note that this method must not be used to set any of the known parameters
36169 /// which have their own setter method. If done anyway, the request will fail.
36170 ///
36171 /// # Additional Parameters
36172 ///
36173 /// * *$.xgafv* (query-string) - V1 error format.
36174 /// * *access_token* (query-string) - OAuth access token.
36175 /// * *alt* (query-string) - Data format for response.
36176 /// * *callback* (query-string) - JSONP
36177 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36178 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
36179 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36180 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36181 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
36182 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
36183 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
36184 pub fn param<T>(mut self, name: T, value: T) -> UserProfileGuardianInvitationCreateCall<'a, C>
36185 where
36186 T: AsRef<str>,
36187 {
36188 self._additional_params
36189 .insert(name.as_ref().to_string(), value.as_ref().to_string());
36190 self
36191 }
36192
36193 /// Identifies the authorization scope for the method you are building.
36194 ///
36195 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36196 /// [`Scope::GuardianlinkStudent`].
36197 ///
36198 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36199 /// tokens for more than one scope.
36200 ///
36201 /// Usually there is more than one suitable scope to authorize an operation, some of which may
36202 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36203 /// sufficient, a read-write scope will do as well.
36204 pub fn add_scope<St>(mut self, scope: St) -> UserProfileGuardianInvitationCreateCall<'a, C>
36205 where
36206 St: AsRef<str>,
36207 {
36208 self._scopes.insert(String::from(scope.as_ref()));
36209 self
36210 }
36211 /// Identifies the authorization scope(s) for the method you are building.
36212 ///
36213 /// See [`Self::add_scope()`] for details.
36214 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserProfileGuardianInvitationCreateCall<'a, C>
36215 where
36216 I: IntoIterator<Item = St>,
36217 St: AsRef<str>,
36218 {
36219 self._scopes
36220 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36221 self
36222 }
36223
36224 /// Removes all scopes, and no default scope will be used either.
36225 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36226 /// for details).
36227 pub fn clear_scopes(mut self) -> UserProfileGuardianInvitationCreateCall<'a, C> {
36228 self._scopes.clear();
36229 self
36230 }
36231}
36232
36233/// Returns a specific guardian invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view guardian invitations for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). * `NOT_FOUND` if Classroom cannot find any record of the given student or `invitation_id`. May also be returned if the student exists, but the requesting user does not have access to see that student.
36234///
36235/// A builder for the *guardianInvitations.get* method supported by a *userProfile* resource.
36236/// It is not used directly, but through a [`UserProfileMethods`] instance.
36237///
36238/// # Example
36239///
36240/// Instantiate a resource method builder
36241///
36242/// ```test_harness,no_run
36243/// # extern crate hyper;
36244/// # extern crate hyper_rustls;
36245/// # extern crate google_classroom1 as classroom1;
36246/// # async fn dox() {
36247/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
36248///
36249/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
36250/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
36251/// # .with_native_roots()
36252/// # .unwrap()
36253/// # .https_only()
36254/// # .enable_http2()
36255/// # .build();
36256///
36257/// # let executor = hyper_util::rt::TokioExecutor::new();
36258/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
36259/// # secret,
36260/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
36261/// # yup_oauth2::client::CustomHyperClientBuilder::from(
36262/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
36263/// # ),
36264/// # ).build().await.unwrap();
36265///
36266/// # let client = hyper_util::client::legacy::Client::builder(
36267/// # hyper_util::rt::TokioExecutor::new()
36268/// # )
36269/// # .build(
36270/// # hyper_rustls::HttpsConnectorBuilder::new()
36271/// # .with_native_roots()
36272/// # .unwrap()
36273/// # .https_or_http()
36274/// # .enable_http2()
36275/// # .build()
36276/// # );
36277/// # let mut hub = Classroom::new(client, auth);
36278/// // You can configure optional parameters by calling the respective setters at will, and
36279/// // execute the final call using `doit()`.
36280/// // Values shown here are possibly random and not representative !
36281/// let result = hub.user_profiles().guardian_invitations_get("studentId", "invitationId")
36282/// .doit().await;
36283/// # }
36284/// ```
36285pub struct UserProfileGuardianInvitationGetCall<'a, C>
36286where
36287 C: 'a,
36288{
36289 hub: &'a Classroom<C>,
36290 _student_id: String,
36291 _invitation_id: String,
36292 _delegate: Option<&'a mut dyn common::Delegate>,
36293 _additional_params: HashMap<String, String>,
36294 _scopes: BTreeSet<String>,
36295}
36296
36297impl<'a, C> common::CallBuilder for UserProfileGuardianInvitationGetCall<'a, C> {}
36298
36299impl<'a, C> UserProfileGuardianInvitationGetCall<'a, C>
36300where
36301 C: common::Connector,
36302{
36303 /// Perform the operation you have build so far.
36304 pub async fn doit(mut self) -> common::Result<(common::Response, GuardianInvitation)> {
36305 use std::borrow::Cow;
36306 use std::io::{Read, Seek};
36307
36308 use common::{url::Params, ToParts};
36309 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36310
36311 let mut dd = common::DefaultDelegate;
36312 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
36313 dlg.begin(common::MethodInfo {
36314 id: "classroom.userProfiles.guardianInvitations.get",
36315 http_method: hyper::Method::GET,
36316 });
36317
36318 for &field in ["alt", "studentId", "invitationId"].iter() {
36319 if self._additional_params.contains_key(field) {
36320 dlg.finished(false);
36321 return Err(common::Error::FieldClash(field));
36322 }
36323 }
36324
36325 let mut params = Params::with_capacity(4 + self._additional_params.len());
36326 params.push("studentId", self._student_id);
36327 params.push("invitationId", self._invitation_id);
36328
36329 params.extend(self._additional_params.iter());
36330
36331 params.push("alt", "json");
36332 let mut url = self.hub._base_url.clone()
36333 + "v1/userProfiles/{studentId}/guardianInvitations/{invitationId}";
36334 if self._scopes.is_empty() {
36335 self._scopes
36336 .insert(Scope::GuardianlinkStudentReadonly.as_ref().to_string());
36337 }
36338
36339 #[allow(clippy::single_element_loop)]
36340 for &(find_this, param_name) in [
36341 ("{studentId}", "studentId"),
36342 ("{invitationId}", "invitationId"),
36343 ]
36344 .iter()
36345 {
36346 url = params.uri_replacement(url, param_name, find_this, false);
36347 }
36348 {
36349 let to_remove = ["invitationId", "studentId"];
36350 params.remove_params(&to_remove);
36351 }
36352
36353 let url = params.parse_with_url(&url);
36354
36355 loop {
36356 let token = match self
36357 .hub
36358 .auth
36359 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36360 .await
36361 {
36362 Ok(token) => token,
36363 Err(e) => match dlg.token(e) {
36364 Ok(token) => token,
36365 Err(e) => {
36366 dlg.finished(false);
36367 return Err(common::Error::MissingToken(e));
36368 }
36369 },
36370 };
36371 let mut req_result = {
36372 let client = &self.hub.client;
36373 dlg.pre_request();
36374 let mut req_builder = hyper::Request::builder()
36375 .method(hyper::Method::GET)
36376 .uri(url.as_str())
36377 .header(USER_AGENT, self.hub._user_agent.clone());
36378
36379 if let Some(token) = token.as_ref() {
36380 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36381 }
36382
36383 let request = req_builder
36384 .header(CONTENT_LENGTH, 0_u64)
36385 .body(common::to_body::<String>(None));
36386
36387 client.request(request.unwrap()).await
36388 };
36389
36390 match req_result {
36391 Err(err) => {
36392 if let common::Retry::After(d) = dlg.http_error(&err) {
36393 sleep(d).await;
36394 continue;
36395 }
36396 dlg.finished(false);
36397 return Err(common::Error::HttpError(err));
36398 }
36399 Ok(res) => {
36400 let (mut parts, body) = res.into_parts();
36401 let mut body = common::Body::new(body);
36402 if !parts.status.is_success() {
36403 let bytes = common::to_bytes(body).await.unwrap_or_default();
36404 let error = serde_json::from_str(&common::to_string(&bytes));
36405 let response = common::to_response(parts, bytes.into());
36406
36407 if let common::Retry::After(d) =
36408 dlg.http_failure(&response, error.as_ref().ok())
36409 {
36410 sleep(d).await;
36411 continue;
36412 }
36413
36414 dlg.finished(false);
36415
36416 return Err(match error {
36417 Ok(value) => common::Error::BadRequest(value),
36418 _ => common::Error::Failure(response),
36419 });
36420 }
36421 let response = {
36422 let bytes = common::to_bytes(body).await.unwrap_or_default();
36423 let encoded = common::to_string(&bytes);
36424 match serde_json::from_str(&encoded) {
36425 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36426 Err(error) => {
36427 dlg.response_json_decode_error(&encoded, &error);
36428 return Err(common::Error::JsonDecodeError(
36429 encoded.to_string(),
36430 error,
36431 ));
36432 }
36433 }
36434 };
36435
36436 dlg.finished(true);
36437 return Ok(response);
36438 }
36439 }
36440 }
36441 }
36442
36443 /// The ID of the student whose guardian invitation is being requested.
36444 ///
36445 /// Sets the *student id* path property to the given value.
36446 ///
36447 /// Even though the property as already been set when instantiating this call,
36448 /// we provide this method for API completeness.
36449 pub fn student_id(mut self, new_value: &str) -> UserProfileGuardianInvitationGetCall<'a, C> {
36450 self._student_id = new_value.to_string();
36451 self
36452 }
36453 /// The `id` field of the `GuardianInvitation` being requested.
36454 ///
36455 /// Sets the *invitation id* path property to the given value.
36456 ///
36457 /// Even though the property as already been set when instantiating this call,
36458 /// we provide this method for API completeness.
36459 pub fn invitation_id(mut self, new_value: &str) -> UserProfileGuardianInvitationGetCall<'a, C> {
36460 self._invitation_id = new_value.to_string();
36461 self
36462 }
36463 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36464 /// while executing the actual API request.
36465 ///
36466 /// ````text
36467 /// It should be used to handle progress information, and to implement a certain level of resilience.
36468 /// ````
36469 ///
36470 /// Sets the *delegate* property to the given value.
36471 pub fn delegate(
36472 mut self,
36473 new_value: &'a mut dyn common::Delegate,
36474 ) -> UserProfileGuardianInvitationGetCall<'a, C> {
36475 self._delegate = Some(new_value);
36476 self
36477 }
36478
36479 /// Set any additional parameter of the query string used in the request.
36480 /// It should be used to set parameters which are not yet available through their own
36481 /// setters.
36482 ///
36483 /// Please note that this method must not be used to set any of the known parameters
36484 /// which have their own setter method. If done anyway, the request will fail.
36485 ///
36486 /// # Additional Parameters
36487 ///
36488 /// * *$.xgafv* (query-string) - V1 error format.
36489 /// * *access_token* (query-string) - OAuth access token.
36490 /// * *alt* (query-string) - Data format for response.
36491 /// * *callback* (query-string) - JSONP
36492 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36493 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
36494 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36495 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36496 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
36497 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
36498 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
36499 pub fn param<T>(mut self, name: T, value: T) -> UserProfileGuardianInvitationGetCall<'a, C>
36500 where
36501 T: AsRef<str>,
36502 {
36503 self._additional_params
36504 .insert(name.as_ref().to_string(), value.as_ref().to_string());
36505 self
36506 }
36507
36508 /// Identifies the authorization scope for the method you are building.
36509 ///
36510 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36511 /// [`Scope::GuardianlinkStudentReadonly`].
36512 ///
36513 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36514 /// tokens for more than one scope.
36515 ///
36516 /// Usually there is more than one suitable scope to authorize an operation, some of which may
36517 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36518 /// sufficient, a read-write scope will do as well.
36519 pub fn add_scope<St>(mut self, scope: St) -> UserProfileGuardianInvitationGetCall<'a, C>
36520 where
36521 St: AsRef<str>,
36522 {
36523 self._scopes.insert(String::from(scope.as_ref()));
36524 self
36525 }
36526 /// Identifies the authorization scope(s) for the method you are building.
36527 ///
36528 /// See [`Self::add_scope()`] for details.
36529 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserProfileGuardianInvitationGetCall<'a, C>
36530 where
36531 I: IntoIterator<Item = St>,
36532 St: AsRef<str>,
36533 {
36534 self._scopes
36535 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36536 self
36537 }
36538
36539 /// Removes all scopes, and no default scope will be used either.
36540 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36541 /// for details).
36542 pub fn clear_scopes(mut self) -> UserProfileGuardianInvitationGetCall<'a, C> {
36543 self._scopes.clear();
36544 self
36545 }
36546}
36547
36548/// Returns a list of guardian invitations that the requesting user is permitted to view, filtered by the parameters provided. This method returns the following error codes: * `PERMISSION_DENIED` if a `student_id` is specified, and the requesting user is not permitted to view guardian invitations for that student, if `"-"` is specified as the `student_id` and the user is not a domain administrator, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). May also be returned if an invalid `page_token` or `state` is provided. * `NOT_FOUND` if a `student_id` is specified, and its format can be recognized, but Classroom has no record of that student.
36549///
36550/// A builder for the *guardianInvitations.list* method supported by a *userProfile* resource.
36551/// It is not used directly, but through a [`UserProfileMethods`] instance.
36552///
36553/// # Example
36554///
36555/// Instantiate a resource method builder
36556///
36557/// ```test_harness,no_run
36558/// # extern crate hyper;
36559/// # extern crate hyper_rustls;
36560/// # extern crate google_classroom1 as classroom1;
36561/// # async fn dox() {
36562/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
36563///
36564/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
36565/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
36566/// # .with_native_roots()
36567/// # .unwrap()
36568/// # .https_only()
36569/// # .enable_http2()
36570/// # .build();
36571///
36572/// # let executor = hyper_util::rt::TokioExecutor::new();
36573/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
36574/// # secret,
36575/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
36576/// # yup_oauth2::client::CustomHyperClientBuilder::from(
36577/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
36578/// # ),
36579/// # ).build().await.unwrap();
36580///
36581/// # let client = hyper_util::client::legacy::Client::builder(
36582/// # hyper_util::rt::TokioExecutor::new()
36583/// # )
36584/// # .build(
36585/// # hyper_rustls::HttpsConnectorBuilder::new()
36586/// # .with_native_roots()
36587/// # .unwrap()
36588/// # .https_or_http()
36589/// # .enable_http2()
36590/// # .build()
36591/// # );
36592/// # let mut hub = Classroom::new(client, auth);
36593/// // You can configure optional parameters by calling the respective setters at will, and
36594/// // execute the final call using `doit()`.
36595/// // Values shown here are possibly random and not representative !
36596/// let result = hub.user_profiles().guardian_invitations_list("studentId")
36597/// .add_states("sea")
36598/// .page_token("ipsum")
36599/// .page_size(-15)
36600/// .invited_email_address("gubergren")
36601/// .doit().await;
36602/// # }
36603/// ```
36604pub struct UserProfileGuardianInvitationListCall<'a, C>
36605where
36606 C: 'a,
36607{
36608 hub: &'a Classroom<C>,
36609 _student_id: String,
36610 _states: Vec<String>,
36611 _page_token: Option<String>,
36612 _page_size: Option<i32>,
36613 _invited_email_address: Option<String>,
36614 _delegate: Option<&'a mut dyn common::Delegate>,
36615 _additional_params: HashMap<String, String>,
36616 _scopes: BTreeSet<String>,
36617}
36618
36619impl<'a, C> common::CallBuilder for UserProfileGuardianInvitationListCall<'a, C> {}
36620
36621impl<'a, C> UserProfileGuardianInvitationListCall<'a, C>
36622where
36623 C: common::Connector,
36624{
36625 /// Perform the operation you have build so far.
36626 pub async fn doit(
36627 mut self,
36628 ) -> common::Result<(common::Response, ListGuardianInvitationsResponse)> {
36629 use std::borrow::Cow;
36630 use std::io::{Read, Seek};
36631
36632 use common::{url::Params, ToParts};
36633 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36634
36635 let mut dd = common::DefaultDelegate;
36636 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
36637 dlg.begin(common::MethodInfo {
36638 id: "classroom.userProfiles.guardianInvitations.list",
36639 http_method: hyper::Method::GET,
36640 });
36641
36642 for &field in [
36643 "alt",
36644 "studentId",
36645 "states",
36646 "pageToken",
36647 "pageSize",
36648 "invitedEmailAddress",
36649 ]
36650 .iter()
36651 {
36652 if self._additional_params.contains_key(field) {
36653 dlg.finished(false);
36654 return Err(common::Error::FieldClash(field));
36655 }
36656 }
36657
36658 let mut params = Params::with_capacity(7 + self._additional_params.len());
36659 params.push("studentId", self._student_id);
36660 if !self._states.is_empty() {
36661 for f in self._states.iter() {
36662 params.push("states", f);
36663 }
36664 }
36665 if let Some(value) = self._page_token.as_ref() {
36666 params.push("pageToken", value);
36667 }
36668 if let Some(value) = self._page_size.as_ref() {
36669 params.push("pageSize", value.to_string());
36670 }
36671 if let Some(value) = self._invited_email_address.as_ref() {
36672 params.push("invitedEmailAddress", value);
36673 }
36674
36675 params.extend(self._additional_params.iter());
36676
36677 params.push("alt", "json");
36678 let mut url =
36679 self.hub._base_url.clone() + "v1/userProfiles/{studentId}/guardianInvitations";
36680 if self._scopes.is_empty() {
36681 self._scopes
36682 .insert(Scope::GuardianlinkStudentReadonly.as_ref().to_string());
36683 }
36684
36685 #[allow(clippy::single_element_loop)]
36686 for &(find_this, param_name) in [("{studentId}", "studentId")].iter() {
36687 url = params.uri_replacement(url, param_name, find_this, false);
36688 }
36689 {
36690 let to_remove = ["studentId"];
36691 params.remove_params(&to_remove);
36692 }
36693
36694 let url = params.parse_with_url(&url);
36695
36696 loop {
36697 let token = match self
36698 .hub
36699 .auth
36700 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36701 .await
36702 {
36703 Ok(token) => token,
36704 Err(e) => match dlg.token(e) {
36705 Ok(token) => token,
36706 Err(e) => {
36707 dlg.finished(false);
36708 return Err(common::Error::MissingToken(e));
36709 }
36710 },
36711 };
36712 let mut req_result = {
36713 let client = &self.hub.client;
36714 dlg.pre_request();
36715 let mut req_builder = hyper::Request::builder()
36716 .method(hyper::Method::GET)
36717 .uri(url.as_str())
36718 .header(USER_AGENT, self.hub._user_agent.clone());
36719
36720 if let Some(token) = token.as_ref() {
36721 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36722 }
36723
36724 let request = req_builder
36725 .header(CONTENT_LENGTH, 0_u64)
36726 .body(common::to_body::<String>(None));
36727
36728 client.request(request.unwrap()).await
36729 };
36730
36731 match req_result {
36732 Err(err) => {
36733 if let common::Retry::After(d) = dlg.http_error(&err) {
36734 sleep(d).await;
36735 continue;
36736 }
36737 dlg.finished(false);
36738 return Err(common::Error::HttpError(err));
36739 }
36740 Ok(res) => {
36741 let (mut parts, body) = res.into_parts();
36742 let mut body = common::Body::new(body);
36743 if !parts.status.is_success() {
36744 let bytes = common::to_bytes(body).await.unwrap_or_default();
36745 let error = serde_json::from_str(&common::to_string(&bytes));
36746 let response = common::to_response(parts, bytes.into());
36747
36748 if let common::Retry::After(d) =
36749 dlg.http_failure(&response, error.as_ref().ok())
36750 {
36751 sleep(d).await;
36752 continue;
36753 }
36754
36755 dlg.finished(false);
36756
36757 return Err(match error {
36758 Ok(value) => common::Error::BadRequest(value),
36759 _ => common::Error::Failure(response),
36760 });
36761 }
36762 let response = {
36763 let bytes = common::to_bytes(body).await.unwrap_or_default();
36764 let encoded = common::to_string(&bytes);
36765 match serde_json::from_str(&encoded) {
36766 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36767 Err(error) => {
36768 dlg.response_json_decode_error(&encoded, &error);
36769 return Err(common::Error::JsonDecodeError(
36770 encoded.to_string(),
36771 error,
36772 ));
36773 }
36774 }
36775 };
36776
36777 dlg.finished(true);
36778 return Ok(response);
36779 }
36780 }
36781 }
36782 }
36783
36784 /// The ID of the student whose guardian invitations are to be returned. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user * the string literal `"-"`, indicating that results should be returned for all students that the requesting user is permitted to view guardian invitations.
36785 ///
36786 /// Sets the *student id* path property to the given value.
36787 ///
36788 /// Even though the property as already been set when instantiating this call,
36789 /// we provide this method for API completeness.
36790 pub fn student_id(mut self, new_value: &str) -> UserProfileGuardianInvitationListCall<'a, C> {
36791 self._student_id = new_value.to_string();
36792 self
36793 }
36794 /// If specified, only results with the specified `state` values are returned. Otherwise, results with a `state` of `PENDING` are returned.
36795 ///
36796 /// Append the given value to the *states* query property.
36797 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
36798 pub fn add_states(mut self, new_value: &str) -> UserProfileGuardianInvitationListCall<'a, C> {
36799 self._states.push(new_value.to_string());
36800 self
36801 }
36802 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
36803 ///
36804 /// Sets the *page token* query property to the given value.
36805 pub fn page_token(mut self, new_value: &str) -> UserProfileGuardianInvitationListCall<'a, C> {
36806 self._page_token = Some(new_value.to_string());
36807 self
36808 }
36809 /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.
36810 ///
36811 /// Sets the *page size* query property to the given value.
36812 pub fn page_size(mut self, new_value: i32) -> UserProfileGuardianInvitationListCall<'a, C> {
36813 self._page_size = Some(new_value);
36814 self
36815 }
36816 /// If specified, only results with the specified `invited_email_address` are returned.
36817 ///
36818 /// Sets the *invited email address* query property to the given value.
36819 pub fn invited_email_address(
36820 mut self,
36821 new_value: &str,
36822 ) -> UserProfileGuardianInvitationListCall<'a, C> {
36823 self._invited_email_address = Some(new_value.to_string());
36824 self
36825 }
36826 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36827 /// while executing the actual API request.
36828 ///
36829 /// ````text
36830 /// It should be used to handle progress information, and to implement a certain level of resilience.
36831 /// ````
36832 ///
36833 /// Sets the *delegate* property to the given value.
36834 pub fn delegate(
36835 mut self,
36836 new_value: &'a mut dyn common::Delegate,
36837 ) -> UserProfileGuardianInvitationListCall<'a, C> {
36838 self._delegate = Some(new_value);
36839 self
36840 }
36841
36842 /// Set any additional parameter of the query string used in the request.
36843 /// It should be used to set parameters which are not yet available through their own
36844 /// setters.
36845 ///
36846 /// Please note that this method must not be used to set any of the known parameters
36847 /// which have their own setter method. If done anyway, the request will fail.
36848 ///
36849 /// # Additional Parameters
36850 ///
36851 /// * *$.xgafv* (query-string) - V1 error format.
36852 /// * *access_token* (query-string) - OAuth access token.
36853 /// * *alt* (query-string) - Data format for response.
36854 /// * *callback* (query-string) - JSONP
36855 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36856 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
36857 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36858 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36859 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
36860 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
36861 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
36862 pub fn param<T>(mut self, name: T, value: T) -> UserProfileGuardianInvitationListCall<'a, C>
36863 where
36864 T: AsRef<str>,
36865 {
36866 self._additional_params
36867 .insert(name.as_ref().to_string(), value.as_ref().to_string());
36868 self
36869 }
36870
36871 /// Identifies the authorization scope for the method you are building.
36872 ///
36873 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36874 /// [`Scope::GuardianlinkStudentReadonly`].
36875 ///
36876 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36877 /// tokens for more than one scope.
36878 ///
36879 /// Usually there is more than one suitable scope to authorize an operation, some of which may
36880 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36881 /// sufficient, a read-write scope will do as well.
36882 pub fn add_scope<St>(mut self, scope: St) -> UserProfileGuardianInvitationListCall<'a, C>
36883 where
36884 St: AsRef<str>,
36885 {
36886 self._scopes.insert(String::from(scope.as_ref()));
36887 self
36888 }
36889 /// Identifies the authorization scope(s) for the method you are building.
36890 ///
36891 /// See [`Self::add_scope()`] for details.
36892 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserProfileGuardianInvitationListCall<'a, C>
36893 where
36894 I: IntoIterator<Item = St>,
36895 St: AsRef<str>,
36896 {
36897 self._scopes
36898 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36899 self
36900 }
36901
36902 /// Removes all scopes, and no default scope will be used either.
36903 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36904 /// for details).
36905 pub fn clear_scopes(mut self) -> UserProfileGuardianInvitationListCall<'a, C> {
36906 self._scopes.clear();
36907 self
36908 }
36909}
36910
36911/// Modifies a guardian invitation. Currently, the only valid modification is to change the `state` from `PENDING` to `COMPLETE`. This has the effect of withdrawing the invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the current user does not have permission to manage guardians, if guardians are not enabled for the domain in question or for other access errors. * `FAILED_PRECONDITION` if the guardian link is not in the `PENDING` state. * `INVALID_ARGUMENT` if the format of the student ID provided cannot be recognized (it is not an email address, nor a `user_id` from this API), or if the passed `GuardianInvitation` has a `state` other than `COMPLETE`, or if it modifies fields other than `state`. * `NOT_FOUND` if the student ID provided is a valid student ID, but Classroom has no record of that student, or if the `id` field does not refer to a guardian invitation known to Classroom.
36912///
36913/// A builder for the *guardianInvitations.patch* method supported by a *userProfile* resource.
36914/// It is not used directly, but through a [`UserProfileMethods`] instance.
36915///
36916/// # Example
36917///
36918/// Instantiate a resource method builder
36919///
36920/// ```test_harness,no_run
36921/// # extern crate hyper;
36922/// # extern crate hyper_rustls;
36923/// # extern crate google_classroom1 as classroom1;
36924/// use classroom1::api::GuardianInvitation;
36925/// # async fn dox() {
36926/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
36927///
36928/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
36929/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
36930/// # .with_native_roots()
36931/// # .unwrap()
36932/// # .https_only()
36933/// # .enable_http2()
36934/// # .build();
36935///
36936/// # let executor = hyper_util::rt::TokioExecutor::new();
36937/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
36938/// # secret,
36939/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
36940/// # yup_oauth2::client::CustomHyperClientBuilder::from(
36941/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
36942/// # ),
36943/// # ).build().await.unwrap();
36944///
36945/// # let client = hyper_util::client::legacy::Client::builder(
36946/// # hyper_util::rt::TokioExecutor::new()
36947/// # )
36948/// # .build(
36949/// # hyper_rustls::HttpsConnectorBuilder::new()
36950/// # .with_native_roots()
36951/// # .unwrap()
36952/// # .https_or_http()
36953/// # .enable_http2()
36954/// # .build()
36955/// # );
36956/// # let mut hub = Classroom::new(client, auth);
36957/// // As the method needs a request, you would usually fill it with the desired information
36958/// // into the respective structure. Some of the parts shown here might not be applicable !
36959/// // Values shown here are possibly random and not representative !
36960/// let mut req = GuardianInvitation::default();
36961///
36962/// // You can configure optional parameters by calling the respective setters at will, and
36963/// // execute the final call using `doit()`.
36964/// // Values shown here are possibly random and not representative !
36965/// let result = hub.user_profiles().guardian_invitations_patch(req, "studentId", "invitationId")
36966/// .update_mask(FieldMask::new::<&str>(&[]))
36967/// .doit().await;
36968/// # }
36969/// ```
36970pub struct UserProfileGuardianInvitationPatchCall<'a, C>
36971where
36972 C: 'a,
36973{
36974 hub: &'a Classroom<C>,
36975 _request: GuardianInvitation,
36976 _student_id: String,
36977 _invitation_id: String,
36978 _update_mask: Option<common::FieldMask>,
36979 _delegate: Option<&'a mut dyn common::Delegate>,
36980 _additional_params: HashMap<String, String>,
36981 _scopes: BTreeSet<String>,
36982}
36983
36984impl<'a, C> common::CallBuilder for UserProfileGuardianInvitationPatchCall<'a, C> {}
36985
36986impl<'a, C> UserProfileGuardianInvitationPatchCall<'a, C>
36987where
36988 C: common::Connector,
36989{
36990 /// Perform the operation you have build so far.
36991 pub async fn doit(mut self) -> common::Result<(common::Response, GuardianInvitation)> {
36992 use std::borrow::Cow;
36993 use std::io::{Read, Seek};
36994
36995 use common::{url::Params, ToParts};
36996 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36997
36998 let mut dd = common::DefaultDelegate;
36999 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
37000 dlg.begin(common::MethodInfo {
37001 id: "classroom.userProfiles.guardianInvitations.patch",
37002 http_method: hyper::Method::PATCH,
37003 });
37004
37005 for &field in ["alt", "studentId", "invitationId", "updateMask"].iter() {
37006 if self._additional_params.contains_key(field) {
37007 dlg.finished(false);
37008 return Err(common::Error::FieldClash(field));
37009 }
37010 }
37011
37012 let mut params = Params::with_capacity(6 + self._additional_params.len());
37013 params.push("studentId", self._student_id);
37014 params.push("invitationId", self._invitation_id);
37015 if let Some(value) = self._update_mask.as_ref() {
37016 params.push("updateMask", value.to_string());
37017 }
37018
37019 params.extend(self._additional_params.iter());
37020
37021 params.push("alt", "json");
37022 let mut url = self.hub._base_url.clone()
37023 + "v1/userProfiles/{studentId}/guardianInvitations/{invitationId}";
37024 if self._scopes.is_empty() {
37025 self._scopes
37026 .insert(Scope::GuardianlinkStudent.as_ref().to_string());
37027 }
37028
37029 #[allow(clippy::single_element_loop)]
37030 for &(find_this, param_name) in [
37031 ("{studentId}", "studentId"),
37032 ("{invitationId}", "invitationId"),
37033 ]
37034 .iter()
37035 {
37036 url = params.uri_replacement(url, param_name, find_this, false);
37037 }
37038 {
37039 let to_remove = ["invitationId", "studentId"];
37040 params.remove_params(&to_remove);
37041 }
37042
37043 let url = params.parse_with_url(&url);
37044
37045 let mut json_mime_type = mime::APPLICATION_JSON;
37046 let mut request_value_reader = {
37047 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
37048 common::remove_json_null_values(&mut value);
37049 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
37050 serde_json::to_writer(&mut dst, &value).unwrap();
37051 dst
37052 };
37053 let request_size = request_value_reader
37054 .seek(std::io::SeekFrom::End(0))
37055 .unwrap();
37056 request_value_reader
37057 .seek(std::io::SeekFrom::Start(0))
37058 .unwrap();
37059
37060 loop {
37061 let token = match self
37062 .hub
37063 .auth
37064 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
37065 .await
37066 {
37067 Ok(token) => token,
37068 Err(e) => match dlg.token(e) {
37069 Ok(token) => token,
37070 Err(e) => {
37071 dlg.finished(false);
37072 return Err(common::Error::MissingToken(e));
37073 }
37074 },
37075 };
37076 request_value_reader
37077 .seek(std::io::SeekFrom::Start(0))
37078 .unwrap();
37079 let mut req_result = {
37080 let client = &self.hub.client;
37081 dlg.pre_request();
37082 let mut req_builder = hyper::Request::builder()
37083 .method(hyper::Method::PATCH)
37084 .uri(url.as_str())
37085 .header(USER_AGENT, self.hub._user_agent.clone());
37086
37087 if let Some(token) = token.as_ref() {
37088 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
37089 }
37090
37091 let request = req_builder
37092 .header(CONTENT_TYPE, json_mime_type.to_string())
37093 .header(CONTENT_LENGTH, request_size as u64)
37094 .body(common::to_body(
37095 request_value_reader.get_ref().clone().into(),
37096 ));
37097
37098 client.request(request.unwrap()).await
37099 };
37100
37101 match req_result {
37102 Err(err) => {
37103 if let common::Retry::After(d) = dlg.http_error(&err) {
37104 sleep(d).await;
37105 continue;
37106 }
37107 dlg.finished(false);
37108 return Err(common::Error::HttpError(err));
37109 }
37110 Ok(res) => {
37111 let (mut parts, body) = res.into_parts();
37112 let mut body = common::Body::new(body);
37113 if !parts.status.is_success() {
37114 let bytes = common::to_bytes(body).await.unwrap_or_default();
37115 let error = serde_json::from_str(&common::to_string(&bytes));
37116 let response = common::to_response(parts, bytes.into());
37117
37118 if let common::Retry::After(d) =
37119 dlg.http_failure(&response, error.as_ref().ok())
37120 {
37121 sleep(d).await;
37122 continue;
37123 }
37124
37125 dlg.finished(false);
37126
37127 return Err(match error {
37128 Ok(value) => common::Error::BadRequest(value),
37129 _ => common::Error::Failure(response),
37130 });
37131 }
37132 let response = {
37133 let bytes = common::to_bytes(body).await.unwrap_or_default();
37134 let encoded = common::to_string(&bytes);
37135 match serde_json::from_str(&encoded) {
37136 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
37137 Err(error) => {
37138 dlg.response_json_decode_error(&encoded, &error);
37139 return Err(common::Error::JsonDecodeError(
37140 encoded.to_string(),
37141 error,
37142 ));
37143 }
37144 }
37145 };
37146
37147 dlg.finished(true);
37148 return Ok(response);
37149 }
37150 }
37151 }
37152 }
37153
37154 ///
37155 /// Sets the *request* property to the given value.
37156 ///
37157 /// Even though the property as already been set when instantiating this call,
37158 /// we provide this method for API completeness.
37159 pub fn request(
37160 mut self,
37161 new_value: GuardianInvitation,
37162 ) -> UserProfileGuardianInvitationPatchCall<'a, C> {
37163 self._request = new_value;
37164 self
37165 }
37166 /// The ID of the student whose guardian invitation is to be modified.
37167 ///
37168 /// Sets the *student id* path property to the given value.
37169 ///
37170 /// Even though the property as already been set when instantiating this call,
37171 /// we provide this method for API completeness.
37172 pub fn student_id(mut self, new_value: &str) -> UserProfileGuardianInvitationPatchCall<'a, C> {
37173 self._student_id = new_value.to_string();
37174 self
37175 }
37176 /// The `id` field of the `GuardianInvitation` to be modified.
37177 ///
37178 /// Sets the *invitation id* path property to the given value.
37179 ///
37180 /// Even though the property as already been set when instantiating this call,
37181 /// we provide this method for API completeness.
37182 pub fn invitation_id(
37183 mut self,
37184 new_value: &str,
37185 ) -> UserProfileGuardianInvitationPatchCall<'a, C> {
37186 self._invitation_id = new_value.to_string();
37187 self
37188 }
37189 /// Mask that identifies which fields on the course to update. This field is required to do an update. The update fails if invalid fields are specified. The following fields are valid: * `state` When set in a query parameter, this field should be specified as `updateMask=,,...`
37190 ///
37191 /// Sets the *update mask* query property to the given value.
37192 pub fn update_mask(
37193 mut self,
37194 new_value: common::FieldMask,
37195 ) -> UserProfileGuardianInvitationPatchCall<'a, C> {
37196 self._update_mask = Some(new_value);
37197 self
37198 }
37199 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
37200 /// while executing the actual API request.
37201 ///
37202 /// ````text
37203 /// It should be used to handle progress information, and to implement a certain level of resilience.
37204 /// ````
37205 ///
37206 /// Sets the *delegate* property to the given value.
37207 pub fn delegate(
37208 mut self,
37209 new_value: &'a mut dyn common::Delegate,
37210 ) -> UserProfileGuardianInvitationPatchCall<'a, C> {
37211 self._delegate = Some(new_value);
37212 self
37213 }
37214
37215 /// Set any additional parameter of the query string used in the request.
37216 /// It should be used to set parameters which are not yet available through their own
37217 /// setters.
37218 ///
37219 /// Please note that this method must not be used to set any of the known parameters
37220 /// which have their own setter method. If done anyway, the request will fail.
37221 ///
37222 /// # Additional Parameters
37223 ///
37224 /// * *$.xgafv* (query-string) - V1 error format.
37225 /// * *access_token* (query-string) - OAuth access token.
37226 /// * *alt* (query-string) - Data format for response.
37227 /// * *callback* (query-string) - JSONP
37228 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
37229 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
37230 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
37231 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
37232 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
37233 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
37234 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
37235 pub fn param<T>(mut self, name: T, value: T) -> UserProfileGuardianInvitationPatchCall<'a, C>
37236 where
37237 T: AsRef<str>,
37238 {
37239 self._additional_params
37240 .insert(name.as_ref().to_string(), value.as_ref().to_string());
37241 self
37242 }
37243
37244 /// Identifies the authorization scope for the method you are building.
37245 ///
37246 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
37247 /// [`Scope::GuardianlinkStudent`].
37248 ///
37249 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
37250 /// tokens for more than one scope.
37251 ///
37252 /// Usually there is more than one suitable scope to authorize an operation, some of which may
37253 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
37254 /// sufficient, a read-write scope will do as well.
37255 pub fn add_scope<St>(mut self, scope: St) -> UserProfileGuardianInvitationPatchCall<'a, C>
37256 where
37257 St: AsRef<str>,
37258 {
37259 self._scopes.insert(String::from(scope.as_ref()));
37260 self
37261 }
37262 /// Identifies the authorization scope(s) for the method you are building.
37263 ///
37264 /// See [`Self::add_scope()`] for details.
37265 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserProfileGuardianInvitationPatchCall<'a, C>
37266 where
37267 I: IntoIterator<Item = St>,
37268 St: AsRef<str>,
37269 {
37270 self._scopes
37271 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
37272 self
37273 }
37274
37275 /// Removes all scopes, and no default scope will be used either.
37276 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
37277 /// for details).
37278 pub fn clear_scopes(mut self) -> UserProfileGuardianInvitationPatchCall<'a, C> {
37279 self._scopes.clear();
37280 self
37281 }
37282}
37283
37284/// Deletes a guardian. The guardian will no longer receive guardian notifications and the guardian will no longer be accessible via the API. This method returns the following error codes: * `PERMISSION_DENIED` if no user that matches the provided `student_id` is visible to the requesting user, if the requesting user is not permitted to manage guardians for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API). * `NOT_FOUND` if the requesting user is permitted to modify guardians for the requested `student_id`, but no `Guardian` record exists for that student with the provided `guardian_id`.
37285///
37286/// A builder for the *guardians.delete* method supported by a *userProfile* resource.
37287/// It is not used directly, but through a [`UserProfileMethods`] instance.
37288///
37289/// # Example
37290///
37291/// Instantiate a resource method builder
37292///
37293/// ```test_harness,no_run
37294/// # extern crate hyper;
37295/// # extern crate hyper_rustls;
37296/// # extern crate google_classroom1 as classroom1;
37297/// # async fn dox() {
37298/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
37299///
37300/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
37301/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
37302/// # .with_native_roots()
37303/// # .unwrap()
37304/// # .https_only()
37305/// # .enable_http2()
37306/// # .build();
37307///
37308/// # let executor = hyper_util::rt::TokioExecutor::new();
37309/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
37310/// # secret,
37311/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
37312/// # yup_oauth2::client::CustomHyperClientBuilder::from(
37313/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
37314/// # ),
37315/// # ).build().await.unwrap();
37316///
37317/// # let client = hyper_util::client::legacy::Client::builder(
37318/// # hyper_util::rt::TokioExecutor::new()
37319/// # )
37320/// # .build(
37321/// # hyper_rustls::HttpsConnectorBuilder::new()
37322/// # .with_native_roots()
37323/// # .unwrap()
37324/// # .https_or_http()
37325/// # .enable_http2()
37326/// # .build()
37327/// # );
37328/// # let mut hub = Classroom::new(client, auth);
37329/// // You can configure optional parameters by calling the respective setters at will, and
37330/// // execute the final call using `doit()`.
37331/// // Values shown here are possibly random and not representative !
37332/// let result = hub.user_profiles().guardians_delete("studentId", "guardianId")
37333/// .doit().await;
37334/// # }
37335/// ```
37336pub struct UserProfileGuardianDeleteCall<'a, C>
37337where
37338 C: 'a,
37339{
37340 hub: &'a Classroom<C>,
37341 _student_id: String,
37342 _guardian_id: String,
37343 _delegate: Option<&'a mut dyn common::Delegate>,
37344 _additional_params: HashMap<String, String>,
37345 _scopes: BTreeSet<String>,
37346}
37347
37348impl<'a, C> common::CallBuilder for UserProfileGuardianDeleteCall<'a, C> {}
37349
37350impl<'a, C> UserProfileGuardianDeleteCall<'a, C>
37351where
37352 C: common::Connector,
37353{
37354 /// Perform the operation you have build so far.
37355 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
37356 use std::borrow::Cow;
37357 use std::io::{Read, Seek};
37358
37359 use common::{url::Params, ToParts};
37360 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
37361
37362 let mut dd = common::DefaultDelegate;
37363 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
37364 dlg.begin(common::MethodInfo {
37365 id: "classroom.userProfiles.guardians.delete",
37366 http_method: hyper::Method::DELETE,
37367 });
37368
37369 for &field in ["alt", "studentId", "guardianId"].iter() {
37370 if self._additional_params.contains_key(field) {
37371 dlg.finished(false);
37372 return Err(common::Error::FieldClash(field));
37373 }
37374 }
37375
37376 let mut params = Params::with_capacity(4 + self._additional_params.len());
37377 params.push("studentId", self._student_id);
37378 params.push("guardianId", self._guardian_id);
37379
37380 params.extend(self._additional_params.iter());
37381
37382 params.push("alt", "json");
37383 let mut url =
37384 self.hub._base_url.clone() + "v1/userProfiles/{studentId}/guardians/{guardianId}";
37385 if self._scopes.is_empty() {
37386 self._scopes
37387 .insert(Scope::GuardianlinkStudent.as_ref().to_string());
37388 }
37389
37390 #[allow(clippy::single_element_loop)]
37391 for &(find_this, param_name) in
37392 [("{studentId}", "studentId"), ("{guardianId}", "guardianId")].iter()
37393 {
37394 url = params.uri_replacement(url, param_name, find_this, false);
37395 }
37396 {
37397 let to_remove = ["guardianId", "studentId"];
37398 params.remove_params(&to_remove);
37399 }
37400
37401 let url = params.parse_with_url(&url);
37402
37403 loop {
37404 let token = match self
37405 .hub
37406 .auth
37407 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
37408 .await
37409 {
37410 Ok(token) => token,
37411 Err(e) => match dlg.token(e) {
37412 Ok(token) => token,
37413 Err(e) => {
37414 dlg.finished(false);
37415 return Err(common::Error::MissingToken(e));
37416 }
37417 },
37418 };
37419 let mut req_result = {
37420 let client = &self.hub.client;
37421 dlg.pre_request();
37422 let mut req_builder = hyper::Request::builder()
37423 .method(hyper::Method::DELETE)
37424 .uri(url.as_str())
37425 .header(USER_AGENT, self.hub._user_agent.clone());
37426
37427 if let Some(token) = token.as_ref() {
37428 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
37429 }
37430
37431 let request = req_builder
37432 .header(CONTENT_LENGTH, 0_u64)
37433 .body(common::to_body::<String>(None));
37434
37435 client.request(request.unwrap()).await
37436 };
37437
37438 match req_result {
37439 Err(err) => {
37440 if let common::Retry::After(d) = dlg.http_error(&err) {
37441 sleep(d).await;
37442 continue;
37443 }
37444 dlg.finished(false);
37445 return Err(common::Error::HttpError(err));
37446 }
37447 Ok(res) => {
37448 let (mut parts, body) = res.into_parts();
37449 let mut body = common::Body::new(body);
37450 if !parts.status.is_success() {
37451 let bytes = common::to_bytes(body).await.unwrap_or_default();
37452 let error = serde_json::from_str(&common::to_string(&bytes));
37453 let response = common::to_response(parts, bytes.into());
37454
37455 if let common::Retry::After(d) =
37456 dlg.http_failure(&response, error.as_ref().ok())
37457 {
37458 sleep(d).await;
37459 continue;
37460 }
37461
37462 dlg.finished(false);
37463
37464 return Err(match error {
37465 Ok(value) => common::Error::BadRequest(value),
37466 _ => common::Error::Failure(response),
37467 });
37468 }
37469 let response = {
37470 let bytes = common::to_bytes(body).await.unwrap_or_default();
37471 let encoded = common::to_string(&bytes);
37472 match serde_json::from_str(&encoded) {
37473 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
37474 Err(error) => {
37475 dlg.response_json_decode_error(&encoded, &error);
37476 return Err(common::Error::JsonDecodeError(
37477 encoded.to_string(),
37478 error,
37479 ));
37480 }
37481 }
37482 };
37483
37484 dlg.finished(true);
37485 return Ok(response);
37486 }
37487 }
37488 }
37489 }
37490
37491 /// The student whose guardian is to be deleted. One of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
37492 ///
37493 /// Sets the *student id* path property to the given value.
37494 ///
37495 /// Even though the property as already been set when instantiating this call,
37496 /// we provide this method for API completeness.
37497 pub fn student_id(mut self, new_value: &str) -> UserProfileGuardianDeleteCall<'a, C> {
37498 self._student_id = new_value.to_string();
37499 self
37500 }
37501 /// The `id` field from a `Guardian`.
37502 ///
37503 /// Sets the *guardian id* path property to the given value.
37504 ///
37505 /// Even though the property as already been set when instantiating this call,
37506 /// we provide this method for API completeness.
37507 pub fn guardian_id(mut self, new_value: &str) -> UserProfileGuardianDeleteCall<'a, C> {
37508 self._guardian_id = new_value.to_string();
37509 self
37510 }
37511 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
37512 /// while executing the actual API request.
37513 ///
37514 /// ````text
37515 /// It should be used to handle progress information, and to implement a certain level of resilience.
37516 /// ````
37517 ///
37518 /// Sets the *delegate* property to the given value.
37519 pub fn delegate(
37520 mut self,
37521 new_value: &'a mut dyn common::Delegate,
37522 ) -> UserProfileGuardianDeleteCall<'a, C> {
37523 self._delegate = Some(new_value);
37524 self
37525 }
37526
37527 /// Set any additional parameter of the query string used in the request.
37528 /// It should be used to set parameters which are not yet available through their own
37529 /// setters.
37530 ///
37531 /// Please note that this method must not be used to set any of the known parameters
37532 /// which have their own setter method. If done anyway, the request will fail.
37533 ///
37534 /// # Additional Parameters
37535 ///
37536 /// * *$.xgafv* (query-string) - V1 error format.
37537 /// * *access_token* (query-string) - OAuth access token.
37538 /// * *alt* (query-string) - Data format for response.
37539 /// * *callback* (query-string) - JSONP
37540 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
37541 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
37542 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
37543 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
37544 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
37545 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
37546 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
37547 pub fn param<T>(mut self, name: T, value: T) -> UserProfileGuardianDeleteCall<'a, C>
37548 where
37549 T: AsRef<str>,
37550 {
37551 self._additional_params
37552 .insert(name.as_ref().to_string(), value.as_ref().to_string());
37553 self
37554 }
37555
37556 /// Identifies the authorization scope for the method you are building.
37557 ///
37558 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
37559 /// [`Scope::GuardianlinkStudent`].
37560 ///
37561 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
37562 /// tokens for more than one scope.
37563 ///
37564 /// Usually there is more than one suitable scope to authorize an operation, some of which may
37565 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
37566 /// sufficient, a read-write scope will do as well.
37567 pub fn add_scope<St>(mut self, scope: St) -> UserProfileGuardianDeleteCall<'a, C>
37568 where
37569 St: AsRef<str>,
37570 {
37571 self._scopes.insert(String::from(scope.as_ref()));
37572 self
37573 }
37574 /// Identifies the authorization scope(s) for the method you are building.
37575 ///
37576 /// See [`Self::add_scope()`] for details.
37577 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserProfileGuardianDeleteCall<'a, C>
37578 where
37579 I: IntoIterator<Item = St>,
37580 St: AsRef<str>,
37581 {
37582 self._scopes
37583 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
37584 self
37585 }
37586
37587 /// Removes all scopes, and no default scope will be used either.
37588 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
37589 /// for details).
37590 pub fn clear_scopes(mut self) -> UserProfileGuardianDeleteCall<'a, C> {
37591 self._scopes.clear();
37592 self
37593 }
37594}
37595
37596/// Returns a specific guardian. This method returns the following error codes: * `PERMISSION_DENIED` if no user that matches the provided `student_id` is visible to the requesting user, if the requesting user is not permitted to view guardian information for the student identified by the `student_id`, if guardians are not enabled for the domain in question, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). * `NOT_FOUND` if the requesting user is permitted to view guardians for the requested `student_id`, but no `Guardian` record exists for that student that matches the provided `guardian_id`.
37597///
37598/// A builder for the *guardians.get* method supported by a *userProfile* resource.
37599/// It is not used directly, but through a [`UserProfileMethods`] instance.
37600///
37601/// # Example
37602///
37603/// Instantiate a resource method builder
37604///
37605/// ```test_harness,no_run
37606/// # extern crate hyper;
37607/// # extern crate hyper_rustls;
37608/// # extern crate google_classroom1 as classroom1;
37609/// # async fn dox() {
37610/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
37611///
37612/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
37613/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
37614/// # .with_native_roots()
37615/// # .unwrap()
37616/// # .https_only()
37617/// # .enable_http2()
37618/// # .build();
37619///
37620/// # let executor = hyper_util::rt::TokioExecutor::new();
37621/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
37622/// # secret,
37623/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
37624/// # yup_oauth2::client::CustomHyperClientBuilder::from(
37625/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
37626/// # ),
37627/// # ).build().await.unwrap();
37628///
37629/// # let client = hyper_util::client::legacy::Client::builder(
37630/// # hyper_util::rt::TokioExecutor::new()
37631/// # )
37632/// # .build(
37633/// # hyper_rustls::HttpsConnectorBuilder::new()
37634/// # .with_native_roots()
37635/// # .unwrap()
37636/// # .https_or_http()
37637/// # .enable_http2()
37638/// # .build()
37639/// # );
37640/// # let mut hub = Classroom::new(client, auth);
37641/// // You can configure optional parameters by calling the respective setters at will, and
37642/// // execute the final call using `doit()`.
37643/// // Values shown here are possibly random and not representative !
37644/// let result = hub.user_profiles().guardians_get("studentId", "guardianId")
37645/// .doit().await;
37646/// # }
37647/// ```
37648pub struct UserProfileGuardianGetCall<'a, C>
37649where
37650 C: 'a,
37651{
37652 hub: &'a Classroom<C>,
37653 _student_id: String,
37654 _guardian_id: String,
37655 _delegate: Option<&'a mut dyn common::Delegate>,
37656 _additional_params: HashMap<String, String>,
37657 _scopes: BTreeSet<String>,
37658}
37659
37660impl<'a, C> common::CallBuilder for UserProfileGuardianGetCall<'a, C> {}
37661
37662impl<'a, C> UserProfileGuardianGetCall<'a, C>
37663where
37664 C: common::Connector,
37665{
37666 /// Perform the operation you have build so far.
37667 pub async fn doit(mut self) -> common::Result<(common::Response, Guardian)> {
37668 use std::borrow::Cow;
37669 use std::io::{Read, Seek};
37670
37671 use common::{url::Params, ToParts};
37672 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
37673
37674 let mut dd = common::DefaultDelegate;
37675 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
37676 dlg.begin(common::MethodInfo {
37677 id: "classroom.userProfiles.guardians.get",
37678 http_method: hyper::Method::GET,
37679 });
37680
37681 for &field in ["alt", "studentId", "guardianId"].iter() {
37682 if self._additional_params.contains_key(field) {
37683 dlg.finished(false);
37684 return Err(common::Error::FieldClash(field));
37685 }
37686 }
37687
37688 let mut params = Params::with_capacity(4 + self._additional_params.len());
37689 params.push("studentId", self._student_id);
37690 params.push("guardianId", self._guardian_id);
37691
37692 params.extend(self._additional_params.iter());
37693
37694 params.push("alt", "json");
37695 let mut url =
37696 self.hub._base_url.clone() + "v1/userProfiles/{studentId}/guardians/{guardianId}";
37697 if self._scopes.is_empty() {
37698 self._scopes
37699 .insert(Scope::GuardianlinkMeReadonly.as_ref().to_string());
37700 }
37701
37702 #[allow(clippy::single_element_loop)]
37703 for &(find_this, param_name) in
37704 [("{studentId}", "studentId"), ("{guardianId}", "guardianId")].iter()
37705 {
37706 url = params.uri_replacement(url, param_name, find_this, false);
37707 }
37708 {
37709 let to_remove = ["guardianId", "studentId"];
37710 params.remove_params(&to_remove);
37711 }
37712
37713 let url = params.parse_with_url(&url);
37714
37715 loop {
37716 let token = match self
37717 .hub
37718 .auth
37719 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
37720 .await
37721 {
37722 Ok(token) => token,
37723 Err(e) => match dlg.token(e) {
37724 Ok(token) => token,
37725 Err(e) => {
37726 dlg.finished(false);
37727 return Err(common::Error::MissingToken(e));
37728 }
37729 },
37730 };
37731 let mut req_result = {
37732 let client = &self.hub.client;
37733 dlg.pre_request();
37734 let mut req_builder = hyper::Request::builder()
37735 .method(hyper::Method::GET)
37736 .uri(url.as_str())
37737 .header(USER_AGENT, self.hub._user_agent.clone());
37738
37739 if let Some(token) = token.as_ref() {
37740 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
37741 }
37742
37743 let request = req_builder
37744 .header(CONTENT_LENGTH, 0_u64)
37745 .body(common::to_body::<String>(None));
37746
37747 client.request(request.unwrap()).await
37748 };
37749
37750 match req_result {
37751 Err(err) => {
37752 if let common::Retry::After(d) = dlg.http_error(&err) {
37753 sleep(d).await;
37754 continue;
37755 }
37756 dlg.finished(false);
37757 return Err(common::Error::HttpError(err));
37758 }
37759 Ok(res) => {
37760 let (mut parts, body) = res.into_parts();
37761 let mut body = common::Body::new(body);
37762 if !parts.status.is_success() {
37763 let bytes = common::to_bytes(body).await.unwrap_or_default();
37764 let error = serde_json::from_str(&common::to_string(&bytes));
37765 let response = common::to_response(parts, bytes.into());
37766
37767 if let common::Retry::After(d) =
37768 dlg.http_failure(&response, error.as_ref().ok())
37769 {
37770 sleep(d).await;
37771 continue;
37772 }
37773
37774 dlg.finished(false);
37775
37776 return Err(match error {
37777 Ok(value) => common::Error::BadRequest(value),
37778 _ => common::Error::Failure(response),
37779 });
37780 }
37781 let response = {
37782 let bytes = common::to_bytes(body).await.unwrap_or_default();
37783 let encoded = common::to_string(&bytes);
37784 match serde_json::from_str(&encoded) {
37785 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
37786 Err(error) => {
37787 dlg.response_json_decode_error(&encoded, &error);
37788 return Err(common::Error::JsonDecodeError(
37789 encoded.to_string(),
37790 error,
37791 ));
37792 }
37793 }
37794 };
37795
37796 dlg.finished(true);
37797 return Ok(response);
37798 }
37799 }
37800 }
37801 }
37802
37803 /// The student whose guardian is being requested. One of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
37804 ///
37805 /// Sets the *student id* path property to the given value.
37806 ///
37807 /// Even though the property as already been set when instantiating this call,
37808 /// we provide this method for API completeness.
37809 pub fn student_id(mut self, new_value: &str) -> UserProfileGuardianGetCall<'a, C> {
37810 self._student_id = new_value.to_string();
37811 self
37812 }
37813 /// The `id` field from a `Guardian`.
37814 ///
37815 /// Sets the *guardian id* path property to the given value.
37816 ///
37817 /// Even though the property as already been set when instantiating this call,
37818 /// we provide this method for API completeness.
37819 pub fn guardian_id(mut self, new_value: &str) -> UserProfileGuardianGetCall<'a, C> {
37820 self._guardian_id = new_value.to_string();
37821 self
37822 }
37823 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
37824 /// while executing the actual API request.
37825 ///
37826 /// ````text
37827 /// It should be used to handle progress information, and to implement a certain level of resilience.
37828 /// ````
37829 ///
37830 /// Sets the *delegate* property to the given value.
37831 pub fn delegate(
37832 mut self,
37833 new_value: &'a mut dyn common::Delegate,
37834 ) -> UserProfileGuardianGetCall<'a, C> {
37835 self._delegate = Some(new_value);
37836 self
37837 }
37838
37839 /// Set any additional parameter of the query string used in the request.
37840 /// It should be used to set parameters which are not yet available through their own
37841 /// setters.
37842 ///
37843 /// Please note that this method must not be used to set any of the known parameters
37844 /// which have their own setter method. If done anyway, the request will fail.
37845 ///
37846 /// # Additional Parameters
37847 ///
37848 /// * *$.xgafv* (query-string) - V1 error format.
37849 /// * *access_token* (query-string) - OAuth access token.
37850 /// * *alt* (query-string) - Data format for response.
37851 /// * *callback* (query-string) - JSONP
37852 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
37853 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
37854 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
37855 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
37856 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
37857 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
37858 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
37859 pub fn param<T>(mut self, name: T, value: T) -> UserProfileGuardianGetCall<'a, C>
37860 where
37861 T: AsRef<str>,
37862 {
37863 self._additional_params
37864 .insert(name.as_ref().to_string(), value.as_ref().to_string());
37865 self
37866 }
37867
37868 /// Identifies the authorization scope for the method you are building.
37869 ///
37870 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
37871 /// [`Scope::GuardianlinkMeReadonly`].
37872 ///
37873 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
37874 /// tokens for more than one scope.
37875 ///
37876 /// Usually there is more than one suitable scope to authorize an operation, some of which may
37877 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
37878 /// sufficient, a read-write scope will do as well.
37879 pub fn add_scope<St>(mut self, scope: St) -> UserProfileGuardianGetCall<'a, C>
37880 where
37881 St: AsRef<str>,
37882 {
37883 self._scopes.insert(String::from(scope.as_ref()));
37884 self
37885 }
37886 /// Identifies the authorization scope(s) for the method you are building.
37887 ///
37888 /// See [`Self::add_scope()`] for details.
37889 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserProfileGuardianGetCall<'a, C>
37890 where
37891 I: IntoIterator<Item = St>,
37892 St: AsRef<str>,
37893 {
37894 self._scopes
37895 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
37896 self
37897 }
37898
37899 /// Removes all scopes, and no default scope will be used either.
37900 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
37901 /// for details).
37902 pub fn clear_scopes(mut self) -> UserProfileGuardianGetCall<'a, C> {
37903 self._scopes.clear();
37904 self
37905 }
37906}
37907
37908/// Returns a list of guardians that the requesting user is permitted to view, restricted to those that match the request. To list guardians for any student that the requesting user may view guardians for, use the literal character `-` for the student ID. This method returns the following error codes: * `PERMISSION_DENIED` if a `student_id` is specified, and the requesting user is not permitted to view guardian information for that student, if `"-"` is specified as the `student_id` and the user is not a domain administrator, if guardians are not enabled for the domain in question, if the `invited_email_address` filter is set by a user who is not a domain administrator, or for other access errors. * `INVALID_ARGUMENT` if a `student_id` is specified, but its format cannot be recognized (it is not an email address, nor a `student_id` from the API, nor the literal string `me`). May also be returned if an invalid `page_token` is provided. * `NOT_FOUND` if a `student_id` is specified, and its format can be recognized, but Classroom has no record of that student.
37909///
37910/// A builder for the *guardians.list* method supported by a *userProfile* resource.
37911/// It is not used directly, but through a [`UserProfileMethods`] instance.
37912///
37913/// # Example
37914///
37915/// Instantiate a resource method builder
37916///
37917/// ```test_harness,no_run
37918/// # extern crate hyper;
37919/// # extern crate hyper_rustls;
37920/// # extern crate google_classroom1 as classroom1;
37921/// # async fn dox() {
37922/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
37923///
37924/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
37925/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
37926/// # .with_native_roots()
37927/// # .unwrap()
37928/// # .https_only()
37929/// # .enable_http2()
37930/// # .build();
37931///
37932/// # let executor = hyper_util::rt::TokioExecutor::new();
37933/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
37934/// # secret,
37935/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
37936/// # yup_oauth2::client::CustomHyperClientBuilder::from(
37937/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
37938/// # ),
37939/// # ).build().await.unwrap();
37940///
37941/// # let client = hyper_util::client::legacy::Client::builder(
37942/// # hyper_util::rt::TokioExecutor::new()
37943/// # )
37944/// # .build(
37945/// # hyper_rustls::HttpsConnectorBuilder::new()
37946/// # .with_native_roots()
37947/// # .unwrap()
37948/// # .https_or_http()
37949/// # .enable_http2()
37950/// # .build()
37951/// # );
37952/// # let mut hub = Classroom::new(client, auth);
37953/// // You can configure optional parameters by calling the respective setters at will, and
37954/// // execute the final call using `doit()`.
37955/// // Values shown here are possibly random and not representative !
37956/// let result = hub.user_profiles().guardians_list("studentId")
37957/// .page_token("invidunt")
37958/// .page_size(-1)
37959/// .invited_email_address("sed")
37960/// .doit().await;
37961/// # }
37962/// ```
37963pub struct UserProfileGuardianListCall<'a, C>
37964where
37965 C: 'a,
37966{
37967 hub: &'a Classroom<C>,
37968 _student_id: String,
37969 _page_token: Option<String>,
37970 _page_size: Option<i32>,
37971 _invited_email_address: Option<String>,
37972 _delegate: Option<&'a mut dyn common::Delegate>,
37973 _additional_params: HashMap<String, String>,
37974 _scopes: BTreeSet<String>,
37975}
37976
37977impl<'a, C> common::CallBuilder for UserProfileGuardianListCall<'a, C> {}
37978
37979impl<'a, C> UserProfileGuardianListCall<'a, C>
37980where
37981 C: common::Connector,
37982{
37983 /// Perform the operation you have build so far.
37984 pub async fn doit(mut self) -> common::Result<(common::Response, ListGuardiansResponse)> {
37985 use std::borrow::Cow;
37986 use std::io::{Read, Seek};
37987
37988 use common::{url::Params, ToParts};
37989 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
37990
37991 let mut dd = common::DefaultDelegate;
37992 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
37993 dlg.begin(common::MethodInfo {
37994 id: "classroom.userProfiles.guardians.list",
37995 http_method: hyper::Method::GET,
37996 });
37997
37998 for &field in [
37999 "alt",
38000 "studentId",
38001 "pageToken",
38002 "pageSize",
38003 "invitedEmailAddress",
38004 ]
38005 .iter()
38006 {
38007 if self._additional_params.contains_key(field) {
38008 dlg.finished(false);
38009 return Err(common::Error::FieldClash(field));
38010 }
38011 }
38012
38013 let mut params = Params::with_capacity(6 + self._additional_params.len());
38014 params.push("studentId", self._student_id);
38015 if let Some(value) = self._page_token.as_ref() {
38016 params.push("pageToken", value);
38017 }
38018 if let Some(value) = self._page_size.as_ref() {
38019 params.push("pageSize", value.to_string());
38020 }
38021 if let Some(value) = self._invited_email_address.as_ref() {
38022 params.push("invitedEmailAddress", value);
38023 }
38024
38025 params.extend(self._additional_params.iter());
38026
38027 params.push("alt", "json");
38028 let mut url = self.hub._base_url.clone() + "v1/userProfiles/{studentId}/guardians";
38029 if self._scopes.is_empty() {
38030 self._scopes
38031 .insert(Scope::GuardianlinkMeReadonly.as_ref().to_string());
38032 }
38033
38034 #[allow(clippy::single_element_loop)]
38035 for &(find_this, param_name) in [("{studentId}", "studentId")].iter() {
38036 url = params.uri_replacement(url, param_name, find_this, false);
38037 }
38038 {
38039 let to_remove = ["studentId"];
38040 params.remove_params(&to_remove);
38041 }
38042
38043 let url = params.parse_with_url(&url);
38044
38045 loop {
38046 let token = match self
38047 .hub
38048 .auth
38049 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
38050 .await
38051 {
38052 Ok(token) => token,
38053 Err(e) => match dlg.token(e) {
38054 Ok(token) => token,
38055 Err(e) => {
38056 dlg.finished(false);
38057 return Err(common::Error::MissingToken(e));
38058 }
38059 },
38060 };
38061 let mut req_result = {
38062 let client = &self.hub.client;
38063 dlg.pre_request();
38064 let mut req_builder = hyper::Request::builder()
38065 .method(hyper::Method::GET)
38066 .uri(url.as_str())
38067 .header(USER_AGENT, self.hub._user_agent.clone());
38068
38069 if let Some(token) = token.as_ref() {
38070 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
38071 }
38072
38073 let request = req_builder
38074 .header(CONTENT_LENGTH, 0_u64)
38075 .body(common::to_body::<String>(None));
38076
38077 client.request(request.unwrap()).await
38078 };
38079
38080 match req_result {
38081 Err(err) => {
38082 if let common::Retry::After(d) = dlg.http_error(&err) {
38083 sleep(d).await;
38084 continue;
38085 }
38086 dlg.finished(false);
38087 return Err(common::Error::HttpError(err));
38088 }
38089 Ok(res) => {
38090 let (mut parts, body) = res.into_parts();
38091 let mut body = common::Body::new(body);
38092 if !parts.status.is_success() {
38093 let bytes = common::to_bytes(body).await.unwrap_or_default();
38094 let error = serde_json::from_str(&common::to_string(&bytes));
38095 let response = common::to_response(parts, bytes.into());
38096
38097 if let common::Retry::After(d) =
38098 dlg.http_failure(&response, error.as_ref().ok())
38099 {
38100 sleep(d).await;
38101 continue;
38102 }
38103
38104 dlg.finished(false);
38105
38106 return Err(match error {
38107 Ok(value) => common::Error::BadRequest(value),
38108 _ => common::Error::Failure(response),
38109 });
38110 }
38111 let response = {
38112 let bytes = common::to_bytes(body).await.unwrap_or_default();
38113 let encoded = common::to_string(&bytes);
38114 match serde_json::from_str(&encoded) {
38115 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
38116 Err(error) => {
38117 dlg.response_json_decode_error(&encoded, &error);
38118 return Err(common::Error::JsonDecodeError(
38119 encoded.to_string(),
38120 error,
38121 ));
38122 }
38123 }
38124 };
38125
38126 dlg.finished(true);
38127 return Ok(response);
38128 }
38129 }
38130 }
38131 }
38132
38133 /// Filter results by the student who the guardian is linked to. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user * the string literal `"-"`, indicating that results should be returned for all students that the requesting user has access to view.
38134 ///
38135 /// Sets the *student id* path property to the given value.
38136 ///
38137 /// Even though the property as already been set when instantiating this call,
38138 /// we provide this method for API completeness.
38139 pub fn student_id(mut self, new_value: &str) -> UserProfileGuardianListCall<'a, C> {
38140 self._student_id = new_value.to_string();
38141 self
38142 }
38143 /// nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.
38144 ///
38145 /// Sets the *page token* query property to the given value.
38146 pub fn page_token(mut self, new_value: &str) -> UserProfileGuardianListCall<'a, C> {
38147 self._page_token = Some(new_value.to_string());
38148 self
38149 }
38150 /// Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.
38151 ///
38152 /// Sets the *page size* query property to the given value.
38153 pub fn page_size(mut self, new_value: i32) -> UserProfileGuardianListCall<'a, C> {
38154 self._page_size = Some(new_value);
38155 self
38156 }
38157 /// Filter results by the email address that the original invitation was sent to, resulting in this guardian link. This filter can only be used by domain administrators.
38158 ///
38159 /// Sets the *invited email address* query property to the given value.
38160 pub fn invited_email_address(mut self, new_value: &str) -> UserProfileGuardianListCall<'a, C> {
38161 self._invited_email_address = Some(new_value.to_string());
38162 self
38163 }
38164 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
38165 /// while executing the actual API request.
38166 ///
38167 /// ````text
38168 /// It should be used to handle progress information, and to implement a certain level of resilience.
38169 /// ````
38170 ///
38171 /// Sets the *delegate* property to the given value.
38172 pub fn delegate(
38173 mut self,
38174 new_value: &'a mut dyn common::Delegate,
38175 ) -> UserProfileGuardianListCall<'a, C> {
38176 self._delegate = Some(new_value);
38177 self
38178 }
38179
38180 /// Set any additional parameter of the query string used in the request.
38181 /// It should be used to set parameters which are not yet available through their own
38182 /// setters.
38183 ///
38184 /// Please note that this method must not be used to set any of the known parameters
38185 /// which have their own setter method. If done anyway, the request will fail.
38186 ///
38187 /// # Additional Parameters
38188 ///
38189 /// * *$.xgafv* (query-string) - V1 error format.
38190 /// * *access_token* (query-string) - OAuth access token.
38191 /// * *alt* (query-string) - Data format for response.
38192 /// * *callback* (query-string) - JSONP
38193 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
38194 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
38195 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
38196 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
38197 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
38198 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
38199 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
38200 pub fn param<T>(mut self, name: T, value: T) -> UserProfileGuardianListCall<'a, C>
38201 where
38202 T: AsRef<str>,
38203 {
38204 self._additional_params
38205 .insert(name.as_ref().to_string(), value.as_ref().to_string());
38206 self
38207 }
38208
38209 /// Identifies the authorization scope for the method you are building.
38210 ///
38211 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
38212 /// [`Scope::GuardianlinkMeReadonly`].
38213 ///
38214 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
38215 /// tokens for more than one scope.
38216 ///
38217 /// Usually there is more than one suitable scope to authorize an operation, some of which may
38218 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
38219 /// sufficient, a read-write scope will do as well.
38220 pub fn add_scope<St>(mut self, scope: St) -> UserProfileGuardianListCall<'a, C>
38221 where
38222 St: AsRef<str>,
38223 {
38224 self._scopes.insert(String::from(scope.as_ref()));
38225 self
38226 }
38227 /// Identifies the authorization scope(s) for the method you are building.
38228 ///
38229 /// See [`Self::add_scope()`] for details.
38230 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserProfileGuardianListCall<'a, C>
38231 where
38232 I: IntoIterator<Item = St>,
38233 St: AsRef<str>,
38234 {
38235 self._scopes
38236 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
38237 self
38238 }
38239
38240 /// Removes all scopes, and no default scope will be used either.
38241 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
38242 /// for details).
38243 pub fn clear_scopes(mut self) -> UserProfileGuardianListCall<'a, C> {
38244 self._scopes.clear();
38245 self
38246 }
38247}
38248
38249/// Returns a user profile. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access this user profile, if no profile exists with the requested ID, or for access errors.
38250///
38251/// A builder for the *get* method supported by a *userProfile* resource.
38252/// It is not used directly, but through a [`UserProfileMethods`] instance.
38253///
38254/// # Example
38255///
38256/// Instantiate a resource method builder
38257///
38258/// ```test_harness,no_run
38259/// # extern crate hyper;
38260/// # extern crate hyper_rustls;
38261/// # extern crate google_classroom1 as classroom1;
38262/// # async fn dox() {
38263/// # use classroom1::{Classroom, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
38264///
38265/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
38266/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
38267/// # .with_native_roots()
38268/// # .unwrap()
38269/// # .https_only()
38270/// # .enable_http2()
38271/// # .build();
38272///
38273/// # let executor = hyper_util::rt::TokioExecutor::new();
38274/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
38275/// # secret,
38276/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
38277/// # yup_oauth2::client::CustomHyperClientBuilder::from(
38278/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
38279/// # ),
38280/// # ).build().await.unwrap();
38281///
38282/// # let client = hyper_util::client::legacy::Client::builder(
38283/// # hyper_util::rt::TokioExecutor::new()
38284/// # )
38285/// # .build(
38286/// # hyper_rustls::HttpsConnectorBuilder::new()
38287/// # .with_native_roots()
38288/// # .unwrap()
38289/// # .https_or_http()
38290/// # .enable_http2()
38291/// # .build()
38292/// # );
38293/// # let mut hub = Classroom::new(client, auth);
38294/// // You can configure optional parameters by calling the respective setters at will, and
38295/// // execute the final call using `doit()`.
38296/// // Values shown here are possibly random and not representative !
38297/// let result = hub.user_profiles().get("userId")
38298/// .doit().await;
38299/// # }
38300/// ```
38301pub struct UserProfileGetCall<'a, C>
38302where
38303 C: 'a,
38304{
38305 hub: &'a Classroom<C>,
38306 _user_id: String,
38307 _delegate: Option<&'a mut dyn common::Delegate>,
38308 _additional_params: HashMap<String, String>,
38309 _scopes: BTreeSet<String>,
38310}
38311
38312impl<'a, C> common::CallBuilder for UserProfileGetCall<'a, C> {}
38313
38314impl<'a, C> UserProfileGetCall<'a, C>
38315where
38316 C: common::Connector,
38317{
38318 /// Perform the operation you have build so far.
38319 pub async fn doit(mut self) -> common::Result<(common::Response, UserProfile)> {
38320 use std::borrow::Cow;
38321 use std::io::{Read, Seek};
38322
38323 use common::{url::Params, ToParts};
38324 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
38325
38326 let mut dd = common::DefaultDelegate;
38327 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
38328 dlg.begin(common::MethodInfo {
38329 id: "classroom.userProfiles.get",
38330 http_method: hyper::Method::GET,
38331 });
38332
38333 for &field in ["alt", "userId"].iter() {
38334 if self._additional_params.contains_key(field) {
38335 dlg.finished(false);
38336 return Err(common::Error::FieldClash(field));
38337 }
38338 }
38339
38340 let mut params = Params::with_capacity(3 + self._additional_params.len());
38341 params.push("userId", self._user_id);
38342
38343 params.extend(self._additional_params.iter());
38344
38345 params.push("alt", "json");
38346 let mut url = self.hub._base_url.clone() + "v1/userProfiles/{userId}";
38347 if self._scopes.is_empty() {
38348 self._scopes
38349 .insert(Scope::RosterReadonly.as_ref().to_string());
38350 }
38351
38352 #[allow(clippy::single_element_loop)]
38353 for &(find_this, param_name) in [("{userId}", "userId")].iter() {
38354 url = params.uri_replacement(url, param_name, find_this, false);
38355 }
38356 {
38357 let to_remove = ["userId"];
38358 params.remove_params(&to_remove);
38359 }
38360
38361 let url = params.parse_with_url(&url);
38362
38363 loop {
38364 let token = match self
38365 .hub
38366 .auth
38367 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
38368 .await
38369 {
38370 Ok(token) => token,
38371 Err(e) => match dlg.token(e) {
38372 Ok(token) => token,
38373 Err(e) => {
38374 dlg.finished(false);
38375 return Err(common::Error::MissingToken(e));
38376 }
38377 },
38378 };
38379 let mut req_result = {
38380 let client = &self.hub.client;
38381 dlg.pre_request();
38382 let mut req_builder = hyper::Request::builder()
38383 .method(hyper::Method::GET)
38384 .uri(url.as_str())
38385 .header(USER_AGENT, self.hub._user_agent.clone());
38386
38387 if let Some(token) = token.as_ref() {
38388 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
38389 }
38390
38391 let request = req_builder
38392 .header(CONTENT_LENGTH, 0_u64)
38393 .body(common::to_body::<String>(None));
38394
38395 client.request(request.unwrap()).await
38396 };
38397
38398 match req_result {
38399 Err(err) => {
38400 if let common::Retry::After(d) = dlg.http_error(&err) {
38401 sleep(d).await;
38402 continue;
38403 }
38404 dlg.finished(false);
38405 return Err(common::Error::HttpError(err));
38406 }
38407 Ok(res) => {
38408 let (mut parts, body) = res.into_parts();
38409 let mut body = common::Body::new(body);
38410 if !parts.status.is_success() {
38411 let bytes = common::to_bytes(body).await.unwrap_or_default();
38412 let error = serde_json::from_str(&common::to_string(&bytes));
38413 let response = common::to_response(parts, bytes.into());
38414
38415 if let common::Retry::After(d) =
38416 dlg.http_failure(&response, error.as_ref().ok())
38417 {
38418 sleep(d).await;
38419 continue;
38420 }
38421
38422 dlg.finished(false);
38423
38424 return Err(match error {
38425 Ok(value) => common::Error::BadRequest(value),
38426 _ => common::Error::Failure(response),
38427 });
38428 }
38429 let response = {
38430 let bytes = common::to_bytes(body).await.unwrap_or_default();
38431 let encoded = common::to_string(&bytes);
38432 match serde_json::from_str(&encoded) {
38433 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
38434 Err(error) => {
38435 dlg.response_json_decode_error(&encoded, &error);
38436 return Err(common::Error::JsonDecodeError(
38437 encoded.to_string(),
38438 error,
38439 ));
38440 }
38441 }
38442 };
38443
38444 dlg.finished(true);
38445 return Ok(response);
38446 }
38447 }
38448 }
38449 }
38450
38451 /// Identifier of the profile to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `"me"`, indicating the requesting user
38452 ///
38453 /// Sets the *user id* path property to the given value.
38454 ///
38455 /// Even though the property as already been set when instantiating this call,
38456 /// we provide this method for API completeness.
38457 pub fn user_id(mut self, new_value: &str) -> UserProfileGetCall<'a, C> {
38458 self._user_id = new_value.to_string();
38459 self
38460 }
38461 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
38462 /// while executing the actual API request.
38463 ///
38464 /// ````text
38465 /// It should be used to handle progress information, and to implement a certain level of resilience.
38466 /// ````
38467 ///
38468 /// Sets the *delegate* property to the given value.
38469 pub fn delegate(
38470 mut self,
38471 new_value: &'a mut dyn common::Delegate,
38472 ) -> UserProfileGetCall<'a, C> {
38473 self._delegate = Some(new_value);
38474 self
38475 }
38476
38477 /// Set any additional parameter of the query string used in the request.
38478 /// It should be used to set parameters which are not yet available through their own
38479 /// setters.
38480 ///
38481 /// Please note that this method must not be used to set any of the known parameters
38482 /// which have their own setter method. If done anyway, the request will fail.
38483 ///
38484 /// # Additional Parameters
38485 ///
38486 /// * *$.xgafv* (query-string) - V1 error format.
38487 /// * *access_token* (query-string) - OAuth access token.
38488 /// * *alt* (query-string) - Data format for response.
38489 /// * *callback* (query-string) - JSONP
38490 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
38491 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
38492 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
38493 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
38494 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
38495 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
38496 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
38497 pub fn param<T>(mut self, name: T, value: T) -> UserProfileGetCall<'a, C>
38498 where
38499 T: AsRef<str>,
38500 {
38501 self._additional_params
38502 .insert(name.as_ref().to_string(), value.as_ref().to_string());
38503 self
38504 }
38505
38506 /// Identifies the authorization scope for the method you are building.
38507 ///
38508 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
38509 /// [`Scope::RosterReadonly`].
38510 ///
38511 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
38512 /// tokens for more than one scope.
38513 ///
38514 /// Usually there is more than one suitable scope to authorize an operation, some of which may
38515 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
38516 /// sufficient, a read-write scope will do as well.
38517 pub fn add_scope<St>(mut self, scope: St) -> UserProfileGetCall<'a, C>
38518 where
38519 St: AsRef<str>,
38520 {
38521 self._scopes.insert(String::from(scope.as_ref()));
38522 self
38523 }
38524 /// Identifies the authorization scope(s) for the method you are building.
38525 ///
38526 /// See [`Self::add_scope()`] for details.
38527 pub fn add_scopes<I, St>(mut self, scopes: I) -> UserProfileGetCall<'a, C>
38528 where
38529 I: IntoIterator<Item = St>,
38530 St: AsRef<str>,
38531 {
38532 self._scopes
38533 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
38534 self
38535 }
38536
38537 /// Removes all scopes, and no default scope will be used either.
38538 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
38539 /// for details).
38540 pub fn clear_scopes(mut self) -> UserProfileGetCall<'a, C> {
38541 self._scopes.clear();
38542 self
38543 }
38544}