Sha256: 727e9f305587bee42322e9bf317beb2c8d6e4d199b62bfe56de111f6febbb38c

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


require "google/cloud/spanner/database/backup_info"

module Google
  module Cloud
    module Spanner
      class Database
        class RestoreInfo
          ##
          # @private Creates a new Database::RestoreInfo instance.
          def initialize grpc
            @grpc = grpc
          end

          ##
          # The database restored from source type `:BACKUP`.
          # @return [Symbol]
          def source_type
            @grpc.source_type
          end

          ##
          # Database restored from backup.
          #
          # @return [Boolean]
          def source_backup?
            @grpc.source_type == :BACKUP
          end

          # Information about the backup used to restore the database.
          # The backup may no longer exist.
          #
          # @return [Google::Cloud::Spanner::Database::BackupInfo, nil]
          def backup_info
            return nil unless @grpc.backup_info
            BackupInfo.from_grpc @grpc.backup_info
          end

          ##
          # @private Creates a new Database::RestoreInfo instance from a
          # Google::Spanner::Admin::Database::V1::RestoreInfo.
          def self.from_grpc grpc
            new grpc
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
google-cloud-spanner-1.16.2 lib/google/cloud/spanner/database/restore_info.rb
google-cloud-spanner-1.16.1 lib/google/cloud/spanner/database/restore_info.rb
google-cloud-spanner-1.16.0 lib/google/cloud/spanner/database/restore_info.rb