Class: Aws::EC2::KeyPair

Inherits:
Object
  • Object
show all
Extended by:
Deprecations
Defined in:
lib/aws-sdk-ec2/key_pair.rb

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ KeyPair #initialize(options = {}) ⇒ KeyPair

Returns a new instance of KeyPair.

Overloads:

  • #initialize(name, options = {}) ⇒ KeyPair

    Parameters:

    • name (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ KeyPair

    Options Hash (options):

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


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

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

Instance Method Details

#clientClient

Returns:



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

def client
  @client
end

#dataTypes::KeyPair

Returns the data for this Aws::EC2::KeyPair.

Returns:

Raises:

  • (NotImplementedError)

    Raises when #data_loaded? is ‘false`.



64
65
66
67
# File 'lib/aws-sdk-ec2/key_pair.rb', line 64

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.



72
73
74
# File 'lib/aws-sdk-ec2/key_pair.rb', line 72

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


key_pair.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)


90
91
92
93
94
# File 'lib/aws-sdk-ec2/key_pair.rb', line 90

def delete(options = {})
  options = options.merge(key_name: @name)
  resp = @client.delete_key_pair(options)
  resp.data
end

#identifiersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.


98
99
100
# File 'lib/aws-sdk-ec2/key_pair.rb', line 98

def identifiers
  { name: @name }
end

#key_fingerprintString

The SHA-1 digest of the DER encoded private key.

Returns:

  • (String)


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

def key_fingerprint
  data.key_fingerprint
end

#key_materialString

An unencrypted PEM encoded RSA private key.

Returns:

  • (String)


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

def key_material
  data.key_material
end

#loadObject Also known as: reload

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (NotImplementedError)


55
56
57
58
# File 'lib/aws-sdk-ec2/key_pair.rb', line 55

def load
  msg = "#load is not implemented, data only available via enumeration"
  raise NotImplementedError, msg
end

#nameString Also known as: key_name

Returns:

  • (String)


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

def name
  @name
end