[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\ChangeQuorumRequest;
|
---|
| 21 | use Google\Service\Spanner\CreateDatabaseRequest;
|
---|
| 22 | use Google\Service\Spanner\Database;
|
---|
| 23 | use Google\Service\Spanner\GetDatabaseDdlResponse;
|
---|
| 24 | use Google\Service\Spanner\GetIamPolicyRequest;
|
---|
| 25 | use Google\Service\Spanner\ListDatabasesResponse;
|
---|
| 26 | use Google\Service\Spanner\Operation;
|
---|
| 27 | use Google\Service\Spanner\Policy;
|
---|
| 28 | use Google\Service\Spanner\RestoreDatabaseRequest;
|
---|
| 29 | use Google\Service\Spanner\Scan;
|
---|
| 30 | use Google\Service\Spanner\SetIamPolicyRequest;
|
---|
| 31 | use Google\Service\Spanner\SpannerEmpty;
|
---|
| 32 | use Google\Service\Spanner\TestIamPermissionsRequest;
|
---|
| 33 | use Google\Service\Spanner\TestIamPermissionsResponse;
|
---|
| 34 | use Google\Service\Spanner\UpdateDatabaseDdlRequest;
|
---|
| 35 |
|
---|
| 36 | /**
|
---|
| 37 | * The "databases" collection of methods.
|
---|
| 38 | * Typical usage is:
|
---|
| 39 | * <code>
|
---|
| 40 | * $spannerService = new Google\Service\Spanner(...);
|
---|
| 41 | * $databases = $spannerService->projects_instances_databases;
|
---|
| 42 | * </code>
|
---|
| 43 | */
|
---|
| 44 | class ProjectsInstancesDatabases extends \Google\Service\Resource
|
---|
| 45 | {
|
---|
| 46 | /**
|
---|
| 47 | * `ChangeQuorum` is strictly restricted to databases that use dual-region
|
---|
| 48 | * instance configurations. Initiates a background operation to change the
|
---|
| 49 | * quorum of a database from dual-region mode to single-region mode or vice
|
---|
| 50 | * versa. The returned long-running operation has a name of the format
|
---|
| 51 | * `projects//instances//databases//operations/` and can be used to track
|
---|
| 52 | * execution of the `ChangeQuorum`. The metadata field type is
|
---|
| 53 | * ChangeQuorumMetadata. Authorization requires `spanner.databases.changequorum`
|
---|
| 54 | * permission on the resource database. (databases.changequorum)
|
---|
| 55 | *
|
---|
| 56 | * @param string $name Required. Name of the database in which to apply
|
---|
| 57 | * `ChangeQuorum`. Values are of the form `projects//instances//databases/`.
|
---|
| 58 | * @param ChangeQuorumRequest $postBody
|
---|
| 59 | * @param array $optParams Optional parameters.
|
---|
| 60 | * @return Operation
|
---|
| 61 | * @throws \Google\Service\Exception
|
---|
| 62 | */
|
---|
| 63 | public function changequorum($name, ChangeQuorumRequest $postBody, $optParams = [])
|
---|
| 64 | {
|
---|
| 65 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 66 | $params = array_merge($params, $optParams);
|
---|
| 67 | return $this->call('changequorum', [$params], Operation::class);
|
---|
| 68 | }
|
---|
| 69 | /**
|
---|
| 70 | * Creates a new Spanner database and starts to prepare it for serving. The
|
---|
| 71 | * returned long-running operation will have a name of the format `/operations/`
|
---|
| 72 | * and can be used to track preparation of the database. The metadata field type
|
---|
| 73 | * is CreateDatabaseMetadata. The response field type is Database, if
|
---|
| 74 | * successful. (databases.create)
|
---|
| 75 | *
|
---|
| 76 | * @param string $parent Required. The name of the instance that will serve the
|
---|
| 77 | * new database. Values are of the form `projects//instances/`.
|
---|
| 78 | * @param CreateDatabaseRequest $postBody
|
---|
| 79 | * @param array $optParams Optional parameters.
|
---|
| 80 | * @return Operation
|
---|
| 81 | * @throws \Google\Service\Exception
|
---|
| 82 | */
|
---|
| 83 | public function create($parent, CreateDatabaseRequest $postBody, $optParams = [])
|
---|
| 84 | {
|
---|
| 85 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 86 | $params = array_merge($params, $optParams);
|
---|
| 87 | return $this->call('create', [$params], Operation::class);
|
---|
| 88 | }
|
---|
| 89 | /**
|
---|
| 90 | * Drops (aka deletes) a Cloud Spanner database. Completed backups for the
|
---|
| 91 | * database will be retained according to their `expire_time`. Note: Cloud
|
---|
| 92 | * Spanner might continue to accept requests for a few seconds after the
|
---|
| 93 | * database has been deleted. (databases.dropDatabase)
|
---|
| 94 | *
|
---|
| 95 | * @param string $database Required. The database to be dropped.
|
---|
| 96 | * @param array $optParams Optional parameters.
|
---|
| 97 | * @return SpannerEmpty
|
---|
| 98 | * @throws \Google\Service\Exception
|
---|
| 99 | */
|
---|
| 100 | public function dropDatabase($database, $optParams = [])
|
---|
| 101 | {
|
---|
| 102 | $params = ['database' => $database];
|
---|
| 103 | $params = array_merge($params, $optParams);
|
---|
| 104 | return $this->call('dropDatabase', [$params], SpannerEmpty::class);
|
---|
| 105 | }
|
---|
| 106 | /**
|
---|
| 107 | * Gets the state of a Cloud Spanner database. (databases.get)
|
---|
| 108 | *
|
---|
| 109 | * @param string $name Required. The name of the requested database. Values are
|
---|
| 110 | * of the form `projects//instances//databases/`.
|
---|
| 111 | * @param array $optParams Optional parameters.
|
---|
| 112 | * @return Database
|
---|
| 113 | * @throws \Google\Service\Exception
|
---|
| 114 | */
|
---|
| 115 | public function get($name, $optParams = [])
|
---|
| 116 | {
|
---|
| 117 | $params = ['name' => $name];
|
---|
| 118 | $params = array_merge($params, $optParams);
|
---|
| 119 | return $this->call('get', [$params], Database::class);
|
---|
| 120 | }
|
---|
| 121 | /**
|
---|
| 122 | * Returns the schema of a Cloud Spanner database as a list of formatted DDL
|
---|
| 123 | * statements. This method does not show pending schema updates, those may be
|
---|
| 124 | * queried using the Operations API. (databases.getDdl)
|
---|
| 125 | *
|
---|
| 126 | * @param string $database Required. The database whose schema we wish to get.
|
---|
| 127 | * Values are of the form `projects//instances//databases/`
|
---|
| 128 | * @param array $optParams Optional parameters.
|
---|
| 129 | * @return GetDatabaseDdlResponse
|
---|
| 130 | * @throws \Google\Service\Exception
|
---|
| 131 | */
|
---|
| 132 | public function getDdl($database, $optParams = [])
|
---|
| 133 | {
|
---|
| 134 | $params = ['database' => $database];
|
---|
| 135 | $params = array_merge($params, $optParams);
|
---|
| 136 | return $this->call('getDdl', [$params], GetDatabaseDdlResponse::class);
|
---|
| 137 | }
|
---|
| 138 | /**
|
---|
| 139 | * Gets the access control policy for a database or backup resource. Returns an
|
---|
| 140 | * empty policy if a database or backup exists but does not have a policy set.
|
---|
| 141 | * Authorization requires `spanner.databases.getIamPolicy` permission on
|
---|
| 142 | * resource. For backups, authorization requires `spanner.backups.getIamPolicy`
|
---|
| 143 | * permission on resource. For backup schedules, authorization requires
|
---|
| 144 | * `spanner.backupSchedules.getIamPolicy` permission on resource.
|
---|
| 145 | * (databases.getIamPolicy)
|
---|
| 146 | *
|
---|
| 147 | * @param string $resource REQUIRED: The Cloud Spanner resource for which the
|
---|
| 148 | * policy is being retrieved. The format is `projects//instances/` for instance
|
---|
| 149 | * resources and `projects//instances//databases/` for database resources.
|
---|
| 150 | * @param GetIamPolicyRequest $postBody
|
---|
| 151 | * @param array $optParams Optional parameters.
|
---|
| 152 | * @return Policy
|
---|
| 153 | * @throws \Google\Service\Exception
|
---|
| 154 | */
|
---|
| 155 | public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
|
---|
| 156 | {
|
---|
| 157 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 158 | $params = array_merge($params, $optParams);
|
---|
| 159 | return $this->call('getIamPolicy', [$params], Policy::class);
|
---|
| 160 | }
|
---|
| 161 | /**
|
---|
| 162 | * Request a specific scan with Database-specific data for Cloud Key Visualizer.
|
---|
| 163 | * (databases.getScans)
|
---|
| 164 | *
|
---|
| 165 | * @param string $name Required. The unique name of the scan containing the
|
---|
| 166 | * requested information, specific to the Database service implementing this
|
---|
| 167 | * interface.
|
---|
| 168 | * @param array $optParams Optional parameters.
|
---|
| 169 | *
|
---|
| 170 | * @opt_param string endTime The upper bound for the time range to retrieve Scan
|
---|
| 171 | * data for.
|
---|
| 172 | * @opt_param string startTime These fields restrict the Database-specific
|
---|
| 173 | * information returned in the `Scan.data` field. If a `View` is provided that
|
---|
| 174 | * does not include the `Scan.data` field, these are ignored. This range of time
|
---|
| 175 | * must be entirely contained within the defined time range of the targeted
|
---|
| 176 | * scan. The lower bound for the time range to retrieve Scan data for.
|
---|
| 177 | * @opt_param string view Specifies which parts of the Scan should be returned
|
---|
| 178 | * in the response. Note, if left unspecified, the FULL view is assumed.
|
---|
| 179 | * @return Scan
|
---|
| 180 | * @throws \Google\Service\Exception
|
---|
| 181 | */
|
---|
| 182 | public function getScans($name, $optParams = [])
|
---|
| 183 | {
|
---|
| 184 | $params = ['name' => $name];
|
---|
| 185 | $params = array_merge($params, $optParams);
|
---|
| 186 | return $this->call('getScans', [$params], Scan::class);
|
---|
| 187 | }
|
---|
| 188 | /**
|
---|
| 189 | * Lists Cloud Spanner databases. (databases.listProjectsInstancesDatabases)
|
---|
| 190 | *
|
---|
| 191 | * @param string $parent Required. The instance whose databases should be
|
---|
| 192 | * listed. Values are of the form `projects//instances/`.
|
---|
| 193 | * @param array $optParams Optional parameters.
|
---|
| 194 | *
|
---|
| 195 | * @opt_param int pageSize Number of databases to be returned in the response.
|
---|
| 196 | * If 0 or less, defaults to the server's maximum allowed page size.
|
---|
| 197 | * @opt_param string pageToken If non-empty, `page_token` should contain a
|
---|
| 198 | * next_page_token from a previous ListDatabasesResponse.
|
---|
| 199 | * @return ListDatabasesResponse
|
---|
| 200 | * @throws \Google\Service\Exception
|
---|
| 201 | */
|
---|
| 202 | public function listProjectsInstancesDatabases($parent, $optParams = [])
|
---|
| 203 | {
|
---|
| 204 | $params = ['parent' => $parent];
|
---|
| 205 | $params = array_merge($params, $optParams);
|
---|
| 206 | return $this->call('list', [$params], ListDatabasesResponse::class);
|
---|
| 207 | }
|
---|
| 208 | /**
|
---|
| 209 | * Updates a Cloud Spanner database. The returned long-running operation can be
|
---|
| 210 | * used to track the progress of updating the database. If the named database
|
---|
| 211 | * does not exist, returns `NOT_FOUND`. While the operation is pending: * The
|
---|
| 212 | * database's reconciling field is set to true. * Cancelling the operation is
|
---|
| 213 | * best-effort. If the cancellation succeeds, the operation metadata's
|
---|
| 214 | * cancel_time is set, the updates are reverted, and the operation terminates
|
---|
| 215 | * with a `CANCELLED` status. * New UpdateDatabase requests will return a
|
---|
| 216 | * `FAILED_PRECONDITION` error until the pending operation is done (returns
|
---|
| 217 | * successfully or with error). * Reading the database via the API continues to
|
---|
| 218 | * give the pre-request values. Upon completion of the returned operation: * The
|
---|
| 219 | * new values are in effect and readable via the API. * The database's
|
---|
| 220 | * reconciling field becomes false. The returned long-running operation will
|
---|
| 221 | * have a name of the format `projects//instances//databases//operations/` and
|
---|
| 222 | * can be used to track the database modification. The metadata field type is
|
---|
| 223 | * UpdateDatabaseMetadata. The response field type is Database, if successful.
|
---|
| 224 | * (databases.patch)
|
---|
| 225 | *
|
---|
| 226 | * @param string $name Required. The name of the database. Values are of the
|
---|
| 227 | * form `projects//instances//databases/`, where `` is as specified in the
|
---|
| 228 | * `CREATE DATABASE` statement. This name can be passed to other API methods to
|
---|
| 229 | * identify the database.
|
---|
| 230 | * @param Database $postBody
|
---|
| 231 | * @param array $optParams Optional parameters.
|
---|
| 232 | *
|
---|
| 233 | * @opt_param string updateMask Required. The list of fields to update.
|
---|
| 234 | * Currently, only `enable_drop_protection` field can be updated.
|
---|
| 235 | * @return Operation
|
---|
| 236 | * @throws \Google\Service\Exception
|
---|
| 237 | */
|
---|
| 238 | public function patch($name, Database $postBody, $optParams = [])
|
---|
| 239 | {
|
---|
| 240 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
| 241 | $params = array_merge($params, $optParams);
|
---|
| 242 | return $this->call('patch', [$params], Operation::class);
|
---|
| 243 | }
|
---|
| 244 | /**
|
---|
| 245 | * Create a new database by restoring from a completed backup. The new database
|
---|
| 246 | * must be in the same project and in an instance with the same instance
|
---|
| 247 | * configuration as the instance containing the backup. The returned database
|
---|
| 248 | * long-running operation has a name of the format
|
---|
| 249 | * `projects//instances//databases//operations/`, and can be used to track the
|
---|
| 250 | * progress of the operation, and to cancel it. The metadata field type is
|
---|
| 251 | * RestoreDatabaseMetadata. The response type is Database, if successful.
|
---|
| 252 | * Cancelling the returned operation will stop the restore and delete the
|
---|
| 253 | * database. There can be only one database being restored into an instance at a
|
---|
| 254 | * time. Once the restore operation completes, a new restore operation can be
|
---|
| 255 | * initiated, without waiting for the optimize operation associated with the
|
---|
| 256 | * first restore to complete. (databases.restore)
|
---|
| 257 | *
|
---|
| 258 | * @param string $parent Required. The name of the instance in which to create
|
---|
| 259 | * the restored database. This instance must be in the same project and have the
|
---|
| 260 | * same instance configuration as the instance containing the source backup.
|
---|
| 261 | * Values are of the form `projects//instances/`.
|
---|
| 262 | * @param RestoreDatabaseRequest $postBody
|
---|
| 263 | * @param array $optParams Optional parameters.
|
---|
| 264 | * @return Operation
|
---|
| 265 | * @throws \Google\Service\Exception
|
---|
| 266 | */
|
---|
| 267 | public function restore($parent, RestoreDatabaseRequest $postBody, $optParams = [])
|
---|
| 268 | {
|
---|
| 269 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
| 270 | $params = array_merge($params, $optParams);
|
---|
| 271 | return $this->call('restore', [$params], Operation::class);
|
---|
| 272 | }
|
---|
| 273 | /**
|
---|
| 274 | * Sets the access control policy on a database or backup resource. Replaces any
|
---|
| 275 | * existing policy. Authorization requires `spanner.databases.setIamPolicy`
|
---|
| 276 | * permission on resource. For backups, authorization requires
|
---|
| 277 | * `spanner.backups.setIamPolicy` permission on resource. For backup schedules,
|
---|
| 278 | * authorization requires `spanner.backupSchedules.setIamPolicy` permission on
|
---|
| 279 | * resource. (databases.setIamPolicy)
|
---|
| 280 | *
|
---|
| 281 | * @param string $resource REQUIRED: The Cloud Spanner resource for which the
|
---|
| 282 | * policy is being set. The format is `projects//instances/` for instance
|
---|
| 283 | * resources and `projects//instances//databases/` for databases resources.
|
---|
| 284 | * @param SetIamPolicyRequest $postBody
|
---|
| 285 | * @param array $optParams Optional parameters.
|
---|
| 286 | * @return Policy
|
---|
| 287 | * @throws \Google\Service\Exception
|
---|
| 288 | */
|
---|
| 289 | public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
|
---|
| 290 | {
|
---|
| 291 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 292 | $params = array_merge($params, $optParams);
|
---|
| 293 | return $this->call('setIamPolicy', [$params], Policy::class);
|
---|
| 294 | }
|
---|
| 295 | /**
|
---|
| 296 | * Returns permissions that the caller has on the specified database or backup
|
---|
| 297 | * resource. Attempting this RPC on a non-existent Cloud Spanner database will
|
---|
| 298 | * result in a NOT_FOUND error if the user has `spanner.databases.list`
|
---|
| 299 | * permission on the containing Cloud Spanner instance. Otherwise returns an
|
---|
| 300 | * empty set of permissions. Calling this method on a backup that does not exist
|
---|
| 301 | * will result in a NOT_FOUND error if the user has `spanner.backups.list`
|
---|
| 302 | * permission on the containing instance. Calling this method on a backup
|
---|
| 303 | * schedule that does not exist will result in a NOT_FOUND error if the user has
|
---|
| 304 | * `spanner.backupSchedules.list` permission on the containing database.
|
---|
| 305 | * (databases.testIamPermissions)
|
---|
| 306 | *
|
---|
| 307 | * @param string $resource REQUIRED: The Cloud Spanner resource for which
|
---|
| 308 | * permissions are being tested. The format is `projects//instances/` for
|
---|
| 309 | * instance resources and `projects//instances//databases/` for database
|
---|
| 310 | * resources.
|
---|
| 311 | * @param TestIamPermissionsRequest $postBody
|
---|
| 312 | * @param array $optParams Optional parameters.
|
---|
| 313 | * @return TestIamPermissionsResponse
|
---|
| 314 | * @throws \Google\Service\Exception
|
---|
| 315 | */
|
---|
| 316 | public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
|
---|
| 317 | {
|
---|
| 318 | $params = ['resource' => $resource, 'postBody' => $postBody];
|
---|
| 319 | $params = array_merge($params, $optParams);
|
---|
| 320 | return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
|
---|
| 321 | }
|
---|
| 322 | /**
|
---|
| 323 | * Updates the schema of a Cloud Spanner database by creating/altering/dropping
|
---|
| 324 | * tables, columns, indexes, etc. The returned long-running operation will have
|
---|
| 325 | * a name of the format `/operations/` and can be used to track execution of the
|
---|
| 326 | * schema change(s). The metadata field type is UpdateDatabaseDdlMetadata. The
|
---|
| 327 | * operation has no response. (databases.updateDdl)
|
---|
| 328 | *
|
---|
| 329 | * @param string $database Required. The database to update.
|
---|
| 330 | * @param UpdateDatabaseDdlRequest $postBody
|
---|
| 331 | * @param array $optParams Optional parameters.
|
---|
| 332 | * @return Operation
|
---|
| 333 | * @throws \Google\Service\Exception
|
---|
| 334 | */
|
---|
| 335 | public function updateDdl($database, UpdateDatabaseDdlRequest $postBody, $optParams = [])
|
---|
| 336 | {
|
---|
| 337 | $params = ['database' => $database, 'postBody' => $postBody];
|
---|
| 338 | $params = array_merge($params, $optParams);
|
---|
| 339 | return $this->call('updateDdl', [$params], Operation::class);
|
---|
| 340 | }
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 344 | class_alias(ProjectsInstancesDatabases::class, 'Google_Service_Spanner_Resource_ProjectsInstancesDatabases');
|
---|