« blib/lib/VM/EC2/Instance/Status/Event.pm
↑ Summary
blib/lib/VM/EC2/NetworkInterface/Association.pm »
| 1 | package VM::EC2::KeyPair; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | VM::EC2::KeyPair - Object describing an Amazon EC2 ssh key pair | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use VM::EC2; | ||
| 10 | |||
| 11 | $ec2 = VM::EC2->new(...); | ||
| 12 | @pairs = $ec2->describe_key_pairs(); | ||
| 13 | |||
| 14 | foreach (@pairs) { | ||
| 15 | $fingerprint = $_->keyFingerprint; | ||
| 16 | $name = $_->keyName; | ||
| 17 | } | ||
| 18 | |||
| 19 | $newkey = $ec2->create_key_pair("fred's key"); | ||
| 20 | print $newkey->privateKey; | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | This object represents an Amazon EC2 ssh key pair, and is returned | ||
| 25 | by VM::EC2->describe_key_pairs(). | ||
| 26 | |||
| 27 | =head1 METHODS | ||
| 28 | |||
| 29 | These object methods are supported: | ||
| 30 | |||
| 31 | keyName -- Name of the key, e.g. "fred-default" | ||
| 32 | name -- Shorter version of keyName() | ||
| 33 | |||
| 34 | keyFingerprint -- Key's fingerprint | ||
| 35 | fingerprint -- Shorter version of keyFingerprint() | ||
| 36 | |||
| 37 | keyMaterial -- PEM encoded RSA private key (only available when | ||
| 38 | creating a new key) | ||
| 39 | privateKey -- More intuitive version of keyMaterial() | ||
| 40 | |||
| 41 | =head1 STRING OVERLOADING | ||
| 42 | |||
| 43 | When used in a string context, this object will interpolate the | ||
| 44 | keyName. | ||
| 45 | |||
| 46 | =head1 SEE ALSO | ||
| 47 | |||
| 48 | L<VM::EC2> | ||
| 49 | L<VM::EC2::Generic> | ||
| 50 | |||
| 51 | =head1 AUTHOR | ||
| 52 | |||
| 53 | Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||
| 54 | |||
| 55 | Copyright (c) 2011 Ontario Institute for Cancer Research | ||
| 56 | |||
| 57 | This package and its accompanying libraries is free software; you can | ||
| 58 | redistribute it and/or modify it under the terms of the GPL (either | ||
| 59 | version 1, or at your option, any later version) or the Artistic | ||
| 60 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||
| 61 | please see DISCLAIMER.txt for disclaimers of warranty. | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | use strict; | ||
| 66 | use base 'VM::EC2::Generic'; | ||
| 67 | |||
| 68 | sub primary_id {shift->keyName} | ||
| 69 | |||
| 70 | sub valid_fields { | ||
| 71 | my $self = shift; | ||
| 72 | return qw(requestId keyName keyFingerprint keyMaterial); | ||
| 73 | } | ||
| 74 | |||
| 75 | sub name { shift->keyName } | ||
| 76 | sub fingerprint { shift->keyFingerprint } | ||
| 77 | sub privateKey { shift->keyMaterial } | ||
| 78 | |||
| 79 | 1; |