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\SecurityPoliciesAggregatedList; 22use Google\Service\Compute\SecurityPoliciesListPreconfiguredExpressionSetsResponse; 23use Google\Service\Compute\SecurityPolicy; 24use Google\Service\Compute\SecurityPolicyList; 25use Google\Service\Compute\SecurityPolicyRule; 26 27/** 28 * The "securityPolicies" collection of methods. 29 * Typical usage is: 30 * <code> 31 * $computeService = new Google\Service\Compute(...); 32 * $securityPolicies = $computeService->securityPolicies; 33 * </code> 34 */ 35class SecurityPolicies extends \Google\Service\Resource 36{ 37 /** 38 * Inserts a rule into a security policy. (securityPolicies.addRule) 39 * 40 * @param string $project Project ID for this request. 41 * @param string $securityPolicy Name of the security policy to update. 42 * @param SecurityPolicyRule $postBody 43 * @param array $optParams Optional parameters. 44 * @return Operation 45 */ 46 public function addRule($project, $securityPolicy, SecurityPolicyRule $postBody, $optParams = []) 47 { 48 $params = ['project' => $project, 'securityPolicy' => $securityPolicy, 'postBody' => $postBody]; 49 $params = array_merge($params, $optParams); 50 return $this->call('addRule', [$params], Operation::class); 51 } 52 /** 53 * Retrieves the list of all SecurityPolicy resources, regional and global, 54 * available to the specified project. (securityPolicies.aggregatedList) 55 * 56 * @param string $project Name of the project scoping this request. 57 * @param array $optParams Optional parameters. 58 * 59 * @opt_param string filter A filter expression that filters resources listed in 60 * the response. The expression must specify the field name, an operator, and 61 * the value that you want to use for filtering. The value must be a string, a 62 * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, 63 * `>=` or `:`. For example, if you are filtering Compute Engine instances, you 64 * can exclude instances named `example-instance` by specifying `name != 65 * example-instance`. The `:` operator can be used with string fields to match 66 * substrings. For non-string fields it is equivalent to the `=` operator. The 67 * `:*` comparison can be used to test whether a key has been defined. For 68 * example, to find all objects with `owner` label use: ``` labels.owner:* ``` 69 * You can also filter nested fields. For example, you could specify 70 * `scheduling.automaticRestart = false` to include instances only if they are 71 * not scheduled for automatic restarts. You can use filtering on nested fields 72 * to filter based on resource labels. To filter on multiple expressions, 73 * provide each separate expression within parentheses. For example: ``` 74 * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By 75 * default, each expression is an `AND` expression. However, you can include 76 * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel 77 * Skylake") OR (cpuPlatform = "Intel Broadwell") AND 78 * (scheduling.automaticRestart = true) ``` 79 * @opt_param bool includeAllScopes Indicates whether every visible scope for 80 * each scope type (zone, region, global) should be included in the response. 81 * For new resource types added after this field, the flag has no effect as new 82 * resource types will always include every visible scope for each scope type in 83 * response. For resource types which predate this field, if this flag is 84 * omitted or false, only scopes of the scope types where the resource type is 85 * expected to be found will be included. 86 * @opt_param string maxResults The maximum number of results per page that 87 * should be returned. If the number of available results is larger than 88 * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to 89 * get the next page of results in subsequent list requests. Acceptable values 90 * are `0` to `500`, inclusive. (Default: `500`) 91 * @opt_param string orderBy Sorts list results by a certain order. By default, 92 * results are returned in alphanumerical order based on the resource name. You 93 * can also sort results in descending order based on the creation timestamp 94 * using `orderBy="creationTimestamp desc"`. This sorts results based on the 95 * `creationTimestamp` field in reverse chronological order (newest result 96 * first). Use this to sort resources like operations so that the newest 97 * operation is returned first. Currently, only sorting by `name` or 98 * `creationTimestamp desc` is supported. 99 * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to 100 * the `nextPageToken` returned by a previous list request to get the next page 101 * of results. 102 * @opt_param bool returnPartialSuccess Opt-in for partial success behavior 103 * which provides partial results in case of failure. The default value is 104 * false. 105 * @return SecurityPoliciesAggregatedList 106 */ 107 public function aggregatedList($project, $optParams = []) 108 { 109 $params = ['project' => $project]; 110 $params = array_merge($params, $optParams); 111 return $this->call('aggregatedList', [$params], SecurityPoliciesAggregatedList::class); 112 } 113 /** 114 * Deletes the specified policy. (securityPolicies.delete) 115 * 116 * @param string $project Project ID for this request. 117 * @param string $securityPolicy Name of the security policy to delete. 118 * @param array $optParams Optional parameters. 119 * 120 * @opt_param string requestId An optional request ID to identify requests. 121 * Specify a unique request ID so that if you must retry your request, the 122 * server will know to ignore the request if it has already been completed. For 123 * example, consider a situation where you make an initial request and the 124 * request times out. If you make the request again with the same request ID, 125 * the server can check if original operation with the same request ID was 126 * received, and if so, will ignore the second request. This prevents clients 127 * from accidentally creating duplicate commitments. The request ID must be a 128 * valid UUID with the exception that zero UUID is not supported ( 129 * 00000000-0000-0000-0000-000000000000). 130 * @return Operation 131 */ 132 public function delete($project, $securityPolicy, $optParams = []) 133 { 134 $params = ['project' => $project, 'securityPolicy' => $securityPolicy]; 135 $params = array_merge($params, $optParams); 136 return $this->call('delete', [$params], Operation::class); 137 } 138 /** 139 * List all of the ordered rules present in a single specified policy. 140 * (securityPolicies.get) 141 * 142 * @param string $project Project ID for this request. 143 * @param string $securityPolicy Name of the security policy to get. 144 * @param array $optParams Optional parameters. 145 * @return SecurityPolicy 146 */ 147 public function get($project, $securityPolicy, $optParams = []) 148 { 149 $params = ['project' => $project, 'securityPolicy' => $securityPolicy]; 150 $params = array_merge($params, $optParams); 151 return $this->call('get', [$params], SecurityPolicy::class); 152 } 153 /** 154 * Gets a rule at the specified priority. (securityPolicies.getRule) 155 * 156 * @param string $project Project ID for this request. 157 * @param string $securityPolicy Name of the security policy to which the 158 * queried rule belongs. 159 * @param array $optParams Optional parameters. 160 * 161 * @opt_param int priority The priority of the rule to get from the security 162 * policy. 163 * @return SecurityPolicyRule 164 */ 165 public function getRule($project, $securityPolicy, $optParams = []) 166 { 167 $params = ['project' => $project, 'securityPolicy' => $securityPolicy]; 168 $params = array_merge($params, $optParams); 169 return $this->call('getRule', [$params], SecurityPolicyRule::class); 170 } 171 /** 172 * Creates a new policy in the specified project using the data included in the 173 * request. (securityPolicies.insert) 174 * 175 * @param string $project Project ID for this request. 176 * @param SecurityPolicy $postBody 177 * @param array $optParams Optional parameters. 178 * 179 * @opt_param string requestId An optional request ID to identify requests. 180 * Specify a unique request ID so that if you must retry your request, the 181 * server will know to ignore the request if it has already been completed. For 182 * example, consider a situation where you make an initial request and the 183 * request times out. If you make the request again with the same request ID, 184 * the server can check if original operation with the same request ID was 185 * received, and if so, will ignore the second request. This prevents clients 186 * from accidentally creating duplicate commitments. The request ID must be a 187 * valid UUID with the exception that zero UUID is not supported ( 188 * 00000000-0000-0000-0000-000000000000). 189 * @return Operation 190 */ 191 public function insert($project, SecurityPolicy $postBody, $optParams = []) 192 { 193 $params = ['project' => $project, 'postBody' => $postBody]; 194 $params = array_merge($params, $optParams); 195 return $this->call('insert', [$params], Operation::class); 196 } 197 /** 198 * List all the policies that have been configured for the specified project. 199 * (securityPolicies.listSecurityPolicies) 200 * 201 * @param string $project Project ID for this request. 202 * @param array $optParams Optional parameters. 203 * 204 * @opt_param string filter A filter expression that filters resources listed in 205 * the response. The expression must specify the field name, an operator, and 206 * the value that you want to use for filtering. The value must be a string, a 207 * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, 208 * `>=` or `:`. For example, if you are filtering Compute Engine instances, you 209 * can exclude instances named `example-instance` by specifying `name != 210 * example-instance`. The `:` operator can be used with string fields to match 211 * substrings. For non-string fields it is equivalent to the `=` operator. The 212 * `:*` comparison can be used to test whether a key has been defined. For 213 * example, to find all objects with `owner` label use: ``` labels.owner:* ``` 214 * You can also filter nested fields. For example, you could specify 215 * `scheduling.automaticRestart = false` to include instances only if they are 216 * not scheduled for automatic restarts. You can use filtering on nested fields 217 * to filter based on resource labels. To filter on multiple expressions, 218 * provide each separate expression within parentheses. For example: ``` 219 * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By 220 * default, each expression is an `AND` expression. However, you can include 221 * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel 222 * Skylake") OR (cpuPlatform = "Intel Broadwell") AND 223 * (scheduling.automaticRestart = true) ``` 224 * @opt_param string maxResults The maximum number of results per page that 225 * should be returned. If the number of available results is larger than 226 * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to 227 * get the next page of results in subsequent list requests. Acceptable values 228 * are `0` to `500`, inclusive. (Default: `500`) 229 * @opt_param string orderBy Sorts list results by a certain order. By default, 230 * results are returned in alphanumerical order based on the resource name. You 231 * can also sort results in descending order based on the creation timestamp 232 * using `orderBy="creationTimestamp desc"`. This sorts results based on the 233 * `creationTimestamp` field in reverse chronological order (newest result 234 * first). Use this to sort resources like operations so that the newest 235 * operation is returned first. Currently, only sorting by `name` or 236 * `creationTimestamp desc` is supported. 237 * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to 238 * the `nextPageToken` returned by a previous list request to get the next page 239 * of results. 240 * @opt_param bool returnPartialSuccess Opt-in for partial success behavior 241 * which provides partial results in case of failure. The default value is 242 * false. 243 * @return SecurityPolicyList 244 */ 245 public function listSecurityPolicies($project, $optParams = []) 246 { 247 $params = ['project' => $project]; 248 $params = array_merge($params, $optParams); 249 return $this->call('list', [$params], SecurityPolicyList::class); 250 } 251 /** 252 * Gets the current list of preconfigured Web Application Firewall (WAF) 253 * expressions. (securityPolicies.listPreconfiguredExpressionSets) 254 * 255 * @param string $project Project ID for this request. 256 * @param array $optParams Optional parameters. 257 * 258 * @opt_param string filter A filter expression that filters resources listed in 259 * the response. The expression must specify the field name, an operator, and 260 * the value that you want to use for filtering. The value must be a string, a 261 * number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, 262 * `>=` or `:`. For example, if you are filtering Compute Engine instances, you 263 * can exclude instances named `example-instance` by specifying `name != 264 * example-instance`. The `:` operator can be used with string fields to match 265 * substrings. For non-string fields it is equivalent to the `=` operator. The 266 * `:*` comparison can be used to test whether a key has been defined. For 267 * example, to find all objects with `owner` label use: ``` labels.owner:* ``` 268 * You can also filter nested fields. For example, you could specify 269 * `scheduling.automaticRestart = false` to include instances only if they are 270 * not scheduled for automatic restarts. You can use filtering on nested fields 271 * to filter based on resource labels. To filter on multiple expressions, 272 * provide each separate expression within parentheses. For example: ``` 273 * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By 274 * default, each expression is an `AND` expression. However, you can include 275 * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel 276 * Skylake") OR (cpuPlatform = "Intel Broadwell") AND 277 * (scheduling.automaticRestart = true) ``` 278 * @opt_param string maxResults The maximum number of results per page that 279 * should be returned. If the number of available results is larger than 280 * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to 281 * get the next page of results in subsequent list requests. Acceptable values 282 * are `0` to `500`, inclusive. (Default: `500`) 283 * @opt_param string orderBy Sorts list results by a certain order. By default, 284 * results are returned in alphanumerical order based on the resource name. You 285 * can also sort results in descending order based on the creation timestamp 286 * using `orderBy="creationTimestamp desc"`. This sorts results based on the 287 * `creationTimestamp` field in reverse chronological order (newest result 288 * first). Use this to sort resources like operations so that the newest 289 * operation is returned first. Currently, only sorting by `name` or 290 * `creationTimestamp desc` is supported. 291 * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to 292 * the `nextPageToken` returned by a previous list request to get the next page 293 * of results. 294 * @opt_param bool returnPartialSuccess Opt-in for partial success behavior 295 * which provides partial results in case of failure. The default value is 296 * false. 297 * @return SecurityPoliciesListPreconfiguredExpressionSetsResponse 298 */ 299 public function listPreconfiguredExpressionSets($project, $optParams = []) 300 { 301 $params = ['project' => $project]; 302 $params = array_merge($params, $optParams); 303 return $this->call('listPreconfiguredExpressionSets', [$params], SecurityPoliciesListPreconfiguredExpressionSetsResponse::class); 304 } 305 /** 306 * Patches the specified policy with the data included in the request. This 307 * cannot be used to be update the rules in the policy. Please use the per rule 308 * methods like addRule, patchRule, and removeRule instead. 309 * (securityPolicies.patch) 310 * 311 * @param string $project Project ID for this request. 312 * @param string $securityPolicy Name of the security policy to update. 313 * @param SecurityPolicy $postBody 314 * @param array $optParams Optional parameters. 315 * 316 * @opt_param string requestId An optional request ID to identify requests. 317 * Specify a unique request ID so that if you must retry your request, the 318 * server will know to ignore the request if it has already been completed. For 319 * example, consider a situation where you make an initial request and the 320 * request times out. If you make the request again with the same request ID, 321 * the server can check if original operation with the same request ID was 322 * received, and if so, will ignore the second request. This prevents clients 323 * from accidentally creating duplicate commitments. The request ID must be a 324 * valid UUID with the exception that zero UUID is not supported ( 325 * 00000000-0000-0000-0000-000000000000). 326 * @return Operation 327 */ 328 public function patch($project, $securityPolicy, SecurityPolicy $postBody, $optParams = []) 329 { 330 $params = ['project' => $project, 'securityPolicy' => $securityPolicy, 'postBody' => $postBody]; 331 $params = array_merge($params, $optParams); 332 return $this->call('patch', [$params], Operation::class); 333 } 334 /** 335 * Patches a rule at the specified priority. (securityPolicies.patchRule) 336 * 337 * @param string $project Project ID for this request. 338 * @param string $securityPolicy Name of the security policy to update. 339 * @param SecurityPolicyRule $postBody 340 * @param array $optParams Optional parameters. 341 * 342 * @opt_param int priority The priority of the rule to patch. 343 * @return Operation 344 */ 345 public function patchRule($project, $securityPolicy, SecurityPolicyRule $postBody, $optParams = []) 346 { 347 $params = ['project' => $project, 'securityPolicy' => $securityPolicy, 'postBody' => $postBody]; 348 $params = array_merge($params, $optParams); 349 return $this->call('patchRule', [$params], Operation::class); 350 } 351 /** 352 * Deletes a rule at the specified priority. (securityPolicies.removeRule) 353 * 354 * @param string $project Project ID for this request. 355 * @param string $securityPolicy Name of the security policy to update. 356 * @param array $optParams Optional parameters. 357 * 358 * @opt_param int priority The priority of the rule to remove from the security 359 * policy. 360 * @return Operation 361 */ 362 public function removeRule($project, $securityPolicy, $optParams = []) 363 { 364 $params = ['project' => $project, 'securityPolicy' => $securityPolicy]; 365 $params = array_merge($params, $optParams); 366 return $this->call('removeRule', [$params], Operation::class); 367 } 368} 369 370// Adding a class alias for backwards compatibility with the previous class name. 371class_alias(SecurityPolicies::class, 'Google_Service_Compute_Resource_SecurityPolicies'); 372