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