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\AIPlatformNotebooks\Resource;
19
20use Google\Service\AIPlatformNotebooks\GetInstanceHealthResponse;
21use Google\Service\AIPlatformNotebooks\Instance;
22use Google\Service\AIPlatformNotebooks\IsInstanceUpgradeableResponse;
23use Google\Service\AIPlatformNotebooks\ListInstancesResponse;
24use Google\Service\AIPlatformNotebooks\Operation;
25use Google\Service\AIPlatformNotebooks\Policy;
26use Google\Service\AIPlatformNotebooks\RegisterInstanceRequest;
27use Google\Service\AIPlatformNotebooks\ReportInstanceInfoRequest;
28use Google\Service\AIPlatformNotebooks\ResetInstanceRequest;
29use Google\Service\AIPlatformNotebooks\RollbackInstanceRequest;
30use Google\Service\AIPlatformNotebooks\SetIamPolicyRequest;
31use Google\Service\AIPlatformNotebooks\SetInstanceAcceleratorRequest;
32use Google\Service\AIPlatformNotebooks\SetInstanceLabelsRequest;
33use Google\Service\AIPlatformNotebooks\SetInstanceMachineTypeRequest;
34use Google\Service\AIPlatformNotebooks\StartInstanceRequest;
35use Google\Service\AIPlatformNotebooks\StopInstanceRequest;
36use Google\Service\AIPlatformNotebooks\TestIamPermissionsRequest;
37use Google\Service\AIPlatformNotebooks\TestIamPermissionsResponse;
38use Google\Service\AIPlatformNotebooks\UpdateInstanceConfigRequest;
39use Google\Service\AIPlatformNotebooks\UpdateInstanceMetadataItemsRequest;
40use Google\Service\AIPlatformNotebooks\UpdateInstanceMetadataItemsResponse;
41use Google\Service\AIPlatformNotebooks\UpdateShieldedInstanceConfigRequest;
42use Google\Service\AIPlatformNotebooks\UpgradeInstanceInternalRequest;
43use Google\Service\AIPlatformNotebooks\UpgradeInstanceRequest;
44
45/**
46 * The "instances" collection of methods.
47 * Typical usage is:
48 *  <code>
49 *   $notebooksService = new Google\Service\AIPlatformNotebooks(...);
50 *   $instances = $notebooksService->instances;
51 *  </code>
52 */
53class ProjectsLocationsInstances extends \Google\Service\Resource
54{
55  /**
56   * Creates a new Instance in a given project and location. (instances.create)
57   *
58   * @param string $parent Required. Format:
59   * `parent=projects/{project_id}/locations/{location}`
60   * @param Instance $postBody
61   * @param array $optParams Optional parameters.
62   *
63   * @opt_param string instanceId Required. User-defined unique ID of this
64   * instance.
65   * @return Operation
66   */
67  public function create($parent, Instance $postBody, $optParams = [])
68  {
69    $params = ['parent' => $parent, 'postBody' => $postBody];
70    $params = array_merge($params, $optParams);
71    return $this->call('create', [$params], Operation::class);
72  }
73  /**
74   * Deletes a single Instance. (instances.delete)
75   *
76   * @param string $name Required. Format:
77   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
78   * @param array $optParams Optional parameters.
79   * @return Operation
80   */
81  public function delete($name, $optParams = [])
82  {
83    $params = ['name' => $name];
84    $params = array_merge($params, $optParams);
85    return $this->call('delete', [$params], Operation::class);
86  }
87  /**
88   * Gets details of a single Instance. (instances.get)
89   *
90   * @param string $name Required. Format:
91   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
92   * @param array $optParams Optional parameters.
93   * @return Instance
94   */
95  public function get($name, $optParams = [])
96  {
97    $params = ['name' => $name];
98    $params = array_merge($params, $optParams);
99    return $this->call('get', [$params], Instance::class);
100  }
101  /**
102   * Gets the access control policy for a resource. Returns an empty policy if the
103   * resource exists and does not have a policy set. (instances.getIamPolicy)
104   *
105   * @param string $resource REQUIRED: The resource for which the policy is being
106   * requested. See the operation documentation for the appropriate value for this
107   * field.
108   * @param array $optParams Optional parameters.
109   *
110   * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
111   * version that will be used to format the policy. Valid values are 0, 1, and 3.
112   * Requests specifying an invalid value will be rejected. Requests for policies
113   * with any conditional role bindings must specify version 3. Policies with no
114   * conditional role bindings may specify any valid value or leave the field
115   * unset. The policy in the response might use the policy version that you
116   * specified, or it might use a lower policy version. For example, if you
117   * specify version 3, but the policy has no conditional role bindings, the
118   * response uses version 1. To learn which resources support conditions in their
119   * IAM policies, see the [IAM
120   * documentation](https://cloud.google.com/iam/help/conditions/resource-
121   * policies).
122   * @return Policy
123   */
124  public function getIamPolicy($resource, $optParams = [])
125  {
126    $params = ['resource' => $resource];
127    $params = array_merge($params, $optParams);
128    return $this->call('getIamPolicy', [$params], Policy::class);
129  }
130  /**
131   * Check if a notebook instance is healthy. (instances.getInstanceHealth)
132   *
133   * @param string $name Required. Format:
134   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
135   * @param array $optParams Optional parameters.
136   * @return GetInstanceHealthResponse
137   */
138  public function getInstanceHealth($name, $optParams = [])
139  {
140    $params = ['name' => $name];
141    $params = array_merge($params, $optParams);
142    return $this->call('getInstanceHealth', [$params], GetInstanceHealthResponse::class);
143  }
144  /**
145   * Check if a notebook instance is upgradable. (instances.isUpgradeable)
146   *
147   * @param string $notebookInstance Required. Format:
148   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
149   * @param array $optParams Optional parameters.
150   *
151   * @opt_param string type Optional. The optional UpgradeType. Setting this field
152   * will search for additional compute images to upgrade this instance.
153   * @return IsInstanceUpgradeableResponse
154   */
155  public function isUpgradeable($notebookInstance, $optParams = [])
156  {
157    $params = ['notebookInstance' => $notebookInstance];
158    $params = array_merge($params, $optParams);
159    return $this->call('isUpgradeable', [$params], IsInstanceUpgradeableResponse::class);
160  }
161  /**
162   * Lists instances in a given project and location.
163   * (instances.listProjectsLocationsInstances)
164   *
165   * @param string $parent Required. Format:
166   * `parent=projects/{project_id}/locations/{location}`
167   * @param array $optParams Optional parameters.
168   *
169   * @opt_param int pageSize Maximum return size of the list call.
170   * @opt_param string pageToken A previous returned page token that can be used
171   * to continue listing from the last result.
172   * @return ListInstancesResponse
173   */
174  public function listProjectsLocationsInstances($parent, $optParams = [])
175  {
176    $params = ['parent' => $parent];
177    $params = array_merge($params, $optParams);
178    return $this->call('list', [$params], ListInstancesResponse::class);
179  }
180  /**
181   * Registers an existing legacy notebook instance to the Notebooks API server.
182   * Legacy instances are instances created with the legacy Compute Engine calls.
183   * They are not manageable by the Notebooks API out of the box. This call makes
184   * these instances manageable by the Notebooks API. (instances.register)
185   *
186   * @param string $parent Required. Format:
187   * `parent=projects/{project_id}/locations/{location}`
188   * @param RegisterInstanceRequest $postBody
189   * @param array $optParams Optional parameters.
190   * @return Operation
191   */
192  public function register($parent, RegisterInstanceRequest $postBody, $optParams = [])
193  {
194    $params = ['parent' => $parent, 'postBody' => $postBody];
195    $params = array_merge($params, $optParams);
196    return $this->call('register', [$params], Operation::class);
197  }
198  /**
199   * Allows notebook instances to report their latest instance information to the
200   * Notebooks API server. The server will merge the reported information to the
201   * instance metadata store. Do not use this method directly. (instances.report)
202   *
203   * @param string $name Required. Format:
204   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
205   * @param ReportInstanceInfoRequest $postBody
206   * @param array $optParams Optional parameters.
207   * @return Operation
208   */
209  public function report($name, ReportInstanceInfoRequest $postBody, $optParams = [])
210  {
211    $params = ['name' => $name, 'postBody' => $postBody];
212    $params = array_merge($params, $optParams);
213    return $this->call('report', [$params], Operation::class);
214  }
215  /**
216   * Resets a notebook instance. (instances.reset)
217   *
218   * @param string $name Required. Format:
219   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
220   * @param ResetInstanceRequest $postBody
221   * @param array $optParams Optional parameters.
222   * @return Operation
223   */
224  public function reset($name, ResetInstanceRequest $postBody, $optParams = [])
225  {
226    $params = ['name' => $name, 'postBody' => $postBody];
227    $params = array_merge($params, $optParams);
228    return $this->call('reset', [$params], Operation::class);
229  }
230  /**
231   * Rollbacks a notebook instance to the previous version. (instances.rollback)
232   *
233   * @param string $name Required. Format:
234   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
235   * @param RollbackInstanceRequest $postBody
236   * @param array $optParams Optional parameters.
237   * @return Operation
238   */
239  public function rollback($name, RollbackInstanceRequest $postBody, $optParams = [])
240  {
241    $params = ['name' => $name, 'postBody' => $postBody];
242    $params = array_merge($params, $optParams);
243    return $this->call('rollback', [$params], Operation::class);
244  }
245  /**
246   * Updates the guest accelerators of a single Instance.
247   * (instances.setAccelerator)
248   *
249   * @param string $name Required. Format:
250   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
251   * @param SetInstanceAcceleratorRequest $postBody
252   * @param array $optParams Optional parameters.
253   * @return Operation
254   */
255  public function setAccelerator($name, SetInstanceAcceleratorRequest $postBody, $optParams = [])
256  {
257    $params = ['name' => $name, 'postBody' => $postBody];
258    $params = array_merge($params, $optParams);
259    return $this->call('setAccelerator', [$params], Operation::class);
260  }
261  /**
262   * Sets the access control policy on the specified resource. Replaces any
263   * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
264   * `PERMISSION_DENIED` errors. (instances.setIamPolicy)
265   *
266   * @param string $resource REQUIRED: The resource for which the policy is being
267   * specified. See the operation documentation for the appropriate value for this
268   * field.
269   * @param SetIamPolicyRequest $postBody
270   * @param array $optParams Optional parameters.
271   * @return Policy
272   */
273  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
274  {
275    $params = ['resource' => $resource, 'postBody' => $postBody];
276    $params = array_merge($params, $optParams);
277    return $this->call('setIamPolicy', [$params], Policy::class);
278  }
279  /**
280   * Replaces all the labels of an Instance. (instances.setLabels)
281   *
282   * @param string $name Required. Format:
283   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
284   * @param SetInstanceLabelsRequest $postBody
285   * @param array $optParams Optional parameters.
286   * @return Operation
287   */
288  public function setLabels($name, SetInstanceLabelsRequest $postBody, $optParams = [])
289  {
290    $params = ['name' => $name, 'postBody' => $postBody];
291    $params = array_merge($params, $optParams);
292    return $this->call('setLabels', [$params], Operation::class);
293  }
294  /**
295   * Updates the machine type of a single Instance. (instances.setMachineType)
296   *
297   * @param string $name Required. Format:
298   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
299   * @param SetInstanceMachineTypeRequest $postBody
300   * @param array $optParams Optional parameters.
301   * @return Operation
302   */
303  public function setMachineType($name, SetInstanceMachineTypeRequest $postBody, $optParams = [])
304  {
305    $params = ['name' => $name, 'postBody' => $postBody];
306    $params = array_merge($params, $optParams);
307    return $this->call('setMachineType', [$params], Operation::class);
308  }
309  /**
310   * Starts a notebook instance. (instances.start)
311   *
312   * @param string $name Required. Format:
313   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
314   * @param StartInstanceRequest $postBody
315   * @param array $optParams Optional parameters.
316   * @return Operation
317   */
318  public function start($name, StartInstanceRequest $postBody, $optParams = [])
319  {
320    $params = ['name' => $name, 'postBody' => $postBody];
321    $params = array_merge($params, $optParams);
322    return $this->call('start', [$params], Operation::class);
323  }
324  /**
325   * Stops a notebook instance. (instances.stop)
326   *
327   * @param string $name Required. Format:
328   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
329   * @param StopInstanceRequest $postBody
330   * @param array $optParams Optional parameters.
331   * @return Operation
332   */
333  public function stop($name, StopInstanceRequest $postBody, $optParams = [])
334  {
335    $params = ['name' => $name, 'postBody' => $postBody];
336    $params = array_merge($params, $optParams);
337    return $this->call('stop', [$params], Operation::class);
338  }
339  /**
340   * Returns permissions that a caller has on the specified resource. If the
341   * resource does not exist, this will return an empty set of permissions, not a
342   * `NOT_FOUND` error. Note: This operation is designed to be used for building
343   * permission-aware UIs and command-line tools, not for authorization checking.
344   * This operation may "fail open" without warning.
345   * (instances.testIamPermissions)
346   *
347   * @param string $resource REQUIRED: The resource for which the policy detail is
348   * being requested. See the operation documentation for the appropriate value
349   * for this field.
350   * @param TestIamPermissionsRequest $postBody
351   * @param array $optParams Optional parameters.
352   * @return TestIamPermissionsResponse
353   */
354  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
355  {
356    $params = ['resource' => $resource, 'postBody' => $postBody];
357    $params = array_merge($params, $optParams);
358    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
359  }
360  /**
361   * Update Notebook Instance configurations. (instances.updateConfig)
362   *
363   * @param string $name Required. Format:
364   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
365   * @param UpdateInstanceConfigRequest $postBody
366   * @param array $optParams Optional parameters.
367   * @return Operation
368   */
369  public function updateConfig($name, UpdateInstanceConfigRequest $postBody, $optParams = [])
370  {
371    $params = ['name' => $name, 'postBody' => $postBody];
372    $params = array_merge($params, $optParams);
373    return $this->call('updateConfig', [$params], Operation::class);
374  }
375  /**
376   * Add/update metadata items for an instance. (instances.updateMetadataItems)
377   *
378   * @param string $name Required. Format:
379   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
380   * @param UpdateInstanceMetadataItemsRequest $postBody
381   * @param array $optParams Optional parameters.
382   * @return UpdateInstanceMetadataItemsResponse
383   */
384  public function updateMetadataItems($name, UpdateInstanceMetadataItemsRequest $postBody, $optParams = [])
385  {
386    $params = ['name' => $name, 'postBody' => $postBody];
387    $params = array_merge($params, $optParams);
388    return $this->call('updateMetadataItems', [$params], UpdateInstanceMetadataItemsResponse::class);
389  }
390  /**
391   * Updates the Shielded instance configuration of a single Instance.
392   * (instances.updateShieldedInstanceConfig)
393   *
394   * @param string $name Required. Format:
395   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
396   * @param UpdateShieldedInstanceConfigRequest $postBody
397   * @param array $optParams Optional parameters.
398   * @return Operation
399   */
400  public function updateShieldedInstanceConfig($name, UpdateShieldedInstanceConfigRequest $postBody, $optParams = [])
401  {
402    $params = ['name' => $name, 'postBody' => $postBody];
403    $params = array_merge($params, $optParams);
404    return $this->call('updateShieldedInstanceConfig', [$params], Operation::class);
405  }
406  /**
407   * Upgrades a notebook instance to the latest version. (instances.upgrade)
408   *
409   * @param string $name Required. Format:
410   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
411   * @param UpgradeInstanceRequest $postBody
412   * @param array $optParams Optional parameters.
413   * @return Operation
414   */
415  public function upgrade($name, UpgradeInstanceRequest $postBody, $optParams = [])
416  {
417    $params = ['name' => $name, 'postBody' => $postBody];
418    $params = array_merge($params, $optParams);
419    return $this->call('upgrade', [$params], Operation::class);
420  }
421  /**
422   * Allows notebook instances to call this endpoint to upgrade themselves. Do not
423   * use this method directly. (instances.upgradeInternal)
424   *
425   * @param string $name Required. Format:
426   * `projects/{project_id}/locations/{location}/instances/{instance_id}`
427   * @param UpgradeInstanceInternalRequest $postBody
428   * @param array $optParams Optional parameters.
429   * @return Operation
430   */
431  public function upgradeInternal($name, UpgradeInstanceInternalRequest $postBody, $optParams = [])
432  {
433    $params = ['name' => $name, 'postBody' => $postBody];
434    $params = array_merge($params, $optParams);
435    return $this->call('upgradeInternal', [$params], Operation::class);
436  }
437}
438
439// Adding a class alias for backwards compatibility with the previous class name.
440class_alias(ProjectsLocationsInstances::class, 'Google_Service_AIPlatformNotebooks_Resource_ProjectsLocationsInstances');
441