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\Storage\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Storage\Bucket;
|
---|
21 | use Google\Service\Storage\BucketStorageLayout;
|
---|
22 | use Google\Service\Storage\Buckets as BucketsModel;
|
---|
23 | use Google\Service\Storage\GoogleLongrunningOperation;
|
---|
24 | use Google\Service\Storage\Policy;
|
---|
25 | use Google\Service\Storage\RelocateBucketRequest;
|
---|
26 | use Google\Service\Storage\TestIamPermissionsResponse;
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * The "buckets" collection of methods.
|
---|
30 | * Typical usage is:
|
---|
31 | * <code>
|
---|
32 | * $storageService = new Google\Service\Storage(...);
|
---|
33 | * $buckets = $storageService->buckets;
|
---|
34 | * </code>
|
---|
35 | */
|
---|
36 | class Buckets extends \Google\Service\Resource
|
---|
37 | {
|
---|
38 | /**
|
---|
39 | * Deletes an empty bucket. Deletions are permanent unless soft delete is
|
---|
40 | * enabled on the bucket. (buckets.delete)
|
---|
41 | *
|
---|
42 | * @param string $bucket Name of a bucket.
|
---|
43 | * @param array $optParams Optional parameters.
|
---|
44 | *
|
---|
45 | * @opt_param string ifMetagenerationMatch If set, only deletes the bucket if
|
---|
46 | * its metageneration matches this value.
|
---|
47 | * @opt_param string ifMetagenerationNotMatch If set, only deletes the bucket if
|
---|
48 | * its metageneration does not match this value.
|
---|
49 | * @opt_param string userProject The project to be billed for this request.
|
---|
50 | * Required for Requester Pays buckets.
|
---|
51 | * @throws \Google\Service\Exception
|
---|
52 | */
|
---|
53 | public function delete($bucket, $optParams = [])
|
---|
54 | {
|
---|
55 | $params = ['bucket' => $bucket];
|
---|
56 | $params = array_merge($params, $optParams);
|
---|
57 | return $this->call('delete', [$params]);
|
---|
58 | }
|
---|
59 | /**
|
---|
60 | * Returns metadata for the specified bucket. (buckets.get)
|
---|
61 | *
|
---|
62 | * @param string $bucket Name of a bucket.
|
---|
63 | * @param array $optParams Optional parameters.
|
---|
64 | *
|
---|
65 | * @opt_param string generation If present, specifies the generation of the
|
---|
66 | * bucket. This is required if softDeleted is true.
|
---|
67 | * @opt_param string ifMetagenerationMatch Makes the return of the bucket
|
---|
68 | * metadata conditional on whether the bucket's current metageneration matches
|
---|
69 | * the given value.
|
---|
70 | * @opt_param string ifMetagenerationNotMatch Makes the return of the bucket
|
---|
71 | * metadata conditional on whether the bucket's current metageneration does not
|
---|
72 | * match the given value.
|
---|
73 | * @opt_param string projection Set of properties to return. Defaults to noAcl.
|
---|
74 | * @opt_param bool softDeleted If true, return the soft-deleted version of this
|
---|
75 | * bucket. The default is false. For more information, see [Soft
|
---|
76 | * Delete](https://cloud.google.com/storage/docs/soft-delete).
|
---|
77 | * @opt_param string userProject The project to be billed for this request.
|
---|
78 | * Required for Requester Pays buckets.
|
---|
79 | * @return Bucket
|
---|
80 | * @throws \Google\Service\Exception
|
---|
81 | */
|
---|
82 | public function get($bucket, $optParams = [])
|
---|
83 | {
|
---|
84 | $params = ['bucket' => $bucket];
|
---|
85 | $params = array_merge($params, $optParams);
|
---|
86 | return $this->call('get', [$params], Bucket::class);
|
---|
87 | }
|
---|
88 | /**
|
---|
89 | * Returns an IAM policy for the specified bucket. (buckets.getIamPolicy)
|
---|
90 | *
|
---|
91 | * @param string $bucket Name of a bucket.
|
---|
92 | * @param array $optParams Optional parameters.
|
---|
93 | *
|
---|
94 | * @opt_param int optionsRequestedPolicyVersion The IAM policy format version to
|
---|
95 | * be returned. If the optionsRequestedPolicyVersion is for an older version
|
---|
96 | * that doesn't support part of the requested IAM policy, the request fails.
|
---|
97 | * @opt_param string userProject The project to be billed for this request.
|
---|
98 | * Required for Requester Pays buckets.
|
---|
99 | * @return Policy
|
---|
100 | * @throws \Google\Service\Exception
|
---|
101 | */
|
---|
102 | public function getIamPolicy($bucket, $optParams = [])
|
---|
103 | {
|
---|
104 | $params = ['bucket' => $bucket];
|
---|
105 | $params = array_merge($params, $optParams);
|
---|
106 | return $this->call('getIamPolicy', [$params], Policy::class);
|
---|
107 | }
|
---|
108 | /**
|
---|
109 | * Returns the storage layout configuration for the specified bucket. Note that
|
---|
110 | * this operation requires storage.objects.list permission.
|
---|
111 | * (buckets.getStorageLayout)
|
---|
112 | *
|
---|
113 | * @param string $bucket Name of a bucket.
|
---|
114 | * @param array $optParams Optional parameters.
|
---|
115 | *
|
---|
116 | * @opt_param string prefix An optional prefix used for permission check. It is
|
---|
117 | * useful when the caller only has storage.objects.list permission under a
|
---|
118 | * specific prefix.
|
---|
119 | * @return BucketStorageLayout
|
---|
120 | * @throws \Google\Service\Exception
|
---|
121 | */
|
---|
122 | public function getStorageLayout($bucket, $optParams = [])
|
---|
123 | {
|
---|
124 | $params = ['bucket' => $bucket];
|
---|
125 | $params = array_merge($params, $optParams);
|
---|
126 | return $this->call('getStorageLayout', [$params], BucketStorageLayout::class);
|
---|
127 | }
|
---|
128 | /**
|
---|
129 | * Creates a new bucket. (buckets.insert)
|
---|
130 | *
|
---|
131 | * @param string $project A valid API project identifier.
|
---|
132 | * @param Bucket $postBody
|
---|
133 | * @param array $optParams Optional parameters.
|
---|
134 | *
|
---|
135 | * @opt_param bool enableObjectRetention When set to true, object retention is
|
---|
136 | * enabled for this bucket.
|
---|
137 | * @opt_param string predefinedAcl Apply a predefined set of access controls to
|
---|
138 | * this bucket.
|
---|
139 | * @opt_param string predefinedDefaultObjectAcl Apply a predefined set of
|
---|
140 | * default object access controls to this bucket.
|
---|
141 | * @opt_param string projection Set of properties to return. Defaults to noAcl,
|
---|
142 | * unless the bucket resource specifies acl or defaultObjectAcl properties, when
|
---|
143 | * it defaults to full.
|
---|
144 | * @opt_param string userProject The project to be billed for this request.
|
---|
145 | * @return Bucket
|
---|
146 | * @throws \Google\Service\Exception
|
---|
147 | */
|
---|
148 | public function insert($project, Bucket $postBody, $optParams = [])
|
---|
149 | {
|
---|
150 | $params = ['project' => $project, 'postBody' => $postBody];
|
---|
151 | $params = array_merge($params, $optParams);
|
---|
152 | return $this->call('insert', [$params], Bucket::class);
|
---|
153 | }
|
---|
154 | /**
|
---|
155 | * Retrieves a list of buckets for a given project. (buckets.listBuckets)
|
---|
156 | *
|
---|
157 | * @param string $project A valid API project identifier.
|
---|
158 | * @param array $optParams Optional parameters.
|
---|
159 | *
|
---|
160 | * @opt_param string maxResults Maximum number of buckets to return in a single
|
---|
161 | * response. The service will use this parameter or 1,000 items, whichever is
|
---|
162 | * smaller.
|
---|
163 | * @opt_param string pageToken A previously-returned page token representing
|
---|
164 | * part of the larger set of results to view.
|
---|
165 | * @opt_param string prefix Filter results to buckets whose names begin with
|
---|
166 | * this prefix.
|
---|
167 | * @opt_param string projection Set of properties to return. Defaults to noAcl.
|
---|
168 | * @opt_param bool softDeleted If true, only soft-deleted bucket versions will
|
---|
169 | * be returned. The default is false. For more information, see [Soft
|
---|
170 | * Delete](https://cloud.google.com/storage/docs/soft-delete).
|
---|
171 | * @opt_param string userProject The project to be billed for this request.
|
---|
172 | * @return BucketsModel
|
---|
173 | * @throws \Google\Service\Exception
|
---|
174 | */
|
---|
175 | public function listBuckets($project, $optParams = [])
|
---|
176 | {
|
---|
177 | $params = ['project' => $project];
|
---|
178 | $params = array_merge($params, $optParams);
|
---|
179 | return $this->call('list', [$params], BucketsModel::class);
|
---|
180 | }
|
---|
181 | /**
|
---|
182 | * Locks retention policy on a bucket. (buckets.lockRetentionPolicy)
|
---|
183 | *
|
---|
184 | * @param string $bucket Name of a bucket.
|
---|
185 | * @param string $ifMetagenerationMatch Makes the operation conditional on
|
---|
186 | * whether bucket's current metageneration matches the given value.
|
---|
187 | * @param array $optParams Optional parameters.
|
---|
188 | *
|
---|
189 | * @opt_param string userProject The project to be billed for this request.
|
---|
190 | * Required for Requester Pays buckets.
|
---|
191 | * @return Bucket
|
---|
192 | * @throws \Google\Service\Exception
|
---|
193 | */
|
---|
194 | public function lockRetentionPolicy($bucket, $ifMetagenerationMatch, $optParams = [])
|
---|
195 | {
|
---|
196 | $params = ['bucket' => $bucket, 'ifMetagenerationMatch' => $ifMetagenerationMatch];
|
---|
197 | $params = array_merge($params, $optParams);
|
---|
198 | return $this->call('lockRetentionPolicy', [$params], Bucket::class);
|
---|
199 | }
|
---|
200 | /**
|
---|
201 | * Patches a bucket. Changes to the bucket will be readable immediately after
|
---|
202 | * writing, but configuration changes may take time to propagate.
|
---|
203 | * (buckets.patch)
|
---|
204 | *
|
---|
205 | * @param string $bucket Name of a bucket.
|
---|
206 | * @param Bucket $postBody
|
---|
207 | * @param array $optParams Optional parameters.
|
---|
208 | *
|
---|
209 | * @opt_param string ifMetagenerationMatch Makes the return of the bucket
|
---|
210 | * metadata conditional on whether the bucket's current metageneration matches
|
---|
211 | * the given value.
|
---|
212 | * @opt_param string ifMetagenerationNotMatch Makes the return of the bucket
|
---|
213 | * metadata conditional on whether the bucket's current metageneration does not
|
---|
214 | * match the given value.
|
---|
215 | * @opt_param string predefinedAcl Apply a predefined set of access controls to
|
---|
216 | * this bucket.
|
---|
217 | * @opt_param string predefinedDefaultObjectAcl Apply a predefined set of
|
---|
218 | * default object access controls to this bucket.
|
---|
219 | * @opt_param string projection Set of properties to return. Defaults to full.
|
---|
220 | * @opt_param string userProject The project to be billed for this request.
|
---|
221 | * Required for Requester Pays buckets.
|
---|
222 | * @return Bucket
|
---|
223 | * @throws \Google\Service\Exception
|
---|
224 | */
|
---|
225 | public function patch($bucket, Bucket $postBody, $optParams = [])
|
---|
226 | {
|
---|
227 | $params = ['bucket' => $bucket, 'postBody' => $postBody];
|
---|
228 | $params = array_merge($params, $optParams);
|
---|
229 | return $this->call('patch', [$params], Bucket::class);
|
---|
230 | }
|
---|
231 | /**
|
---|
232 | * Initiates a long-running Relocate Bucket operation on the specified bucket.
|
---|
233 | * (buckets.relocate)
|
---|
234 | *
|
---|
235 | * @param string $bucket Name of the bucket to be moved.
|
---|
236 | * @param RelocateBucketRequest $postBody
|
---|
237 | * @param array $optParams Optional parameters.
|
---|
238 | * @return GoogleLongrunningOperation
|
---|
239 | * @throws \Google\Service\Exception
|
---|
240 | */
|
---|
241 | public function relocate($bucket, RelocateBucketRequest $postBody, $optParams = [])
|
---|
242 | {
|
---|
243 | $params = ['bucket' => $bucket, 'postBody' => $postBody];
|
---|
244 | $params = array_merge($params, $optParams);
|
---|
245 | return $this->call('relocate', [$params], GoogleLongrunningOperation::class);
|
---|
246 | }
|
---|
247 | /**
|
---|
248 | * Restores a soft-deleted bucket. (buckets.restore)
|
---|
249 | *
|
---|
250 | * @param string $bucket Name of a bucket.
|
---|
251 | * @param string $generation Generation of a bucket.
|
---|
252 | * @param array $optParams Optional parameters.
|
---|
253 | *
|
---|
254 | * @opt_param string projection Set of properties to return. Defaults to full.
|
---|
255 | * @opt_param string userProject The project to be billed for this request.
|
---|
256 | * Required for Requester Pays buckets.
|
---|
257 | * @return Bucket
|
---|
258 | * @throws \Google\Service\Exception
|
---|
259 | */
|
---|
260 | public function restore($bucket, $generation, $optParams = [])
|
---|
261 | {
|
---|
262 | $params = ['bucket' => $bucket, 'generation' => $generation];
|
---|
263 | $params = array_merge($params, $optParams);
|
---|
264 | return $this->call('restore', [$params], Bucket::class);
|
---|
265 | }
|
---|
266 | /**
|
---|
267 | * Updates an IAM policy for the specified bucket. (buckets.setIamPolicy)
|
---|
268 | *
|
---|
269 | * @param string $bucket Name of a bucket.
|
---|
270 | * @param Policy $postBody
|
---|
271 | * @param array $optParams Optional parameters.
|
---|
272 | *
|
---|
273 | * @opt_param string userProject The project to be billed for this request.
|
---|
274 | * Required for Requester Pays buckets.
|
---|
275 | * @return Policy
|
---|
276 | * @throws \Google\Service\Exception
|
---|
277 | */
|
---|
278 | public function setIamPolicy($bucket, Policy $postBody, $optParams = [])
|
---|
279 | {
|
---|
280 | $params = ['bucket' => $bucket, 'postBody' => $postBody];
|
---|
281 | $params = array_merge($params, $optParams);
|
---|
282 | return $this->call('setIamPolicy', [$params], Policy::class);
|
---|
283 | }
|
---|
284 | /**
|
---|
285 | * Tests a set of permissions on the given bucket to see which, if any, are held
|
---|
286 | * by the caller. (buckets.testIamPermissions)
|
---|
287 | *
|
---|
288 | * @param string $bucket Name of a bucket.
|
---|
289 | * @param string|array $permissions Permissions to test.
|
---|
290 | * @param array $optParams Optional parameters.
|
---|
291 | *
|
---|
292 | * @opt_param string userProject The project to be billed for this request.
|
---|
293 | * Required for Requester Pays buckets.
|
---|
294 | * @return TestIamPermissionsResponse
|
---|
295 | * @throws \Google\Service\Exception
|
---|
296 | */
|
---|
297 | public function testIamPermissions($bucket, $permissions, $optParams = [])
|
---|
298 | {
|
---|
299 | $params = ['bucket' => $bucket, 'permissions' => $permissions];
|
---|
300 | $params = array_merge($params, $optParams);
|
---|
301 | return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
|
---|
302 | }
|
---|
303 | /**
|
---|
304 | * Updates a bucket. Changes to the bucket will be readable immediately after
|
---|
305 | * writing, but configuration changes may take time to propagate.
|
---|
306 | * (buckets.update)
|
---|
307 | *
|
---|
308 | * @param string $bucket Name of a bucket.
|
---|
309 | * @param Bucket $postBody
|
---|
310 | * @param array $optParams Optional parameters.
|
---|
311 | *
|
---|
312 | * @opt_param string ifMetagenerationMatch Makes the return of the bucket
|
---|
313 | * metadata conditional on whether the bucket's current metageneration matches
|
---|
314 | * the given value.
|
---|
315 | * @opt_param string ifMetagenerationNotMatch Makes the return of the bucket
|
---|
316 | * metadata conditional on whether the bucket's current metageneration does not
|
---|
317 | * match the given value.
|
---|
318 | * @opt_param string predefinedAcl Apply a predefined set of access controls to
|
---|
319 | * this bucket.
|
---|
320 | * @opt_param string predefinedDefaultObjectAcl Apply a predefined set of
|
---|
321 | * default object access controls to this bucket.
|
---|
322 | * @opt_param string projection Set of properties to return. Defaults to full.
|
---|
323 | * @opt_param string userProject The project to be billed for this request.
|
---|
324 | * Required for Requester Pays buckets.
|
---|
325 | * @return Bucket
|
---|
326 | * @throws \Google\Service\Exception
|
---|
327 | */
|
---|
328 | public function update($bucket, Bucket $postBody, $optParams = [])
|
---|
329 | {
|
---|
330 | $params = ['bucket' => $bucket, 'postBody' => $postBody];
|
---|
331 | $params = array_merge($params, $optParams);
|
---|
332 | return $this->call('update', [$params], Bucket::class);
|
---|
333 | }
|
---|
334 | }
|
---|
335 |
|
---|
336 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
337 | class_alias(Buckets::class, 'Google_Service_Storage_Resource_Buckets');
|
---|