Skip to content

Commit a48c4b1

Browse files
chore: add backups (via synth)
Co-authored-by: larkee <31196561+larkee@users.noreply.github.com>
1 parent 5147921 commit a48c4b1

16 files changed

+5126
-145
lines changed

β€Žgoogle/cloud/spanner_admin_database_v1/gapic/database_admin_client.pyβ€Ž

Lines changed: 929 additions & 12 deletions
Large diffs are not rendered by default.

β€Žgoogle/cloud/spanner_admin_database_v1/gapic/database_admin_client_config.pyβ€Ž

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,46 @@
5757
"retry_codes_name": "non_idempotent",
5858
"retry_params_name": "default",
5959
},
60+
"CreateBackup": {
61+
"timeout_millis": 30000,
62+
"retry_codes_name": "non_idempotent",
63+
"retry_params_name": "default",
64+
},
65+
"GetBackup": {
66+
"timeout_millis": 30000,
67+
"retry_codes_name": "idempotent",
68+
"retry_params_name": "default",
69+
},
70+
"UpdateBackup": {
71+
"timeout_millis": 30000,
72+
"retry_codes_name": "non_idempotent",
73+
"retry_params_name": "default",
74+
},
75+
"DeleteBackup": {
76+
"timeout_millis": 30000,
77+
"retry_codes_name": "idempotent",
78+
"retry_params_name": "default",
79+
},
80+
"ListBackups": {
81+
"timeout_millis": 30000,
82+
"retry_codes_name": "idempotent",
83+
"retry_params_name": "default",
84+
},
85+
"RestoreDatabase": {
86+
"timeout_millis": 30000,
87+
"retry_codes_name": "non_idempotent",
88+
"retry_params_name": "default",
89+
},
90+
"ListDatabaseOperations": {
91+
"timeout_millis": 30000,
92+
"retry_codes_name": "idempotent",
93+
"retry_params_name": "default",
94+
},
95+
"ListBackupOperations": {
96+
"timeout_millis": 30000,
97+
"retry_codes_name": "idempotent",
98+
"retry_params_name": "default",
99+
},
60100
"ListDatabases": {
61101
"timeout_millis": 60000,
62102
"retry_codes_name": "idempotent",

β€Žgoogle/cloud/spanner_admin_database_v1/gapic/enums.pyβ€Ž

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,36 @@
1919
import enum
2020

2121

22+
class RestoreSourceType(enum.IntEnum):
23+
"""
24+
Indicates the type of the restore source.
25+
26+
Attributes:
27+
TYPE_UNSPECIFIED (int): No restore associated.
28+
BACKUP (int): A backup was used as the source of the restore.
29+
"""
30+
31+
TYPE_UNSPECIFIED = 0
32+
BACKUP = 1
33+
34+
35+
class Backup(object):
36+
class State(enum.IntEnum):
37+
"""
38+
Indicates the current state of the backup.
39+
40+
Attributes:
41+
STATE_UNSPECIFIED (int): Not specified.
42+
CREATING (int): The pending backup is still being created. Operations on the backup may
43+
fail with ``FAILED_PRECONDITION`` in this state.
44+
READY (int): The backup is complete and ready for use.
45+
"""
46+
47+
STATE_UNSPECIFIED = 0
48+
CREATING = 1
49+
READY = 2
50+
51+
2252
class Database(object):
2353
class State(enum.IntEnum):
2454
"""
@@ -29,8 +59,16 @@ class State(enum.IntEnum):
2959
CREATING (int): The database is still being created. Operations on the database may fail
3060
with ``FAILED_PRECONDITION`` in this state.
3161
READY (int): The database is fully created and ready for use.
62+
READY_OPTIMIZING (int): The database is fully created and ready for use, but is still being
63+
optimized for performance and cannot handle full load.
64+
65+
In this state, the database still references the backup it was restore
66+
from, preventing the backup from being deleted. When optimizations are
67+
complete, the full performance of the database will be restored, and the
68+
database will transition to ``READY`` state.
3269
"""
3370

3471
STATE_UNSPECIFIED = 0
3572
CREATING = 1
3673
READY = 2
74+
READY_OPTIMIZING = 3

β€Žgoogle/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.pyβ€Ž

Lines changed: 156 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ def update_database_ddl(self):
173173
def drop_database(self):
174174
"""Return the gRPC stub for :meth:`DatabaseAdminClient.drop_database`.
175175
176-
Drops (aka deletes) a Cloud Spanner database.
176+
Drops (aka deletes) a Cloud Spanner database. Completed backups for the
177+
database will be retained according to their ``expire_time``.
177178
178179
Returns:
179180
Callable: A callable which accepts the appropriate
@@ -201,11 +202,12 @@ def get_database_ddl(self):
201202
def set_iam_policy(self):
202203
"""Return the gRPC stub for :meth:`DatabaseAdminClient.set_iam_policy`.
203204
204-
Sets the access control policy on a database resource. Replaces any
205-
existing policy.
205+
Sets the access control policy on a database or backup resource.
206+
Replaces any existing policy.
206207
207208
Authorization requires ``spanner.databases.setIamPolicy`` permission on
208-
``resource``.
209+
``resource``. For backups, authorization requires
210+
``spanner.backups.setIamPolicy`` permission on ``resource``.
209211
210212
Returns:
211213
Callable: A callable which accepts the appropriate
@@ -218,11 +220,13 @@ def set_iam_policy(self):
218220
def get_iam_policy(self):
219221
"""Return the gRPC stub for :meth:`DatabaseAdminClient.get_iam_policy`.
220222
221-
Gets the access control policy for a database resource. Returns an empty
222-
policy if a database exists but does not have a policy set.
223+
Gets the access control policy for a database or backup resource.
224+
Returns an empty policy if a database or backup exists but does not have
225+
a policy set.
223226
224227
Authorization requires ``spanner.databases.getIamPolicy`` permission on
225-
``resource``.
228+
``resource``. For backups, authorization requires
229+
``spanner.backups.getIamPolicy`` permission on ``resource``.
226230
227231
Returns:
228232
Callable: A callable which accepts the appropriate
@@ -235,13 +239,15 @@ def get_iam_policy(self):
235239
def test_iam_permissions(self):
236240
"""Return the gRPC stub for :meth:`DatabaseAdminClient.test_iam_permissions`.
237241
238-
Returns permissions that the caller has on the specified database
239-
resource.
242+
Returns permissions that the caller has on the specified database or
243+
backup resource.
240244
241245
Attempting this RPC on a non-existent Cloud Spanner database will result
242246
in a NOT\_FOUND error if the user has ``spanner.databases.list``
243247
permission on the containing Cloud Spanner instance. Otherwise returns
244-
an empty set of permissions.
248+
an empty set of permissions. Calling this method on a backup that does
249+
not exist will result in a NOT\_FOUND error if the user has
250+
``spanner.backups.list`` permission on the containing instance.
245251
246252
Returns:
247253
Callable: A callable which accepts the appropriate
@@ -250,6 +256,146 @@ def test_iam_permissions(self):
250256
"""
251257
return self._stubs["database_admin_stub"].TestIamPermissions
252258

259+
@property
260+
def create_backup(self):
261+
"""Return the gRPC stub for :meth:`DatabaseAdminClient.create_backup`.
262+
263+
Starts creating a new Cloud Spanner Backup. The returned backup
264+
``long-running operation`` will have a name of the format
265+
``projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>``
266+
and can be used to track creation of the backup. The ``metadata`` field
267+
type is ``CreateBackupMetadata``. The ``response`` field type is
268+
``Backup``, if successful. Cancelling the returned operation will stop
269+
the creation and delete the backup. There can be only one pending backup
270+
creation per database. Backup creation of different databases can run
271+
concurrently.
272+
273+
Returns:
274+
Callable: A callable which accepts the appropriate
275+
deserialized request object and returns a
276+
deserialized response object.
277+
"""
278+
return self._stubs["database_admin_stub"].CreateBackup
279+
280+
@property
281+
def get_backup(self):
282+
"""Return the gRPC stub for :meth:`DatabaseAdminClient.get_backup`.
283+
284+
Gets metadata on a pending or completed ``Backup``.
285+
286+
Returns:
287+
Callable: A callable which accepts the appropriate
288+
deserialized request object and returns a
289+
deserialized response object.
290+
"""
291+
return self._stubs["database_admin_stub"].GetBackup
292+
293+
@property
294+
def update_backup(self):
295+
"""Return the gRPC stub for :meth:`DatabaseAdminClient.update_backup`.
296+
297+
Updates a pending or completed ``Backup``.
298+
299+
Returns:
300+
Callable: A callable which accepts the appropriate
301+
deserialized request object and returns a
302+
deserialized response object.
303+
"""
304+
return self._stubs["database_admin_stub"].UpdateBackup
305+
306+
@property
307+
def delete_backup(self):
308+
"""Return the gRPC stub for :meth:`DatabaseAdminClient.delete_backup`.
309+
310+
Deletes a pending or completed ``Backup``.
311+
312+
Returns:
313+
Callable: A callable which accepts the appropriate
314+
deserialized request object and returns a
315+
deserialized response object.
316+
"""
317+
return self._stubs["database_admin_stub"].DeleteBackup
318+
319+
@property
320+
def list_backups(self):
321+
"""Return the gRPC stub for :meth:`DatabaseAdminClient.list_backups`.
322+
323+
Lists completed and pending backups. Backups returned are ordered by
324+
``create_time`` in descending order, starting from the most recent
325+
``create_time``.
326+
327+
Returns:
328+
Callable: A callable which accepts the appropriate
329+
deserialized request object and returns a
330+
deserialized response object.
331+
"""
332+
return self._stubs["database_admin_stub"].ListBackups
333+
334+
@property
335+
def restore_database(self):
336+
"""Return the gRPC stub for :meth:`DatabaseAdminClient.restore_database`.
337+
338+
Create a new database by restoring from a completed backup. The new
339+
database must be in the same project and in an instance with the same
340+
instance configuration as the instance containing the backup. The
341+
returned database ``long-running operation`` has a name of the format
342+
``projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>``,
343+
and can be used to track the progress of the operation, and to cancel
344+
it. The ``metadata`` field type is ``RestoreDatabaseMetadata``. The
345+
``response`` type is ``Database``, if successful. Cancelling the
346+
returned operation will stop the restore and delete the database. There
347+
can be only one database being restored into an instance at a time. Once
348+
the restore operation completes, a new restore operation can be
349+
initiated, without waiting for the optimize operation associated with
350+
the first restore to complete.
351+
352+
Returns:
353+
Callable: A callable which accepts the appropriate
354+
deserialized request object and returns a
355+
deserialized response object.
356+
"""
357+
return self._stubs["database_admin_stub"].RestoreDatabase
358+
359+
@property
360+
def list_database_operations(self):
361+
"""Return the gRPC stub for :meth:`DatabaseAdminClient.list_database_operations`.
362+
363+
Lists database ``longrunning-operations``. A database operation has a
364+
name of the form
365+
``projects/<project>/instances/<instance>/databases/<database>/operations/<operation>``.
366+
The long-running operation ``metadata`` field type ``metadata.type_url``
367+
describes the type of the metadata. Operations returned include those
368+
that have completed/failed/canceled within the last 7 days, and pending
369+
operations.
370+
371+
Returns:
372+
Callable: A callable which accepts the appropriate
373+
deserialized request object and returns a
374+
deserialized response object.
375+
"""
376+
return self._stubs["database_admin_stub"].ListDatabaseOperations
377+
378+
@property
379+
def list_backup_operations(self):
380+
"""Return the gRPC stub for :meth:`DatabaseAdminClient.list_backup_operations`.
381+
382+
Lists the backup ``long-running operations`` in the given instance. A
383+
backup operation has a name of the form
384+
``projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>``.
385+
The long-running operation ``metadata`` field type ``metadata.type_url``
386+
describes the type of the metadata. Operations returned include those
387+
that have completed/failed/canceled within the last 7 days, and pending
388+
operations. Operations returned are ordered by
389+
``operation.metadata.value.progress.start_time`` in descending order
390+
starting from the most recently started operation.
391+
392+
Returns:
393+
Callable: A callable which accepts the appropriate
394+
deserialized request object and returns a
395+
deserialized response object.
396+
"""
397+
return self._stubs["database_admin_stub"].ListBackupOperations
398+
253399
@property
254400
def list_databases(self):
255401
"""Return the gRPC stub for :meth:`DatabaseAdminClient.list_databases`.

0 commit comments

Comments
 (0)