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\Registration;
22
23/**
24 * The "registrations" collection of methods.
25 * Typical usage is:
26 *  <code>
27 *   $classroomService = new Google\Service\Classroom(...);
28 *   $registrations = $classroomService->registrations;
29 *  </code>
30 */
31class Registrations extends \Google\Service\Resource
32{
33  /**
34   * Creates a `Registration`, causing Classroom to start sending notifications
35   * from the provided `feed` to the destination provided in `cloudPubSubTopic`.
36   * Returns the created `Registration`. Currently, this will be the same as the
37   * argument, but with server-assigned fields such as `expiry_time` and `id`
38   * filled in. Note that any value specified for the `expiry_time` or `id` fields
39   * will be ignored. While Classroom may validate the `cloudPubSubTopic` and
40   * return errors on a best effort basis, it is the caller's responsibility to
41   * ensure that it exists and that Classroom has permission to publish to it.
42   * This method may return the following error codes: * `PERMISSION_DENIED` if: *
43   * the authenticated user does not have permission to receive notifications from
44   * the requested field; or * the current user has not granted access to the
45   * current Cloud project with the appropriate scope for the requested feed. Note
46   * that domain-wide delegation of authority is not currently supported for this
47   * purpose. If the request has the appropriate scope, but no grant exists, a
48   * Request Errors is returned. * another access error is encountered. *
49   * `INVALID_ARGUMENT` if: * no `cloudPubsubTopic` is specified, or the specified
50   * `cloudPubsubTopic` is not valid; or * no `feed` is specified, or the
51   * specified `feed` is not valid. * `NOT_FOUND` if: * the specified `feed`
52   * cannot be located, or the requesting user does not have permission to
53   * determine whether or not it exists; or * the specified `cloudPubsubTopic`
54   * cannot be located, or Classroom has not been granted permission to publish to
55   * it. (registrations.create)
56   *
57   * @param Registration $postBody
58   * @param array $optParams Optional parameters.
59   * @return Registration
60   */
61  public function create(Registration $postBody, $optParams = [])
62  {
63    $params = ['postBody' => $postBody];
64    $params = array_merge($params, $optParams);
65    return $this->call('create', [$params], Registration::class);
66  }
67  /**
68   * Deletes a `Registration`, causing Classroom to stop sending notifications for
69   * that `Registration`. (registrations.delete)
70   *
71   * @param string $registrationId The `registration_id` of the `Registration` to
72   * be deleted.
73   * @param array $optParams Optional parameters.
74   * @return ClassroomEmpty
75   */
76  public function delete($registrationId, $optParams = [])
77  {
78    $params = ['registrationId' => $registrationId];
79    $params = array_merge($params, $optParams);
80    return $this->call('delete', [$params], ClassroomEmpty::class);
81  }
82}
83
84// Adding a class alias for backwards compatibility with the previous class name.
85class_alias(Registrations::class, 'Google_Service_Classroom_Resource_Registrations');
86