Sha256: 83e871278c136c52799e37c86134e8c5e4615e7bc9b9450af1d28a81758a4b5e

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

require 'fog/core/model'

module Fog
  module OracleCloud
    class Database
      class Snapshot < Fog::Model
        identity  :name

        attribute :cloned_services_size,  :aliases=>'clonedServicesSize'
        attribute :creation_time,  :aliases=>'creationTime'
        attribute :cloned_services,  :aliases=>'clonedServices'
        attribute :status
        attribute :description

        attribute :database_id
       
        def completed?
          status == "Succeeded"
        end

        def deleting?
          status == "Terminating"
        end
 
        def save
          create
        end

        def destroy
          requires :name, :database_id
          service.delete_snapshot(database_id, name).body
        end

        # Had to override snapshot as we need to pass the database_id
        def reload
          requires :identity, :database_id

          data = begin
            collection.get(database_id, identity)
          rescue Excon::Errors::SocketError
            nil
          end

          return unless data

          new_attributes = data.attributes
          merge_attributes(new_attributes)
          self
        end

        private

        def create
          requires :name, :description, :database_id 
          data = service.create_snapshot(name, description, database_id)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fog-oraclecloud-0.1.17 lib/fog/oraclecloud/models/database/snapshot.rb
fog-oraclecloud-0.1.16 lib/fog/oraclecloud/models/database/snapshot.rb
fog-oraclecloud-0.1.15 lib/fog/oraclecloud/models/database/snapshot.rb
fog-oraclecloud-0.1.14 lib/fog/oraclecloud/models/database/snapshot.rb
fog-oraclecloud-0.1.13 lib/fog/oraclecloud/models/database/snapshot.rb