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

Class: Aws::EC2::DhcpOptions

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

Defined Under Namespace

Classes: Collection

Actions collapse

Read-Only Attributes collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of DhcpOptions

Overloads:

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

    Parameters:

    • id (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ DhcpOptions

    Options Hash (options):

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


19
20
21
22
23
24
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/dhcp_options.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

#associate_with_vpc(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


dhcp_options.associate_with_vpc({
  vpc_id: "String", # required
  dry_run: false,
})

Parameters:

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

    ({})

Options Hash (options):

  • :vpc_id (required, String)

    The ID of the VPC.

  • :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)


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

def associate_with_vpc(options = {})
  options = options.merge(dhcp_options_id: @id)
  resp = @client.associate_dhcp_options(options)
  resp.data
end

#clientClient

Returns:



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

def client
  @client
end

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

Examples:

Request syntax with placeholder values


tag = dhcp_options.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/dhcp_options.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::DhcpOptions

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

Returns:



69
70
71
72
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/dhcp_options.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/dhcp_options.rb', line 77

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


dhcp_options.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/dhcp_options.rb', line 153

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

#dhcp_configurationsArray<Types::DhcpConfiguration>

One or more DHCP options in the set.

Returns:



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

def dhcp_configurations
  data.dhcp_configurations
end

#idString Also known as: dhcp_options_id

Returns:

  • (String)


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

def id
  @id
end

#loadself Also known as: reload

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

dhcp_options.reload.data

Returns:

  • (self)


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

def load
  resp = @client.describe_dhcp_options(dhcp_options_ids: [@id])
  @data = resp.dhcp_options[0]
  self
end

#tagsArray<Types::Tag>

Any tags assigned to the DHCP options set.

Returns:



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

def tags
  data.tags
end