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

Class: Aws::EC2::KeyPair

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

Defined Under Namespace

Classes: Collection

Actions collapse

Read-Only Attributes 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 'gems/aws-sdk-ec2/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 'gems/aws-sdk-ec2/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:



64
65
66
67
# File 'gems/aws-sdk-ec2/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 'gems/aws-sdk-ec2/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 'gems/aws-sdk-ec2/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

#key_fingerprintString

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

Returns:

  • (String)


36
37
38
# File 'gems/aws-sdk-ec2/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 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/key_pair.rb', line 42

def key_material
  data.key_material
end

#nameString Also known as: key_name

Returns:

  • (String)


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

def name
  @name
end