Class: AWS::EC2::NetworkInterface::Attachment

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/ec2/network_interface/attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(network_interface, details) ⇒ Attachment

Returns a new instance of Attachment.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/aws/ec2/network_interface/attachment.rb', line 21

def initialize network_interface, details
  @network_interface = network_interface
  @attachment_id = details[:attachment_id]
  @instance = Instance.new(details[:instance_id],
    :owner_id => details[:instance_owner_id],
    :config => network_interface.config)
  @instance_owner_id = details[:instance_owner_id]
  @device_index = details[:device_index]
  @status = details[:status].to_sym
  @attach_time = details[:attach_time]
  @delete_on_termination = details[:delete_on_termination]
end

Instance Attribute Details

#attach_timeTime (readonly)

Returns:

  • (Time)


58
59
60
# File 'lib/aws/ec2/network_interface/attachment.rb', line 58

def attach_time
  @attach_time
end

#attachment_idString (readonly) Also known as: id

Returns the attachment id.

Returns:

  • (String)

    Returns the attachment id.



35
36
37
# File 'lib/aws/ec2/network_interface/attachment.rb', line 35

def attachment_id
  @attachment_id
end

#delete_on_terminationBoolean Also known as: delete_on_termination?

Returns:

  • (Boolean)


61
62
63
# File 'lib/aws/ec2/network_interface/attachment.rb', line 61

def delete_on_termination
  @delete_on_termination
end

#device_indexInteger (readonly)

Returns The index of the device for the network interface attachment on the instance.

Returns:

  • (Integer)

    The index of the device for the network interface attachment on the instance.



52
53
54
# File 'lib/aws/ec2/network_interface/attachment.rb', line 52

def device_index
  @device_index
end

#instanceInstance (readonly)

Returns the instance the network interface is attached to.

Returns:

  • (Instance)

    Returns the instance the network interface is attached to.



45
46
47
# File 'lib/aws/ec2/network_interface/attachment.rb', line 45

def instance
  @instance
end

#instance_owner_idString (readonly)

Returns the instance owner id.

Returns:

  • (String)

    Returns the instance owner id.



48
49
50
# File 'lib/aws/ec2/network_interface/attachment.rb', line 48

def instance_owner_id
  @instance_owner_id
end

#network_interfaceNetworkInterface (readonly)

Returns the network interface this is an attachment for.

Returns:

  • (NetworkInterface)

    Returns the network interface this is an attachment for.



41
42
43
# File 'lib/aws/ec2/network_interface/attachment.rb', line 41

def network_interface
  @network_interface
end

#statusSymbol (readonly)

Returns the attachment status.

Returns:

  • (Symbol)

    Returns the attachment status.



55
56
57
# File 'lib/aws/ec2/network_interface/attachment.rb', line 55

def status
  @status
end

Instance Method Details

#detach(options = {}) ⇒ nil Also known as: delete

Detaches the network interface from the instance.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :force (Boolean) — default: false

    Set true to force a detachment.

Returns:

  • (nil)


89
90
91
92
93
94
# File 'lib/aws/ec2/network_interface/attachment.rb', line 89

def detach options = {}
  client_opts = {}
  client_opts[:attachment_id] = attachment_id
  client_opts[:force] = options[:force] == true
  network_interface.client.detach_network_interface(client_opts)
end