[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\Spanner\Resource;
|
---|
| 19 |
|
---|
| 20 | use Google\Service\Spanner\CreateInstanceRequest;
|
---|
| 21 | use Google\Service\Spanner\GetIamPolicyRequest;
|
---|
| 22 | use Google\Service\Spanner\Instance;
|
---|
| 23 | use Google\Service\Spanner\ListInstancesResponse;
|
---|
| 24 | use Google\Service\Spanner\MoveInstanceRequest;
|
---|
| 25 | use Google\Service\Spanner\Operation;
|
---|
| 26 | use Google\Service\Spanner\Policy;
|
---|
| 27 | use Google\Service\Spanner\SetIamPolicyRequest;
|
---|
| 28 | use Google\Service\Spanner\SpannerEmpty;
|
---|
| 29 | use Google\Service\Spanner\TestIamPermissionsRequest;
|
---|
| 30 | use Google\Service\Spanner\TestIamPermissionsResponse;
|
---|
| 31 | use Google\Service\Spanner\UpdateInstanceRequest;
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | * The "instances" collection of methods.
|
---|
| 35 | * Typical usage is:
|
---|
| 36 | * <code>
|
---|
| 37 | * $spannerService = new Google\Service\Spanner(...);
|
---|
| 38 | * $instances = $spannerService->projects_instances;
|
---|
| 39 | * </code>
|
---|
| 40 | */
|
---|
| 41 | class ProjectsInstances extends \Google\Service\Resource
|
---|
| 42 | {
|
---|
| 43 | /**
|
---|
| 44 | * Creates an instance and begins preparing it to begin serving. The returned
|
---|
| 45 | * long-running operation can be used to track the progress of preparing the new
|
---|
| 46 | * instance. The instance name is assigned by the caller. If the named instance
|
---|
| 47 | * already exists, `CreateInstance` returns `ALREADY_EXISTS`. Immediately upon
|
---|
| 48 | * completion of this request: * The instance is readable via the API, with all
|
---|
| 49 | * requested attributes but no allocated resources. Its state is `CREATING`.
|
---|
| 50 | * Until completion of the returned operation: * Cancelling the operation
|
---|
| 51 | * renders the instance immediately unreadable via the API. * The instance can
|
---|
| 52 | * be deleted. * All other attempts to modify the instance are rejected. Upon
|
---|
| 53 | * completion of the returned operation: * Billing for all successfully-
|
---|
| 54 | * allocated resources begins (some types may have lower than the requested
|
---|
| 55 | * levels). * Databases can be created in the instance. * The instance's
|
---|
| 56 | * allocated resource levels are readable via the API. * The instance's state
|
---|
| 57 | * becomes `READY`. The returned long-running operation will have a name of the
|
---|
| 58 | * format `/operations/` and can be used to track creation of the instance. The
|
---|
| 59 | * metadata field type is CreateInstanceMetadata. The response field type is
|
---|
| 60 | * Instance, if successful. (instances.create)
|
---|
| 61 | *
|
---|
| 62 | * @param string $parent Required. The name of the project in which to create
|
---|
| 63 | * the instance. Values are of the form `projects/`.
|
---|
| 64 | * @param CreateInstanceRequest $postBody
|
---|
| 65 | * @param array $optParams Optional parameters.
|
---|
| 66 | * @return Operation
|
---|
| 67 | * @throws \Google\Service\Exception
|
---|
| 68 | */
|
---|
| 69 | public function create($parent, CreateInstanceRequest $postBody, $optParams = [])
|
---|
| 70 | {
|
---|
| 71 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 72 | $params = array_merge($params, $optParams);
|
---|
| 73 | return $this->call('create', [$params], Operation::class);
|
---|
| 74 | }
|
---|
| 75 | /**
|
---|
| 76 | * Deletes an instance. Immediately upon completion of the request: * Billing
|
---|
| 77 | * ceases for all of the instance's reserved resources. Soon afterward: * The
|
---|
| 78 | * instance and *all of its databases* immediately and irrevocably disappear
|
---|
| 79 | * from the API. All data in the databases is permanently deleted.
|
---|
| 80 | * (instances.delete)
|
---|
| 81 | *
|
---|
| 82 | * @param string $name Required. The name of the instance to be deleted. Values
|
---|
| 83 | * are of the form `projects//instances/`
|
---|
| 84 | * @param array $optParams Optional parameters.
|
---|
| 85 | * @return SpannerEmpty
|
---|
| 86 | * @throws \Google\Service\Exception
|
---|
| 87 | */
|
---|
| 88 | public function delete($name, $optParams = [])
|
---|
| 89 | {
|
---|
| 90 | $params = ['name' => $name];
|
---|
| 91 | $params = array_merge($params, $optParams);
|
---|
| 92 | return $this->call('delete', [$params], SpannerEmpty::class);
|
---|
| 93 | }
|
---|
| 94 | /**
|
---|
| 95 | * Gets information about a particular instance. (instances.get)
|
---|
| 96 | *
|
---|
| 97 | * @param string $name Required. The name of the requested instance. Values are
|
---|
| 98 | * of the form `projects//instances/`.
|
---|
| 99 | * @param array $optParams Optional parameters.
|
---|
| 100 | *
|
---|
| 101 | * @opt_param string fieldMask If field_mask is present, specifies the subset of
|
---|
| 102 | * Instance fields that should be returned. If absent, all Instance fields are
|
---|
| 103 | * returned.
|
---|
| 104 | * @return Instance
|
---|
| 105 | * @throws \Google\Service\Exception
|
---|
| 106 | */
|
---|
| 107 | public function get($name, $optParams = [])
|
---|
| 108 | {
|
---|
| 109 | $params = ['name' => $name];
|
---|
| 110 | $params = array_merge($params, $optParams);
|
---|
| 111 | return $this->call('get', [$params], Instance::class);
|
---|
| 112 | }
|
---|
| 113 | /**
|
---|
| 114 | * Gets the access control policy for an instance resource. Returns an empty
|
---|
| 115 | * policy if an instance exists but does not have a policy set. Authorization
|
---|
| 116 | * requires `spanner.instances.getIamPolicy` on resource.
|
---|
| 117 | * (instances.getIamPolicy)
|
---|
| 118 | *
|
---|
| 119 | * @param string $resource REQUIRED: The Cloud Spanner resource for which the
|
---|
| 120 | * policy is being retrieved. The format is `projects//instances/` for instance
|
---|
| 121 | * resources and `projects//instances//databases/` for database resources.
|
---|
| 122 | * @param GetIamPolicyRequest $postBody
|
---|
| 123 | * @param array $optParams Optional parameters.
|
---|
| 124 | * @return Policy
|
---|
| 125 | * @throws \Google\Service\Exception
|
---|
| 126 | */
|
---|
| 127 | public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
|
---|
| 128 | {
|
---|
| 129 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 130 | $params = array_merge($params, $optParams);
|
---|
| 131 | return $this->call('getIamPolicy', [$params], Policy::class);
|
---|
| 132 | }
|
---|
| 133 | /**
|
---|
| 134 | * Lists all instances in the given project. (instances.listProjectsInstances)
|
---|
| 135 | *
|
---|
| 136 | * @param string $parent Required. The name of the project for which a list of
|
---|
| 137 | * instances is requested. Values are of the form `projects/`.
|
---|
| 138 | * @param array $optParams Optional parameters.
|
---|
| 139 | *
|
---|
| 140 | * @opt_param string filter An expression for filtering the results of the
|
---|
| 141 | * request. Filter rules are case insensitive. The fields eligible for filtering
|
---|
| 142 | * are: * `name` * `display_name` * `labels.key` where key is the name of a
|
---|
| 143 | * label Some examples of using filters are: * `name:*` --> The instance has a
|
---|
| 144 | * name. * `name:Howl` --> The instance's name contains the string "howl". *
|
---|
| 145 | * `name:HOWL` --> Equivalent to above. * `NAME:howl` --> Equivalent to above. *
|
---|
| 146 | * `labels.env:*` --> The instance has the label "env". * `labels.env:dev` -->
|
---|
| 147 | * The instance has the label "env" and the value of the label contains the
|
---|
| 148 | * string "dev". * `name:howl labels.env:dev` --> The instance's name contains
|
---|
| 149 | * "howl" and it has the label "env" with its value containing "dev".
|
---|
| 150 | * @opt_param string instanceDeadline Deadline used while retrieving metadata
|
---|
| 151 | * for instances. Instances whose metadata cannot be retrieved within this
|
---|
| 152 | * deadline will be added to unreachable in ListInstancesResponse.
|
---|
| 153 | * @opt_param int pageSize Number of instances to be returned in the response.
|
---|
| 154 | * If 0 or less, defaults to the server's maximum allowed page size.
|
---|
| 155 | * @opt_param string pageToken If non-empty, `page_token` should contain a
|
---|
| 156 | * next_page_token from a previous ListInstancesResponse.
|
---|
| 157 | * @return ListInstancesResponse
|
---|
| 158 | * @throws \Google\Service\Exception
|
---|
| 159 | */
|
---|
| 160 | public function listProjectsInstances($parent, $optParams = [])
|
---|
| 161 | {
|
---|
| 162 | $params = ['parent' => $parent];
|
---|
| 163 | $params = array_merge($params, $optParams);
|
---|
| 164 | return $this->call('list', [$params], ListInstancesResponse::class);
|
---|
| 165 | }
|
---|
| 166 | /**
|
---|
| 167 | * Moves an instance to the target instance configuration. You can use the
|
---|
| 168 | * returned long-running operation to track the progress of moving the instance.
|
---|
| 169 | * `MoveInstance` returns `FAILED_PRECONDITION` if the instance meets any of the
|
---|
| 170 | * following criteria: * Is undergoing a move to a different instance
|
---|
| 171 | * configuration * Has backups * Has an ongoing update * Contains any CMEK-
|
---|
| 172 | * enabled databases * Is a free trial instance While the operation is pending:
|
---|
| 173 | * * All other attempts to modify the instance, including changes to its compute
|
---|
| 174 | * capacity, are rejected. * The following database and backup admin operations
|
---|
| 175 | * are rejected: * `DatabaseAdmin.CreateDatabase` *
|
---|
| 176 | * `DatabaseAdmin.UpdateDatabaseDdl` (disabled if default_leader is specified in
|
---|
| 177 | * the request.) * `DatabaseAdmin.RestoreDatabase` *
|
---|
| 178 | * `DatabaseAdmin.CreateBackup` * `DatabaseAdmin.CopyBackup` * Both the source
|
---|
| 179 | * and target instance configurations are subject to hourly compute and storage
|
---|
| 180 | * charges. * The instance might experience higher read-write latencies and a
|
---|
| 181 | * higher transaction abort rate. However, moving an instance doesn't cause any
|
---|
| 182 | * downtime. The returned long-running operation has a name of the format
|
---|
| 183 | * `/operations/` and can be used to track the move instance operation. The
|
---|
| 184 | * metadata field type is MoveInstanceMetadata. The response field type is
|
---|
| 185 | * Instance, if successful. Cancelling the operation sets its metadata's
|
---|
| 186 | * cancel_time. Cancellation is not immediate because it involves moving any
|
---|
| 187 | * data previously moved to the target instance configuration back to the
|
---|
| 188 | * original instance configuration. You can use this operation to track the
|
---|
| 189 | * progress of the cancellation. Upon successful completion of the cancellation,
|
---|
| 190 | * the operation terminates with `CANCELLED` status. If not cancelled, upon
|
---|
| 191 | * completion of the returned operation: * The instance successfully moves to
|
---|
| 192 | * the target instance configuration. * You are billed for compute and storage
|
---|
| 193 | * in target instance configuration. Authorization requires the
|
---|
| 194 | * `spanner.instances.update` permission on the resource instance. For more
|
---|
| 195 | * details, see [Move an instance](https://cloud.google.com/spanner/docs/move-
|
---|
| 196 | * instance). (instances.move)
|
---|
| 197 | *
|
---|
| 198 | * @param string $name Required. The instance to move. Values are of the form
|
---|
| 199 | * `projects//instances/`.
|
---|
| 200 | * @param MoveInstanceRequest $postBody
|
---|
| 201 | * @param array $optParams Optional parameters.
|
---|
| 202 | * @return Operation
|
---|
| 203 | * @throws \Google\Service\Exception
|
---|
| 204 | */
|
---|
| 205 | public function move($name, MoveInstanceRequest $postBody, $optParams = [])
|
---|
| 206 | {
|
---|
| 207 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 208 | $params = array_merge($params, $optParams);
|
---|
| 209 | return $this->call('move', [$params], Operation::class);
|
---|
| 210 | }
|
---|
| 211 | /**
|
---|
| 212 | * Updates an instance, and begins allocating or releasing resources as
|
---|
| 213 | * requested. The returned long-running operation can be used to track the
|
---|
| 214 | * progress of updating the instance. If the named instance does not exist,
|
---|
| 215 | * returns `NOT_FOUND`. Immediately upon completion of this request: * For
|
---|
| 216 | * resource types for which a decrease in the instance's allocation has been
|
---|
| 217 | * requested, billing is based on the newly-requested level. Until completion of
|
---|
| 218 | * the returned operation: * Cancelling the operation sets its metadata's
|
---|
| 219 | * cancel_time, and begins restoring resources to their pre-request values. The
|
---|
| 220 | * operation is guaranteed to succeed at undoing all resource changes, after
|
---|
| 221 | * which point it terminates with a `CANCELLED` status. * All other attempts to
|
---|
| 222 | * modify the instance are rejected. * Reading the instance via the API
|
---|
| 223 | * continues to give the pre-request resource levels. Upon completion of the
|
---|
| 224 | * returned operation: * Billing begins for all successfully-allocated resources
|
---|
| 225 | * (some types may have lower than the requested levels). * All newly-reserved
|
---|
| 226 | * resources are available for serving the instance's tables. * The instance's
|
---|
| 227 | * new resource levels are readable via the API. The returned long-running
|
---|
| 228 | * operation will have a name of the format `/operations/` and can be used to
|
---|
| 229 | * track the instance modification. The metadata field type is
|
---|
| 230 | * UpdateInstanceMetadata. The response field type is Instance, if successful.
|
---|
| 231 | * Authorization requires `spanner.instances.update` permission on the resource
|
---|
| 232 | * name. (instances.patch)
|
---|
| 233 | *
|
---|
| 234 | * @param string $name Required. A unique identifier for the instance, which
|
---|
| 235 | * cannot be changed after the instance is created. Values are of the form
|
---|
| 236 | * `projects//instances/a-z*[a-z0-9]`. The final segment of the name must be
|
---|
| 237 | * between 2 and 64 characters in length.
|
---|
| 238 | * @param UpdateInstanceRequest $postBody
|
---|
| 239 | * @param array $optParams Optional parameters.
|
---|
| 240 | * @return Operation
|
---|
| 241 | * @throws \Google\Service\Exception
|
---|
| 242 | */
|
---|
| 243 | public function patch($name, UpdateInstanceRequest $postBody, $optParams = [])
|
---|
| 244 | {
|
---|
| 245 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 246 | $params = array_merge($params, $optParams);
|
---|
| 247 | return $this->call('patch', [$params], Operation::class);
|
---|
| 248 | }
|
---|
| 249 | /**
|
---|
| 250 | * Sets the access control policy on an instance resource. Replaces any existing
|
---|
| 251 | * policy. Authorization requires `spanner.instances.setIamPolicy` on resource.
|
---|
| 252 | * (instances.setIamPolicy)
|
---|
| 253 | *
|
---|
| 254 | * @param string $resource REQUIRED: The Cloud Spanner resource for which the
|
---|
| 255 | * policy is being set. The format is `projects//instances/` for instance
|
---|
| 256 | * resources and `projects//instances//databases/` for databases resources.
|
---|
| 257 | * @param SetIamPolicyRequest $postBody
|
---|
| 258 | * @param array $optParams Optional parameters.
|
---|
| 259 | * @return Policy
|
---|
| 260 | * @throws \Google\Service\Exception
|
---|
| 261 | */
|
---|
| 262 | public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
|
---|
| 263 | {
|
---|
| 264 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 265 | $params = array_merge($params, $optParams);
|
---|
| 266 | return $this->call('setIamPolicy', [$params], Policy::class);
|
---|
| 267 | }
|
---|
| 268 | /**
|
---|
| 269 | * Returns permissions that the caller has on the specified instance resource.
|
---|
| 270 | * Attempting this RPC on a non-existent Cloud Spanner instance resource will
|
---|
| 271 | * result in a NOT_FOUND error if the user has `spanner.instances.list`
|
---|
| 272 | * permission on the containing Google Cloud Project. Otherwise returns an empty
|
---|
| 273 | * set of permissions. (instances.testIamPermissions)
|
---|
| 274 | *
|
---|
| 275 | * @param string $resource REQUIRED: The Cloud Spanner resource for which
|
---|
| 276 | * permissions are being tested. The format is `projects//instances/` for
|
---|
| 277 | * instance resources and `projects//instances//databases/` for database
|
---|
| 278 | * resources.
|
---|
| 279 | * @param TestIamPermissionsRequest $postBody
|
---|
| 280 | * @param array $optParams Optional parameters.
|
---|
| 281 | * @return TestIamPermissionsResponse
|
---|
| 282 | * @throws \Google\Service\Exception
|
---|
| 283 | */
|
---|
| 284 | public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
|
---|
| 285 | {
|
---|
| 286 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 287 | $params = array_merge($params, $optParams);
|
---|
| 288 | return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 293 | class_alias(ProjectsInstances::class, 'Google_Service_Spanner_Resource_ProjectsInstances');
|
---|