[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\CreateSnapshotRequest;
|
---|
| 21 | use Google\Service\Pubsub\ListSnapshotsResponse;
|
---|
| 22 | use Google\Service\Pubsub\Policy;
|
---|
| 23 | use Google\Service\Pubsub\PubsubEmpty;
|
---|
| 24 | use Google\Service\Pubsub\SetIamPolicyRequest;
|
---|
| 25 | use Google\Service\Pubsub\Snapshot;
|
---|
| 26 | use Google\Service\Pubsub\TestIamPermissionsRequest;
|
---|
| 27 | use Google\Service\Pubsub\TestIamPermissionsResponse;
|
---|
| 28 | use Google\Service\Pubsub\UpdateSnapshotRequest;
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * The "snapshots" collection of methods.
|
---|
| 32 | * Typical usage is:
|
---|
| 33 | * <code>
|
---|
| 34 | * $pubsubService = new Google\Service\Pubsub(...);
|
---|
| 35 | * $snapshots = $pubsubService->projects_snapshots;
|
---|
| 36 | * </code>
|
---|
| 37 | */
|
---|
| 38 | class ProjectsSnapshots extends \Google\Service\Resource
|
---|
| 39 | {
|
---|
| 40 | /**
|
---|
| 41 | * Creates a snapshot from the requested subscription. Snapshots are used in
|
---|
| 42 | * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations,
|
---|
| 43 | * which allow you to manage message acknowledgments in bulk. That is, you can
|
---|
| 44 | * set the acknowledgment state of messages in an existing subscription to the
|
---|
| 45 | * state captured by a snapshot. If the snapshot already exists, returns
|
---|
| 46 | * `ALREADY_EXISTS`. If the requested subscription doesn't exist, returns
|
---|
| 47 | * `NOT_FOUND`. If the backlog in the subscription is too old -- and the
|
---|
| 48 | * resulting snapshot would expire in less than 1 hour -- then
|
---|
| 49 | * `FAILED_PRECONDITION` is returned. See also the `Snapshot.expire_time` field.
|
---|
| 50 | * If the name is not provided in the request, the server will assign a random
|
---|
| 51 | * name for this snapshot on the same project as the subscription, conforming to
|
---|
| 52 | * the [resource name format] (https://cloud.google.com/pubsub/docs/pubsub-
|
---|
| 53 | * basics#resource_names). The generated name is populated in the returned
|
---|
| 54 | * Snapshot object. Note that for REST API requests, you must specify a name in
|
---|
| 55 | * the request. (snapshots.create)
|
---|
| 56 | *
|
---|
| 57 | * @param string $name Required. User-provided name for this snapshot. If the
|
---|
| 58 | * name is not provided in the request, the server will assign a random name for
|
---|
| 59 | * this snapshot on the same project as the subscription. Note that for REST API
|
---|
| 60 | * requests, you must specify a name. See the [resource name
|
---|
| 61 | * rules](https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names).
|
---|
| 62 | * Format is `projects/{project}/snapshots/{snap}`.
|
---|
| 63 | * @param CreateSnapshotRequest $postBody
|
---|
| 64 | * @param array $optParams Optional parameters.
|
---|
| 65 | * @return Snapshot
|
---|
| 66 | * @throws \Google\Service\Exception
|
---|
| 67 | */
|
---|
| 68 | public function create($name, CreateSnapshotRequest $postBody, $optParams = [])
|
---|
| 69 | {
|
---|
| 70 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 71 | $params = array_merge($params, $optParams);
|
---|
| 72 | return $this->call('create', [$params], Snapshot::class);
|
---|
| 73 | }
|
---|
| 74 | /**
|
---|
| 75 | * Removes an existing snapshot. Snapshots are used in [Seek]
|
---|
| 76 | * (https://cloud.google.com/pubsub/docs/replay-overview) operations, which
|
---|
| 77 | * allow you to manage message acknowledgments in bulk. That is, you can set the
|
---|
| 78 | * acknowledgment state of messages in an existing subscription to the state
|
---|
| 79 | * captured by a snapshot. When the snapshot is deleted, all messages retained
|
---|
| 80 | * in the snapshot are immediately dropped. After a snapshot is deleted, a new
|
---|
| 81 | * one may be created with the same name, but the new one has no association
|
---|
| 82 | * with the old snapshot or its subscription, unless the same subscription is
|
---|
| 83 | * specified. (snapshots.delete)
|
---|
| 84 | *
|
---|
| 85 | * @param string $snapshot Required. The name of the snapshot to delete. Format
|
---|
| 86 | * is `projects/{project}/snapshots/{snap}`.
|
---|
| 87 | * @param array $optParams Optional parameters.
|
---|
| 88 | * @return PubsubEmpty
|
---|
| 89 | * @throws \Google\Service\Exception
|
---|
| 90 | */
|
---|
| 91 | public function delete($snapshot, $optParams = [])
|
---|
| 92 | {
|
---|
| 93 | $params = ['snapshot' => $snapshot];
|
---|
| 94 | $params = array_merge($params, $optParams);
|
---|
| 95 | return $this->call('delete', [$params], PubsubEmpty::class);
|
---|
| 96 | }
|
---|
| 97 | /**
|
---|
| 98 | * Gets the configuration details of a snapshot. Snapshots are used in
|
---|
| 99 | * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations,
|
---|
| 100 | * which allow you to manage message acknowledgments in bulk. That is, you can
|
---|
| 101 | * set the acknowledgment state of messages in an existing subscription to the
|
---|
| 102 | * state captured by a snapshot. (snapshots.get)
|
---|
| 103 | *
|
---|
| 104 | * @param string $snapshot Required. The name of the snapshot to get. Format is
|
---|
| 105 | * `projects/{project}/snapshots/{snap}`.
|
---|
| 106 | * @param array $optParams Optional parameters.
|
---|
| 107 | * @return Snapshot
|
---|
| 108 | * @throws \Google\Service\Exception
|
---|
| 109 | */
|
---|
| 110 | public function get($snapshot, $optParams = [])
|
---|
| 111 | {
|
---|
| 112 | $params = ['snapshot' => $snapshot];
|
---|
| 113 | $params = array_merge($params, $optParams);
|
---|
| 114 | return $this->call('get', [$params], Snapshot::class);
|
---|
| 115 | }
|
---|
| 116 | /**
|
---|
| 117 | * Gets the access control policy for a resource. Returns an empty policy if the
|
---|
| 118 | * resource exists and does not have a policy set. (snapshots.getIamPolicy)
|
---|
| 119 | *
|
---|
| 120 | * @param string $resource REQUIRED: The resource for which the policy is being
|
---|
| 121 | * requested. See [Resource
|
---|
| 122 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
| 123 | * appropriate value for this field.
|
---|
| 124 | * @param array $optParams Optional parameters.
|
---|
| 125 | *
|
---|
| 126 | * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
|
---|
| 127 | * version that will be used to format the policy. Valid values are 0, 1, and 3.
|
---|
| 128 | * Requests specifying an invalid value will be rejected. Requests for policies
|
---|
| 129 | * with any conditional role bindings must specify version 3. Policies with no
|
---|
| 130 | * conditional role bindings may specify any valid value or leave the field
|
---|
| 131 | * unset. The policy in the response might use the policy version that you
|
---|
| 132 | * specified, or it might use a lower policy version. For example, if you
|
---|
| 133 | * specify version 3, but the policy has no conditional role bindings, the
|
---|
| 134 | * response uses version 1. To learn which resources support conditions in their
|
---|
| 135 | * IAM policies, see the [IAM
|
---|
| 136 | * documentation](https://cloud.google.com/iam/help/conditions/resource-
|
---|
| 137 | * policies).
|
---|
| 138 | * @return Policy
|
---|
| 139 | * @throws \Google\Service\Exception
|
---|
| 140 | */
|
---|
| 141 | public function getIamPolicy($resource, $optParams = [])
|
---|
| 142 | {
|
---|
| 143 | $params = ['resource' => $resource];
|
---|
| 144 | $params = array_merge($params, $optParams);
|
---|
| 145 | return $this->call('getIamPolicy', [$params], Policy::class);
|
---|
| 146 | }
|
---|
| 147 | /**
|
---|
| 148 | * Lists the existing snapshots. Snapshots are used in [Seek](
|
---|
| 149 | * https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow
|
---|
| 150 | * you to manage message acknowledgments in bulk. That is, you can set the
|
---|
| 151 | * acknowledgment state of messages in an existing subscription to the state
|
---|
| 152 | * captured by a snapshot. (snapshots.listProjectsSnapshots)
|
---|
| 153 | *
|
---|
| 154 | * @param string $project Required. The name of the project in which to list
|
---|
| 155 | * snapshots. Format is `projects/{project-id}`.
|
---|
| 156 | * @param array $optParams Optional parameters.
|
---|
| 157 | *
|
---|
| 158 | * @opt_param int pageSize Optional. Maximum number of snapshots to return.
|
---|
| 159 | * @opt_param string pageToken Optional. The value returned by the last
|
---|
| 160 | * `ListSnapshotsResponse`; indicates that this is a continuation of a prior
|
---|
| 161 | * `ListSnapshots` call, and that the system should return the next page of
|
---|
| 162 | * data.
|
---|
| 163 | * @return ListSnapshotsResponse
|
---|
| 164 | * @throws \Google\Service\Exception
|
---|
| 165 | */
|
---|
| 166 | public function listProjectsSnapshots($project, $optParams = [])
|
---|
| 167 | {
|
---|
| 168 | $params = ['project' => $project];
|
---|
| 169 | $params = array_merge($params, $optParams);
|
---|
| 170 | return $this->call('list', [$params], ListSnapshotsResponse::class);
|
---|
| 171 | }
|
---|
| 172 | /**
|
---|
| 173 | * Updates an existing snapshot by updating the fields specified in the update
|
---|
| 174 | * mask. Snapshots are used in
|
---|
| 175 | * [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations,
|
---|
| 176 | * which allow you to manage message acknowledgments in bulk. That is, you can
|
---|
| 177 | * set the acknowledgment state of messages in an existing subscription to the
|
---|
| 178 | * state captured by a snapshot. (snapshots.patch)
|
---|
| 179 | *
|
---|
| 180 | * @param string $name Optional. The name of the snapshot.
|
---|
| 181 | * @param UpdateSnapshotRequest $postBody
|
---|
| 182 | * @param array $optParams Optional parameters.
|
---|
| 183 | * @return Snapshot
|
---|
| 184 | * @throws \Google\Service\Exception
|
---|
| 185 | */
|
---|
| 186 | public function patch($name, UpdateSnapshotRequest $postBody, $optParams = [])
|
---|
| 187 | {
|
---|
| 188 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 189 | $params = array_merge($params, $optParams);
|
---|
| 190 | return $this->call('patch', [$params], Snapshot::class);
|
---|
| 191 | }
|
---|
| 192 | /**
|
---|
| 193 | * Sets the access control policy on the specified resource. Replaces any
|
---|
| 194 | * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
|
---|
| 195 | * `PERMISSION_DENIED` errors. (snapshots.setIamPolicy)
|
---|
| 196 | *
|
---|
| 197 | * @param string $resource REQUIRED: The resource for which the policy is being
|
---|
| 198 | * specified. See [Resource
|
---|
| 199 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
| 200 | * appropriate value for this field.
|
---|
| 201 | * @param SetIamPolicyRequest $postBody
|
---|
| 202 | * @param array $optParams Optional parameters.
|
---|
| 203 | * @return Policy
|
---|
| 204 | * @throws \Google\Service\Exception
|
---|
| 205 | */
|
---|
| 206 | public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
|
---|
| 207 | {
|
---|
| 208 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 209 | $params = array_merge($params, $optParams);
|
---|
| 210 | return $this->call('setIamPolicy', [$params], Policy::class);
|
---|
| 211 | }
|
---|
| 212 | /**
|
---|
| 213 | * Returns permissions that a caller has on the specified resource. If the
|
---|
| 214 | * resource does not exist, this will return an empty set of permissions, not a
|
---|
| 215 | * `NOT_FOUND` error. Note: This operation is designed to be used for building
|
---|
| 216 | * permission-aware UIs and command-line tools, not for authorization checking.
|
---|
| 217 | * This operation may "fail open" without warning.
|
---|
| 218 | * (snapshots.testIamPermissions)
|
---|
| 219 | *
|
---|
| 220 | * @param string $resource REQUIRED: The resource for which the policy detail is
|
---|
| 221 | * being requested. See [Resource
|
---|
| 222 | * names](https://cloud.google.com/apis/design/resource_names) for the
|
---|
| 223 | * appropriate value for this field.
|
---|
| 224 | * @param TestIamPermissionsRequest $postBody
|
---|
| 225 | * @param array $optParams Optional parameters.
|
---|
| 226 | * @return TestIamPermissionsResponse
|
---|
| 227 | * @throws \Google\Service\Exception
|
---|
| 228 | */
|
---|
| 229 | public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
|
---|
| 230 | {
|
---|
| 231 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 232 | $params = array_merge($params, $optParams);
|
---|
| 233 | return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
|
---|
| 234 | }
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 238 | class_alias(ProjectsSnapshots::class, 'Google_Service_Pubsub_Resource_ProjectsSnapshots');
|
---|