1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\Classroom\Resource;
19
20use Google\Service\Classroom\ClassroomEmpty;
21use Google\Service\Classroom\ListTeachersResponse;
22use Google\Service\Classroom\Teacher;
23
24/**
25 * The "teachers" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $classroomService = new Google\Service\Classroom(...);
29 *   $teachers = $classroomService->teachers;
30 *  </code>
31 */
32class CoursesTeachers extends \Google\Service\Resource
33{
34  /**
35   * Creates a teacher of a course. Domain administrators are permitted to
36   * [directly add](https://developers.google.com/classroom/guides/manage-users)
37   * users within their domain as teachers to courses within their domain. Non-
38   * admin users should send an Invitation instead. This method returns the
39   * following error codes: * `PERMISSION_DENIED` if the requesting user is not
40   * permitted to create teachers in this course or for access errors. *
41   * `NOT_FOUND` if the requested course ID does not exist. *
42   * `FAILED_PRECONDITION` if the requested user's account is disabled, for the
43   * following request errors: * CourseMemberLimitReached * CourseNotModifiable *
44   * CourseTeacherLimitReached * UserGroupsMembershipLimitReached *
45   * InactiveCourseOwner * `ALREADY_EXISTS` if the user is already a teacher or
46   * student in the course. (teachers.create)
47   *
48   * @param string $courseId Identifier of the course. This identifier can be
49   * either the Classroom-assigned identifier or an alias.
50   * @param Teacher $postBody
51   * @param array $optParams Optional parameters.
52   * @return Teacher
53   */
54  public function create($courseId, Teacher $postBody, $optParams = [])
55  {
56    $params = ['courseId' => $courseId, 'postBody' => $postBody];
57    $params = array_merge($params, $optParams);
58    return $this->call('create', [$params], Teacher::class);
59  }
60  /**
61   * Removes the specified teacher from the specified course. This method returns
62   * the following error codes: * `PERMISSION_DENIED` if the requesting user is
63   * not permitted to delete teachers of this course or for access errors. *
64   * `NOT_FOUND` if no teacher of this course has the requested ID or if the
65   * course does not exist. * `FAILED_PRECONDITION` if the requested ID belongs to
66   * the primary teacher of this course. * `FAILED_PRECONDITION` if the requested
67   * ID belongs to the owner of the course Drive folder. * `FAILED_PRECONDITION`
68   * if the course no longer has an active owner. (teachers.delete)
69   *
70   * @param string $courseId Identifier of the course. This identifier can be
71   * either the Classroom-assigned identifier or an alias.
72   * @param string $userId Identifier of the teacher to delete. The identifier can
73   * be one of the following: * the numeric identifier for the user * the email
74   * address of the user * the string literal `"me"`, indicating the requesting
75   * user
76   * @param array $optParams Optional parameters.
77   * @return ClassroomEmpty
78   */
79  public function delete($courseId, $userId, $optParams = [])
80  {
81    $params = ['courseId' => $courseId, 'userId' => $userId];
82    $params = array_merge($params, $optParams);
83    return $this->call('delete', [$params], ClassroomEmpty::class);
84  }
85  /**
86   * Returns a teacher of a course. This method returns the following error codes:
87   * * `PERMISSION_DENIED` if the requesting user is not permitted to view
88   * teachers of this course or for access errors. * `NOT_FOUND` if no teacher of
89   * this course has the requested ID or if the course does not exist.
90   * (teachers.get)
91   *
92   * @param string $courseId Identifier of the course. This identifier can be
93   * either the Classroom-assigned identifier or an alias.
94   * @param string $userId Identifier of the teacher to return. The identifier can
95   * be one of the following: * the numeric identifier for the user * the email
96   * address of the user * the string literal `"me"`, indicating the requesting
97   * user
98   * @param array $optParams Optional parameters.
99   * @return Teacher
100   */
101  public function get($courseId, $userId, $optParams = [])
102  {
103    $params = ['courseId' => $courseId, 'userId' => $userId];
104    $params = array_merge($params, $optParams);
105    return $this->call('get', [$params], Teacher::class);
106  }
107  /**
108   * Returns a list of teachers of this course that the requester is permitted to
109   * view. This method returns the following error codes: * `NOT_FOUND` if the
110   * course does not exist. * `PERMISSION_DENIED` for access errors.
111   * (teachers.listCoursesTeachers)
112   *
113   * @param string $courseId Identifier of the course. This identifier can be
114   * either the Classroom-assigned identifier or an alias.
115   * @param array $optParams Optional parameters.
116   *
117   * @opt_param int pageSize Maximum number of items to return. The default is 30
118   * if unspecified or `0`. The server may return fewer than the specified number
119   * of results.
120   * @opt_param string pageToken nextPageToken value returned from a previous list
121   * call, indicating that the subsequent page of results should be returned. The
122   * list request must be otherwise identical to the one that resulted in this
123   * token.
124   * @return ListTeachersResponse
125   */
126  public function listCoursesTeachers($courseId, $optParams = [])
127  {
128    $params = ['courseId' => $courseId];
129    $params = array_merge($params, $optParams);
130    return $this->call('list', [$params], ListTeachersResponse::class);
131  }
132}
133
134// Adding a class alias for backwards compatibility with the previous class name.
135class_alias(CoursesTeachers::class, 'Google_Service_Classroom_Resource_CoursesTeachers');
136