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\CloudShell\Resource;
19
20use Google\Service\CloudShell\AddPublicKeyRequest;
21use Google\Service\CloudShell\AuthorizeEnvironmentRequest;
22use Google\Service\CloudShell\Environment;
23use Google\Service\CloudShell\Operation;
24use Google\Service\CloudShell\RemovePublicKeyRequest;
25use Google\Service\CloudShell\StartEnvironmentRequest;
26
27/**
28 * The "environments" collection of methods.
29 * Typical usage is:
30 *  <code>
31 *   $cloudshellService = new Google\Service\CloudShell(...);
32 *   $environments = $cloudshellService->environments;
33 *  </code>
34 */
35class UsersEnvironments extends \Google\Service\Resource
36{
37  /**
38   * Adds a public SSH key to an environment, allowing clients with the
39   * corresponding private key to connect to that environment via SSH. If a key
40   * with the same content already exists, this will error with ALREADY_EXISTS.
41   * (environments.addPublicKey)
42   *
43   * @param string $environment Environment this key should be added to, e.g.
44   * `users/me/environments/default`.
45   * @param AddPublicKeyRequest $postBody
46   * @param array $optParams Optional parameters.
47   * @return Operation
48   */
49  public function addPublicKey($environment, AddPublicKeyRequest $postBody, $optParams = [])
50  {
51    $params = ['environment' => $environment, 'postBody' => $postBody];
52    $params = array_merge($params, $optParams);
53    return $this->call('addPublicKey', [$params], Operation::class);
54  }
55  /**
56   * Sends OAuth credentials to a running environment on behalf of a user. When
57   * this completes, the environment will be authorized to run various Google
58   * Cloud command line tools without requiring the user to manually authenticate.
59   * (environments.authorize)
60   *
61   * @param string $name Name of the resource that should receive the credentials,
62   * for example `users/me/environments/default` or
63   * `users/someone@example.com/environments/default`.
64   * @param AuthorizeEnvironmentRequest $postBody
65   * @param array $optParams Optional parameters.
66   * @return Operation
67   */
68  public function authorize($name, AuthorizeEnvironmentRequest $postBody, $optParams = [])
69  {
70    $params = ['name' => $name, 'postBody' => $postBody];
71    $params = array_merge($params, $optParams);
72    return $this->call('authorize', [$params], Operation::class);
73  }
74  /**
75   * Gets an environment. Returns NOT_FOUND if the environment does not exist.
76   * (environments.get)
77   *
78   * @param string $name Required. Name of the requested resource, for example
79   * `users/me/environments/default` or
80   * `users/someone@example.com/environments/default`.
81   * @param array $optParams Optional parameters.
82   * @return Environment
83   */
84  public function get($name, $optParams = [])
85  {
86    $params = ['name' => $name];
87    $params = array_merge($params, $optParams);
88    return $this->call('get', [$params], Environment::class);
89  }
90  /**
91   * Removes a public SSH key from an environment. Clients will no longer be able
92   * to connect to the environment using the corresponding private key. If a key
93   * with the same content is not present, this will error with NOT_FOUND.
94   * (environments.removePublicKey)
95   *
96   * @param string $environment Environment this key should be removed from, e.g.
97   * `users/me/environments/default`.
98   * @param RemovePublicKeyRequest $postBody
99   * @param array $optParams Optional parameters.
100   * @return Operation
101   */
102  public function removePublicKey($environment, RemovePublicKeyRequest $postBody, $optParams = [])
103  {
104    $params = ['environment' => $environment, 'postBody' => $postBody];
105    $params = array_merge($params, $optParams);
106    return $this->call('removePublicKey', [$params], Operation::class);
107  }
108  /**
109   * Starts an existing environment, allowing clients to connect to it. The
110   * returned operation will contain an instance of StartEnvironmentMetadata in
111   * its metadata field. Users can wait for the environment to start by polling
112   * this operation via GetOperation. Once the environment has finished starting
113   * and is ready to accept connections, the operation will contain a
114   * StartEnvironmentResponse in its response field. (environments.start)
115   *
116   * @param string $name Name of the resource that should be started, for example
117   * `users/me/environments/default` or
118   * `users/someone@example.com/environments/default`.
119   * @param StartEnvironmentRequest $postBody
120   * @param array $optParams Optional parameters.
121   * @return Operation
122   */
123  public function start($name, StartEnvironmentRequest $postBody, $optParams = [])
124  {
125    $params = ['name' => $name, 'postBody' => $postBody];
126    $params = array_merge($params, $optParams);
127    return $this->call('start', [$params], Operation::class);
128  }
129}
130
131// Adding a class alias for backwards compatibility with the previous class name.
132class_alias(UsersEnvironments::class, 'Google_Service_CloudShell_Resource_UsersEnvironments');
133