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\GlobalSetLabelsRequest; 21use Google\Service\Compute\GlobalSetPolicyRequest; 22use Google\Service\Compute\Operation; 23use Google\Service\Compute\Policy; 24use Google\Service\Compute\Snapshot; 25use Google\Service\Compute\SnapshotList; 26use Google\Service\Compute\TestPermissionsRequest; 27use Google\Service\Compute\TestPermissionsResponse; 28 29/** 30 * The "snapshots" collection of methods. 31 * Typical usage is: 32 * <code> 33 * $computeService = new Google\Service\Compute(...); 34 * $snapshots = $computeService->snapshots; 35 * </code> 36 */ 37class Snapshots extends \Google\Service\Resource 38{ 39 /** 40 * Deletes the specified Snapshot resource. Keep in mind that deleting a single 41 * snapshot might not necessarily delete all the data on that snapshot. If any 42 * data on the snapshot that is marked for deletion is needed for subsequent 43 * snapshots, the data will be moved to the next corresponding snapshot. For 44 * more information, see Deleting snapshots. (snapshots.delete) 45 * 46 * @param string $project Project ID for this request. 47 * @param string $snapshot Name of the Snapshot resource to delete. 48 * @param array $optParams Optional parameters. 49 * 50 * @opt_param string requestId An optional request ID to identify requests. 51 * Specify a unique request ID so that if you must retry your request, the 52 * server will know to ignore the request if it has already been completed. For 53 * example, consider a situation where you make an initial request and the 54 * request times out. If you make the request again with the same request ID, 55 * the server can check if original operation with the same request ID was 56 * received, and if so, will ignore the second request. This prevents clients 57 * from accidentally creating duplicate commitments. The request ID must be a 58 * valid UUID with the exception that zero UUID is not supported ( 59 * 00000000-0000-0000-0000-000000000000). 60 * @return Operation 61 */ 62 public function delete($project, $snapshot, $optParams = []) 63 { 64 $params = ['project' => $project, 'snapshot' => $snapshot]; 65 $params = array_merge($params, $optParams); 66 return $this->call('delete', [$params], Operation::class); 67 } 68 /** 69 * Returns the specified Snapshot resource. Gets a list of available snapshots 70 * by making a list() request. (snapshots.get) 71 * 72 * @param string $project Project ID for this request. 73 * @param string $snapshot Name of the Snapshot resource to return. 74 * @param array $optParams Optional parameters. 75 * @return Snapshot 76 */ 77 public function get($project, $snapshot, $optParams = []) 78 { 79 $params = ['project' => $project, 'snapshot' => $snapshot]; 80 $params = array_merge($params, $optParams); 81 return $this->call('get', [$params], Snapshot::class); 82 } 83 /** 84 * Gets the access control policy for a resource. May be empty if no such policy 85 * or resource exists. (snapshots.getIamPolicy) 86 * 87 * @param string $project Project ID for this request. 88 * @param string $resource Name or id of the resource for this request. 89 * @param array $optParams Optional parameters. 90 * 91 * @opt_param int optionsRequestedPolicyVersion Requested IAM Policy version. 92 * @return Policy 93 */ 94 public function getIamPolicy($project, $resource, $optParams = []) 95 { 96 $params = ['project' => $project, 'resource' => $resource]; 97 $params = array_merge($params, $optParams); 98 return $this->call('getIamPolicy', [$params], Policy::class); 99 } 100 /** 101 * Creates a snapshot in the specified project using the data included in the 102 * request. For regular snapshot creation, consider using this method instead of 103 * disks.createSnapshot, as this method supports more features, such as creating 104 * snapshots in a project different from the source disk project. 105 * (snapshots.insert) 106 * 107 * @param string $project Project ID for this request. 108 * @param Snapshot $postBody 109 * @param array $optParams Optional parameters. 110 * 111 * @opt_param string requestId An optional request ID to identify requests. 112 * Specify a unique request ID so that if you must retry your request, the 113 * server will know to ignore the request if it has already been completed. For 114 * example, consider a situation where you make an initial request and the 115 * request times out. If you make the request again with the same request ID, 116 * the server can check if original operation with the same request ID was 117 * received, and if so, will ignore the second request. This prevents clients 118 * from accidentally creating duplicate commitments. The request ID must be a 119 * valid UUID with the exception that zero UUID is not supported ( 120 * 00000000-0000-0000-0000-000000000000). 121 * @return Operation 122 */ 123 public function insert($project, Snapshot $postBody, $optParams = []) 124 { 125 $params = ['project' => $project, 'postBody' => $postBody]; 126 $params = array_merge($params, $optParams); 127 return $this->call('insert', [$params], Operation::class); 128 } 129 /** 130 * Retrieves the list of Snapshot resources contained within the specified 131 * project. (snapshots.listSnapshots) 132 * 133 * @param string $project Project ID for this request. 134 * @param array $optParams Optional parameters. 135 * 136 * @opt_param string filter A filter expression that filters resources listed in 137 * the response. The expression must specify the field name, an operator, and 138 * the value that you want to use for filtering. The value must be a string, a 139 * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, 140 * `>=` or `:`. For example, if you are filtering Compute Engine instances, you 141 * can exclude instances named `example-instance` by specifying `name != 142 * example-instance`. The `:` operator can be used with string fields to match 143 * substrings. For non-string fields it is equivalent to the `=` operator. The 144 * `:*` comparison can be used to test whether a key has been defined. For 145 * example, to find all objects with `owner` label use: ``` labels.owner:* ``` 146 * You can also filter nested fields. For example, you could specify 147 * `scheduling.automaticRestart = false` to include instances only if they are 148 * not scheduled for automatic restarts. You can use filtering on nested fields 149 * to filter based on resource labels. To filter on multiple expressions, 150 * provide each separate expression within parentheses. For example: ``` 151 * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By 152 * default, each expression is an `AND` expression. However, you can include 153 * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel 154 * Skylake") OR (cpuPlatform = "Intel Broadwell") AND 155 * (scheduling.automaticRestart = true) ``` 156 * @opt_param string maxResults The maximum number of results per page that 157 * should be returned. If the number of available results is larger than 158 * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to 159 * get the next page of results in subsequent list requests. Acceptable values 160 * are `0` to `500`, inclusive. (Default: `500`) 161 * @opt_param string orderBy Sorts list results by a certain order. By default, 162 * results are returned in alphanumerical order based on the resource name. You 163 * can also sort results in descending order based on the creation timestamp 164 * using `orderBy="creationTimestamp desc"`. This sorts results based on the 165 * `creationTimestamp` field in reverse chronological order (newest result 166 * first). Use this to sort resources like operations so that the newest 167 * operation is returned first. Currently, only sorting by `name` or 168 * `creationTimestamp desc` is supported. 169 * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to 170 * the `nextPageToken` returned by a previous list request to get the next page 171 * of results. 172 * @opt_param bool returnPartialSuccess Opt-in for partial success behavior 173 * which provides partial results in case of failure. The default value is 174 * false. 175 * @return SnapshotList 176 */ 177 public function listSnapshots($project, $optParams = []) 178 { 179 $params = ['project' => $project]; 180 $params = array_merge($params, $optParams); 181 return $this->call('list', [$params], SnapshotList::class); 182 } 183 /** 184 * Sets the access control policy on the specified resource. Replaces any 185 * existing policy. (snapshots.setIamPolicy) 186 * 187 * @param string $project Project ID for this request. 188 * @param string $resource Name or id of the resource for this request. 189 * @param GlobalSetPolicyRequest $postBody 190 * @param array $optParams Optional parameters. 191 * @return Policy 192 */ 193 public function setIamPolicy($project, $resource, GlobalSetPolicyRequest $postBody, $optParams = []) 194 { 195 $params = ['project' => $project, 'resource' => $resource, 'postBody' => $postBody]; 196 $params = array_merge($params, $optParams); 197 return $this->call('setIamPolicy', [$params], Policy::class); 198 } 199 /** 200 * Sets the labels on a snapshot. To learn more about labels, read the Labeling 201 * Resources documentation. (snapshots.setLabels) 202 * 203 * @param string $project Project ID for this request. 204 * @param string $resource Name or id of the resource for this request. 205 * @param GlobalSetLabelsRequest $postBody 206 * @param array $optParams Optional parameters. 207 * @return Operation 208 */ 209 public function setLabels($project, $resource, GlobalSetLabelsRequest $postBody, $optParams = []) 210 { 211 $params = ['project' => $project, 'resource' => $resource, 'postBody' => $postBody]; 212 $params = array_merge($params, $optParams); 213 return $this->call('setLabels', [$params], Operation::class); 214 } 215 /** 216 * Returns permissions that a caller has on the specified resource. 217 * (snapshots.testIamPermissions) 218 * 219 * @param string $project Project ID for this request. 220 * @param string $resource Name or id of the resource for this request. 221 * @param TestPermissionsRequest $postBody 222 * @param array $optParams Optional parameters. 223 * @return TestPermissionsResponse 224 */ 225 public function testIamPermissions($project, $resource, TestPermissionsRequest $postBody, $optParams = []) 226 { 227 $params = ['project' => $project, 'resource' => $resource, 'postBody' => $postBody]; 228 $params = array_merge($params, $optParams); 229 return $this->call('testIamPermissions', [$params], TestPermissionsResponse::class); 230 } 231} 232 233// Adding a class alias for backwards compatibility with the previous class name. 234class_alias(Snapshots::class, 'Google_Service_Compute_Resource_Snapshots'); 235