[e3d4e0a] | 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\CloudComposer\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\CloudComposer\CheckUpgradeRequest;
|
---|
| 21 | use Google\Service\CloudComposer\DatabaseFailoverRequest;
|
---|
| 22 | use Google\Service\CloudComposer\Environment;
|
---|
| 23 | use Google\Service\CloudComposer\ExecuteAirflowCommandRequest;
|
---|
| 24 | use Google\Service\CloudComposer\ExecuteAirflowCommandResponse;
|
---|
| 25 | use Google\Service\CloudComposer\FetchDatabasePropertiesResponse;
|
---|
| 26 | use Google\Service\CloudComposer\ListEnvironmentsResponse;
|
---|
| 27 | use Google\Service\CloudComposer\LoadSnapshotRequest;
|
---|
| 28 | use Google\Service\CloudComposer\Operation;
|
---|
| 29 | use Google\Service\CloudComposer\PollAirflowCommandRequest;
|
---|
| 30 | use Google\Service\CloudComposer\PollAirflowCommandResponse;
|
---|
| 31 | use Google\Service\CloudComposer\SaveSnapshotRequest;
|
---|
| 32 | use Google\Service\CloudComposer\StopAirflowCommandRequest;
|
---|
| 33 | use Google\Service\CloudComposer\StopAirflowCommandResponse;
|
---|
| 34 |
|
---|
| 35 | /**
|
---|
| 36 | * The "environments" collection of methods.
|
---|
| 37 | * Typical usage is:
|
---|
| 38 | * <code>
|
---|
| 39 | * $composerService = new Google\Service\CloudComposer(...);
|
---|
| 40 | * $environments = $composerService->projects_locations_environments;
|
---|
| 41 | * </code>
|
---|
| 42 | */
|
---|
| 43 | class ProjectsLocationsEnvironments extends \Google\Service\Resource
|
---|
| 44 | {
|
---|
| 45 | /**
|
---|
| 46 | * Check if an upgrade operation on the environment will succeed. In case of
|
---|
| 47 | * problems detailed info can be found in the returned Operation.
|
---|
| 48 | * (environments.checkUpgrade)
|
---|
| 49 | *
|
---|
| 50 | * @param string $environment Required. The resource name of the environment to
|
---|
| 51 | * check upgrade for, in the form:
|
---|
| 52 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
|
---|
| 53 | * @param CheckUpgradeRequest $postBody
|
---|
| 54 | * @param array $optParams Optional parameters.
|
---|
| 55 | * @return Operation
|
---|
| 56 | * @throws \Google\Service\Exception
|
---|
| 57 | */
|
---|
| 58 | public function checkUpgrade($environment, CheckUpgradeRequest $postBody, $optParams = [])
|
---|
| 59 | {
|
---|
| 60 | $params = ['environment' => $environment, 'postBody' => $postBody];
|
---|
| 61 | $params = array_merge($params, $optParams);
|
---|
| 62 | return $this->call('checkUpgrade', [$params], Operation::class);
|
---|
| 63 | }
|
---|
| 64 | /**
|
---|
| 65 | * Create a new environment. (environments.create)
|
---|
| 66 | *
|
---|
| 67 | * @param string $parent The parent must be of the form
|
---|
| 68 | * "projects/{projectId}/locations/{locationId}".
|
---|
| 69 | * @param Environment $postBody
|
---|
| 70 | * @param array $optParams Optional parameters.
|
---|
| 71 | * @return Operation
|
---|
| 72 | * @throws \Google\Service\Exception
|
---|
| 73 | */
|
---|
| 74 | public function create($parent, Environment $postBody, $optParams = [])
|
---|
| 75 | {
|
---|
| 76 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 77 | $params = array_merge($params, $optParams);
|
---|
| 78 | return $this->call('create', [$params], Operation::class);
|
---|
| 79 | }
|
---|
| 80 | /**
|
---|
| 81 | * Triggers database failover (only for highly resilient environments).
|
---|
| 82 | * (environments.databaseFailover)
|
---|
| 83 | *
|
---|
| 84 | * @param string $environment Target environment:
|
---|
| 85 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
|
---|
| 86 | * @param DatabaseFailoverRequest $postBody
|
---|
| 87 | * @param array $optParams Optional parameters.
|
---|
| 88 | * @return Operation
|
---|
| 89 | * @throws \Google\Service\Exception
|
---|
| 90 | */
|
---|
| 91 | public function databaseFailover($environment, DatabaseFailoverRequest $postBody, $optParams = [])
|
---|
| 92 | {
|
---|
| 93 | $params = ['environment' => $environment, 'postBody' => $postBody];
|
---|
| 94 | $params = array_merge($params, $optParams);
|
---|
| 95 | return $this->call('databaseFailover', [$params], Operation::class);
|
---|
| 96 | }
|
---|
| 97 | /**
|
---|
| 98 | * Delete an environment. (environments.delete)
|
---|
| 99 | *
|
---|
| 100 | * @param string $name The environment to delete, in the form:
|
---|
| 101 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
|
---|
| 102 | * @param array $optParams Optional parameters.
|
---|
| 103 | * @return Operation
|
---|
| 104 | * @throws \Google\Service\Exception
|
---|
| 105 | */
|
---|
| 106 | public function delete($name, $optParams = [])
|
---|
| 107 | {
|
---|
| 108 | $params = ['name' => $name];
|
---|
| 109 | $params = array_merge($params, $optParams);
|
---|
| 110 | return $this->call('delete', [$params], Operation::class);
|
---|
| 111 | }
|
---|
| 112 | /**
|
---|
| 113 | * Executes Airflow CLI command. (environments.executeAirflowCommand)
|
---|
| 114 | *
|
---|
| 115 | * @param string $environment The resource name of the environment in the form:
|
---|
| 116 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}".
|
---|
| 117 | * @param ExecuteAirflowCommandRequest $postBody
|
---|
| 118 | * @param array $optParams Optional parameters.
|
---|
| 119 | * @return ExecuteAirflowCommandResponse
|
---|
| 120 | * @throws \Google\Service\Exception
|
---|
| 121 | */
|
---|
| 122 | public function executeAirflowCommand($environment, ExecuteAirflowCommandRequest $postBody, $optParams = [])
|
---|
| 123 | {
|
---|
| 124 | $params = ['environment' => $environment, 'postBody' => $postBody];
|
---|
| 125 | $params = array_merge($params, $optParams);
|
---|
| 126 | return $this->call('executeAirflowCommand', [$params], ExecuteAirflowCommandResponse::class);
|
---|
| 127 | }
|
---|
| 128 | /**
|
---|
| 129 | * Fetches database properties. (environments.fetchDatabaseProperties)
|
---|
| 130 | *
|
---|
| 131 | * @param string $environment Required. The resource name of the environment, in
|
---|
| 132 | * the form:
|
---|
| 133 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
|
---|
| 134 | * @param array $optParams Optional parameters.
|
---|
| 135 | * @return FetchDatabasePropertiesResponse
|
---|
| 136 | * @throws \Google\Service\Exception
|
---|
| 137 | */
|
---|
| 138 | public function fetchDatabaseProperties($environment, $optParams = [])
|
---|
| 139 | {
|
---|
| 140 | $params = ['environment' => $environment];
|
---|
| 141 | $params = array_merge($params, $optParams);
|
---|
| 142 | return $this->call('fetchDatabaseProperties', [$params], FetchDatabasePropertiesResponse::class);
|
---|
| 143 | }
|
---|
| 144 | /**
|
---|
| 145 | * Get an existing environment. (environments.get)
|
---|
| 146 | *
|
---|
| 147 | * @param string $name The resource name of the environment to get, in the form:
|
---|
| 148 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
|
---|
| 149 | * @param array $optParams Optional parameters.
|
---|
| 150 | * @return Environment
|
---|
| 151 | * @throws \Google\Service\Exception
|
---|
| 152 | */
|
---|
| 153 | public function get($name, $optParams = [])
|
---|
| 154 | {
|
---|
| 155 | $params = ['name' => $name];
|
---|
| 156 | $params = array_merge($params, $optParams);
|
---|
| 157 | return $this->call('get', [$params], Environment::class);
|
---|
| 158 | }
|
---|
| 159 | /**
|
---|
| 160 | * List environments. (environments.listProjectsLocationsEnvironments)
|
---|
| 161 | *
|
---|
| 162 | * @param string $parent List environments in the given project and location, in
|
---|
| 163 | * the form: "projects/{projectId}/locations/{locationId}"
|
---|
| 164 | * @param array $optParams Optional parameters.
|
---|
| 165 | *
|
---|
| 166 | * @opt_param int pageSize The maximum number of environments to return.
|
---|
| 167 | * @opt_param string pageToken The next_page_token value returned from a
|
---|
| 168 | * previous List request, if any.
|
---|
| 169 | * @return ListEnvironmentsResponse
|
---|
| 170 | * @throws \Google\Service\Exception
|
---|
| 171 | */
|
---|
| 172 | public function listProjectsLocationsEnvironments($parent, $optParams = [])
|
---|
| 173 | {
|
---|
| 174 | $params = ['parent' => $parent];
|
---|
| 175 | $params = array_merge($params, $optParams);
|
---|
| 176 | return $this->call('list', [$params], ListEnvironmentsResponse::class);
|
---|
| 177 | }
|
---|
| 178 | /**
|
---|
| 179 | * Loads a snapshot of a Cloud Composer environment. As a result of this
|
---|
| 180 | * operation, a snapshot of environment's specified in LoadSnapshotRequest is
|
---|
| 181 | * loaded into the environment. (environments.loadSnapshot)
|
---|
| 182 | *
|
---|
| 183 | * @param string $environment The resource name of the target environment in the
|
---|
| 184 | * form:
|
---|
| 185 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
|
---|
| 186 | * @param LoadSnapshotRequest $postBody
|
---|
| 187 | * @param array $optParams Optional parameters.
|
---|
| 188 | * @return Operation
|
---|
| 189 | * @throws \Google\Service\Exception
|
---|
| 190 | */
|
---|
| 191 | public function loadSnapshot($environment, LoadSnapshotRequest $postBody, $optParams = [])
|
---|
| 192 | {
|
---|
| 193 | $params = ['environment' => $environment, 'postBody' => $postBody];
|
---|
| 194 | $params = array_merge($params, $optParams);
|
---|
| 195 | return $this->call('loadSnapshot', [$params], Operation::class);
|
---|
| 196 | }
|
---|
| 197 | /**
|
---|
| 198 | * Update an environment. (environments.patch)
|
---|
| 199 | *
|
---|
| 200 | * @param string $name The relative resource name of the environment to update,
|
---|
| 201 | * in the form:
|
---|
| 202 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
|
---|
| 203 | * @param Environment $postBody
|
---|
| 204 | * @param array $optParams Optional parameters.
|
---|
| 205 | *
|
---|
| 206 | * @opt_param string updateMask Required. A comma-separated list of paths,
|
---|
| 207 | * relative to `Environment`, of fields to update. For example, to set the
|
---|
| 208 | * version of scikit-learn to install in the environment to 0.19.0 and to remove
|
---|
| 209 | * an existing installation of numpy, the `updateMask` parameter would include
|
---|
| 210 | * the following two `paths` values: "config.softwareConfig.pypiPackages.scikit-
|
---|
| 211 | * learn" and "config.softwareConfig.pypiPackages.numpy". The included patch
|
---|
| 212 | * environment would specify the scikit-learn version as follows: { "config":{
|
---|
| 213 | * "softwareConfig":{ "pypiPackages":{ "scikit-learn":"==0.19.0" } } } } Note
|
---|
| 214 | * that in the above example, any existing PyPI packages other than scikit-learn
|
---|
| 215 | * and numpy will be unaffected. Only one update type may be included in a
|
---|
| 216 | * single request's `updateMask`. For example, one cannot update both the PyPI
|
---|
| 217 | * packages and labels in the same request. However, it is possible to update
|
---|
| 218 | * multiple members of a map field simultaneously in the same request. For
|
---|
| 219 | * example, to set the labels "label1" and "label2" while clearing "label3"
|
---|
| 220 | * (assuming it already exists), one can provide the paths "labels.label1",
|
---|
| 221 | * "labels.label2", and "labels.label3" and populate the patch environment as
|
---|
| 222 | * follows: { "labels":{ "label1":"new-label1-value" "label2":"new-label2-value"
|
---|
| 223 | * } } Note that in the above example, any existing labels that are not included
|
---|
| 224 | * in the `updateMask` will be unaffected. It is also possible to replace an
|
---|
| 225 | * entire map field by providing the map field's path in the `updateMask`. The
|
---|
| 226 | * new value of the field will be that which is provided in the patch
|
---|
| 227 | * environment. For example, to delete all pre-existing user-specified PyPI
|
---|
| 228 | * packages and install botocore at version 1.7.14, the `updateMask` would
|
---|
| 229 | * contain the path "config.softwareConfig.pypiPackages", and the patch
|
---|
| 230 | * environment would be the following: { "config":{ "softwareConfig":{
|
---|
| 231 | * "pypiPackages":{ "botocore":"==1.7.14" } } } } **Note:** Only the following
|
---|
| 232 | * fields can be updated: * `config.softwareConfig.pypiPackages` * Replace all
|
---|
| 233 | * custom custom PyPI packages. If a replacement package map is not included in
|
---|
| 234 | * `environment`, all custom PyPI packages are cleared. It is an error to
|
---|
| 235 | * provide both this mask and a mask specifying an individual package. *
|
---|
| 236 | * `config.softwareConfig.pypiPackages.`packagename * Update the custom PyPI
|
---|
| 237 | * package *packagename*, preserving other packages. To delete the package,
|
---|
| 238 | * include it in `updateMask`, and omit the mapping for it in
|
---|
| 239 | * `environment.config.softwareConfig.pypiPackages`. It is an error to provide
|
---|
| 240 | * both a mask of this form and the `config.softwareConfig.pypiPackages` mask. *
|
---|
| 241 | * `labels` * Replace all environment labels. If a replacement labels map is not
|
---|
| 242 | * included in `environment`, all labels are cleared. It is an error to provide
|
---|
| 243 | * both this mask and a mask specifying one or more individual labels. *
|
---|
| 244 | * `labels.`labelName * Set the label named *labelName*, while preserving other
|
---|
| 245 | * labels. To delete the label, include it in `updateMask` and omit its mapping
|
---|
| 246 | * in `environment.labels`. It is an error to provide both a mask of this form
|
---|
| 247 | * and the `labels` mask. * `config.nodeCount` * Horizontally scale the number
|
---|
| 248 | * of nodes in the environment. An integer greater than or equal to 3 must be
|
---|
| 249 | * provided in the `config.nodeCount` field. Supported for Cloud Composer
|
---|
| 250 | * environments in versions composer-1.*.*-airflow-*.*.*. *
|
---|
| 251 | * `config.webServerNetworkAccessControl` * Replace the environment's current
|
---|
| 252 | * `WebServerNetworkAccessControl`. *
|
---|
| 253 | * `config.softwareConfig.airflowConfigOverrides` * Replace all Apache Airflow
|
---|
| 254 | * config overrides. If a replacement config overrides map is not included in
|
---|
| 255 | * `environment`, all config overrides are cleared. It is an error to provide
|
---|
| 256 | * both this mask and a mask specifying one or more individual config overrides.
|
---|
| 257 | * * `config.softwareConfig.airflowConfigOverrides.`section-name * Override the
|
---|
| 258 | * Apache Airflow config property *name* in the section named *section*,
|
---|
| 259 | * preserving other properties. To delete the property override, include it in
|
---|
| 260 | * `updateMask` and omit its mapping in
|
---|
| 261 | * `environment.config.softwareConfig.airflowConfigOverrides`. It is an error to
|
---|
| 262 | * provide both a mask of this form and the
|
---|
| 263 | * `config.softwareConfig.airflowConfigOverrides` mask. *
|
---|
| 264 | * `config.softwareConfig.envVariables` * Replace all environment variables. If
|
---|
| 265 | * a replacement environment variable map is not included in `environment`, all
|
---|
| 266 | * custom environment variables are cleared. *
|
---|
| 267 | * `config.softwareConfig.schedulerCount` * Horizontally scale the number of
|
---|
| 268 | * schedulers in Airflow. A positive integer not greater than the number of
|
---|
| 269 | * nodes must be provided in the `config.softwareConfig.schedulerCount` field.
|
---|
| 270 | * Supported for Cloud Composer environments in versions
|
---|
| 271 | * composer-1.*.*-airflow-2.*.*. * `config.databaseConfig.machineType` * Cloud
|
---|
| 272 | * SQL machine type used by Airflow database. It has to be one of:
|
---|
| 273 | * db-n1-standard-2, db-n1-standard-4, db-n1-standard-8 or db-n1-standard-16.
|
---|
| 274 | * Supported for Cloud Composer environments in versions
|
---|
| 275 | * composer-1.*.*-airflow-*.*.*. * `config.webServerConfig.machineType` *
|
---|
| 276 | * Machine type on which Airflow web server is running. It has to be one of:
|
---|
| 277 | * composer-n1-webserver-2, composer-n1-webserver-4 or composer-n1-webserver-8.
|
---|
| 278 | * Supported for Cloud Composer environments in versions
|
---|
| 279 | * composer-1.*.*-airflow-*.*.*.
|
---|
| 280 | * @return Operation
|
---|
| 281 | * @throws \Google\Service\Exception
|
---|
| 282 | */
|
---|
| 283 | public function patch($name, Environment $postBody, $optParams = [])
|
---|
| 284 | {
|
---|
| 285 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 286 | $params = array_merge($params, $optParams);
|
---|
| 287 | return $this->call('patch', [$params], Operation::class);
|
---|
| 288 | }
|
---|
| 289 | /**
|
---|
| 290 | * Polls Airflow CLI command execution and fetches logs.
|
---|
| 291 | * (environments.pollAirflowCommand)
|
---|
| 292 | *
|
---|
| 293 | * @param string $environment The resource name of the environment in the form:
|
---|
| 294 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
|
---|
| 295 | * @param PollAirflowCommandRequest $postBody
|
---|
| 296 | * @param array $optParams Optional parameters.
|
---|
| 297 | * @return PollAirflowCommandResponse
|
---|
| 298 | * @throws \Google\Service\Exception
|
---|
| 299 | */
|
---|
| 300 | public function pollAirflowCommand($environment, PollAirflowCommandRequest $postBody, $optParams = [])
|
---|
| 301 | {
|
---|
| 302 | $params = ['environment' => $environment, 'postBody' => $postBody];
|
---|
| 303 | $params = array_merge($params, $optParams);
|
---|
| 304 | return $this->call('pollAirflowCommand', [$params], PollAirflowCommandResponse::class);
|
---|
| 305 | }
|
---|
| 306 | /**
|
---|
| 307 | * Creates a snapshots of a Cloud Composer environment. As a result of this
|
---|
| 308 | * operation, snapshot of environment's state is stored in a location specified
|
---|
| 309 | * in the SaveSnapshotRequest. (environments.saveSnapshot)
|
---|
| 310 | *
|
---|
| 311 | * @param string $environment The resource name of the source environment in the
|
---|
| 312 | * form:
|
---|
| 313 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
|
---|
| 314 | * @param SaveSnapshotRequest $postBody
|
---|
| 315 | * @param array $optParams Optional parameters.
|
---|
| 316 | * @return Operation
|
---|
| 317 | * @throws \Google\Service\Exception
|
---|
| 318 | */
|
---|
| 319 | public function saveSnapshot($environment, SaveSnapshotRequest $postBody, $optParams = [])
|
---|
| 320 | {
|
---|
| 321 | $params = ['environment' => $environment, 'postBody' => $postBody];
|
---|
| 322 | $params = array_merge($params, $optParams);
|
---|
| 323 | return $this->call('saveSnapshot', [$params], Operation::class);
|
---|
| 324 | }
|
---|
| 325 | /**
|
---|
| 326 | * Stops Airflow CLI command execution. (environments.stopAirflowCommand)
|
---|
| 327 | *
|
---|
| 328 | * @param string $environment The resource name of the environment in the form:
|
---|
| 329 | * "projects/{projectId}/locations/{locationId}/environments/{environmentId}".
|
---|
| 330 | * @param StopAirflowCommandRequest $postBody
|
---|
| 331 | * @param array $optParams Optional parameters.
|
---|
| 332 | * @return StopAirflowCommandResponse
|
---|
| 333 | * @throws \Google\Service\Exception
|
---|
| 334 | */
|
---|
| 335 | public function stopAirflowCommand($environment, StopAirflowCommandRequest $postBody, $optParams = [])
|
---|
| 336 | {
|
---|
| 337 | $params = ['environment' => $environment, 'postBody' => $postBody];
|
---|
| 338 | $params = array_merge($params, $optParams);
|
---|
| 339 | return $this->call('stopAirflowCommand', [$params], StopAirflowCommandResponse::class);
|
---|
| 340 | }
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 344 | class_alias(ProjectsLocationsEnvironments::class, 'Google_Service_CloudComposer_Resource_ProjectsLocationsEnvironments');
|
---|