Sha256: 976cc016a4448a29cbaa3d942cd7315df4f9b27f3277a85bab7027898dafef8b

Contents?: true

Size: 1.34 KB

Versions: 46

Compression:

Stored size: 1.34 KB

Contents

module Fog
  module Sql
    class AzureRM
      # Sql Server model for Server Firewall Rule Service
      class FirewallRule < Fog::Model
        identity :name
        attribute :id
        attribute :type
        attribute :resource_group
        attribute :location
        attribute :start_ip, aliases: %w(startIpAddress)
        attribute :end_ip, aliases: %w(endIpAddress)
        attribute :server_name

        def self.parse(firewall)
          firewall_hash = get_hash_from_object(firewall)

          firewall_hash['resource_group'] = get_resource_group_from_id(firewall.id)
          firewall_hash['server_name'] = get_resource_from_resource_id(firewall.id, 8)

          firewall_hash
        end

        def save
          requires :resource_group, :server_name, :name, :start_ip, :end_ip
          firewall_rule = service.create_or_update_firewall_rule(format_firewall_params)
          merge_attributes(Fog::Sql::AzureRM::FirewallRule.parse(firewall_rule))
        end

        def destroy
          service.delete_firewall_rule(resource_group, server_name, name)
        end

        private

        def format_firewall_params
          {
            resource_group: resource_group,
            server_name: server_name,
            name: name,
            start_ip: start_ip,
            end_ip: end_ip
          }
        end
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 4 rubygems

Version Path
fog-azure-rm-0.6.0 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.5.3 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.5.2 lib/fog/azurerm/models/sql/firewall_rule.rb
far-gem-0.5.6 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.5.1 lib/fog/azurerm/models/sql/firewall_rule.rb
far-gem-0.5.5 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.5.0 lib/fog/azurerm/models/sql/firewall_rule.rb
far-gem-0.5.4 lib/fog/azurerm/models/sql/firewall_rule.rb
far-gem-0.5.3 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.4.9 lib/fog/azurerm/models/sql/firewall_rule.rb
far-gem-0.5.2 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.4.8 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.4.7 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.4.6 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.4.5 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-temp-0.0.5 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.4.4 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.4.3 lib/fog/azurerm/models/sql/firewall_rule.rb
far-gem-0.5.1 lib/fog/azurerm/models/sql/firewall_rule.rb
fog-azure-rm-0.4.2 lib/fog/azurerm/models/sql/firewall_rule.rb