Sha256: 44379d576b8d06f912865bf236f44732849c5ab8be3c206c9c52fff85f76405f

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'fog/core/model'

module Fog
  module OracleCloud
    class Database
      class AccessRule < Fog::Model
        identity  :ruleName

        attribute :destination
        attribute :description
        attribute :ports
        attribute :source
        attribute :status

        attribute :database_id
       
        def save
          create
        end

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

        # Had to override reload 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 :ruleName, :database_id, :source 
          service.create_access_rule(database_id, ruleName, description, ports, source, destination || 'DB', status || 'enabled')
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-oraclecloud-0.1.17 lib/fog/oraclecloud/models/database/access_rule.rb
fog-oraclecloud-0.1.16 lib/fog/oraclecloud/models/database/access_rule.rb