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\Course;
22use Google\Service\Classroom\ListCoursesResponse;
23
24/**
25 * The "courses" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $classroomService = new Google\Service\Classroom(...);
29 *   $courses = $classroomService->courses;
30 *  </code>
31 */
32class Courses extends \Google\Service\Resource
33{
34  /**
35   * Creates a course. The user specified in `ownerId` is the owner of the created
36   * course and added as a teacher. A non-admin requesting user can only create a
37   * course with themselves as the owner. Domain admins can create courses owned
38   * by any user within their domain. This method returns the following error
39   * codes: * `PERMISSION_DENIED` if the requesting user is not permitted to
40   * create courses or for access errors. * `NOT_FOUND` if the primary teacher is
41   * not a valid user. * `FAILED_PRECONDITION` if the course owner's account is
42   * disabled or for the following request errors: *
43   * UserGroupsMembershipLimitReached * `ALREADY_EXISTS` if an alias was specified
44   * in the `id` and already exists. (courses.create)
45   *
46   * @param Course $postBody
47   * @param array $optParams Optional parameters.
48   * @return Course
49   */
50  public function create(Course $postBody, $optParams = [])
51  {
52    $params = ['postBody' => $postBody];
53    $params = array_merge($params, $optParams);
54    return $this->call('create', [$params], Course::class);
55  }
56  /**
57   * Deletes a course. This method returns the following error codes: *
58   * `PERMISSION_DENIED` if the requesting user is not permitted to delete the
59   * requested course or for access errors. * `NOT_FOUND` if no course exists with
60   * the requested ID. (courses.delete)
61   *
62   * @param string $id Identifier of the course to delete. This identifier can be
63   * either the Classroom-assigned identifier or an alias.
64   * @param array $optParams Optional parameters.
65   * @return ClassroomEmpty
66   */
67  public function delete($id, $optParams = [])
68  {
69    $params = ['id' => $id];
70    $params = array_merge($params, $optParams);
71    return $this->call('delete', [$params], ClassroomEmpty::class);
72  }
73  /**
74   * Returns a course. This method returns the following error codes: *
75   * `PERMISSION_DENIED` if the requesting user is not permitted to access the
76   * requested course or for access errors. * `NOT_FOUND` if no course exists with
77   * the requested ID. (courses.get)
78   *
79   * @param string $id Identifier of the course to return. This identifier can be
80   * either the Classroom-assigned identifier or an alias.
81   * @param array $optParams Optional parameters.
82   * @return Course
83   */
84  public function get($id, $optParams = [])
85  {
86    $params = ['id' => $id];
87    $params = array_merge($params, $optParams);
88    return $this->call('get', [$params], Course::class);
89  }
90  /**
91   * Returns a list of courses that the requesting user is permitted to view,
92   * restricted to those that match the request. Returned courses are ordered by
93   * creation time, with the most recently created coming first. This method
94   * returns the following error codes: * `PERMISSION_DENIED` for access errors. *
95   * `INVALID_ARGUMENT` if the query argument is malformed. * `NOT_FOUND` if any
96   * users specified in the query arguments do not exist. (courses.listCourses)
97   *
98   * @param array $optParams Optional parameters.
99   *
100   * @opt_param string courseStates Restricts returned courses to those in one of
101   * the specified states The default value is ACTIVE, ARCHIVED, PROVISIONED,
102   * DECLINED.
103   * @opt_param int pageSize Maximum number of items to return. Zero or
104   * unspecified indicates that the server may assign a maximum. The server may
105   * return fewer than the specified number of results.
106   * @opt_param string pageToken nextPageToken value returned from a previous list
107   * call, indicating that the subsequent page of results should be returned. The
108   * list request must be otherwise identical to the one that resulted in this
109   * token.
110   * @opt_param string studentId Restricts returned courses to those having a
111   * student with the specified identifier. The identifier can be one of the
112   * following: * the numeric identifier for the user * the email address of the
113   * user * the string literal `"me"`, indicating the requesting user
114   * @opt_param string teacherId Restricts returned courses to those having a
115   * teacher with the specified identifier. The identifier can be one of the
116   * following: * the numeric identifier for the user * the email address of the
117   * user * the string literal `"me"`, indicating the requesting user
118   * @return ListCoursesResponse
119   */
120  public function listCourses($optParams = [])
121  {
122    $params = [];
123    $params = array_merge($params, $optParams);
124    return $this->call('list', [$params], ListCoursesResponse::class);
125  }
126  /**
127   * Updates one or more fields in a course. This method returns the following
128   * error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to
129   * modify the requested course or for access errors. * `NOT_FOUND` if no course
130   * exists with the requested ID. * `INVALID_ARGUMENT` if invalid fields are
131   * specified in the update mask or if no update mask is supplied. *
132   * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable
133   * * InactiveCourseOwner (courses.patch)
134   *
135   * @param string $id Identifier of the course to update. This identifier can be
136   * either the Classroom-assigned identifier or an alias.
137   * @param Course $postBody
138   * @param array $optParams Optional parameters.
139   *
140   * @opt_param string updateMask Mask that identifies which fields on the course
141   * to update. This field is required to do an update. The update will fail if
142   * invalid fields are specified. The following fields are valid: * `name` *
143   * `section` * `descriptionHeading` * `description` * `room` * `courseState` *
144   * `ownerId` Note: patches to ownerId are treated as being effective
145   * immediately, but in practice it may take some time for the ownership transfer
146   * of all affected resources to complete. When set in a query parameter, this
147   * field should be specified as `updateMask=,,...`
148   * @return Course
149   */
150  public function patch($id, Course $postBody, $optParams = [])
151  {
152    $params = ['id' => $id, 'postBody' => $postBody];
153    $params = array_merge($params, $optParams);
154    return $this->call('patch', [$params], Course::class);
155  }
156  /**
157   * Updates a course. This method returns the following error codes: *
158   * `PERMISSION_DENIED` if the requesting user is not permitted to modify the
159   * requested course or for access errors. * `NOT_FOUND` if no course exists with
160   * the requested ID. * `FAILED_PRECONDITION` for the following request errors: *
161   * CourseNotModifiable (courses.update)
162   *
163   * @param string $id Identifier of the course to update. This identifier can be
164   * either the Classroom-assigned identifier or an alias.
165   * @param Course $postBody
166   * @param array $optParams Optional parameters.
167   * @return Course
168   */
169  public function update($id, Course $postBody, $optParams = [])
170  {
171    $params = ['id' => $id, 'postBody' => $postBody];
172    $params = array_merge($params, $optParams);
173    return $this->call('update', [$params], Course::class);
174  }
175}
176
177// Adding a class alias for backwards compatibility with the previous class name.
178class_alias(Courses::class, 'Google_Service_Classroom_Resource_Courses');
179