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\PubsubLite\Resource;
19
20use Google\Service\PubsubLite\ListSubscriptionsResponse;
21use Google\Service\PubsubLite\Operation;
22use Google\Service\PubsubLite\PubsubliteEmpty;
23use Google\Service\PubsubLite\SeekSubscriptionRequest;
24use Google\Service\PubsubLite\Subscription;
25
26/**
27 * The "subscriptions" collection of methods.
28 * Typical usage is:
29 *  <code>
30 *   $pubsubliteService = new Google\Service\PubsubLite(...);
31 *   $subscriptions = $pubsubliteService->subscriptions;
32 *  </code>
33 */
34class AdminProjectsLocationsSubscriptions extends \Google\Service\Resource
35{
36  /**
37   * Creates a new subscription. (subscriptions.create)
38   *
39   * @param string $parent Required. The parent location in which to create the
40   * subscription. Structured like
41   * `projects/{project_number}/locations/{location}`.
42   * @param Subscription $postBody
43   * @param array $optParams Optional parameters.
44   *
45   * @opt_param bool skipBacklog If true, the newly created subscription will only
46   * receive messages published after the subscription was created. Otherwise, the
47   * entire message backlog will be received on the subscription. Defaults to
48   * false.
49   * @opt_param string subscriptionId Required. The ID to use for the
50   * subscription, which will become the final component of the subscription's
51   * name. This value is structured like: `my-sub-name`.
52   * @return Subscription
53   */
54  public function create($parent, Subscription $postBody, $optParams = [])
55  {
56    $params = ['parent' => $parent, 'postBody' => $postBody];
57    $params = array_merge($params, $optParams);
58    return $this->call('create', [$params], Subscription::class);
59  }
60  /**
61   * Deletes the specified subscription. (subscriptions.delete)
62   *
63   * @param string $name Required. The name of the subscription to delete.
64   * @param array $optParams Optional parameters.
65   * @return PubsubliteEmpty
66   */
67  public function delete($name, $optParams = [])
68  {
69    $params = ['name' => $name];
70    $params = array_merge($params, $optParams);
71    return $this->call('delete', [$params], PubsubliteEmpty::class);
72  }
73  /**
74   * Returns the subscription configuration. (subscriptions.get)
75   *
76   * @param string $name Required. The name of the subscription whose
77   * configuration to return.
78   * @param array $optParams Optional parameters.
79   * @return Subscription
80   */
81  public function get($name, $optParams = [])
82  {
83    $params = ['name' => $name];
84    $params = array_merge($params, $optParams);
85    return $this->call('get', [$params], Subscription::class);
86  }
87  /**
88   * Returns the list of subscriptions for the given project.
89   * (subscriptions.listAdminProjectsLocationsSubscriptions)
90   *
91   * @param string $parent Required. The parent whose subscriptions are to be
92   * listed. Structured like `projects/{project_number}/locations/{location}`.
93   * @param array $optParams Optional parameters.
94   *
95   * @opt_param int pageSize The maximum number of subscriptions to return. The
96   * service may return fewer than this value. If unset or zero, all subscriptions
97   * for the parent will be returned.
98   * @opt_param string pageToken A page token, received from a previous
99   * `ListSubscriptions` call. Provide this to retrieve the subsequent page. When
100   * paginating, all other parameters provided to `ListSubscriptions` must match
101   * the call that provided the page token.
102   * @return ListSubscriptionsResponse
103   */
104  public function listAdminProjectsLocationsSubscriptions($parent, $optParams = [])
105  {
106    $params = ['parent' => $parent];
107    $params = array_merge($params, $optParams);
108    return $this->call('list', [$params], ListSubscriptionsResponse::class);
109  }
110  /**
111   * Updates properties of the specified subscription. (subscriptions.patch)
112   *
113   * @param string $name The name of the subscription. Structured like: projects/{
114   * project_number}/locations/{location}/subscriptions/{subscription_id}
115   * @param Subscription $postBody
116   * @param array $optParams Optional parameters.
117   *
118   * @opt_param string updateMask Required. A mask specifying the subscription
119   * fields to change.
120   * @return Subscription
121   */
122  public function patch($name, Subscription $postBody, $optParams = [])
123  {
124    $params = ['name' => $name, 'postBody' => $postBody];
125    $params = array_merge($params, $optParams);
126    return $this->call('patch', [$params], Subscription::class);
127  }
128  /**
129   * Performs an out-of-band seek for a subscription to a specified target, which
130   * may be timestamps or named positions within the message backlog. Seek
131   * translates these targets to cursors for each partition and orchestrates
132   * subscribers to start consuming messages from these seek cursors. If an
133   * operation is returned, the seek has been registered and subscribers will
134   * eventually receive messages from the seek cursors (i.e. eventual
135   * consistency), as long as they are using a minimum supported client library
136   * version and not a system that tracks cursors independently of Pub/Sub Lite
137   * (e.g. Apache Beam, Dataflow, Spark). The seek operation will fail for
138   * unsupported clients. If clients would like to know when subscribers react to
139   * the seek (or not), they can poll the operation. The seek operation will
140   * succeed and complete once subscribers are ready to receive messages from the
141   * seek cursors for all partitions of the topic. This means that the seek
142   * operation will not complete until all subscribers come online. If the
143   * previous seek operation has not yet completed, it will be aborted and the new
144   * invocation of seek will supersede it. (subscriptions.seek)
145   *
146   * @param string $name Required. The name of the subscription to seek.
147   * @param SeekSubscriptionRequest $postBody
148   * @param array $optParams Optional parameters.
149   * @return Operation
150   */
151  public function seek($name, SeekSubscriptionRequest $postBody, $optParams = [])
152  {
153    $params = ['name' => $name, 'postBody' => $postBody];
154    $params = array_merge($params, $optParams);
155    return $this->call('seek', [$params], Operation::class);
156  }
157}
158
159// Adding a class alias for backwards compatibility with the previous class name.
160class_alias(AdminProjectsLocationsSubscriptions::class, 'Google_Service_PubsubLite_Resource_AdminProjectsLocationsSubscriptions');
161