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