| 1 | package VM::EC2::Tag; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | VM::EC2::Tag -- Object describing a tagged Amazon EC2 resource | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use VM::EC2; | ||
| 10 | |||
| 11 | $ec2 = VM::EC2->new(...); | ||
| 12 | @tags = $ec2->describe_tags(-filter=> {'resource-type'=>'volume'}); | ||
| 13 | for my $t (@tags) { | ||
| 14 | $id = $t->resourceId; | ||
| 15 | $type = $t->resourceType; | ||
| 16 | $key = $t->key; | ||
| 17 | $value = $t->value; | ||
| 18 | } | ||
| 19 | |||
| 20 | =head1 DESCRIPTION | ||
| 21 | |||
| 22 | This object is used to describe an Amazon EC2 tag. Each object | ||
| 23 | contains information about the resource it is tagging, the tag key, | ||
| 24 | and the tag value. Tags are returned by the VM::EC2->describe_tags() | ||
| 25 | method. | ||
| 26 | |||
| 27 | In most cases you will not want to work with this object directly, but | ||
| 28 | instead read tags by calling a resource object's tags() method, which | ||
| 29 | returns a hash of key value pairs, or specify particular tag values as | ||
| 30 | one of the filters in a describe_*() call. | ||
| 31 | |||
| 32 | =head1 METHODS | ||
| 33 | |||
| 34 | The following object methods are supported: | ||
| 35 | |||
| 36 | resourceId -- The ID of the resource being tagged. | ||
| 37 | resourceType -- The type of the resource being tagged e.g. "image" | ||
| 38 | key -- The tag key. | ||
| 39 | value -- The tag value. | ||
| 40 | |||
| 41 | =head1 STRING OVERLOADING | ||
| 42 | |||
| 43 | When used in a string context, this object will interpolate the | ||
| 44 | resourceId. | ||
| 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 | |||
| 66 | use strict; | ||
| 67 | use base 'VM::EC2::Generic'; | ||
| 68 | |||
| 69 | use overload | ||
| 70 | '""' => sub { | ||
| 71 | my $self = shift; | ||
| 72 | return $self->resourceId}, | ||
| 73 | fallback => 1; | ||
| 74 | |||
| 75 | sub valid_fields { | ||
| 76 | my $self = shift; | ||
| 77 | return qw(resourceId resourceType key value); | ||
| 78 | } | ||
| 79 | |||
| 80 | 1; |