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