Sha256: fb9bd6e3048f0a4baf056aa1b5aa759cecb7681b4e0f808c19827be4abbeabaa

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 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
        attribute :end_ip
        attribute :server_name

        def self.parse(firewall)
          {
            id: firewall['id'],
            type: firewall['type'],
            name: firewall['name'],
            location: firewall['location'],
            resource_group: get_resource_group_from_id(firewall['id']),
            server_name: get_server_name_from_id(firewall['id']),
            start_ip: firewall['properties']['startIpAddress'],
            end_ip: firewall['properties']['endIpAddress']
          }
        end

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

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

        private

        def 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

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.1.0 lib/fog/azurerm/models/sql/firewall_rule.rb