Class: Fog::AWS::Compute::SecurityGroup

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

Instance Attribute Summary

Attributes inherited from Model

#connection

Instance Method Summary collapse

Methods inherited from Model

#collection, #initialize, #inspect, #reload, #to_json, #wait_for

Methods included from Fog::Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#authorize_group_and_owner(group, owner) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/fog/aws/models/compute/security_group.rb', line 15

def authorize_group_and_owner(group, owner)
  requires :name

  connection.authorize_security_group_ingress(
    'GroupName'                   => @name,
    'SourceSecurityGroupName'     => group,
    'SourceSecurityGroupOwnerId'  => owner
  )
end

#authorize_port_range(range, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/aws/models/compute/security_group.rb', line 25

def authorize_port_range(range, options = {})
  requires :name

  connection.authorize_security_group_ingress(
    'CidrIp'      => options[:cidr_ip] || '0.0.0.0/0',
    'FromPort'    => range.min,
    'GroupName'   => @name,
    'ToPort'      => range.max,
    'IpProtocol'  => options[:ip_protocol] || 'tcp'
  )
end

#destroyObject



37
38
39
40
41
42
# File 'lib/fog/aws/models/compute/security_group.rb', line 37

def destroy
  requires :name

  connection.delete_security_group(@name)
  true
end

#revoke_group_and_owner(group, owner) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/fog/aws/models/compute/security_group.rb', line 44

def revoke_group_and_owner(group, owner)
  requires :name

  connection.revoke_security_group_ingress(
    'GroupName'                   => @name,
    'SourceSecurityGroupName'     => group,
    'SourceSecurityGroupOwnerId'  => owner
  )
end

#revoke_port_range(range, options = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fog/aws/models/compute/security_group.rb', line 54

def revoke_port_range(range, options = {})
  requires :name

  connection.revoke_security_group_ingress(
    'CidrIp'      => options[:cidr_ip] || '0.0.0.0/0',
    'FromPort'    => range.min,
    'GroupName'   => @name,
    'ToPort'      => range.max,
    'IpProtocol'  => options[:ip_protocol] || 'tcp'
  )
end

#saveObject



66
67
68
69
70
71
# File 'lib/fog/aws/models/compute/security_group.rb', line 66

def save
  requires :description, :name

  data = connection.create_security_group(@name, @description).body
  true
end