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\ListRuntimesResponse;
21use Google\Service\AIPlatformNotebooks\Operation;
22use Google\Service\AIPlatformNotebooks\Policy;
23use Google\Service\AIPlatformNotebooks\RefreshRuntimeTokenInternalRequest;
24use Google\Service\AIPlatformNotebooks\RefreshRuntimeTokenInternalResponse;
25use Google\Service\AIPlatformNotebooks\ReportRuntimeEventRequest;
26use Google\Service\AIPlatformNotebooks\ResetRuntimeRequest;
27use Google\Service\AIPlatformNotebooks\Runtime;
28use Google\Service\AIPlatformNotebooks\SetIamPolicyRequest;
29use Google\Service\AIPlatformNotebooks\StartRuntimeRequest;
30use Google\Service\AIPlatformNotebooks\StopRuntimeRequest;
31use Google\Service\AIPlatformNotebooks\SwitchRuntimeRequest;
32use Google\Service\AIPlatformNotebooks\TestIamPermissionsRequest;
33use Google\Service\AIPlatformNotebooks\TestIamPermissionsResponse;
34
35/**
36 * The "runtimes" collection of methods.
37 * Typical usage is:
38 *  <code>
39 *   $notebooksService = new Google\Service\AIPlatformNotebooks(...);
40 *   $runtimes = $notebooksService->runtimes;
41 *  </code>
42 */
43class ProjectsLocationsRuntimes extends \Google\Service\Resource
44{
45  /**
46   * Creates a new Runtime in a given project and location. (runtimes.create)
47   *
48   * @param string $parent Required. Format:
49   * `parent=projects/{project_id}/locations/{location}`
50   * @param Runtime $postBody
51   * @param array $optParams Optional parameters.
52   *
53   * @opt_param string requestId Idempotent request UUID.
54   * @opt_param string runtimeId Required. User-defined unique ID of this Runtime.
55   * @return Operation
56   */
57  public function create($parent, Runtime $postBody, $optParams = [])
58  {
59    $params = ['parent' => $parent, 'postBody' => $postBody];
60    $params = array_merge($params, $optParams);
61    return $this->call('create', [$params], Operation::class);
62  }
63  /**
64   * Deletes a single Runtime. (runtimes.delete)
65   *
66   * @param string $name Required. Format:
67   * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
68   * @param array $optParams Optional parameters.
69   *
70   * @opt_param string requestId Idempotent request UUID.
71   * @return Operation
72   */
73  public function delete($name, $optParams = [])
74  {
75    $params = ['name' => $name];
76    $params = array_merge($params, $optParams);
77    return $this->call('delete', [$params], Operation::class);
78  }
79  /**
80   * Gets details of a single Runtime. The location must be a regional endpoint
81   * rather than zonal. (runtimes.get)
82   *
83   * @param string $name Required. Format:
84   * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
85   * @param array $optParams Optional parameters.
86   * @return Runtime
87   */
88  public function get($name, $optParams = [])
89  {
90    $params = ['name' => $name];
91    $params = array_merge($params, $optParams);
92    return $this->call('get', [$params], Runtime::class);
93  }
94  /**
95   * Gets the access control policy for a resource. Returns an empty policy if the
96   * resource exists and does not have a policy set. (runtimes.getIamPolicy)
97   *
98   * @param string $resource REQUIRED: The resource for which the policy is being
99   * requested. See the operation documentation for the appropriate value for this
100   * field.
101   * @param array $optParams Optional parameters.
102   *
103   * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
104   * version that will be used to format the policy. Valid values are 0, 1, and 3.
105   * Requests specifying an invalid value will be rejected. Requests for policies
106   * with any conditional role bindings must specify version 3. Policies with no
107   * conditional role bindings may specify any valid value or leave the field
108   * unset. The policy in the response might use the policy version that you
109   * specified, or it might use a lower policy version. For example, if you
110   * specify version 3, but the policy has no conditional role bindings, the
111   * response uses version 1. To learn which resources support conditions in their
112   * IAM policies, see the [IAM
113   * documentation](https://cloud.google.com/iam/help/conditions/resource-
114   * policies).
115   * @return Policy
116   */
117  public function getIamPolicy($resource, $optParams = [])
118  {
119    $params = ['resource' => $resource];
120    $params = array_merge($params, $optParams);
121    return $this->call('getIamPolicy', [$params], Policy::class);
122  }
123  /**
124   * Lists Runtimes in a given project and location.
125   * (runtimes.listProjectsLocationsRuntimes)
126   *
127   * @param string $parent Required. Format:
128   * `parent=projects/{project_id}/locations/{location}`
129   * @param array $optParams Optional parameters.
130   *
131   * @opt_param int pageSize Maximum return size of the list call.
132   * @opt_param string pageToken A previous returned page token that can be used
133   * to continue listing from the last result.
134   * @return ListRuntimesResponse
135   */
136  public function listProjectsLocationsRuntimes($parent, $optParams = [])
137  {
138    $params = ['parent' => $parent];
139    $params = array_merge($params, $optParams);
140    return $this->call('list', [$params], ListRuntimesResponse::class);
141  }
142  /**
143   * Gets an access token for the consumer service account that the customer
144   * attached to the runtime. Only accessible from the tenant instance.
145   * (runtimes.refreshRuntimeTokenInternal)
146   *
147   * @param string $name Required. Format:
148   * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
149   * @param RefreshRuntimeTokenInternalRequest $postBody
150   * @param array $optParams Optional parameters.
151   * @return RefreshRuntimeTokenInternalResponse
152   */
153  public function refreshRuntimeTokenInternal($name, RefreshRuntimeTokenInternalRequest $postBody, $optParams = [])
154  {
155    $params = ['name' => $name, 'postBody' => $postBody];
156    $params = array_merge($params, $optParams);
157    return $this->call('refreshRuntimeTokenInternal', [$params], RefreshRuntimeTokenInternalResponse::class);
158  }
159  /**
160   * Report and process a runtime event. (runtimes.reportEvent)
161   *
162   * @param string $name Required. Format:
163   * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
164   * @param ReportRuntimeEventRequest $postBody
165   * @param array $optParams Optional parameters.
166   * @return Operation
167   */
168  public function reportEvent($name, ReportRuntimeEventRequest $postBody, $optParams = [])
169  {
170    $params = ['name' => $name, 'postBody' => $postBody];
171    $params = array_merge($params, $optParams);
172    return $this->call('reportEvent', [$params], Operation::class);
173  }
174  /**
175   * Resets a Managed Notebook Runtime. (runtimes.reset)
176   *
177   * @param string $name Required. Format:
178   * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
179   * @param ResetRuntimeRequest $postBody
180   * @param array $optParams Optional parameters.
181   * @return Operation
182   */
183  public function reset($name, ResetRuntimeRequest $postBody, $optParams = [])
184  {
185    $params = ['name' => $name, 'postBody' => $postBody];
186    $params = array_merge($params, $optParams);
187    return $this->call('reset', [$params], Operation::class);
188  }
189  /**
190   * Sets the access control policy on the specified resource. Replaces any
191   * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
192   * `PERMISSION_DENIED` errors. (runtimes.setIamPolicy)
193   *
194   * @param string $resource REQUIRED: The resource for which the policy is being
195   * specified. See the operation documentation for the appropriate value for this
196   * field.
197   * @param SetIamPolicyRequest $postBody
198   * @param array $optParams Optional parameters.
199   * @return Policy
200   */
201  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
202  {
203    $params = ['resource' => $resource, 'postBody' => $postBody];
204    $params = array_merge($params, $optParams);
205    return $this->call('setIamPolicy', [$params], Policy::class);
206  }
207  /**
208   * Starts a Managed Notebook Runtime. Perform "Start" on GPU instances; "Resume"
209   * on CPU instances See: https://cloud.google.com/compute/docs/instances/stop-
210   * start-instance https://cloud.google.com/compute/docs/instances/suspend-
211   * resume-instance (runtimes.start)
212   *
213   * @param string $name Required. Format:
214   * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
215   * @param StartRuntimeRequest $postBody
216   * @param array $optParams Optional parameters.
217   * @return Operation
218   */
219  public function start($name, StartRuntimeRequest $postBody, $optParams = [])
220  {
221    $params = ['name' => $name, 'postBody' => $postBody];
222    $params = array_merge($params, $optParams);
223    return $this->call('start', [$params], Operation::class);
224  }
225  /**
226   * Stops a Managed Notebook Runtime. Perform "Stop" on GPU instances; "Suspend"
227   * on CPU instances See: https://cloud.google.com/compute/docs/instances/stop-
228   * start-instance https://cloud.google.com/compute/docs/instances/suspend-
229   * resume-instance (runtimes.stop)
230   *
231   * @param string $name Required. Format:
232   * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
233   * @param StopRuntimeRequest $postBody
234   * @param array $optParams Optional parameters.
235   * @return Operation
236   */
237  public function stop($name, StopRuntimeRequest $postBody, $optParams = [])
238  {
239    $params = ['name' => $name, 'postBody' => $postBody];
240    $params = array_merge($params, $optParams);
241    return $this->call('stop', [$params], Operation::class);
242  }
243  /**
244   * Switch a Managed Notebook Runtime. (runtimes.switchProjectsLocationsRuntimes)
245   *
246   * @param string $name Required. Format:
247   * `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
248   * @param SwitchRuntimeRequest $postBody
249   * @param array $optParams Optional parameters.
250   * @return Operation
251   */
252  public function switchProjectsLocationsRuntimes($name, SwitchRuntimeRequest $postBody, $optParams = [])
253  {
254    $params = ['name' => $name, 'postBody' => $postBody];
255    $params = array_merge($params, $optParams);
256    return $this->call('switch', [$params], Operation::class);
257  }
258  /**
259   * Returns permissions that a caller has on the specified resource. If the
260   * resource does not exist, this will return an empty set of permissions, not a
261   * `NOT_FOUND` error. Note: This operation is designed to be used for building
262   * permission-aware UIs and command-line tools, not for authorization checking.
263   * This operation may "fail open" without warning. (runtimes.testIamPermissions)
264   *
265   * @param string $resource REQUIRED: The resource for which the policy detail is
266   * being requested. See the operation documentation for the appropriate value
267   * for this field.
268   * @param TestIamPermissionsRequest $postBody
269   * @param array $optParams Optional parameters.
270   * @return TestIamPermissionsResponse
271   */
272  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
273  {
274    $params = ['resource' => $resource, 'postBody' => $postBody];
275    $params = array_merge($params, $optParams);
276    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
277  }
278}
279
280// Adding a class alias for backwards compatibility with the previous class name.
281class_alias(ProjectsLocationsRuntimes::class, 'Google_Service_AIPlatformNotebooks_Resource_ProjectsLocationsRuntimes');
282