You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: Aws::EC2::InternetGateway

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb

Defined Under Namespace

Classes: Collection

Actions collapse

Read-Only Attributes collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, options = {}) ⇒ InternetGateway #initialize(options = {}) ⇒ InternetGateway

Returns a new instance of InternetGateway

Overloads:

  • #initialize(id, options = {}) ⇒ InternetGateway

    Parameters:

    • id (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ InternetGateway

    Options Hash (options):

    • :id (required, String)
    • :client (Client)


19
20
21
22
23
24
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 19

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @id = extract_id(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
end

Instance Method Details

#attach_to_vpc(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


internet_gateway.attach_to_vpc({
  dry_run: false,
  vpc_id: "String", # required
})

Parameters:

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

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :vpc_id (required, String)

    The ID of the VPC.

Returns:

  • (EmptyStructure)


98
99
100
101
102
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 98

def attach_to_vpc(options = {})
  options = options.merge(internet_gateway_id: @id)
  resp = @client.attach_internet_gateway(options)
  resp.data
end

#attachmentsArray<Types::InternetGatewayAttachment>

Any VPCs attached to the Internet gateway.



36
37
38
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 36

def attachments
  data.attachments
end

#clientClient

Returns:



49
50
51
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 49

def client
  @client
end

#create_tags(options = {}) ⇒ Tag::Collection

Examples:

Request syntax with placeholder values


tag = internet_gateway.create_tags({
  dry_run: false,
  tags: [ # required
    {
      key: "String",
      value: "String",
    },
  ],
})

Parameters:

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

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :tags (required, Array<Types::Tag>)

    One or more tags. The value parameter is required, but if you don't want the tag to have a value, specify the parameter with no value, and we set the value to an empty string.

Returns:



126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 126

def create_tags(options = {})
  batch = []
  options = Aws::Util.deep_merge(options, resources: [@id])
  resp = @client.create_tags(options)
  options[:tags].each do |t|
    batch << Tag.new(
      resource_id: @id,
      key: t[:key],
      value: t[:value],
      client: @client
    )
  end
  Tag::Collection.new([batch], size: batch.size)
end

#dataTypes::InternetGateway

Returns the data for this Aws::EC2::InternetGateway. Calls Client#describe_internet_gateways if #data_loaded? is false.

Returns:



69
70
71
72
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 69

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



77
78
79
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 77

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


internet_gateway.delete({
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Returns:

  • (EmptyStructure)


153
154
155
156
157
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 153

def delete(options = {})
  options = options.merge(internet_gateway_id: @id)
  resp = @client.delete_internet_gateway(options)
  resp.data
end

#detach_from_vpc(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


internet_gateway.detach_from_vpc({
  dry_run: false,
  vpc_id: "String", # required
})

Parameters:

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

    ({})

Options Hash (options):

  • :dry_run (Boolean)

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • :vpc_id (required, String)

    The ID of the VPC.

Returns:

  • (EmptyStructure)


174
175
176
177
178
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 174

def detach_from_vpc(options = {})
  options = options.merge(internet_gateway_id: @id)
  resp = @client.detach_internet_gateway(options)
  resp.data
end

#idString Also known as: internet_gateway_id

Returns:

  • (String)


29
30
31
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 29

def id
  @id
end

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::EC2::InternetGateway. Returns self making it possible to chain methods.

internet_gateway.reload.data

Returns:

  • (self)


59
60
61
62
63
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 59

def load
  resp = @client.describe_internet_gateways(internet_gateway_ids: [@id])
  @data = resp.internet_gateways[0]
  self
end

#tagsArray<Types::Tag>

Any tags assigned to the Internet gateway.

Returns:



42
43
44
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/internet_gateway.rb', line 42

def tags
  data.tags
end