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\Storage\Resource; 19 20use Google\Service\Storage\Bucket; 21use Google\Service\Storage\Buckets as BucketsModel; 22use Google\Service\Storage\Policy; 23use Google\Service\Storage\TestIamPermissionsResponse; 24 25/** 26 * The "buckets" collection of methods. 27 * Typical usage is: 28 * <code> 29 * $storageService = new Google\Service\Storage(...); 30 * $buckets = $storageService->buckets; 31 * </code> 32 */ 33class Buckets extends \Google\Service\Resource 34{ 35 /** 36 * Permanently deletes an empty bucket. (buckets.delete) 37 * 38 * @param string $bucket Name of a bucket. 39 * @param array $optParams Optional parameters. 40 * 41 * @opt_param string ifMetagenerationMatch If set, only deletes the bucket if 42 * its metageneration matches this value. 43 * @opt_param string ifMetagenerationNotMatch If set, only deletes the bucket if 44 * its metageneration does not match this value. 45 * @opt_param string userProject The project to be billed for this request. 46 * Required for Requester Pays buckets. 47 */ 48 public function delete($bucket, $optParams = []) 49 { 50 $params = ['bucket' => $bucket]; 51 $params = array_merge($params, $optParams); 52 return $this->call('delete', [$params]); 53 } 54 /** 55 * Returns metadata for the specified bucket. (buckets.get) 56 * 57 * @param string $bucket Name of a bucket. 58 * @param array $optParams Optional parameters. 59 * 60 * @opt_param string ifMetagenerationMatch Makes the return of the bucket 61 * metadata conditional on whether the bucket's current metageneration matches 62 * the given value. 63 * @opt_param string ifMetagenerationNotMatch Makes the return of the bucket 64 * metadata conditional on whether the bucket's current metageneration does not 65 * match the given value. 66 * @opt_param string projection Set of properties to return. Defaults to noAcl. 67 * @opt_param string userProject The project to be billed for this request. 68 * Required for Requester Pays buckets. 69 * @return Bucket 70 */ 71 public function get($bucket, $optParams = []) 72 { 73 $params = ['bucket' => $bucket]; 74 $params = array_merge($params, $optParams); 75 return $this->call('get', [$params], Bucket::class); 76 } 77 /** 78 * Returns an IAM policy for the specified bucket. (buckets.getIamPolicy) 79 * 80 * @param string $bucket Name of a bucket. 81 * @param array $optParams Optional parameters. 82 * 83 * @opt_param int optionsRequestedPolicyVersion The IAM policy format version to 84 * be returned. If the optionsRequestedPolicyVersion is for an older version 85 * that doesn't support part of the requested IAM policy, the request fails. 86 * @opt_param string userProject The project to be billed for this request. 87 * Required for Requester Pays buckets. 88 * @return Policy 89 */ 90 public function getIamPolicy($bucket, $optParams = []) 91 { 92 $params = ['bucket' => $bucket]; 93 $params = array_merge($params, $optParams); 94 return $this->call('getIamPolicy', [$params], Policy::class); 95 } 96 /** 97 * Creates a new bucket. (buckets.insert) 98 * 99 * @param string $project A valid API project identifier. 100 * @param Bucket $postBody 101 * @param array $optParams Optional parameters. 102 * 103 * @opt_param string predefinedAcl Apply a predefined set of access controls to 104 * this bucket. 105 * @opt_param string predefinedDefaultObjectAcl Apply a predefined set of 106 * default object access controls to this bucket. 107 * @opt_param string projection Set of properties to return. Defaults to noAcl, 108 * unless the bucket resource specifies acl or defaultObjectAcl properties, when 109 * it defaults to full. 110 * @opt_param string userProject The project to be billed for this request. 111 * @return Bucket 112 */ 113 public function insert($project, Bucket $postBody, $optParams = []) 114 { 115 $params = ['project' => $project, 'postBody' => $postBody]; 116 $params = array_merge($params, $optParams); 117 return $this->call('insert', [$params], Bucket::class); 118 } 119 /** 120 * Retrieves a list of buckets for a given project. (buckets.listBuckets) 121 * 122 * @param string $project A valid API project identifier. 123 * @param array $optParams Optional parameters. 124 * 125 * @opt_param string maxResults Maximum number of buckets to return in a single 126 * response. The service will use this parameter or 1,000 items, whichever is 127 * smaller. 128 * @opt_param string pageToken A previously-returned page token representing 129 * part of the larger set of results to view. 130 * @opt_param string prefix Filter results to buckets whose names begin with 131 * this prefix. 132 * @opt_param string projection Set of properties to return. Defaults to noAcl. 133 * @opt_param string userProject The project to be billed for this request. 134 * @return BucketsModel 135 */ 136 public function listBuckets($project, $optParams = []) 137 { 138 $params = ['project' => $project]; 139 $params = array_merge($params, $optParams); 140 return $this->call('list', [$params], BucketsModel::class); 141 } 142 /** 143 * Locks retention policy on a bucket. (buckets.lockRetentionPolicy) 144 * 145 * @param string $bucket Name of a bucket. 146 * @param string $ifMetagenerationMatch Makes the operation conditional on 147 * whether bucket's current metageneration matches the given value. 148 * @param array $optParams Optional parameters. 149 * 150 * @opt_param string userProject The project to be billed for this request. 151 * Required for Requester Pays buckets. 152 * @return Bucket 153 */ 154 public function lockRetentionPolicy($bucket, $ifMetagenerationMatch, $optParams = []) 155 { 156 $params = ['bucket' => $bucket, 'ifMetagenerationMatch' => $ifMetagenerationMatch]; 157 $params = array_merge($params, $optParams); 158 return $this->call('lockRetentionPolicy', [$params], Bucket::class); 159 } 160 /** 161 * Patches a bucket. Changes to the bucket will be readable immediately after 162 * writing, but configuration changes may take time to propagate. 163 * (buckets.patch) 164 * 165 * @param string $bucket Name of a bucket. 166 * @param Bucket $postBody 167 * @param array $optParams Optional parameters. 168 * 169 * @opt_param string ifMetagenerationMatch Makes the return of the bucket 170 * metadata conditional on whether the bucket's current metageneration matches 171 * the given value. 172 * @opt_param string ifMetagenerationNotMatch Makes the return of the bucket 173 * metadata conditional on whether the bucket's current metageneration does not 174 * match the given value. 175 * @opt_param string predefinedAcl Apply a predefined set of access controls to 176 * this bucket. 177 * @opt_param string predefinedDefaultObjectAcl Apply a predefined set of 178 * default object access controls to this bucket. 179 * @opt_param string projection Set of properties to return. Defaults to full. 180 * @opt_param string userProject The project to be billed for this request. 181 * Required for Requester Pays buckets. 182 * @return Bucket 183 */ 184 public function patch($bucket, Bucket $postBody, $optParams = []) 185 { 186 $params = ['bucket' => $bucket, 'postBody' => $postBody]; 187 $params = array_merge($params, $optParams); 188 return $this->call('patch', [$params], Bucket::class); 189 } 190 /** 191 * Updates an IAM policy for the specified bucket. (buckets.setIamPolicy) 192 * 193 * @param string $bucket Name of a bucket. 194 * @param Policy $postBody 195 * @param array $optParams Optional parameters. 196 * 197 * @opt_param string userProject The project to be billed for this request. 198 * Required for Requester Pays buckets. 199 * @return Policy 200 */ 201 public function setIamPolicy($bucket, Policy $postBody, $optParams = []) 202 { 203 $params = ['bucket' => $bucket, 'postBody' => $postBody]; 204 $params = array_merge($params, $optParams); 205 return $this->call('setIamPolicy', [$params], Policy::class); 206 } 207 /** 208 * Tests a set of permissions on the given bucket to see which, if any, are held 209 * by the caller. (buckets.testIamPermissions) 210 * 211 * @param string $bucket Name of a bucket. 212 * @param string|array $permissions Permissions to test. 213 * @param array $optParams Optional parameters. 214 * 215 * @opt_param string userProject The project to be billed for this request. 216 * Required for Requester Pays buckets. 217 * @return TestIamPermissionsResponse 218 */ 219 public function testIamPermissions($bucket, $permissions, $optParams = []) 220 { 221 $params = ['bucket' => $bucket, 'permissions' => $permissions]; 222 $params = array_merge($params, $optParams); 223 return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class); 224 } 225 /** 226 * Updates a bucket. Changes to the bucket will be readable immediately after 227 * writing, but configuration changes may take time to propagate. 228 * (buckets.update) 229 * 230 * @param string $bucket Name of a bucket. 231 * @param Bucket $postBody 232 * @param array $optParams Optional parameters. 233 * 234 * @opt_param string ifMetagenerationMatch Makes the return of the bucket 235 * metadata conditional on whether the bucket's current metageneration matches 236 * the given value. 237 * @opt_param string ifMetagenerationNotMatch Makes the return of the bucket 238 * metadata conditional on whether the bucket's current metageneration does not 239 * match the given value. 240 * @opt_param string predefinedAcl Apply a predefined set of access controls to 241 * this bucket. 242 * @opt_param string predefinedDefaultObjectAcl Apply a predefined set of 243 * default object access controls to this bucket. 244 * @opt_param string projection Set of properties to return. Defaults to full. 245 * @opt_param string userProject The project to be billed for this request. 246 * Required for Requester Pays buckets. 247 * @return Bucket 248 */ 249 public function update($bucket, Bucket $postBody, $optParams = []) 250 { 251 $params = ['bucket' => $bucket, 'postBody' => $postBody]; 252 $params = array_merge($params, $optParams); 253 return $this->call('update', [$params], Bucket::class); 254 } 255} 256 257// Adding a class alias for backwards compatibility with the previous class name. 258class_alias(Buckets::class, 'Google_Service_Storage_Resource_Buckets'); 259