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 |
|
---|
18 | namespace Google\Service\Compute\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Compute\Operation;
|
---|
21 | use Google\Service\Compute\SecurityPolicyReference;
|
---|
22 | use Google\Service\Compute\TargetInstance;
|
---|
23 | use Google\Service\Compute\TargetInstanceAggregatedList;
|
---|
24 | use Google\Service\Compute\TargetInstanceList;
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * The "targetInstances" collection of methods.
|
---|
28 | * Typical usage is:
|
---|
29 | * <code>
|
---|
30 | * $computeService = new Google\Service\Compute(...);
|
---|
31 | * $targetInstances = $computeService->targetInstances;
|
---|
32 | * </code>
|
---|
33 | */
|
---|
34 | class TargetInstances extends \Google\Service\Resource
|
---|
35 | {
|
---|
36 | /**
|
---|
37 | * Retrieves an aggregated list of target instances. To prevent failure, Google
|
---|
38 | * recommends that you set the `returnPartialSuccess` parameter to `true`.
|
---|
39 | * (targetInstances.aggregatedList)
|
---|
40 | *
|
---|
41 | * @param string $project Project ID for this request.
|
---|
42 | * @param array $optParams Optional parameters.
|
---|
43 | *
|
---|
44 | * @opt_param string filter A filter expression that filters resources listed in
|
---|
45 | * the response. Most Compute resources support two types of filter expressions:
|
---|
46 | * expressions that support regular expressions and expressions that follow API
|
---|
47 | * improvement proposal AIP-160. These two types of filter expressions cannot be
|
---|
48 | * mixed in one request. If you want to use AIP-160, your expression must
|
---|
49 | * specify the field name, an operator, and the value that you want to use for
|
---|
50 | * filtering. The value must be a string, a number, or a boolean. The operator
|
---|
51 | * must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you
|
---|
52 | * are filtering Compute Engine instances, you can exclude instances named
|
---|
53 | * `example-instance` by specifying `name != example-instance`. The `:*`
|
---|
54 | * comparison can be used to test whether a key has been defined. For example,
|
---|
55 | * to find all objects with `owner` label use: ``` labels.owner:* ``` You can
|
---|
56 | * 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) ``` If you want to use a regular
|
---|
66 | * expression, use the `eq` (equal) or `ne` (not equal) operator against a
|
---|
67 | * single un-parenthesized expression with or without quotes or against multiple
|
---|
68 | * parenthesized expressions. Examples: `fieldname eq unquoted literal`
|
---|
69 | * `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"`
|
---|
70 | * `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is
|
---|
71 | * interpreted as a regular expression using Google RE2 library syntax. The
|
---|
72 | * literal value must match the entire field. For example, to filter for
|
---|
73 | * instances that do not end with name "instance", you would use `name ne
|
---|
74 | * .*instance`. You cannot combine constraints on multiple fields using regular
|
---|
75 | * expressions.
|
---|
76 | * @opt_param bool includeAllScopes Indicates whether every visible scope for
|
---|
77 | * each scope type (zone, region, global) should be included in the response.
|
---|
78 | * For new resource types added after this field, the flag has no effect as new
|
---|
79 | * resource types will always include every visible scope for each scope type in
|
---|
80 | * response. For resource types which predate this field, if this flag is
|
---|
81 | * omitted or false, only scopes of the scope types where the resource type is
|
---|
82 | * expected to be found will be included.
|
---|
83 | * @opt_param string maxResults The maximum number of results per page that
|
---|
84 | * should be returned. If the number of available results is larger than
|
---|
85 | * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to
|
---|
86 | * get the next page of results in subsequent list requests. Acceptable values
|
---|
87 | * are `0` to `500`, inclusive. (Default: `500`)
|
---|
88 | * @opt_param string orderBy Sorts list results by a certain order. By default,
|
---|
89 | * results are returned in alphanumerical order based on the resource name. You
|
---|
90 | * can also sort results in descending order based on the creation timestamp
|
---|
91 | * using `orderBy="creationTimestamp desc"`. This sorts results based on the
|
---|
92 | * `creationTimestamp` field in reverse chronological order (newest result
|
---|
93 | * first). Use this to sort resources like operations so that the newest
|
---|
94 | * operation is returned first. Currently, only sorting by `name` or
|
---|
95 | * `creationTimestamp desc` is supported.
|
---|
96 | * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to
|
---|
97 | * the `nextPageToken` returned by a previous list request to get the next page
|
---|
98 | * of results.
|
---|
99 | * @opt_param bool returnPartialSuccess Opt-in for partial success behavior
|
---|
100 | * which provides partial results in case of failure. The default value is
|
---|
101 | * false. For example, when partial success behavior is enabled, aggregatedList
|
---|
102 | * for a single zone scope either returns all resources in the zone or no
|
---|
103 | * resources, with an error code.
|
---|
104 | * @opt_param string serviceProjectNumber The Shared VPC service project id or
|
---|
105 | * service project number for which aggregated list request is invoked for
|
---|
106 | * subnetworks list-usable api.
|
---|
107 | * @return TargetInstanceAggregatedList
|
---|
108 | * @throws \Google\Service\Exception
|
---|
109 | */
|
---|
110 | public function aggregatedList($project, $optParams = [])
|
---|
111 | {
|
---|
112 | $params = ['project' => $project];
|
---|
113 | $params = array_merge($params, $optParams);
|
---|
114 | return $this->call('aggregatedList', [$params], TargetInstanceAggregatedList::class);
|
---|
115 | }
|
---|
116 | /**
|
---|
117 | * Deletes the specified TargetInstance resource. (targetInstances.delete)
|
---|
118 | *
|
---|
119 | * @param string $project Project ID for this request.
|
---|
120 | * @param string $zone Name of the zone scoping this request.
|
---|
121 | * @param string $targetInstance Name of the TargetInstance resource to delete.
|
---|
122 | * @param array $optParams Optional parameters.
|
---|
123 | *
|
---|
124 | * @opt_param string requestId An optional request ID to identify requests.
|
---|
125 | * Specify a unique request ID so that if you must retry your request, the
|
---|
126 | * server will know to ignore the request if it has already been completed. For
|
---|
127 | * example, consider a situation where you make an initial request and the
|
---|
128 | * request times out. If you make the request again with the same request ID,
|
---|
129 | * the server can check if original operation with the same request ID was
|
---|
130 | * received, and if so, will ignore the second request. This prevents clients
|
---|
131 | * from accidentally creating duplicate commitments. The request ID must be a
|
---|
132 | * valid UUID with the exception that zero UUID is not supported (
|
---|
133 | * 00000000-0000-0000-0000-000000000000).
|
---|
134 | * @return Operation
|
---|
135 | * @throws \Google\Service\Exception
|
---|
136 | */
|
---|
137 | public function delete($project, $zone, $targetInstance, $optParams = [])
|
---|
138 | {
|
---|
139 | $params = ['project' => $project, 'zone' => $zone, 'targetInstance' => $targetInstance];
|
---|
140 | $params = array_merge($params, $optParams);
|
---|
141 | return $this->call('delete', [$params], Operation::class);
|
---|
142 | }
|
---|
143 | /**
|
---|
144 | * Returns the specified TargetInstance resource. (targetInstances.get)
|
---|
145 | *
|
---|
146 | * @param string $project Project ID for this request.
|
---|
147 | * @param string $zone Name of the zone scoping this request.
|
---|
148 | * @param string $targetInstance Name of the TargetInstance resource to return.
|
---|
149 | * @param array $optParams Optional parameters.
|
---|
150 | * @return TargetInstance
|
---|
151 | * @throws \Google\Service\Exception
|
---|
152 | */
|
---|
153 | public function get($project, $zone, $targetInstance, $optParams = [])
|
---|
154 | {
|
---|
155 | $params = ['project' => $project, 'zone' => $zone, 'targetInstance' => $targetInstance];
|
---|
156 | $params = array_merge($params, $optParams);
|
---|
157 | return $this->call('get', [$params], TargetInstance::class);
|
---|
158 | }
|
---|
159 | /**
|
---|
160 | * Creates a TargetInstance resource in the specified project and zone using the
|
---|
161 | * data included in the request. (targetInstances.insert)
|
---|
162 | *
|
---|
163 | * @param string $project Project ID for this request.
|
---|
164 | * @param string $zone Name of the zone scoping this request.
|
---|
165 | * @param TargetInstance $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 | * @throws \Google\Service\Exception
|
---|
180 | */
|
---|
181 | public function insert($project, $zone, TargetInstance $postBody, $optParams = [])
|
---|
182 | {
|
---|
183 | $params = ['project' => $project, 'zone' => $zone, 'postBody' => $postBody];
|
---|
184 | $params = array_merge($params, $optParams);
|
---|
185 | return $this->call('insert', [$params], Operation::class);
|
---|
186 | }
|
---|
187 | /**
|
---|
188 | * Retrieves a list of TargetInstance resources available to the specified
|
---|
189 | * project and zone. (targetInstances.listTargetInstances)
|
---|
190 | *
|
---|
191 | * @param string $project Project ID for this request.
|
---|
192 | * @param string $zone Name of the zone scoping this request.
|
---|
193 | * @param array $optParams Optional parameters.
|
---|
194 | *
|
---|
195 | * @opt_param string filter A filter expression that filters resources listed in
|
---|
196 | * the response. Most Compute resources support two types of filter expressions:
|
---|
197 | * expressions that support regular expressions and expressions that follow API
|
---|
198 | * improvement proposal AIP-160. These two types of filter expressions cannot be
|
---|
199 | * mixed in one request. If you want to use AIP-160, your expression must
|
---|
200 | * specify the field name, an operator, and the value that you want to use for
|
---|
201 | * filtering. The value must be a string, a number, or a boolean. The operator
|
---|
202 | * must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you
|
---|
203 | * are filtering Compute Engine instances, you can exclude instances named
|
---|
204 | * `example-instance` by specifying `name != example-instance`. The `:*`
|
---|
205 | * comparison can be used to test whether a key has been defined. For example,
|
---|
206 | * to find all objects with `owner` label use: ``` labels.owner:* ``` You can
|
---|
207 | * also filter nested fields. For example, you could specify
|
---|
208 | * `scheduling.automaticRestart = false` to include instances only if they are
|
---|
209 | * not scheduled for automatic restarts. You can use filtering on nested fields
|
---|
210 | * to filter based on resource labels. To filter on multiple expressions,
|
---|
211 | * provide each separate expression within parentheses. For example: ```
|
---|
212 | * (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By
|
---|
213 | * default, each expression is an `AND` expression. However, you can include
|
---|
214 | * `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel
|
---|
215 | * Skylake") OR (cpuPlatform = "Intel Broadwell") AND
|
---|
216 | * (scheduling.automaticRestart = true) ``` If you want to use a regular
|
---|
217 | * expression, use the `eq` (equal) or `ne` (not equal) operator against a
|
---|
218 | * single un-parenthesized expression with or without quotes or against multiple
|
---|
219 | * parenthesized expressions. Examples: `fieldname eq unquoted literal`
|
---|
220 | * `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"`
|
---|
221 | * `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is
|
---|
222 | * interpreted as a regular expression using Google RE2 library syntax. The
|
---|
223 | * literal value must match the entire field. For example, to filter for
|
---|
224 | * instances that do not end with name "instance", you would use `name ne
|
---|
225 | * .*instance`. You cannot combine constraints on multiple fields using regular
|
---|
226 | * expressions.
|
---|
227 | * @opt_param string maxResults The maximum number of results per page that
|
---|
228 | * should be returned. If the number of available results is larger than
|
---|
229 | * `maxResults`, Compute Engine returns a `nextPageToken` that can be used to
|
---|
230 | * get the next page of results in subsequent list requests. Acceptable values
|
---|
231 | * are `0` to `500`, inclusive. (Default: `500`)
|
---|
232 | * @opt_param string orderBy Sorts list results by a certain order. By default,
|
---|
233 | * results are returned in alphanumerical order based on the resource name. You
|
---|
234 | * can also sort results in descending order based on the creation timestamp
|
---|
235 | * using `orderBy="creationTimestamp desc"`. This sorts results based on the
|
---|
236 | * `creationTimestamp` field in reverse chronological order (newest result
|
---|
237 | * first). Use this to sort resources like operations so that the newest
|
---|
238 | * operation is returned first. Currently, only sorting by `name` or
|
---|
239 | * `creationTimestamp desc` is supported.
|
---|
240 | * @opt_param string pageToken Specifies a page token to use. Set `pageToken` to
|
---|
241 | * the `nextPageToken` returned by a previous list request to get the next page
|
---|
242 | * of results.
|
---|
243 | * @opt_param bool returnPartialSuccess Opt-in for partial success behavior
|
---|
244 | * which provides partial results in case of failure. The default value is
|
---|
245 | * false. For example, when partial success behavior is enabled, aggregatedList
|
---|
246 | * for a single zone scope either returns all resources in the zone or no
|
---|
247 | * resources, with an error code.
|
---|
248 | * @return TargetInstanceList
|
---|
249 | * @throws \Google\Service\Exception
|
---|
250 | */
|
---|
251 | public function listTargetInstances($project, $zone, $optParams = [])
|
---|
252 | {
|
---|
253 | $params = ['project' => $project, 'zone' => $zone];
|
---|
254 | $params = array_merge($params, $optParams);
|
---|
255 | return $this->call('list', [$params], TargetInstanceList::class);
|
---|
256 | }
|
---|
257 | /**
|
---|
258 | * Sets the Google Cloud Armor security policy for the specified target
|
---|
259 | * instance. For more information, see Google Cloud Armor Overview
|
---|
260 | * (targetInstances.setSecurityPolicy)
|
---|
261 | *
|
---|
262 | * @param string $project Project ID for this request.
|
---|
263 | * @param string $zone Name of the zone scoping this request.
|
---|
264 | * @param string $targetInstance Name of the TargetInstance resource to which
|
---|
265 | * the security policy should be set. The name should conform to RFC1035.
|
---|
266 | * @param SecurityPolicyReference $postBody
|
---|
267 | * @param array $optParams Optional parameters.
|
---|
268 | *
|
---|
269 | * @opt_param string requestId An optional request ID to identify requests.
|
---|
270 | * Specify a unique request ID so that if you must retry your request, the
|
---|
271 | * server will know to ignore the request if it has already been completed. For
|
---|
272 | * example, consider a situation where you make an initial request and the
|
---|
273 | * request times out. If you make the request again with the same request ID,
|
---|
274 | * the server can check if original operation with the same request ID was
|
---|
275 | * received, and if so, will ignore the second request. This prevents clients
|
---|
276 | * from accidentally creating duplicate commitments. The request ID must be a
|
---|
277 | * valid UUID with the exception that zero UUID is not supported (
|
---|
278 | * 00000000-0000-0000-0000-000000000000).
|
---|
279 | * @return Operation
|
---|
280 | * @throws \Google\Service\Exception
|
---|
281 | */
|
---|
282 | public function setSecurityPolicy($project, $zone, $targetInstance, SecurityPolicyReference $postBody, $optParams = [])
|
---|
283 | {
|
---|
284 | $params = ['project' => $project, 'zone' => $zone, 'targetInstance' => $targetInstance, 'postBody' => $postBody];
|
---|
285 | $params = array_merge($params, $optParams);
|
---|
286 | return $this->call('setSecurityPolicy', [$params], Operation::class);
|
---|
287 | }
|
---|
288 | }
|
---|
289 |
|
---|
290 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
291 | class_alias(TargetInstances::class, 'Google_Service_Compute_Resource_TargetInstances');
|
---|