Class: Google::Cloud::Spanner::Backup::Restore::Job Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/spanner/backup/restore/job.rb

Overview

Deprecated.

Use the long-running operation returned by Admin::Database.database_admin.restore_database instead.

Job

A resource representing the long-running, asynchronous processing of a backup restore. The job can be refreshed to retrieve the restored database object once the operation has been completed.

See Google::Cloud::Spanner::Backup#restore

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false
job.reload! # API call
job.done? #=> true

if job.error?
  status = job.error
else
  database = job.database
end

See Also:

Instance Method Summary collapse

Instance Method Details

#databaseDatabase?

The database is the object of the operation.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false
job.reload!
job.done? #=> true
database = job.database

Returns:

  • (Database, nil)

    The database instance, or nil if the operation is not complete.



96
97
98
99
100
# File 'lib/google/cloud/spanner/backup/restore/job.rb', line 96

def database
  return nil unless done?
  return nil unless @grpc.grpc_op.result == :response
  Database.from_grpc @grpc.results, service
end

#done?boolean

Checks if the processing of the restore operation is complete.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false

Returns:

  • (boolean)

    true when complete, false otherwise.



118
119
120
# File 'lib/google/cloud/spanner/backup/restore/job.rb', line 118

def done?
  @grpc.done?
end

#end_timeTime?

The operation end time.

Returns:

  • (Time, nil)


234
235
236
237
# File 'lib/google/cloud/spanner/backup/restore/job.rb', line 234

def end_time
  return nil unless @grpc..progress.end_time
  Convert.timestamp_to_time @grpc..progress.end_time
end

#errorGoogle::Cloud::Spanner::Status?

The status if the operation associated with this job produced an error.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.error? # true

error = job.error

Returns:



162
163
164
165
# File 'lib/google/cloud/spanner/backup/restore/job.rb', line 162

def error
  return nil unless error?
  Google::Cloud::Spanner::Status.from_grpc @grpc.error
end

#error?boolean

Checks if the processing of the restore operation has errored.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.error? #=> false

Returns:

  • (boolean)

    true when errored, false otherwise.



138
139
140
# File 'lib/google/cloud/spanner/backup/restore/job.rb', line 138

def error?
  @grpc.error?
end

#progress_percentInteger

The operation progress in percentage.

Returns:

  • (Integer)


217
218
219
# File 'lib/google/cloud/spanner/backup/restore/job.rb', line 217

def progress_percent
  @grpc..progress.progress_percent
end

#reload!Backup::Job Also known as: refresh!

Reloads the job with current data from the long-running, asynchronous processing of a restore operation.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false
job.reload! # API call
job.done? #=> true

Returns:



186
187
188
189
# File 'lib/google/cloud/spanner/backup/restore/job.rb', line 186

def reload!
  @grpc.reload!
  self
end

#start_timeTime?

The operation start time.

Returns:

  • (Time, nil)


225
226
227
228
# File 'lib/google/cloud/spanner/backup/restore/job.rb', line 225

def start_time
  return nil unless @grpc..progress.start_time
  Convert.timestamp_to_time @grpc..progress.start_time
end

#wait_until_done!Object

Reloads the job until the operation is complete. The delay between reloads will incrementally increase.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

instance = spanner.instance "my-instance"
backup = instance.backup "my-backup"
job = backup.restore "my-restored-database"

job.done? #=> false
job.wait_until_done!
job.done? #=> true


209
210
211
# File 'lib/google/cloud/spanner/backup/restore/job.rb', line 209

def wait_until_done!
  @grpc.wait_until_done!
end