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\Spanner\Resource;
19
20use Google\Service\Spanner\Backup;
21use Google\Service\Spanner\CopyBackupRequest;
22use Google\Service\Spanner\GetIamPolicyRequest;
23use Google\Service\Spanner\ListBackupsResponse;
24use Google\Service\Spanner\Operation;
25use Google\Service\Spanner\Policy;
26use Google\Service\Spanner\SetIamPolicyRequest;
27use Google\Service\Spanner\SpannerEmpty;
28use Google\Service\Spanner\TestIamPermissionsRequest;
29use Google\Service\Spanner\TestIamPermissionsResponse;
30
31/**
32 * The "backups" collection of methods.
33 * Typical usage is:
34 *  <code>
35 *   $spannerService = new Google\Service\Spanner(...);
36 *   $backups = $spannerService->backups;
37 *  </code>
38 */
39class ProjectsInstancesBackups extends \Google\Service\Resource
40{
41  /**
42   * Starts copying a Cloud Spanner Backup. The returned backup long-running
43   * operation will have a name of the format
44   * `projects//instances//backups//operations/` and can be used to track copying
45   * of the backup. The operation is associated with the destination backup. The
46   * metadata field type is CopyBackupMetadata. The response field type is Backup,
47   * if successful. Cancelling the returned operation will stop the copying and
48   * delete the backup. Concurrent CopyBackup requests can run on the same source
49   * backup. (backups.copy)
50   *
51   * @param string $parent Required. The name of the destination instance that
52   * will contain the backup copy. Values are of the form: `projects//instances/`.
53   * @param CopyBackupRequest $postBody
54   * @param array $optParams Optional parameters.
55   * @return Operation
56   */
57  public function copy($parent, CopyBackupRequest $postBody, $optParams = [])
58  {
59    $params = ['parent' => $parent, 'postBody' => $postBody];
60    $params = array_merge($params, $optParams);
61    return $this->call('copy', [$params], Operation::class);
62  }
63  /**
64   * Starts creating a new Cloud Spanner Backup. The returned backup long-running
65   * operation will have a name of the format
66   * `projects//instances//backups//operations/` and can be used to track creation
67   * of the backup. The metadata field type is CreateBackupMetadata. The response
68   * field type is Backup, if successful. Cancelling the returned operation will
69   * stop the creation and delete the backup. There can be only one pending backup
70   * creation per database. Backup creation of different databases can run
71   * concurrently. (backups.create)
72   *
73   * @param string $parent Required. The name of the instance in which the backup
74   * will be created. This must be the same instance that contains the database
75   * the backup will be created from. The backup will be stored in the location(s)
76   * specified in the instance configuration of this instance. Values are of the
77   * form `projects//instances/`.
78   * @param Backup $postBody
79   * @param array $optParams Optional parameters.
80   *
81   * @opt_param string backupId Required. The id of the backup to be created. The
82   * `backup_id` appended to `parent` forms the full backup name of the form
83   * `projects//instances//backups/`.
84   * @opt_param string encryptionConfig.encryptionType Required. The encryption
85   * type of the backup.
86   * @opt_param string encryptionConfig.kmsKeyName Optional. The Cloud KMS key
87   * that will be used to protect the backup. This field should be set only when
88   * encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form
89   * `projects//locations//keyRings//cryptoKeys/`.
90   * @return Operation
91   */
92  public function create($parent, Backup $postBody, $optParams = [])
93  {
94    $params = ['parent' => $parent, 'postBody' => $postBody];
95    $params = array_merge($params, $optParams);
96    return $this->call('create', [$params], Operation::class);
97  }
98  /**
99   * Deletes a pending or completed Backup. (backups.delete)
100   *
101   * @param string $name Required. Name of the backup to delete. Values are of the
102   * form `projects//instances//backups/`.
103   * @param array $optParams Optional parameters.
104   * @return SpannerEmpty
105   */
106  public function delete($name, $optParams = [])
107  {
108    $params = ['name' => $name];
109    $params = array_merge($params, $optParams);
110    return $this->call('delete', [$params], SpannerEmpty::class);
111  }
112  /**
113   * Gets metadata on a pending or completed Backup. (backups.get)
114   *
115   * @param string $name Required. Name of the backup. Values are of the form
116   * `projects//instances//backups/`.
117   * @param array $optParams Optional parameters.
118   * @return Backup
119   */
120  public function get($name, $optParams = [])
121  {
122    $params = ['name' => $name];
123    $params = array_merge($params, $optParams);
124    return $this->call('get', [$params], Backup::class);
125  }
126  /**
127   * Gets the access control policy for a database or backup resource. Returns an
128   * empty policy if a database or backup exists but does not have a policy set.
129   * Authorization requires `spanner.databases.getIamPolicy` permission on
130   * resource. For backups, authorization requires `spanner.backups.getIamPolicy`
131   * permission on resource. (backups.getIamPolicy)
132   *
133   * @param string $resource REQUIRED: The Cloud Spanner resource for which the
134   * policy is being retrieved. The format is `projects//instances/` for instance
135   * resources and `projects//instances//databases/` for database resources.
136   * @param GetIamPolicyRequest $postBody
137   * @param array $optParams Optional parameters.
138   * @return Policy
139   */
140  public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
141  {
142    $params = ['resource' => $resource, 'postBody' => $postBody];
143    $params = array_merge($params, $optParams);
144    return $this->call('getIamPolicy', [$params], Policy::class);
145  }
146  /**
147   * Lists completed and pending backups. Backups returned are ordered by
148   * `create_time` in descending order, starting from the most recent
149   * `create_time`. (backups.listProjectsInstancesBackups)
150   *
151   * @param string $parent Required. The instance to list backups from. Values are
152   * of the form `projects//instances/`.
153   * @param array $optParams Optional parameters.
154   *
155   * @opt_param string filter An expression that filters the list of returned
156   * backups. A filter expression consists of a field name, a comparison operator,
157   * and a value for filtering. The value must be a string, a number, or a
158   * boolean. The comparison operator must be one of: `<`, `>`, `<=`, `>=`, `!=`,
159   * `=`, or `:`. Colon `:` is the contains operator. Filter rules are not case
160   * sensitive. The following fields in the Backup are eligible for filtering: *
161   * `name` * `database` * `state` * `create_time` (and values are of the format
162   * YYYY-MM-DDTHH:MM:SSZ) * `expire_time` (and values are of the format YYYY-MM-
163   * DDTHH:MM:SSZ) * `version_time` (and values are of the format YYYY-MM-
164   * DDTHH:MM:SSZ) * `size_bytes` You can combine multiple expressions by
165   * enclosing each expression in parentheses. By default, expressions are
166   * combined with AND logic, but you can specify AND, OR, and NOT logic
167   * explicitly. Here are a few examples: * `name:Howl` - The backup's name
168   * contains the string "howl". * `database:prod` - The database's name contains
169   * the string "prod". * `state:CREATING` - The backup is pending creation. *
170   * `state:READY` - The backup is fully created and ready for use. * `(name:howl)
171   * AND (create_time < \"2018-03-28T14:50:00Z\")` - The backup name contains the
172   * string "howl" and `create_time` of the backup is before 2018-03-28T14:50:00Z.
173   * * `expire_time < \"2018-03-28T14:50:00Z\"` - The backup `expire_time` is
174   * before 2018-03-28T14:50:00Z. * `size_bytes > 10000000000` - The backup's size
175   * is greater than 10GB
176   * @opt_param int pageSize Number of backups to be returned in the response. If
177   * 0 or less, defaults to the server's maximum allowed page size.
178   * @opt_param string pageToken If non-empty, `page_token` should contain a
179   * next_page_token from a previous ListBackupsResponse to the same `parent` and
180   * with the same `filter`.
181   * @return ListBackupsResponse
182   */
183  public function listProjectsInstancesBackups($parent, $optParams = [])
184  {
185    $params = ['parent' => $parent];
186    $params = array_merge($params, $optParams);
187    return $this->call('list', [$params], ListBackupsResponse::class);
188  }
189  /**
190   * Updates a pending or completed Backup. (backups.patch)
191   *
192   * @param string $name Output only for the CreateBackup operation. Required for
193   * the UpdateBackup operation. A globally unique identifier for the backup which
194   * cannot be changed. Values are of the form
195   * `projects//instances//backups/a-z*[a-z0-9]` The final segment of the name
196   * must be between 2 and 60 characters in length. The backup is stored in the
197   * location(s) specified in the instance configuration of the instance
198   * containing the backup, identified by the prefix of the backup name of the
199   * form `projects//instances/`.
200   * @param Backup $postBody
201   * @param array $optParams Optional parameters.
202   *
203   * @opt_param string updateMask Required. A mask specifying which fields (e.g.
204   * `expire_time`) in the Backup resource should be updated. This mask is
205   * relative to the Backup resource, not to the request message. The field mask
206   * must always be specified; this prevents any future fields from being erased
207   * accidentally by clients that do not know about them.
208   * @return Backup
209   */
210  public function patch($name, Backup $postBody, $optParams = [])
211  {
212    $params = ['name' => $name, 'postBody' => $postBody];
213    $params = array_merge($params, $optParams);
214    return $this->call('patch', [$params], Backup::class);
215  }
216  /**
217   * Sets the access control policy on a database or backup resource. Replaces any
218   * existing policy. Authorization requires `spanner.databases.setIamPolicy`
219   * permission on resource. For backups, authorization requires
220   * `spanner.backups.setIamPolicy` permission on resource. (backups.setIamPolicy)
221   *
222   * @param string $resource REQUIRED: The Cloud Spanner resource for which the
223   * policy is being set. The format is `projects//instances/` for instance
224   * resources and `projects//instances//databases/` for databases resources.
225   * @param SetIamPolicyRequest $postBody
226   * @param array $optParams Optional parameters.
227   * @return Policy
228   */
229  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
230  {
231    $params = ['resource' => $resource, 'postBody' => $postBody];
232    $params = array_merge($params, $optParams);
233    return $this->call('setIamPolicy', [$params], Policy::class);
234  }
235  /**
236   * Returns permissions that the caller has on the specified database or backup
237   * resource. Attempting this RPC on a non-existent Cloud Spanner database will
238   * result in a NOT_FOUND error if the user has `spanner.databases.list`
239   * permission on the containing Cloud Spanner instance. Otherwise returns an
240   * empty set of permissions. Calling this method on a backup that does not exist
241   * will result in a NOT_FOUND error if the user has `spanner.backups.list`
242   * permission on the containing instance. (backups.testIamPermissions)
243   *
244   * @param string $resource REQUIRED: The Cloud Spanner resource for which
245   * permissions are being tested. The format is `projects//instances/` for
246   * instance resources and `projects//instances//databases/` for database
247   * resources.
248   * @param TestIamPermissionsRequest $postBody
249   * @param array $optParams Optional parameters.
250   * @return TestIamPermissionsResponse
251   */
252  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
253  {
254    $params = ['resource' => $resource, 'postBody' => $postBody];
255    $params = array_merge($params, $optParams);
256    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
257  }
258}
259
260// Adding a class alias for backwards compatibility with the previous class name.
261class_alias(ProjectsInstancesBackups::class, 'Google_Service_Spanner_Resource_ProjectsInstancesBackups');
262