[e3d4e0a] | 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 |
|
---|
| 18 | namespace Google\Service\Pubsub\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\Pubsub\AcknowledgeRequest;
|
---|
| 21 | use Google\Service\Pubsub\DetachSubscriptionResponse;
|
---|
| 22 | use Google\Service\Pubsub\ListSubscriptionsResponse;
|
---|
| 23 | use Google\Service\Pubsub\ModifyAckDeadlineRequest;
|
---|
| 24 | use Google\Service\Pubsub\ModifyPushConfigRequest;
|
---|
| 25 | use Google\Service\Pubsub\Policy;
|
---|
| 26 | use Google\Service\Pubsub\PubsubEmpty;
|
---|
| 27 | use Google\Service\Pubsub\PullRequest;
|
---|
| 28 | use Google\Service\Pubsub\PullResponse;
|
---|
| 29 | use Google\Service\Pubsub\SeekRequest;
|
---|
| 30 | use Google\Service\Pubsub\SeekResponse;
|
---|
| 31 | use Google\Service\Pubsub\SetIamPolicyRequest;
|
---|
| 32 | use Google\Service\Pubsub\Subscription;
|
---|
| 33 | use Google\Service\Pubsub\TestIamPermissionsRequest;
|
---|
| 34 | use Google\Service\Pubsub\TestIamPermissionsResponse;
|
---|
| 35 | use Google\Service\Pubsub\UpdateSubscriptionRequest;
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | * The "subscriptions" collection of methods.
|
---|
| 39 | * Typical usage is:
|
---|
| 40 | * <code>
|
---|
| 41 | * $pubsubService = new Google\Service\Pubsub(...);
|
---|
| 42 | * $subscriptions = $pubsubService->projects_subscriptions;
|
---|
| 43 | * </code>
|
---|
| 44 | */
|
---|
| 45 | class ProjectsSubscriptions extends \Google\Service\Resource
|
---|
| 46 | {
|
---|
| 47 | /**
|
---|
| 48 | * Acknowledges the messages associated with the `ack_ids` in the
|
---|
| 49 | * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages
|
---|
| 50 | * from the subscription. Acknowledging a message whose ack deadline has expired
|
---|
| 51 | * may succeed, but such a message may be redelivered later. Acknowledging a
|
---|
| 52 | * message more than once will not result in an error.
|
---|
| 53 | * (subscriptions.acknowledge)
|
---|
| 54 | *
|
---|
| 55 | * @param string $subscription Required. The subscription whose message is being
|
---|
| 56 | * acknowledged. Format is `projects/{project}/subscriptions/{sub}`.
|
---|
| 57 | * @param AcknowledgeRequest $postBody
|
---|
| 58 | * @param array $optParams Optional parameters.
|
---|
| 59 | * @return PubsubEmpty
|
---|
| 60 | * @throws \Google\Service\Exception
|
---|
| 61 | */
|
---|
| 62 | public function acknowledge($subscription, AcknowledgeRequest $postBody, $optParams = [])
|
---|
| 63 | {
|
---|
| 64 | $params = ['subscription' => $subscription, 'postBody' => $postBody];
|
---|
| 65 | $params = array_merge($params, $optParams);
|
---|
| 66 | return $this->call('acknowledge', [$params], PubsubEmpty::class);
|
---|
| 67 | }
|
---|
| 68 | /**
|
---|
| 69 | * Creates a subscription to a given topic. See the [resource name rules]
|
---|
| 70 | * (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). If the
|
---|
| 71 | * subscription already exists, returns `ALREADY_EXISTS`. If the corresponding
|
---|
| 72 | * topic doesn't exist, returns `NOT_FOUND`. If the name is not provided in the
|
---|
| 73 | * request, the server will assign a random name for this subscription on the
|
---|
| 74 | * same project as the topic, conforming to the [resource name format]
|
---|
| 75 | * (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). The
|
---|
| 76 | * generated name is populated in the returned Subscription object. Note that
|
---|
| 77 | * for REST API requests, you must specify a name in the request.
|
---|
| 78 | * (subscriptions.create)
|
---|
| 79 | *
|
---|
| 80 | * @param string $name Required. The name of the subscription. It must have the
|
---|
| 81 | * format `"projects/{project}/subscriptions/{subscription}"`. `{subscription}`
|
---|
| 82 | * must start with a letter, and contain only letters (`[A-Za-z]`), numbers
|
---|
| 83 | * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus
|
---|
| 84 | * (`+`) or percent signs (`%`). It must be between 3 and 255 characters in
|
---|
| 85 | * length, and it must not start with `"goog"`.
|
---|
| 86 | * @param Subscription $postBody
|
---|
| 87 | * @param array $optParams Optional parameters.
|
---|
| 88 | * @return Subscription
|
---|
| 89 | * @throws \Google\Service\Exception
|
---|
| 90 | */
|
---|
| 91 | public function create($name, Subscription $postBody, $optParams = [])
|
---|
| 92 | {
|
---|
| 93 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 94 | $params = array_merge($params, $optParams);
|
---|
| 95 | return $this->call('create', [$params], Subscription::class);
|
---|
| 96 | }
|
---|
| 97 | /**
|
---|
| 98 | * Deletes an existing subscription. All messages retained in the subscription
|
---|
| 99 | * are immediately dropped. Calls to `Pull` after deletion will return
|
---|
| 100 | * `NOT_FOUND`. After a subscription is deleted, a new one may be created with
|
---|
| 101 | * the same name, but the new one has no association with the old subscription
|
---|
| 102 | * or its topic unless the same topic is specified. (subscriptions.delete)
|
---|
| 103 | *
|
---|
| 104 | * @param string $subscription Required. The subscription to delete. Format is
|
---|
| 105 | * `projects/{project}/subscriptions/{sub}`.
|
---|
| 106 | * @param array $optParams Optional parameters.
|
---|
| 107 | * @return PubsubEmpty
|
---|
| 108 | * @throws \Google\Service\Exception
|
---|
| 109 | */
|
---|
| 110 | public function delete($subscription, $optParams = [])
|
---|
| 111 | {
|
---|
| 112 | $params = ['subscription' => $subscription];
|
---|
| 113 | $params = array_merge($params, $optParams);
|
---|
| 114 | return $this->call('delete', [$params], PubsubEmpty::class);
|
---|
| 115 | }
|
---|
| 116 | /**
|
---|
| 117 | * Detaches a subscription from this topic. All messages retained in the
|
---|
| 118 | * subscription are dropped. Subsequent `Pull` and `StreamingPull` requests will
|
---|
| 119 | * return FAILED_PRECONDITION. If the subscription is a push subscription,
|
---|
| 120 | * pushes to the endpoint will stop. (subscriptions.detach)
|
---|
| 121 | *
|
---|
| 122 | * @param string $subscription Required. The subscription to detach. Format is
|
---|
| 123 | * `projects/{project}/subscriptions/{subscription}`.
|
---|
| 124 | * @param array $optParams Optional parameters.
|
---|
| 125 | * @return DetachSubscriptionResponse
|
---|
| 126 | * @throws \Google\Service\Exception
|
---|
| 127 | */
|
---|
| 128 | public function detach($subscription, $optParams = [])
|
---|
| 129 | {
|
---|
| 130 | $params = ['subscription' => $subscription];
|
---|
| 131 | $params = array_merge($params, $optParams);
|
---|
| 132 | return $this->call('detach', [$params], DetachSubscriptionResponse::class);
|
---|
| 133 | }
|
---|
| 134 | /**
|
---|
| 135 | * Gets the configuration details of a subscription. (subscriptions.get)
|
---|
| 136 | *
|
---|
| 137 | * @param string $subscription Required. The name of the subscription to get.
|
---|
| 138 | * Format is `projects/{project}/subscriptions/{sub}`.
|
---|
| 139 | * @param array $optParams Optional parameters.
|
---|
| 140 | * @return Subscription
|
---|
| 141 | * @throws \Google\Service\Exception
|
---|
| 142 | */
|
---|
| 143 | public function get($subscription, $optParams = [])
|
---|
| 144 | {
|
---|
| 145 | $params = ['subscription' => $subscription];
|
---|
| 146 | $params = array_merge($params, $optParams);
|
---|
| 147 | return $this->call('get', [$params], Subscription::class);
|
---|
| 148 | }
|
---|
| 149 | /**
|
---|
| 150 | * Gets the access control policy for a resource. Returns an empty policy if the
|
---|
| 151 | * resource exists and does not have a policy set. (subscriptions.getIamPolicy)
|
---|
| 152 | *
|
---|
| 153 | * @param string $resource REQUIRED: The resource for which the policy is being
|
---|
| 154 | * requested. See [Resource
|
---|
| 155 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
| 156 | * appropriate value for this field.
|
---|
| 157 | * @param array $optParams Optional parameters.
|
---|
| 158 | *
|
---|
| 159 | * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
|
---|
| 160 | * version that will be used to format the policy. Valid values are 0, 1, and 3.
|
---|
| 161 | * Requests specifying an invalid value will be rejected. Requests for policies
|
---|
| 162 | * with any conditional role bindings must specify version 3. Policies with no
|
---|
| 163 | * conditional role bindings may specify any valid value or leave the field
|
---|
| 164 | * unset. The policy in the response might use the policy version that you
|
---|
| 165 | * specified, or it might use a lower policy version. For example, if you
|
---|
| 166 | * specify version 3, but the policy has no conditional role bindings, the
|
---|
| 167 | * response uses version 1. To learn which resources support conditions in their
|
---|
| 168 | * IAM policies, see the [IAM
|
---|
| 169 | * documentation](https://cloud.google.com/iam/help/conditions/resource-
|
---|
| 170 | * policies).
|
---|
| 171 | * @return Policy
|
---|
| 172 | * @throws \Google\Service\Exception
|
---|
| 173 | */
|
---|
| 174 | public function getIamPolicy($resource, $optParams = [])
|
---|
| 175 | {
|
---|
| 176 | $params = ['resource' => $resource];
|
---|
| 177 | $params = array_merge($params, $optParams);
|
---|
| 178 | return $this->call('getIamPolicy', [$params], Policy::class);
|
---|
| 179 | }
|
---|
| 180 | /**
|
---|
| 181 | * Lists matching subscriptions. (subscriptions.listProjectsSubscriptions)
|
---|
| 182 | *
|
---|
| 183 | * @param string $project Required. The name of the project in which to list
|
---|
| 184 | * subscriptions. Format is `projects/{project-id}`.
|
---|
| 185 | * @param array $optParams Optional parameters.
|
---|
| 186 | *
|
---|
| 187 | * @opt_param int pageSize Optional. Maximum number of subscriptions to return.
|
---|
| 188 | * @opt_param string pageToken Optional. The value returned by the last
|
---|
| 189 | * `ListSubscriptionsResponse`; indicates that this is a continuation of a prior
|
---|
| 190 | * `ListSubscriptions` call, and that the system should return the next page of
|
---|
| 191 | * data.
|
---|
| 192 | * @return ListSubscriptionsResponse
|
---|
| 193 | * @throws \Google\Service\Exception
|
---|
| 194 | */
|
---|
| 195 | public function listProjectsSubscriptions($project, $optParams = [])
|
---|
| 196 | {
|
---|
| 197 | $params = ['project' => $project];
|
---|
| 198 | $params = array_merge($params, $optParams);
|
---|
| 199 | return $this->call('list', [$params], ListSubscriptionsResponse::class);
|
---|
| 200 | }
|
---|
| 201 | /**
|
---|
| 202 | * Modifies the ack deadline for a specific message. This method is useful to
|
---|
| 203 | * indicate that more time is needed to process a message by the subscriber, or
|
---|
| 204 | * to make the message available for redelivery if the processing was
|
---|
| 205 | * interrupted. Note that this does not modify the subscription-level
|
---|
| 206 | * `ackDeadlineSeconds` used for subsequent messages.
|
---|
| 207 | * (subscriptions.modifyAckDeadline)
|
---|
| 208 | *
|
---|
| 209 | * @param string $subscription Required. The name of the subscription. Format is
|
---|
| 210 | * `projects/{project}/subscriptions/{sub}`.
|
---|
| 211 | * @param ModifyAckDeadlineRequest $postBody
|
---|
| 212 | * @param array $optParams Optional parameters.
|
---|
| 213 | * @return PubsubEmpty
|
---|
| 214 | * @throws \Google\Service\Exception
|
---|
| 215 | */
|
---|
| 216 | public function modifyAckDeadline($subscription, ModifyAckDeadlineRequest $postBody, $optParams = [])
|
---|
| 217 | {
|
---|
| 218 | $params = ['subscription' => $subscription, 'postBody' => $postBody];
|
---|
| 219 | $params = array_merge($params, $optParams);
|
---|
| 220 | return $this->call('modifyAckDeadline', [$params], PubsubEmpty::class);
|
---|
| 221 | }
|
---|
| 222 | /**
|
---|
| 223 | * Modifies the `PushConfig` for a specified subscription. This may be used to
|
---|
| 224 | * change a push subscription to a pull one (signified by an empty `PushConfig`)
|
---|
| 225 | * or vice versa, or change the endpoint URL and other attributes of a push
|
---|
| 226 | * subscription. Messages will accumulate for delivery continuously through the
|
---|
| 227 | * call regardless of changes to the `PushConfig`.
|
---|
| 228 | * (subscriptions.modifyPushConfig)
|
---|
| 229 | *
|
---|
| 230 | * @param string $subscription Required. The name of the subscription. Format is
|
---|
| 231 | * `projects/{project}/subscriptions/{sub}`.
|
---|
| 232 | * @param ModifyPushConfigRequest $postBody
|
---|
| 233 | * @param array $optParams Optional parameters.
|
---|
| 234 | * @return PubsubEmpty
|
---|
| 235 | * @throws \Google\Service\Exception
|
---|
| 236 | */
|
---|
| 237 | public function modifyPushConfig($subscription, ModifyPushConfigRequest $postBody, $optParams = [])
|
---|
| 238 | {
|
---|
| 239 | $params = ['subscription' => $subscription, 'postBody' => $postBody];
|
---|
| 240 | $params = array_merge($params, $optParams);
|
---|
| 241 | return $this->call('modifyPushConfig', [$params], PubsubEmpty::class);
|
---|
| 242 | }
|
---|
| 243 | /**
|
---|
| 244 | * Updates an existing subscription by updating the fields specified in the
|
---|
| 245 | * update mask. Note that certain properties of a subscription, such as its
|
---|
| 246 | * topic, are not modifiable. (subscriptions.patch)
|
---|
| 247 | *
|
---|
| 248 | * @param string $name Required. The name of the subscription. It must have the
|
---|
| 249 | * format `"projects/{project}/subscriptions/{subscription}"`. `{subscription}`
|
---|
| 250 | * must start with a letter, and contain only letters (`[A-Za-z]`), numbers
|
---|
| 251 | * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus
|
---|
| 252 | * (`+`) or percent signs (`%`). It must be between 3 and 255 characters in
|
---|
| 253 | * length, and it must not start with `"goog"`.
|
---|
| 254 | * @param UpdateSubscriptionRequest $postBody
|
---|
| 255 | * @param array $optParams Optional parameters.
|
---|
| 256 | * @return Subscription
|
---|
| 257 | * @throws \Google\Service\Exception
|
---|
| 258 | */
|
---|
| 259 | public function patch($name, UpdateSubscriptionRequest $postBody, $optParams = [])
|
---|
| 260 | {
|
---|
| 261 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 262 | $params = array_merge($params, $optParams);
|
---|
| 263 | return $this->call('patch', [$params], Subscription::class);
|
---|
| 264 | }
|
---|
| 265 | /**
|
---|
| 266 | * Pulls messages from the server. (subscriptions.pull)
|
---|
| 267 | *
|
---|
| 268 | * @param string $subscription Required. The subscription from which messages
|
---|
| 269 | * should be pulled. Format is `projects/{project}/subscriptions/{sub}`.
|
---|
| 270 | * @param PullRequest $postBody
|
---|
| 271 | * @param array $optParams Optional parameters.
|
---|
| 272 | * @return PullResponse
|
---|
| 273 | * @throws \Google\Service\Exception
|
---|
| 274 | */
|
---|
| 275 | public function pull($subscription, PullRequest $postBody, $optParams = [])
|
---|
| 276 | {
|
---|
| 277 | $params = ['subscription' => $subscription, 'postBody' => $postBody];
|
---|
| 278 | $params = array_merge($params, $optParams);
|
---|
| 279 | return $this->call('pull', [$params], PullResponse::class);
|
---|
| 280 | }
|
---|
| 281 | /**
|
---|
| 282 | * Seeks an existing subscription to a point in time or to a given snapshot,
|
---|
| 283 | * whichever is provided in the request. Snapshots are used in [Seek]
|
---|
| 284 | * (https://cloud.google.com/pubsub/docs/replay-overview) operations, which
|
---|
| 285 | * allow you to manage message acknowledgments in bulk. That is, you can set the
|
---|
| 286 | * acknowledgment state of messages in an existing subscription to the state
|
---|
| 287 | * captured by a snapshot. Note that both the subscription and the snapshot must
|
---|
| 288 | * be on the same topic. (subscriptions.seek)
|
---|
| 289 | *
|
---|
| 290 | * @param string $subscription Required. The subscription to affect.
|
---|
| 291 | * @param SeekRequest $postBody
|
---|
| 292 | * @param array $optParams Optional parameters.
|
---|
| 293 | * @return SeekResponse
|
---|
| 294 | * @throws \Google\Service\Exception
|
---|
| 295 | */
|
---|
| 296 | public function seek($subscription, SeekRequest $postBody, $optParams = [])
|
---|
| 297 | {
|
---|
| 298 | $params = ['subscription' => $subscription, 'postBody' => $postBody];
|
---|
| 299 | $params = array_merge($params, $optParams);
|
---|
| 300 | return $this->call('seek', [$params], SeekResponse::class);
|
---|
| 301 | }
|
---|
| 302 | /**
|
---|
| 303 | * Sets the access control policy on the specified resource. Replaces any
|
---|
| 304 | * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
|
---|
| 305 | * `PERMISSION_DENIED` errors. (subscriptions.setIamPolicy)
|
---|
| 306 | *
|
---|
| 307 | * @param string $resource REQUIRED: The resource for which the policy is being
|
---|
| 308 | * specified. See [Resource
|
---|
| 309 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
| 310 | * appropriate value for this field.
|
---|
| 311 | * @param SetIamPolicyRequest $postBody
|
---|
| 312 | * @param array $optParams Optional parameters.
|
---|
| 313 | * @return Policy
|
---|
| 314 | * @throws \Google\Service\Exception
|
---|
| 315 | */
|
---|
| 316 | public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
|
---|
| 317 | {
|
---|
| 318 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 319 | $params = array_merge($params, $optParams);
|
---|
| 320 | return $this->call('setIamPolicy', [$params], Policy::class);
|
---|
| 321 | }
|
---|
| 322 | /**
|
---|
| 323 | * Returns permissions that a caller has on the specified resource. If the
|
---|
| 324 | * resource does not exist, this will return an empty set of permissions, not a
|
---|
| 325 | * `NOT_FOUND` error. Note: This operation is designed to be used for building
|
---|
| 326 | * permission-aware UIs and command-line tools, not for authorization checking.
|
---|
| 327 | * This operation may "fail open" without warning.
|
---|
| 328 | * (subscriptions.testIamPermissions)
|
---|
| 329 | *
|
---|
| 330 | * @param string $resource REQUIRED: The resource for which the policy detail is
|
---|
| 331 | * being requested. See [Resource
|
---|
| 332 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
| 333 | * appropriate value for this field.
|
---|
| 334 | * @param TestIamPermissionsRequest $postBody
|
---|
| 335 | * @param array $optParams Optional parameters.
|
---|
| 336 | * @return TestIamPermissionsResponse
|
---|
| 337 | * @throws \Google\Service\Exception
|
---|
| 338 | */
|
---|
| 339 | public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
|
---|
| 340 | {
|
---|
| 341 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 342 | $params = array_merge($params, $optParams);
|
---|
| 343 | return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
|
---|
| 344 | }
|
---|
| 345 | }
|
---|
| 346 |
|
---|
| 347 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 348 | class_alias(ProjectsSubscriptions::class, 'Google_Service_Pubsub_Resource_ProjectsSubscriptions');
|
---|