Sha256: 4f417b056bdf1483401a1f2b9ce6101049916a1cdde5d773b9cab7bdc29070cc

Contents?: true

Size: 1.99 KB

Versions: 22

Compression:

Stored size: 1.99 KB

Contents

# frozen_string_literal: true

require 'fog/core/model'

module Fog
  module Compute
    class Aliyun
      class SecurityGroupRule < Fog::Model
        attribute :security_group_id, aliases: 'SecurityGroupId'
        attribute :source_cidr_ip, aliases: 'SourceCidrIp'
        attribute :source_owner, aliases: 'SourceGroupOwnerAccount'
        attribute :source_group_id, aliases: 'SourceGroupId'
        attribute :ip_protocol, aliases: 'IpProtocol'
        attribute :dest_cidr_ip, aliases: 'DestCidrIp'
        attribute :dest_owner, aliases: 'DestGroupOwnerAccount'
        attribute :dest_group_id, aliases: 'DestGroupId'
        attribute :nic_type, aliases: 'NicType'
        attribute :policy, aliases: 'Policy'
        attribute :port_range, aliases: 'PortRange'
        attribute :direction, aliases: 'Direction'
        attribute :priority, aliases: 'Priority'

        def save
          requires :security_group_id, :ip_protocol, :port_range, :direction
          options = {}
          options[:portRange] = port_range if port_range
          options[:policy] = policy if policy
          options[:priority] = priority if port_range
          options[:protocol] = ip_protocol if ip_protocol
          if direction == 'egress'
            if dest_cidr_ip
              service.create_security_group_egress_ip_rule(security_group_id, dest_cidr_ip, nic_type, options)
            elsif dest_group_id
              options[:destGroupOwnerAccount] = dest_owner if dest_owner
              service.create_security_group_egress_sg_rule(security_group_id, dest_group_id, options)
            end
          else
            if source_cidr_ip
              service.create_security_group_ip_rule(security_group_id, source_cidr_ip, nic_type, options)
            elsif source_group_id
              options[:sourceGroupOwnerAccount] = source_owner if source_owner
              service.create_security_group_sg_rule(security_group_id, source_group_id, options)
            end
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 20 versions & 2 rubygems

Version Path
fog-aliyun-0.4.0 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.19 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.18 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.17 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.16 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.15 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.13 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.12 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.11 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.10 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.9 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.8 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.7 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.6 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.5 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.4 lib/fog/aliyun/models/compute/security_group_rule.rb
fog-aliyun-0.3.3 lib/fog/aliyun/models/compute/security_group_rule.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/security_group_rule.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/security_group_rule.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/compute/security_group_rule.rb