[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\Storage\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\Storage\BulkRestoreObjectsRequest;
|
---|
| 21 | use Google\Service\Storage\Channel;
|
---|
| 22 | use Google\Service\Storage\ComposeRequest;
|
---|
| 23 | use Google\Service\Storage\GoogleLongrunningOperation;
|
---|
| 24 | use Google\Service\Storage\Objects as ObjectsModel;
|
---|
| 25 | use Google\Service\Storage\Policy;
|
---|
| 26 | use Google\Service\Storage\RewriteResponse;
|
---|
| 27 | use Google\Service\Storage\StorageObject;
|
---|
| 28 | use Google\Service\Storage\TestIamPermissionsResponse;
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * The "objects" collection of methods.
|
---|
| 32 | * Typical usage is:
|
---|
| 33 | * <code>
|
---|
| 34 | * $storageService = new Google\Service\Storage(...);
|
---|
| 35 | * $objects = $storageService->objects;
|
---|
| 36 | * </code>
|
---|
| 37 | */
|
---|
| 38 | class Objects extends \Google\Service\Resource
|
---|
| 39 | {
|
---|
| 40 | /**
|
---|
| 41 | * Initiates a long-running bulk restore operation on the specified bucket.
|
---|
| 42 | * (objects.bulkRestore)
|
---|
| 43 | *
|
---|
| 44 | * @param string $bucket Name of the bucket in which the object resides.
|
---|
| 45 | * @param BulkRestoreObjectsRequest $postBody
|
---|
| 46 | * @param array $optParams Optional parameters.
|
---|
| 47 | * @return GoogleLongrunningOperation
|
---|
| 48 | * @throws \Google\Service\Exception
|
---|
| 49 | */
|
---|
| 50 | public function bulkRestore($bucket, BulkRestoreObjectsRequest $postBody, $optParams = [])
|
---|
| 51 | {
|
---|
| 52 | $params = ['bucket' => $bucket, 'postBody' => $postBody];
|
---|
| 53 | $params = array_merge($params, $optParams);
|
---|
| 54 | return $this->call('bulkRestore', [$params], GoogleLongrunningOperation::class);
|
---|
| 55 | }
|
---|
| 56 | /**
|
---|
| 57 | * Concatenates a list of existing objects into a new object in the same bucket.
|
---|
| 58 | * (objects.compose)
|
---|
| 59 | *
|
---|
| 60 | * @param string $destinationBucket Name of the bucket containing the source
|
---|
| 61 | * objects. The destination object is stored in this bucket.
|
---|
| 62 | * @param string $destinationObject Name of the new object. For information
|
---|
| 63 | * about how to URL encode object names to be path safe, see [Encoding URI Path
|
---|
| 64 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 65 | * @param ComposeRequest $postBody
|
---|
| 66 | * @param array $optParams Optional parameters.
|
---|
| 67 | *
|
---|
| 68 | * @opt_param string destinationPredefinedAcl Apply a predefined set of access
|
---|
| 69 | * controls to the destination object.
|
---|
| 70 | * @opt_param string ifGenerationMatch Makes the operation conditional on
|
---|
| 71 | * whether the object's current generation matches the given value. Setting to 0
|
---|
| 72 | * makes the operation succeed only if there are no live versions of the object.
|
---|
| 73 | * @opt_param string ifMetagenerationMatch Makes the operation conditional on
|
---|
| 74 | * whether the object's current metageneration matches the given value.
|
---|
| 75 | * @opt_param string kmsKeyName Resource name of the Cloud KMS key, of the form
|
---|
| 76 | * projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that
|
---|
| 77 | * will be used to encrypt the object. Overrides the object metadata's
|
---|
| 78 | * kms_key_name value, if any.
|
---|
| 79 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 80 | * Required for Requester Pays buckets.
|
---|
| 81 | * @return StorageObject
|
---|
| 82 | * @throws \Google\Service\Exception
|
---|
| 83 | */
|
---|
| 84 | public function compose($destinationBucket, $destinationObject, ComposeRequest $postBody, $optParams = [])
|
---|
| 85 | {
|
---|
| 86 | $params = ['destinationBucket' => $destinationBucket, 'destinationObject' => $destinationObject, 'postBody' => $postBody];
|
---|
| 87 | $params = array_merge($params, $optParams);
|
---|
| 88 | return $this->call('compose', [$params], StorageObject::class);
|
---|
| 89 | }
|
---|
| 90 | /**
|
---|
| 91 | * Copies a source object to a destination object. Optionally overrides
|
---|
| 92 | * metadata. (objects.copy)
|
---|
| 93 | *
|
---|
| 94 | * @param string $sourceBucket Name of the bucket in which to find the source
|
---|
| 95 | * object.
|
---|
| 96 | * @param string $sourceObject Name of the source object. For information about
|
---|
| 97 | * how to URL encode object names to be path safe, see [Encoding URI Path
|
---|
| 98 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 99 | * @param string $destinationBucket Name of the bucket in which to store the new
|
---|
| 100 | * object. Overrides the provided object metadata's bucket value, if any.For
|
---|
| 101 | * information about how to URL encode object names to be path safe, see
|
---|
| 102 | * [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-
|
---|
| 103 | * endpoints#encoding).
|
---|
| 104 | * @param string $destinationObject Name of the new object. Required when the
|
---|
| 105 | * object metadata is not otherwise provided. Overrides the object metadata's
|
---|
| 106 | * name value, if any.
|
---|
| 107 | * @param StorageObject $postBody
|
---|
| 108 | * @param array $optParams Optional parameters.
|
---|
| 109 | *
|
---|
| 110 | * @opt_param string destinationKmsKeyName Resource name of the Cloud KMS key,
|
---|
| 111 | * of the form projects/my-project/locations/global/keyRings/my-
|
---|
| 112 | * kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the
|
---|
| 113 | * object metadata's kms_key_name value, if any.
|
---|
| 114 | * @opt_param string destinationPredefinedAcl Apply a predefined set of access
|
---|
| 115 | * controls to the destination object.
|
---|
| 116 | * @opt_param string ifGenerationMatch Makes the operation conditional on
|
---|
| 117 | * whether the destination object's current generation matches the given value.
|
---|
| 118 | * Setting to 0 makes the operation succeed only if there are no live versions
|
---|
| 119 | * of the object.
|
---|
| 120 | * @opt_param string ifGenerationNotMatch Makes the operation conditional on
|
---|
| 121 | * whether the destination object's current generation does not match the given
|
---|
| 122 | * value. If no live object exists, the precondition fails. Setting to 0 makes
|
---|
| 123 | * the operation succeed only if there is a live version of the object.
|
---|
| 124 | * @opt_param string ifMetagenerationMatch Makes the operation conditional on
|
---|
| 125 | * whether the destination object's current metageneration matches the given
|
---|
| 126 | * value.
|
---|
| 127 | * @opt_param string ifMetagenerationNotMatch Makes the operation conditional on
|
---|
| 128 | * whether the destination object's current metageneration does not match the
|
---|
| 129 | * given value.
|
---|
| 130 | * @opt_param string ifSourceGenerationMatch Makes the operation conditional on
|
---|
| 131 | * whether the source object's current generation matches the given value.
|
---|
| 132 | * @opt_param string ifSourceGenerationNotMatch Makes the operation conditional
|
---|
| 133 | * on whether the source object's current generation does not match the given
|
---|
| 134 | * value.
|
---|
| 135 | * @opt_param string ifSourceMetagenerationMatch Makes the operation conditional
|
---|
| 136 | * on whether the source object's current metageneration matches the given
|
---|
| 137 | * value.
|
---|
| 138 | * @opt_param string ifSourceMetagenerationNotMatch Makes the operation
|
---|
| 139 | * conditional on whether the source object's current metageneration does not
|
---|
| 140 | * match the given value.
|
---|
| 141 | * @opt_param string projection Set of properties to return. Defaults to noAcl,
|
---|
| 142 | * unless the object resource specifies the acl property, when it defaults to
|
---|
| 143 | * full.
|
---|
| 144 | * @opt_param string sourceGeneration If present, selects a specific revision of
|
---|
| 145 | * the source object (as opposed to the latest version, the default).
|
---|
| 146 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 147 | * Required for Requester Pays buckets.
|
---|
| 148 | * @return StorageObject
|
---|
| 149 | * @throws \Google\Service\Exception
|
---|
| 150 | */
|
---|
| 151 | public function copy($sourceBucket, $sourceObject, $destinationBucket, $destinationObject, StorageObject $postBody, $optParams = [])
|
---|
| 152 | {
|
---|
| 153 | $params = ['sourceBucket' => $sourceBucket, 'sourceObject' => $sourceObject, 'destinationBucket' => $destinationBucket, 'destinationObject' => $destinationObject, 'postBody' => $postBody];
|
---|
| 154 | $params = array_merge($params, $optParams);
|
---|
| 155 | return $this->call('copy', [$params], StorageObject::class);
|
---|
| 156 | }
|
---|
| 157 | /**
|
---|
| 158 | * Deletes an object and its metadata. Deletions are permanent if versioning is
|
---|
| 159 | * not enabled for the bucket, or if the generation parameter is used.
|
---|
| 160 | * (objects.delete)
|
---|
| 161 | *
|
---|
| 162 | * @param string $bucket Name of the bucket in which the object resides.
|
---|
| 163 | * @param string $object Name of the object. For information about how to URL
|
---|
| 164 | * encode object names to be path safe, see [Encoding URI Path
|
---|
| 165 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 166 | * @param array $optParams Optional parameters.
|
---|
| 167 | *
|
---|
| 168 | * @opt_param string generation If present, permanently deletes a specific
|
---|
| 169 | * revision of this object (as opposed to the latest version, the default).
|
---|
| 170 | * @opt_param string ifGenerationMatch Makes the operation conditional on
|
---|
| 171 | * whether the object's current generation matches the given value. Setting to 0
|
---|
| 172 | * makes the operation succeed only if there are no live versions of the object.
|
---|
| 173 | * @opt_param string ifGenerationNotMatch Makes the operation conditional on
|
---|
| 174 | * whether the object's current generation does not match the given value. If no
|
---|
| 175 | * live object exists, the precondition fails. Setting to 0 makes the operation
|
---|
| 176 | * succeed only if there is a live version of the object.
|
---|
| 177 | * @opt_param string ifMetagenerationMatch Makes the operation conditional on
|
---|
| 178 | * whether the object's current metageneration matches the given value.
|
---|
| 179 | * @opt_param string ifMetagenerationNotMatch Makes the operation conditional on
|
---|
| 180 | * whether the object's current metageneration does not match the given value.
|
---|
| 181 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 182 | * Required for Requester Pays buckets.
|
---|
| 183 | * @throws \Google\Service\Exception
|
---|
| 184 | */
|
---|
| 185 | public function delete($bucket, $object, $optParams = [])
|
---|
| 186 | {
|
---|
| 187 | $params = ['bucket' => $bucket, 'object' => $object];
|
---|
| 188 | $params = array_merge($params, $optParams);
|
---|
| 189 | return $this->call('delete', [$params]);
|
---|
| 190 | }
|
---|
| 191 | /**
|
---|
| 192 | * Retrieves an object or its metadata. (objects.get)
|
---|
| 193 | *
|
---|
| 194 | * @param string $bucket Name of the bucket in which the object resides.
|
---|
| 195 | * @param string $object Name of the object. For information about how to URL
|
---|
| 196 | * encode object names to be path safe, see [Encoding URI Path
|
---|
| 197 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 198 | * @param array $optParams Optional parameters.
|
---|
| 199 | *
|
---|
| 200 | * @opt_param string generation If present, selects a specific revision of this
|
---|
| 201 | * object (as opposed to the latest version, the default).
|
---|
| 202 | * @opt_param string ifGenerationMatch Makes the operation conditional on
|
---|
| 203 | * whether the object's current generation matches the given value. Setting to 0
|
---|
| 204 | * makes the operation succeed only if there are no live versions of the object.
|
---|
| 205 | * @opt_param string ifGenerationNotMatch Makes the operation conditional on
|
---|
| 206 | * whether the object's current generation does not match the given value. If no
|
---|
| 207 | * live object exists, the precondition fails. Setting to 0 makes the operation
|
---|
| 208 | * succeed only if there is a live version of the object.
|
---|
| 209 | * @opt_param string ifMetagenerationMatch Makes the operation conditional on
|
---|
| 210 | * whether the object's current metageneration matches the given value.
|
---|
| 211 | * @opt_param string ifMetagenerationNotMatch Makes the operation conditional on
|
---|
| 212 | * whether the object's current metageneration does not match the given value.
|
---|
| 213 | * @opt_param string projection Set of properties to return. Defaults to noAcl.
|
---|
| 214 | * @opt_param string restoreToken Restore token used to differentiate soft-
|
---|
| 215 | * deleted objects with the same name and generation. Only applicable for
|
---|
| 216 | * hierarchical namespace buckets and if softDeleted is set to true. This
|
---|
| 217 | * parameter is optional, and is only required in the rare case when there are
|
---|
| 218 | * multiple soft-deleted objects with the same name and generation.
|
---|
| 219 | * @opt_param bool softDeleted If true, only soft-deleted object versions will
|
---|
| 220 | * be listed. The default is false. For more information, see [Soft
|
---|
| 221 | * Delete](https://cloud.google.com/storage/docs/soft-delete).
|
---|
| 222 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 223 | * Required for Requester Pays buckets.
|
---|
| 224 | * @return StorageObject
|
---|
| 225 | * @throws \Google\Service\Exception
|
---|
| 226 | */
|
---|
| 227 | public function get($bucket, $object, $optParams = [])
|
---|
| 228 | {
|
---|
| 229 | $params = ['bucket' => $bucket, 'object' => $object];
|
---|
| 230 | $params = array_merge($params, $optParams);
|
---|
| 231 | return $this->call('get', [$params], StorageObject::class);
|
---|
| 232 | }
|
---|
| 233 | /**
|
---|
| 234 | * Returns an IAM policy for the specified object. (objects.getIamPolicy)
|
---|
| 235 | *
|
---|
| 236 | * @param string $bucket Name of the bucket in which the object resides.
|
---|
| 237 | * @param string $object Name of the object. For information about how to URL
|
---|
| 238 | * encode object names to be path safe, see [Encoding URI Path
|
---|
| 239 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 240 | * @param array $optParams Optional parameters.
|
---|
| 241 | *
|
---|
| 242 | * @opt_param string generation If present, selects a specific revision of this
|
---|
| 243 | * object (as opposed to the latest version, the default).
|
---|
| 244 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 245 | * Required for Requester Pays buckets.
|
---|
| 246 | * @return Policy
|
---|
| 247 | * @throws \Google\Service\Exception
|
---|
| 248 | */
|
---|
| 249 | public function getIamPolicy($bucket, $object, $optParams = [])
|
---|
| 250 | {
|
---|
| 251 | $params = ['bucket' => $bucket, 'object' => $object];
|
---|
| 252 | $params = array_merge($params, $optParams);
|
---|
| 253 | return $this->call('getIamPolicy', [$params], Policy::class);
|
---|
| 254 | }
|
---|
| 255 | /**
|
---|
| 256 | * Stores a new object and metadata. (objects.insert)
|
---|
| 257 | *
|
---|
| 258 | * @param string $bucket Name of the bucket in which to store the new object.
|
---|
| 259 | * Overrides the provided object metadata's bucket value, if any.
|
---|
| 260 | * @param StorageObject $postBody
|
---|
| 261 | * @param array $optParams Optional parameters.
|
---|
| 262 | *
|
---|
| 263 | * @opt_param string contentEncoding If set, sets the contentEncoding property
|
---|
| 264 | * of the final object to this value. Setting this parameter is equivalent to
|
---|
| 265 | * setting the contentEncoding metadata property. This can be useful when
|
---|
| 266 | * uploading an object with uploadType=media to indicate the encoding of the
|
---|
| 267 | * content being uploaded.
|
---|
| 268 | * @opt_param string ifGenerationMatch Makes the operation conditional on
|
---|
| 269 | * whether the object's current generation matches the given value. Setting to 0
|
---|
| 270 | * makes the operation succeed only if there are no live versions of the object.
|
---|
| 271 | * @opt_param string ifGenerationNotMatch Makes the operation conditional on
|
---|
| 272 | * whether the object's current generation does not match the given value. If no
|
---|
| 273 | * live object exists, the precondition fails. Setting to 0 makes the operation
|
---|
| 274 | * succeed only if there is a live version of the object.
|
---|
| 275 | * @opt_param string ifMetagenerationMatch Makes the operation conditional on
|
---|
| 276 | * whether the object's current metageneration matches the given value.
|
---|
| 277 | * @opt_param string ifMetagenerationNotMatch Makes the operation conditional on
|
---|
| 278 | * whether the object's current metageneration does not match the given value.
|
---|
| 279 | * @opt_param string kmsKeyName Resource name of the Cloud KMS key, of the form
|
---|
| 280 | * projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that
|
---|
| 281 | * will be used to encrypt the object. Overrides the object metadata's
|
---|
| 282 | * kms_key_name value, if any.
|
---|
| 283 | * @opt_param string name Name of the object. Required when the object metadata
|
---|
| 284 | * is not otherwise provided. Overrides the object metadata's name value, if
|
---|
| 285 | * any. For information about how to URL encode object names to be path safe,
|
---|
| 286 | * see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-
|
---|
| 287 | * endpoints#encoding).
|
---|
| 288 | * @opt_param string predefinedAcl Apply a predefined set of access controls to
|
---|
| 289 | * this object.
|
---|
| 290 | * @opt_param string projection Set of properties to return. Defaults to noAcl,
|
---|
| 291 | * unless the object resource specifies the acl property, when it defaults to
|
---|
| 292 | * full.
|
---|
| 293 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 294 | * Required for Requester Pays buckets.
|
---|
| 295 | * @return StorageObject
|
---|
| 296 | * @throws \Google\Service\Exception
|
---|
| 297 | */
|
---|
| 298 | public function insert($bucket, StorageObject $postBody, $optParams = [])
|
---|
| 299 | {
|
---|
| 300 | $params = ['bucket' => $bucket, 'postBody' => $postBody];
|
---|
| 301 | $params = array_merge($params, $optParams);
|
---|
| 302 | return $this->call('insert', [$params], StorageObject::class);
|
---|
| 303 | }
|
---|
| 304 | /**
|
---|
| 305 | * Retrieves a list of objects matching the criteria. (objects.listObjects)
|
---|
| 306 | *
|
---|
| 307 | * @param string $bucket Name of the bucket in which to look for objects.
|
---|
| 308 | * @param array $optParams Optional parameters.
|
---|
| 309 | *
|
---|
| 310 | * @opt_param string delimiter Returns results in a directory-like mode. items
|
---|
| 311 | * will contain only objects whose names, aside from the prefix, do not contain
|
---|
| 312 | * delimiter. Objects whose names, aside from the prefix, contain delimiter will
|
---|
| 313 | * have their name, truncated after the delimiter, returned in prefixes.
|
---|
| 314 | * Duplicate prefixes are omitted.
|
---|
| 315 | * @opt_param string endOffset Filter results to objects whose names are
|
---|
| 316 | * lexicographically before endOffset. If startOffset is also set, the objects
|
---|
| 317 | * listed will have names between startOffset (inclusive) and endOffset
|
---|
| 318 | * (exclusive).
|
---|
| 319 | * @opt_param bool includeFoldersAsPrefixes Only applicable if delimiter is set
|
---|
| 320 | * to '/'. If true, will also include folders and managed folders (besides
|
---|
| 321 | * objects) in the returned prefixes.
|
---|
| 322 | * @opt_param bool includeTrailingDelimiter If true, objects that end in exactly
|
---|
| 323 | * one instance of delimiter will have their metadata included in items in
|
---|
| 324 | * addition to prefixes.
|
---|
| 325 | * @opt_param string matchGlob Filter results to objects and prefixes that match
|
---|
| 326 | * this glob pattern.
|
---|
| 327 | * @opt_param string maxResults Maximum number of items plus prefixes to return
|
---|
| 328 | * in a single page of responses. As duplicate prefixes are omitted, fewer total
|
---|
| 329 | * results may be returned than requested. The service will use this parameter
|
---|
| 330 | * or 1,000 items, whichever is smaller.
|
---|
| 331 | * @opt_param string pageToken A previously-returned page token representing
|
---|
| 332 | * part of the larger set of results to view.
|
---|
| 333 | * @opt_param string prefix Filter results to objects whose names begin with
|
---|
| 334 | * this prefix.
|
---|
| 335 | * @opt_param string projection Set of properties to return. Defaults to noAcl.
|
---|
| 336 | * @opt_param bool softDeleted If true, only soft-deleted object versions will
|
---|
| 337 | * be listed. The default is false. For more information, see [Soft
|
---|
| 338 | * Delete](https://cloud.google.com/storage/docs/soft-delete).
|
---|
| 339 | * @opt_param string startOffset Filter results to objects whose names are
|
---|
| 340 | * lexicographically equal to or after startOffset. If endOffset is also set,
|
---|
| 341 | * the objects listed will have names between startOffset (inclusive) and
|
---|
| 342 | * endOffset (exclusive).
|
---|
| 343 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 344 | * Required for Requester Pays buckets.
|
---|
| 345 | * @opt_param bool versions If true, lists all versions of an object as distinct
|
---|
| 346 | * results. The default is false. For more information, see [Object
|
---|
| 347 | * Versioning](https://cloud.google.com/storage/docs/object-versioning).
|
---|
| 348 | * @return ObjectsModel
|
---|
| 349 | * @throws \Google\Service\Exception
|
---|
| 350 | */
|
---|
| 351 | public function listObjects($bucket, $optParams = [])
|
---|
| 352 | {
|
---|
| 353 | $params = ['bucket' => $bucket];
|
---|
| 354 | $params = array_merge($params, $optParams);
|
---|
| 355 | return $this->call('list', [$params], ObjectsModel::class);
|
---|
| 356 | }
|
---|
| 357 | /**
|
---|
| 358 | * Patches an object's metadata. (objects.patch)
|
---|
| 359 | *
|
---|
| 360 | * @param string $bucket Name of the bucket in which the object resides.
|
---|
| 361 | * @param string $object Name of the object. For information about how to URL
|
---|
| 362 | * encode object names to be path safe, see [Encoding URI Path
|
---|
| 363 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 364 | * @param StorageObject $postBody
|
---|
| 365 | * @param array $optParams Optional parameters.
|
---|
| 366 | *
|
---|
| 367 | * @opt_param string generation If present, selects a specific revision of this
|
---|
| 368 | * object (as opposed to the latest version, the default).
|
---|
| 369 | * @opt_param string ifGenerationMatch Makes the operation conditional on
|
---|
| 370 | * whether the object's current generation matches the given value. Setting to 0
|
---|
| 371 | * makes the operation succeed only if there are no live versions of the object.
|
---|
| 372 | * @opt_param string ifGenerationNotMatch Makes the operation conditional on
|
---|
| 373 | * whether the object's current generation does not match the given value. If no
|
---|
| 374 | * live object exists, the precondition fails. Setting to 0 makes the operation
|
---|
| 375 | * succeed only if there is a live version of the object.
|
---|
| 376 | * @opt_param string ifMetagenerationMatch Makes the operation conditional on
|
---|
| 377 | * whether the object's current metageneration matches the given value.
|
---|
| 378 | * @opt_param string ifMetagenerationNotMatch Makes the operation conditional on
|
---|
| 379 | * whether the object's current metageneration does not match the given value.
|
---|
| 380 | * @opt_param bool overrideUnlockedRetention Must be true to remove the
|
---|
| 381 | * retention configuration, reduce its unlocked retention period, or change its
|
---|
| 382 | * mode from unlocked to locked.
|
---|
| 383 | * @opt_param string predefinedAcl Apply a predefined set of access controls to
|
---|
| 384 | * this object.
|
---|
| 385 | * @opt_param string projection Set of properties to return. Defaults to full.
|
---|
| 386 | * @opt_param string userProject The project to be billed for this request, for
|
---|
| 387 | * Requester Pays buckets.
|
---|
| 388 | * @return StorageObject
|
---|
| 389 | * @throws \Google\Service\Exception
|
---|
| 390 | */
|
---|
| 391 | public function patch($bucket, $object, StorageObject $postBody, $optParams = [])
|
---|
| 392 | {
|
---|
| 393 | $params = ['bucket' => $bucket, 'object' => $object, 'postBody' => $postBody];
|
---|
| 394 | $params = array_merge($params, $optParams);
|
---|
| 395 | return $this->call('patch', [$params], StorageObject::class);
|
---|
| 396 | }
|
---|
| 397 | /**
|
---|
| 398 | * Restores a soft-deleted object. (objects.restore)
|
---|
| 399 | *
|
---|
| 400 | * @param string $bucket Name of the bucket in which the object resides.
|
---|
| 401 | * @param string $object Name of the object. For information about how to URL
|
---|
| 402 | * encode object names to be path safe, see [Encoding URI Path
|
---|
| 403 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 404 | * @param string $generation Selects a specific revision of this object.
|
---|
| 405 | * @param array $optParams Optional parameters.
|
---|
| 406 | *
|
---|
| 407 | * @opt_param bool copySourceAcl If true, copies the source object's ACL;
|
---|
| 408 | * otherwise, uses the bucket's default object ACL. The default is false.
|
---|
| 409 | * @opt_param string ifGenerationMatch Makes the operation conditional on
|
---|
| 410 | * whether the object's one live generation matches the given value. Setting to
|
---|
| 411 | * 0 makes the operation succeed only if there are no live versions of the
|
---|
| 412 | * object.
|
---|
| 413 | * @opt_param string ifGenerationNotMatch Makes the operation conditional on
|
---|
| 414 | * whether none of the object's live generations match the given value. If no
|
---|
| 415 | * live object exists, the precondition fails. Setting to 0 makes the operation
|
---|
| 416 | * succeed only if there is a live version of the object.
|
---|
| 417 | * @opt_param string ifMetagenerationMatch Makes the operation conditional on
|
---|
| 418 | * whether the object's one live metageneration matches the given value.
|
---|
| 419 | * @opt_param string ifMetagenerationNotMatch Makes the operation conditional on
|
---|
| 420 | * whether none of the object's live metagenerations match the given value.
|
---|
| 421 | * @opt_param string projection Set of properties to return. Defaults to full.
|
---|
| 422 | * @opt_param string restoreToken Restore token used to differentiate sof-
|
---|
| 423 | * deleted objects with the same name and generation. Only applicable for
|
---|
| 424 | * hierarchical namespace buckets. This parameter is optional, and is only
|
---|
| 425 | * required in the rare case when there are multiple soft-deleted objects with
|
---|
| 426 | * the same name and generation.
|
---|
| 427 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 428 | * Required for Requester Pays buckets.
|
---|
| 429 | * @return StorageObject
|
---|
| 430 | * @throws \Google\Service\Exception
|
---|
| 431 | */
|
---|
| 432 | public function restore($bucket, $object, $generation, $optParams = [])
|
---|
| 433 | {
|
---|
| 434 | $params = ['bucket' => $bucket, 'object' => $object, 'generation' => $generation];
|
---|
| 435 | $params = array_merge($params, $optParams);
|
---|
| 436 | return $this->call('restore', [$params], StorageObject::class);
|
---|
| 437 | }
|
---|
| 438 | /**
|
---|
| 439 | * Rewrites a source object to a destination object. Optionally overrides
|
---|
| 440 | * metadata. (objects.rewrite)
|
---|
| 441 | *
|
---|
| 442 | * @param string $sourceBucket Name of the bucket in which to find the source
|
---|
| 443 | * object.
|
---|
| 444 | * @param string $sourceObject Name of the source object. For information about
|
---|
| 445 | * how to URL encode object names to be path safe, see [Encoding URI Path
|
---|
| 446 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 447 | * @param string $destinationBucket Name of the bucket in which to store the new
|
---|
| 448 | * object. Overrides the provided object metadata's bucket value, if any.
|
---|
| 449 | * @param string $destinationObject Name of the new object. Required when the
|
---|
| 450 | * object metadata is not otherwise provided. Overrides the object metadata's
|
---|
| 451 | * name value, if any. For information about how to URL encode object names to
|
---|
| 452 | * be path safe, see [Encoding URI Path
|
---|
| 453 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 454 | * @param StorageObject $postBody
|
---|
| 455 | * @param array $optParams Optional parameters.
|
---|
| 456 | *
|
---|
| 457 | * @opt_param string destinationKmsKeyName Resource name of the Cloud KMS key,
|
---|
| 458 | * of the form projects/my-project/locations/global/keyRings/my-
|
---|
| 459 | * kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the
|
---|
| 460 | * object metadata's kms_key_name value, if any.
|
---|
| 461 | * @opt_param string destinationPredefinedAcl Apply a predefined set of access
|
---|
| 462 | * controls to the destination object.
|
---|
| 463 | * @opt_param string ifGenerationMatch Makes the operation conditional on
|
---|
| 464 | * whether the object's current generation matches the given value. Setting to 0
|
---|
| 465 | * makes the operation succeed only if there are no live versions of the object.
|
---|
| 466 | * @opt_param string ifGenerationNotMatch Makes the operation conditional on
|
---|
| 467 | * whether the object's current generation does not match the given value. If no
|
---|
| 468 | * live object exists, the precondition fails. Setting to 0 makes the operation
|
---|
| 469 | * succeed only if there is a live version of the object.
|
---|
| 470 | * @opt_param string ifMetagenerationMatch Makes the operation conditional on
|
---|
| 471 | * whether the destination object's current metageneration matches the given
|
---|
| 472 | * value.
|
---|
| 473 | * @opt_param string ifMetagenerationNotMatch Makes the operation conditional on
|
---|
| 474 | * whether the destination object's current metageneration does not match the
|
---|
| 475 | * given value.
|
---|
| 476 | * @opt_param string ifSourceGenerationMatch Makes the operation conditional on
|
---|
| 477 | * whether the source object's current generation matches the given value.
|
---|
| 478 | * @opt_param string ifSourceGenerationNotMatch Makes the operation conditional
|
---|
| 479 | * on whether the source object's current generation does not match the given
|
---|
| 480 | * value.
|
---|
| 481 | * @opt_param string ifSourceMetagenerationMatch Makes the operation conditional
|
---|
| 482 | * on whether the source object's current metageneration matches the given
|
---|
| 483 | * value.
|
---|
| 484 | * @opt_param string ifSourceMetagenerationNotMatch Makes the operation
|
---|
| 485 | * conditional on whether the source object's current metageneration does not
|
---|
| 486 | * match the given value.
|
---|
| 487 | * @opt_param string maxBytesRewrittenPerCall The maximum number of bytes that
|
---|
| 488 | * will be rewritten per rewrite request. Most callers shouldn't need to specify
|
---|
| 489 | * this parameter - it is primarily in place to support testing. If specified
|
---|
| 490 | * the value must be an integral multiple of 1 MiB (1048576). Also, this only
|
---|
| 491 | * applies to requests where the source and destination span locations and/or
|
---|
| 492 | * storage classes. Finally, this value must not change across rewrite calls
|
---|
| 493 | * else you'll get an error that the rewriteToken is invalid.
|
---|
| 494 | * @opt_param string projection Set of properties to return. Defaults to noAcl,
|
---|
| 495 | * unless the object resource specifies the acl property, when it defaults to
|
---|
| 496 | * full.
|
---|
| 497 | * @opt_param string rewriteToken Include this field (from the previous rewrite
|
---|
| 498 | * response) on each rewrite request after the first one, until the rewrite
|
---|
| 499 | * response 'done' flag is true. Calls that provide a rewriteToken can omit all
|
---|
| 500 | * other request fields, but if included those fields must match the values
|
---|
| 501 | * provided in the first rewrite request.
|
---|
| 502 | * @opt_param string sourceGeneration If present, selects a specific revision of
|
---|
| 503 | * the source object (as opposed to the latest version, the default).
|
---|
| 504 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 505 | * Required for Requester Pays buckets.
|
---|
| 506 | * @return RewriteResponse
|
---|
| 507 | * @throws \Google\Service\Exception
|
---|
| 508 | */
|
---|
| 509 | public function rewrite($sourceBucket, $sourceObject, $destinationBucket, $destinationObject, StorageObject $postBody, $optParams = [])
|
---|
| 510 | {
|
---|
| 511 | $params = ['sourceBucket' => $sourceBucket, 'sourceObject' => $sourceObject, 'destinationBucket' => $destinationBucket, 'destinationObject' => $destinationObject, 'postBody' => $postBody];
|
---|
| 512 | $params = array_merge($params, $optParams);
|
---|
| 513 | return $this->call('rewrite', [$params], RewriteResponse::class);
|
---|
| 514 | }
|
---|
| 515 | /**
|
---|
| 516 | * Updates an IAM policy for the specified object. (objects.setIamPolicy)
|
---|
| 517 | *
|
---|
| 518 | * @param string $bucket Name of the bucket in which the object resides.
|
---|
| 519 | * @param string $object Name of the object. For information about how to URL
|
---|
| 520 | * encode object names to be path safe, see [Encoding URI Path
|
---|
| 521 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 522 | * @param Policy $postBody
|
---|
| 523 | * @param array $optParams Optional parameters.
|
---|
| 524 | *
|
---|
| 525 | * @opt_param string generation If present, selects a specific revision of this
|
---|
| 526 | * object (as opposed to the latest version, the default).
|
---|
| 527 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 528 | * Required for Requester Pays buckets.
|
---|
| 529 | * @return Policy
|
---|
| 530 | * @throws \Google\Service\Exception
|
---|
| 531 | */
|
---|
| 532 | public function setIamPolicy($bucket, $object, Policy $postBody, $optParams = [])
|
---|
| 533 | {
|
---|
| 534 | $params = ['bucket' => $bucket, 'object' => $object, 'postBody' => $postBody];
|
---|
| 535 | $params = array_merge($params, $optParams);
|
---|
| 536 | return $this->call('setIamPolicy', [$params], Policy::class);
|
---|
| 537 | }
|
---|
| 538 | /**
|
---|
| 539 | * Tests a set of permissions on the given object to see which, if any, are held
|
---|
| 540 | * by the caller. (objects.testIamPermissions)
|
---|
| 541 | *
|
---|
| 542 | * @param string $bucket Name of the bucket in which the object resides.
|
---|
| 543 | * @param string $object Name of the object. For information about how to URL
|
---|
| 544 | * encode object names to be path safe, see [Encoding URI Path
|
---|
| 545 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 546 | * @param string|array $permissions Permissions to test.
|
---|
| 547 | * @param array $optParams Optional parameters.
|
---|
| 548 | *
|
---|
| 549 | * @opt_param string generation If present, selects a specific revision of this
|
---|
| 550 | * object (as opposed to the latest version, the default).
|
---|
| 551 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 552 | * Required for Requester Pays buckets.
|
---|
| 553 | * @return TestIamPermissionsResponse
|
---|
| 554 | * @throws \Google\Service\Exception
|
---|
| 555 | */
|
---|
| 556 | public function testIamPermissions($bucket, $object, $permissions, $optParams = [])
|
---|
| 557 | {
|
---|
| 558 | $params = ['bucket' => $bucket, 'object' => $object, 'permissions' => $permissions];
|
---|
| 559 | $params = array_merge($params, $optParams);
|
---|
| 560 | return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
|
---|
| 561 | }
|
---|
| 562 | /**
|
---|
| 563 | * Updates an object's metadata. (objects.update)
|
---|
| 564 | *
|
---|
| 565 | * @param string $bucket Name of the bucket in which the object resides.
|
---|
| 566 | * @param string $object Name of the object. For information about how to URL
|
---|
| 567 | * encode object names to be path safe, see [Encoding URI Path
|
---|
| 568 | * Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
|
---|
| 569 | * @param StorageObject $postBody
|
---|
| 570 | * @param array $optParams Optional parameters.
|
---|
| 571 | *
|
---|
| 572 | * @opt_param string generation If present, selects a specific revision of this
|
---|
| 573 | * object (as opposed to the latest version, the default).
|
---|
| 574 | * @opt_param string ifGenerationMatch Makes the operation conditional on
|
---|
| 575 | * whether the object's current generation matches the given value. Setting to 0
|
---|
| 576 | * makes the operation succeed only if there are no live versions of the object.
|
---|
| 577 | * @opt_param string ifGenerationNotMatch Makes the operation conditional on
|
---|
| 578 | * whether the object's current generation does not match the given value. If no
|
---|
| 579 | * live object exists, the precondition fails. Setting to 0 makes the operation
|
---|
| 580 | * succeed only if there is a live version of the object.
|
---|
| 581 | * @opt_param string ifMetagenerationMatch Makes the operation conditional on
|
---|
| 582 | * whether the object's current metageneration matches the given value.
|
---|
| 583 | * @opt_param string ifMetagenerationNotMatch Makes the operation conditional on
|
---|
| 584 | * whether the object's current metageneration does not match the given value.
|
---|
| 585 | * @opt_param bool overrideUnlockedRetention Must be true to remove the
|
---|
| 586 | * retention configuration, reduce its unlocked retention period, or change its
|
---|
| 587 | * mode from unlocked to locked.
|
---|
| 588 | * @opt_param string predefinedAcl Apply a predefined set of access controls to
|
---|
| 589 | * this object.
|
---|
| 590 | * @opt_param string projection Set of properties to return. Defaults to full.
|
---|
| 591 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 592 | * Required for Requester Pays buckets.
|
---|
| 593 | * @return StorageObject
|
---|
| 594 | * @throws \Google\Service\Exception
|
---|
| 595 | */
|
---|
| 596 | public function update($bucket, $object, StorageObject $postBody, $optParams = [])
|
---|
| 597 | {
|
---|
| 598 | $params = ['bucket' => $bucket, 'object' => $object, 'postBody' => $postBody];
|
---|
| 599 | $params = array_merge($params, $optParams);
|
---|
| 600 | return $this->call('update', [$params], StorageObject::class);
|
---|
| 601 | }
|
---|
| 602 | /**
|
---|
| 603 | * Watch for changes on all objects in a bucket. (objects.watchAll)
|
---|
| 604 | *
|
---|
| 605 | * @param string $bucket Name of the bucket in which to look for objects.
|
---|
| 606 | * @param Channel $postBody
|
---|
| 607 | * @param array $optParams Optional parameters.
|
---|
| 608 | *
|
---|
| 609 | * @opt_param string delimiter Returns results in a directory-like mode. items
|
---|
| 610 | * will contain only objects whose names, aside from the prefix, do not contain
|
---|
| 611 | * delimiter. Objects whose names, aside from the prefix, contain delimiter will
|
---|
| 612 | * have their name, truncated after the delimiter, returned in prefixes.
|
---|
| 613 | * Duplicate prefixes are omitted.
|
---|
| 614 | * @opt_param string endOffset Filter results to objects whose names are
|
---|
| 615 | * lexicographically before endOffset. If startOffset is also set, the objects
|
---|
| 616 | * listed will have names between startOffset (inclusive) and endOffset
|
---|
| 617 | * (exclusive).
|
---|
| 618 | * @opt_param bool includeTrailingDelimiter If true, objects that end in exactly
|
---|
| 619 | * one instance of delimiter will have their metadata included in items in
|
---|
| 620 | * addition to prefixes.
|
---|
| 621 | * @opt_param string maxResults Maximum number of items plus prefixes to return
|
---|
| 622 | * in a single page of responses. As duplicate prefixes are omitted, fewer total
|
---|
| 623 | * results may be returned than requested. The service will use this parameter
|
---|
| 624 | * or 1,000 items, whichever is smaller.
|
---|
| 625 | * @opt_param string pageToken A previously-returned page token representing
|
---|
| 626 | * part of the larger set of results to view.
|
---|
| 627 | * @opt_param string prefix Filter results to objects whose names begin with
|
---|
| 628 | * this prefix.
|
---|
| 629 | * @opt_param string projection Set of properties to return. Defaults to noAcl.
|
---|
| 630 | * @opt_param string startOffset Filter results to objects whose names are
|
---|
| 631 | * lexicographically equal to or after startOffset. If endOffset is also set,
|
---|
| 632 | * the objects listed will have names between startOffset (inclusive) and
|
---|
| 633 | * endOffset (exclusive).
|
---|
| 634 | * @opt_param string userProject The project to be billed for this request.
|
---|
| 635 | * Required for Requester Pays buckets.
|
---|
| 636 | * @opt_param bool versions If true, lists all versions of an object as distinct
|
---|
| 637 | * results. The default is false. For more information, see [Object
|
---|
| 638 | * Versioning](https://cloud.google.com/storage/docs/object-versioning).
|
---|
| 639 | * @return Channel
|
---|
| 640 | * @throws \Google\Service\Exception
|
---|
| 641 | */
|
---|
| 642 | public function watchAll($bucket, Channel $postBody, $optParams = [])
|
---|
| 643 | {
|
---|
| 644 | $params = ['bucket' => $bucket, 'postBody' => $postBody];
|
---|
| 645 | $params = array_merge($params, $optParams);
|
---|
| 646 | return $this->call('watchAll', [$params], Channel::class);
|
---|
| 647 | }
|
---|
| 648 | }
|
---|
| 649 |
|
---|
| 650 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 651 | class_alias(Objects::class, 'Google_Service_Storage_Resource_Objects');
|
---|