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\Compute\Resource; 19 20use Google\Service\Compute\Disk; 21use Google\Service\Compute\DiskAggregatedList; 22use Google\Service\Compute\DiskList; 23use Google\Service\Compute\DisksAddResourcePoliciesRequest; 24use Google\Service\Compute\DisksRemoveResourcePoliciesRequest; 25use Google\Service\Compute\DisksResizeRequest; 26use Google\Service\Compute\Operation; 27use Google\Service\Compute\Policy; 28use Google\Service\Compute\Snapshot; 29use Google\Service\Compute\TestPermissionsRequest; 30use Google\Service\Compute\TestPermissionsResponse; 31use Google\Service\Compute\ZoneSetLabelsRequest; 32use Google\Service\Compute\ZoneSetPolicyRequest; 33 34/** 35 * The "disks" collection of methods. 36 * Typical usage is: 37 * <code> 38 * $computeService = new Google\Service\Compute(...); 39 * $disks = $computeService->disks; 40 * </code> 41 */ 42class Disks extends \Google\Service\Resource 43{ 44 /** 45 * Adds existing resource policies to a disk. You can only add one policy which 46 * will be applied to this disk for scheduling snapshot creation. 47 * (disks.addResourcePolicies) 48 * 49 * @param string $project Project ID for this request. 50 * @param string $zone The name of the zone for this request. 51 * @param string $disk The disk name for this request. 52 * @param DisksAddResourcePoliciesRequest $postBody 53 * @param array $optParams Optional parameters. 54 * 55 * @opt_param string requestId An optional request ID to identify requests. 56 * Specify a unique request ID so that if you must retry your request, the 57 * server will know to ignore the request if it has already been completed. For 58 * example, consider a situation where you make an initial request and the 59 * request times out. If you make the request again with the same request ID, 60 * the server can check if original operation with the same request ID was 61 * received, and if so, will ignore the second request. This prevents clients 62 * from accidentally creating duplicate commitments. The request ID must be a 63 * valid UUID with the exception that zero UUID is not supported ( 64 * 00000000-0000-0000-0000-000000000000). 65 * @return Operation 66 */ 67 public function addResourcePolicies($project, $zone, $disk, DisksAddResourcePoliciesRequest $postBody, $optParams = []) 68 { 69 $params = ['project' => $project, 'zone' => $zone, 'disk' => $disk, 'postBody' => $postBody]; 70 $params = array_merge($params, $optParams); 71 return $this->call('addResourcePolicies', [$params], Operation::class); 72 } 73 /** 74 * Retrieves an aggregated list of persistent disks. (disks.aggregatedList) 75 * 76 * @param string $project Project ID for this request. 77 * @param array $optParams Optional parameters. 78 * 79 * @opt_param string filter A filter expression that filters resources listed in 80 * the response. The expression must specify the field name, an operator, and 81 * the value that you want to use for filtering. The value must be a string, a 82 * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, 83 * `>=` or `:`. For example, if you are filtering Compute Engine instances, you 84 * can exclude instances named `example-instance` by specifying `name != 85 * example-instance`. The `:` operator can be used with string fields to match 86 * substrings. For non-string fields it is equivalent to the `=` operator. The 87 * `:*` comparison can be used to test whether a key has been defined. For 88 * example, to find all objects with `owner` label use: ``` labels.owner:* ``` 89 * You can also filter nested fields. For example, you could specify 90 * `scheduling.automaticRestart = false` to include instances only if they are 91 * not scheduled for automatic restarts. You can use filtering on nested fields 92 * to filter based on resource labels. To filter on multiple expressions, 93 * provide each separate expression within parentheses. For example: ``` 94 * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By 95 * default, each expression is an `AND` expression. However, you can include 96 * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel 97 * Skylake") OR (cpuPlatform = "Intel Broadwell") AND 98 * (scheduling.automaticRestart = true) ``` 99 * @opt_param bool includeAllScopes Indicates whether every visible scope for 100 * each scope type (zone, region, global) should be included in the response. 101 * For new resource types added after this field, the flag has no effect as new 102 * resource types will always include every visible scope for each scope type in 103 * response. For resource types which predate this field, if this flag is 104 * omitted or false, only scopes of the scope types where the resource type is 105 * expected to be found will be included. 106 * @opt_param string maxResults The maximum number of results per page that 107 * should be returned. If the number of available results is larger than 108 * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to 109 * get the next page of results in subsequent list requests. Acceptable values 110 * are `0` to `500`, inclusive. (Default: `500`) 111 * @opt_param string orderBy Sorts list results by a certain order. By default, 112 * results are returned in alphanumerical order based on the resource name. You 113 * can also sort results in descending order based on the creation timestamp 114 * using `orderBy="creationTimestamp desc"`. This sorts results based on the 115 * `creationTimestamp` field in reverse chronological order (newest result 116 * first). Use this to sort resources like operations so that the newest 117 * operation is returned first. Currently, only sorting by `name` or 118 * `creationTimestamp desc` is supported. 119 * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to 120 * the `nextPageToken` returned by a previous list request to get the next page 121 * of results. 122 * @opt_param bool returnPartialSuccess Opt-in for partial success behavior 123 * which provides partial results in case of failure. The default value is 124 * false. 125 * @return DiskAggregatedList 126 */ 127 public function aggregatedList($project, $optParams = []) 128 { 129 $params = ['project' => $project]; 130 $params = array_merge($params, $optParams); 131 return $this->call('aggregatedList', [$params], DiskAggregatedList::class); 132 } 133 /** 134 * Creates a snapshot of a specified persistent disk. For regular snapshot 135 * creation, consider using snapshots.insert instead, as that method supports 136 * more features, such as creating snapshots in a project different from the 137 * source disk project. (disks.createSnapshot) 138 * 139 * @param string $project Project ID for this request. 140 * @param string $zone The name of the zone for this request. 141 * @param string $disk Name of the persistent disk to snapshot. 142 * @param Snapshot $postBody 143 * @param array $optParams Optional parameters. 144 * 145 * @opt_param bool guestFlush [Input Only] Whether to attempt an application 146 * consistent snapshot by informing the OS to prepare for the snapshot process. 147 * @opt_param string requestId An optional request ID to identify requests. 148 * Specify a unique request ID so that if you must retry your request, the 149 * server will know to ignore the request if it has already been completed. For 150 * example, consider a situation where you make an initial request and the 151 * request times out. If you make the request again with the same request ID, 152 * the server can check if original operation with the same request ID was 153 * received, and if so, will ignore the second request. This prevents clients 154 * from accidentally creating duplicate commitments. The request ID must be a 155 * valid UUID with the exception that zero UUID is not supported ( 156 * 00000000-0000-0000-0000-000000000000). 157 * @return Operation 158 */ 159 public function createSnapshot($project, $zone, $disk, Snapshot $postBody, $optParams = []) 160 { 161 $params = ['project' => $project, 'zone' => $zone, 'disk' => $disk, 'postBody' => $postBody]; 162 $params = array_merge($params, $optParams); 163 return $this->call('createSnapshot', [$params], Operation::class); 164 } 165 /** 166 * Deletes the specified persistent disk. Deleting a disk removes its data 167 * permanently and is irreversible. However, deleting a disk does not delete any 168 * snapshots previously made from the disk. You must separately delete 169 * snapshots. (disks.delete) 170 * 171 * @param string $project Project ID for this request. 172 * @param string $zone The name of the zone for this request. 173 * @param string $disk Name of the persistent disk to delete. 174 * @param array $optParams Optional parameters. 175 * 176 * @opt_param string requestId An optional request ID to identify requests. 177 * Specify a unique request ID so that if you must retry your request, the 178 * server will know to ignore the request if it has already been completed. For 179 * example, consider a situation where you make an initial request and the 180 * request times out. If you make the request again with the same request ID, 181 * the server can check if original operation with the same request ID was 182 * received, and if so, will ignore the second request. This prevents clients 183 * from accidentally creating duplicate commitments. The request ID must be a 184 * valid UUID with the exception that zero UUID is not supported ( 185 * 00000000-0000-0000-0000-000000000000). 186 * @return Operation 187 */ 188 public function delete($project, $zone, $disk, $optParams = []) 189 { 190 $params = ['project' => $project, 'zone' => $zone, 'disk' => $disk]; 191 $params = array_merge($params, $optParams); 192 return $this->call('delete', [$params], Operation::class); 193 } 194 /** 195 * Returns a specified persistent disk. Gets a list of available persistent 196 * disks by making a list() request. (disks.get) 197 * 198 * @param string $project Project ID for this request. 199 * @param string $zone The name of the zone for this request. 200 * @param string $disk Name of the persistent disk to return. 201 * @param array $optParams Optional parameters. 202 * @return Disk 203 */ 204 public function get($project, $zone, $disk, $optParams = []) 205 { 206 $params = ['project' => $project, 'zone' => $zone, 'disk' => $disk]; 207 $params = array_merge($params, $optParams); 208 return $this->call('get', [$params], Disk::class); 209 } 210 /** 211 * Gets the access control policy for a resource. May be empty if no such policy 212 * or resource exists. (disks.getIamPolicy) 213 * 214 * @param string $project Project ID for this request. 215 * @param string $zone The name of the zone for this request. 216 * @param string $resource Name or id of the resource for this request. 217 * @param array $optParams Optional parameters. 218 * 219 * @opt_param int optionsRequestedPolicyVersion Requested IAM Policy version. 220 * @return Policy 221 */ 222 public function getIamPolicy($project, $zone, $resource, $optParams = []) 223 { 224 $params = ['project' => $project, 'zone' => $zone, 'resource' => $resource]; 225 $params = array_merge($params, $optParams); 226 return $this->call('getIamPolicy', [$params], Policy::class); 227 } 228 /** 229 * Creates a persistent disk in the specified project using the data in the 230 * request. You can create a disk from a source (sourceImage, sourceSnapshot, or 231 * sourceDisk) or create an empty 500 GB data disk by omitting all properties. 232 * You can also create a disk that is larger than the default size by specifying 233 * the sizeGb property. (disks.insert) 234 * 235 * @param string $project Project ID for this request. 236 * @param string $zone The name of the zone for this request. 237 * @param Disk $postBody 238 * @param array $optParams Optional parameters. 239 * 240 * @opt_param string requestId An optional request ID to identify requests. 241 * Specify a unique request ID so that if you must retry your request, the 242 * server will know to ignore the request if it has already been completed. For 243 * example, consider a situation where you make an initial request and the 244 * request times out. If you make the request again with the same request ID, 245 * the server can check if original operation with the same request ID was 246 * received, and if so, will ignore the second request. This prevents clients 247 * from accidentally creating duplicate commitments. The request ID must be a 248 * valid UUID with the exception that zero UUID is not supported ( 249 * 00000000-0000-0000-0000-000000000000). 250 * @opt_param string sourceImage Source image to restore onto a disk. This field 251 * is optional. 252 * @return Operation 253 */ 254 public function insert($project, $zone, Disk $postBody, $optParams = []) 255 { 256 $params = ['project' => $project, 'zone' => $zone, 'postBody' => $postBody]; 257 $params = array_merge($params, $optParams); 258 return $this->call('insert', [$params], Operation::class); 259 } 260 /** 261 * Retrieves a list of persistent disks contained within the specified zone. 262 * (disks.listDisks) 263 * 264 * @param string $project Project ID for this request. 265 * @param string $zone The name of the zone for this request. 266 * @param array $optParams Optional parameters. 267 * 268 * @opt_param string filter A filter expression that filters resources listed in 269 * the response. The expression must specify the field name, an operator, and 270 * the value that you want to use for filtering. The value must be a string, a 271 * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, 272 * `>=` or `:`. For example, if you are filtering Compute Engine instances, you 273 * can exclude instances named `example-instance` by specifying `name != 274 * example-instance`. The `:` operator can be used with string fields to match 275 * substrings. For non-string fields it is equivalent to the `=` operator. The 276 * `:*` comparison can be used to test whether a key has been defined. For 277 * example, to find all objects with `owner` label use: ``` labels.owner:* ``` 278 * You can also filter nested fields. For example, you could specify 279 * `scheduling.automaticRestart = false` to include instances only if they are 280 * not scheduled for automatic restarts. You can use filtering on nested fields 281 * to filter based on resource labels. To filter on multiple expressions, 282 * provide each separate expression within parentheses. For example: ``` 283 * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By 284 * default, each expression is an `AND` expression. However, you can include 285 * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel 286 * Skylake") OR (cpuPlatform = "Intel Broadwell") AND 287 * (scheduling.automaticRestart = true) ``` 288 * @opt_param string maxResults The maximum number of results per page that 289 * should be returned. If the number of available results is larger than 290 * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to 291 * get the next page of results in subsequent list requests. Acceptable values 292 * are `0` to `500`, inclusive. (Default: `500`) 293 * @opt_param string orderBy Sorts list results by a certain order. By default, 294 * results are returned in alphanumerical order based on the resource name. You 295 * can also sort results in descending order based on the creation timestamp 296 * using `orderBy="creationTimestamp desc"`. This sorts results based on the 297 * `creationTimestamp` field in reverse chronological order (newest result 298 * first). Use this to sort resources like operations so that the newest 299 * operation is returned first. Currently, only sorting by `name` or 300 * `creationTimestamp desc` is supported. 301 * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to 302 * the `nextPageToken` returned by a previous list request to get the next page 303 * of results. 304 * @opt_param bool returnPartialSuccess Opt-in for partial success behavior 305 * which provides partial results in case of failure. The default value is 306 * false. 307 * @return DiskList 308 */ 309 public function listDisks($project, $zone, $optParams = []) 310 { 311 $params = ['project' => $project, 'zone' => $zone]; 312 $params = array_merge($params, $optParams); 313 return $this->call('list', [$params], DiskList::class); 314 } 315 /** 316 * Removes resource policies from a disk. (disks.removeResourcePolicies) 317 * 318 * @param string $project Project ID for this request. 319 * @param string $zone The name of the zone for this request. 320 * @param string $disk The disk name for this request. 321 * @param DisksRemoveResourcePoliciesRequest $postBody 322 * @param array $optParams Optional parameters. 323 * 324 * @opt_param string requestId An optional request ID to identify requests. 325 * Specify a unique request ID so that if you must retry your request, the 326 * server will know to ignore the request if it has already been completed. For 327 * example, consider a situation where you make an initial request and the 328 * request times out. If you make the request again with the same request ID, 329 * the server can check if original operation with the same request ID was 330 * received, and if so, will ignore the second request. This prevents clients 331 * from accidentally creating duplicate commitments. The request ID must be a 332 * valid UUID with the exception that zero UUID is not supported ( 333 * 00000000-0000-0000-0000-000000000000). 334 * @return Operation 335 */ 336 public function removeResourcePolicies($project, $zone, $disk, DisksRemoveResourcePoliciesRequest $postBody, $optParams = []) 337 { 338 $params = ['project' => $project, 'zone' => $zone, 'disk' => $disk, 'postBody' => $postBody]; 339 $params = array_merge($params, $optParams); 340 return $this->call('removeResourcePolicies', [$params], Operation::class); 341 } 342 /** 343 * Resizes the specified persistent disk. You can only increase the size of the 344 * disk. (disks.resize) 345 * 346 * @param string $project Project ID for this request. 347 * @param string $zone The name of the zone for this request. 348 * @param string $disk The name of the persistent disk. 349 * @param DisksResizeRequest $postBody 350 * @param array $optParams Optional parameters. 351 * 352 * @opt_param string requestId An optional request ID to identify requests. 353 * Specify a unique request ID so that if you must retry your request, the 354 * server will know to ignore the request if it has already been completed. For 355 * example, consider a situation where you make an initial request and the 356 * request times out. If you make the request again with the same request ID, 357 * the server can check if original operation with the same request ID was 358 * received, and if so, will ignore the second request. This prevents clients 359 * from accidentally creating duplicate commitments. The request ID must be a 360 * valid UUID with the exception that zero UUID is not supported ( 361 * 00000000-0000-0000-0000-000000000000). 362 * @return Operation 363 */ 364 public function resize($project, $zone, $disk, DisksResizeRequest $postBody, $optParams = []) 365 { 366 $params = ['project' => $project, 'zone' => $zone, 'disk' => $disk, 'postBody' => $postBody]; 367 $params = array_merge($params, $optParams); 368 return $this->call('resize', [$params], Operation::class); 369 } 370 /** 371 * Sets the access control policy on the specified resource. Replaces any 372 * existing policy. (disks.setIamPolicy) 373 * 374 * @param string $project Project ID for this request. 375 * @param string $zone The name of the zone for this request. 376 * @param string $resource Name or id of the resource for this request. 377 * @param ZoneSetPolicyRequest $postBody 378 * @param array $optParams Optional parameters. 379 * @return Policy 380 */ 381 public function setIamPolicy($project, $zone, $resource, ZoneSetPolicyRequest $postBody, $optParams = []) 382 { 383 $params = ['project' => $project, 'zone' => $zone, 'resource' => $resource, 'postBody' => $postBody]; 384 $params = array_merge($params, $optParams); 385 return $this->call('setIamPolicy', [$params], Policy::class); 386 } 387 /** 388 * Sets the labels on a disk. To learn more about labels, read the Labeling 389 * Resources documentation. (disks.setLabels) 390 * 391 * @param string $project Project ID for this request. 392 * @param string $zone The name of the zone for this request. 393 * @param string $resource Name or id of the resource for this request. 394 * @param ZoneSetLabelsRequest $postBody 395 * @param array $optParams Optional parameters. 396 * 397 * @opt_param string requestId An optional request ID to identify requests. 398 * Specify a unique request ID so that if you must retry your request, the 399 * server will know to ignore the request if it has already been completed. For 400 * example, consider a situation where you make an initial request and the 401 * request times out. If you make the request again with the same request ID, 402 * the server can check if original operation with the same request ID was 403 * received, and if so, will ignore the second request. This prevents clients 404 * from accidentally creating duplicate commitments. The request ID must be a 405 * valid UUID with the exception that zero UUID is not supported ( 406 * 00000000-0000-0000-0000-000000000000). 407 * @return Operation 408 */ 409 public function setLabels($project, $zone, $resource, ZoneSetLabelsRequest $postBody, $optParams = []) 410 { 411 $params = ['project' => $project, 'zone' => $zone, 'resource' => $resource, 'postBody' => $postBody]; 412 $params = array_merge($params, $optParams); 413 return $this->call('setLabels', [$params], Operation::class); 414 } 415 /** 416 * Returns permissions that a caller has on the specified resource. 417 * (disks.testIamPermissions) 418 * 419 * @param string $project Project ID for this request. 420 * @param string $zone The name of the zone for this request. 421 * @param string $resource Name or id of the resource for this request. 422 * @param TestPermissionsRequest $postBody 423 * @param array $optParams Optional parameters. 424 * @return TestPermissionsResponse 425 */ 426 public function testIamPermissions($project, $zone, $resource, TestPermissionsRequest $postBody, $optParams = []) 427 { 428 $params = ['project' => $project, 'zone' => $zone, 'resource' => $resource, 'postBody' => $postBody]; 429 $params = array_merge($params, $optParams); 430 return $this->call('testIamPermissions', [$params], TestPermissionsResponse::class); 431 } 432} 433 434// Adding a class alias for backwards compatibility with the previous class name. 435class_alias(Disks::class, 'Google_Service_Compute_Resource_Disks'); 436