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\ListTopicResponse;
22use Google\Service\Classroom\Topic;
23
24/**
25 * The "topics" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $classroomService = new Google\Service\Classroom(...);
29 *   $topics = $classroomService->topics;
30 *  </code>
31 */
32class CoursesTopics extends \Google\Service\Resource
33{
34  /**
35   * Creates a topic. This method returns the following error codes: *
36   * `PERMISSION_DENIED` if the requesting user is not permitted to access the
37   * requested course, create a topic in the requested course, or for access
38   * errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if
39   * the requested course does not exist. (topics.create)
40   *
41   * @param string $courseId Identifier of the course. This identifier can be
42   * either the Classroom-assigned identifier or an alias.
43   * @param Topic $postBody
44   * @param array $optParams Optional parameters.
45   * @return Topic
46   */
47  public function create($courseId, Topic $postBody, $optParams = [])
48  {
49    $params = ['courseId' => $courseId, 'postBody' => $postBody];
50    $params = array_merge($params, $optParams);
51    return $this->call('create', [$params], Topic::class);
52  }
53  /**
54   * Deletes a topic. This method returns the following error codes: *
55   * `PERMISSION_DENIED` if the requesting user is not allowed to delete the
56   * requested topic or for access errors. * `FAILED_PRECONDITION` if the
57   * requested topic has already been deleted. * `NOT_FOUND` if no course or topic
58   * exists with the requested ID. (topics.delete)
59   *
60   * @param string $courseId Identifier of the course. This identifier can be
61   * either the Classroom-assigned identifier or an alias.
62   * @param string $id Identifier of the topic to delete.
63   * @param array $optParams Optional parameters.
64   * @return ClassroomEmpty
65   */
66  public function delete($courseId, $id, $optParams = [])
67  {
68    $params = ['courseId' => $courseId, 'id' => $id];
69    $params = array_merge($params, $optParams);
70    return $this->call('delete', [$params], ClassroomEmpty::class);
71  }
72  /**
73   * Returns a topic. This method returns the following error codes: *
74   * `PERMISSION_DENIED` if the requesting user is not permitted to access the
75   * requested course or topic, or for access errors. * `INVALID_ARGUMENT` if the
76   * request is malformed. * `NOT_FOUND` if the requested course or topic does not
77   * exist. (topics.get)
78   *
79   * @param string $courseId Identifier of the course.
80   * @param string $id Identifier of the topic.
81   * @param array $optParams Optional parameters.
82   * @return Topic
83   */
84  public function get($courseId, $id, $optParams = [])
85  {
86    $params = ['courseId' => $courseId, 'id' => $id];
87    $params = array_merge($params, $optParams);
88    return $this->call('get', [$params], Topic::class);
89  }
90  /**
91   * Returns the list of topics that the requester is permitted to view. This
92   * method returns the following error codes: * `PERMISSION_DENIED` if the
93   * requesting user is not permitted to access the requested course or for access
94   * errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if
95   * the requested course does not exist. (topics.listCoursesTopics)
96   *
97   * @param string $courseId Identifier of the course. This identifier can be
98   * either the Classroom-assigned identifier or an alias.
99   * @param array $optParams Optional parameters.
100   *
101   * @opt_param int pageSize Maximum number of items to return. Zero or
102   * unspecified indicates that the server may assign a maximum. The server may
103   * return fewer than the specified number of results.
104   * @opt_param string pageToken nextPageToken value returned from a previous list
105   * call, indicating that the subsequent page of results should be returned. The
106   * list request must be otherwise identical to the one that resulted in this
107   * token.
108   * @return ListTopicResponse
109   */
110  public function listCoursesTopics($courseId, $optParams = [])
111  {
112    $params = ['courseId' => $courseId];
113    $params = array_merge($params, $optParams);
114    return $this->call('list', [$params], ListTopicResponse::class);
115  }
116  /**
117   * Updates one or more fields of a topic. This method returns the following
118   * error codes: * `PERMISSION_DENIED` if the requesting developer project did
119   * not create the corresponding topic or for access errors. * `INVALID_ARGUMENT`
120   * if the request is malformed. * `NOT_FOUND` if the requested course or topic
121   * does not exist (topics.patch)
122   *
123   * @param string $courseId Identifier of the course. This identifier can be
124   * either the Classroom-assigned identifier or an alias.
125   * @param string $id Identifier of the topic.
126   * @param Topic $postBody
127   * @param array $optParams Optional parameters.
128   *
129   * @opt_param string updateMask Mask that identifies which fields on the topic
130   * to update. This field is required to do an update. The update fails if
131   * invalid fields are specified. If a field supports empty values, it can be
132   * cleared by specifying it in the update mask and not in the Topic object. If a
133   * field that does not support empty values is included in the update mask and
134   * not set in the Topic object, an `INVALID_ARGUMENT` error is returned. The
135   * following fields may be specified: * `name`
136   * @return Topic
137   */
138  public function patch($courseId, $id, Topic $postBody, $optParams = [])
139  {
140    $params = ['courseId' => $courseId, 'id' => $id, 'postBody' => $postBody];
141    $params = array_merge($params, $optParams);
142    return $this->call('patch', [$params], Topic::class);
143  }
144}
145
146// Adding a class alias for backwards compatibility with the previous class name.
147class_alias(CoursesTopics::class, 'Google_Service_Classroom_Resource_CoursesTopics');
148