Class: Cyoi::Cli::KeyPair::KeyPairCliAws
- Inherits:
-
Object
- Object
- Cyoi::Cli::KeyPair::KeyPairCliAws
- Defined in:
- lib/cyoi/cli/provider_key_pair/key_pair_aws.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#hl ⇒ Object
readonly
Returns the value of attribute hl.
-
#provider_client ⇒ Object
readonly
Returns the value of attribute provider_client.
Instance Method Summary collapse
- #display_confirmation ⇒ Object
-
#export_attributes ⇒ Object
helper to export the complete nested attributes.
-
#initialize(provider_client, attributes, highline) ⇒ KeyPairCliAws
constructor
A new instance of KeyPairCliAws.
- #key_pair_name ⇒ Object
- #perform_and_return_attributes ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(provider_client, attributes, highline) ⇒ KeyPairCliAws
Returns a new instance of KeyPairCliAws.
7 8 9 10 11 12 13 |
# File 'lib/cyoi/cli/provider_key_pair/key_pair_aws.rb', line 7 def initialize(provider_client, attributes, highline) @provider_client = provider_client @hl = highline @attributes = attributes.is_a?(Hash) ? ReadWriteSettings.new(attributes) : attributes raise "@attributes must be ReadWriteSettings (or Hash)" unless @attributes.is_a?(ReadWriteSettings) raise "@attributes.name must be set" unless @attributes["name"] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/cyoi/cli/provider_key_pair/key_pair_aws.rb', line 4 def attributes @attributes end |
#hl ⇒ Object (readonly)
Returns the value of attribute hl.
5 6 7 |
# File 'lib/cyoi/cli/provider_key_pair/key_pair_aws.rb', line 5 def hl @hl end |
#provider_client ⇒ Object (readonly)
Returns the value of attribute provider_client.
3 4 5 |
# File 'lib/cyoi/cli/provider_key_pair/key_pair_aws.rb', line 3 def provider_client @provider_client end |
Instance Method Details
#display_confirmation ⇒ Object
33 34 35 36 |
# File 'lib/cyoi/cli/provider_key_pair/key_pair_aws.rb', line 33 def display_confirmation puts "\n" puts "Confirming: Using key pair #{key_pair_name}" end |
#export_attributes ⇒ Object
helper to export the complete nested attributes.
24 25 26 |
# File 'lib/cyoi/cli/provider_key_pair/key_pair_aws.rb', line 24 def export_attributes attributes.to_nested_hash end |
#key_pair_name ⇒ Object
38 39 40 |
# File 'lib/cyoi/cli/provider_key_pair/key_pair_aws.rb', line 38 def key_pair_name attributes.name end |
#perform_and_return_attributes ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/cyoi/cli/provider_key_pair/key_pair_aws.rb', line 15 def perform_and_return_attributes unless valid? destroy_existing_key_pair provision_key_pair end export_attributes end |
#valid? ⇒ Boolean
28 29 30 31 |
# File 'lib/cyoi/cli/provider_key_pair/key_pair_aws.rb', line 28 def valid? attributes["name"] && attributes["fingerprint"] && attributes["private_key"] && provider_client.valid_key_pair_fingerprint?(key_pair_name, attributes.fingerprint) end |