Class: Fog::Compute::Aliyun::SecurityGroup

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aliyun/models/compute/security_group.rb

Instance Method Summary collapse

Instance Method Details

#authorize_security_group_ip_rule(cidr_ip, direction = 'ingress', options = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/fog/aliyun/models/compute/security_group.rb', line 49

def authorize_security_group_ip_rule(cidr_ip, direction = 'ingress', options = {})
  requires :id
  nic_type = options.fetch(:nic_type, 'internet')
  if direction == 'egress'
    service.create_security_group_egress_ip_rule(id, cidr_ip, nic_type, options)
  else
    service.create_security_group_ip_rule(id, cidr_ip, nic_type, options)
  end
  true
end

#authorize_security_group_sg_rule(group_id, direction = 'ingress', options = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/fog/aliyun/models/compute/security_group.rb', line 39

def authorize_security_group_sg_rule(group_id, direction = 'ingress', options = {})
  requires :id
  if direction == 'egress'
    service.create_security_group_egress_sg_rule(id, group_id, options)
  else
    service.create_security_group_sg_rule(id, group_id, options)
  end
  true
end

#destroyObject



33
34
35
36
37
# File 'lib/fog/aliyun/models/compute/security_group.rb', line 33

def destroy
  requires :id
  service.delete_security_group(id)
  true
end

#revoke_security_group_ip_rule(cidr_ip, direction = 'ingress', options = {}) ⇒ Object



70
71
72
73
74
75
76
77
78
79
# File 'lib/fog/aliyun/models/compute/security_group.rb', line 70

def revoke_security_group_ip_rule(cidr_ip, direction = 'ingress', options = {})
  requires :id
  nic_type = options.fetch(:nic_type, 'internet')
  if direction == 'egress'
    service.delete_security_group_egress_ip_rule(id, cidr_ip, nic_type, options)
  else
    service.delete_security_group_ip_rule(id, cidr_ip, nic_type, options)
  end
  true
end

#revoke_seurity_group_sg_rule(group_id, direction = 'ingress', options = {}) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/fog/aliyun/models/compute/security_group.rb', line 60

def revoke_seurity_group_sg_rule(group_id, direction = 'ingress', options = {})
  requires :id
  if direction == 'egress'
    service.delete_security_group_egress_sg_rule(id, group_id, options)
  else
    service.delete_security_group_sg_rule(id, group_id, options)
  end
  true
end

#save(options = {}) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/fog/aliyun/models/compute/security_group.rb', line 25

def save(options = {})
  options[:vpcId] = vpc_id if vpc_id
  options[:name] = name if name
  options[:description] = description if description
  Fog::JSON.decode(service.create_security_group(options).body)
  true
end

#security_group_rulesObject



20
21
22
23
# File 'lib/fog/aliyun/models/compute/security_group.rb', line 20

def security_group_rules
  requires :id
  service.security_group_rules.get(id)
end

#vpcObject



15
16
17
18
# File 'lib/fog/aliyun/models/compute/security_group.rb', line 15

def vpc
  requires :vpc_id
  service.vpcs.get(vpc_id)
end