| 1 | package VM::EC2::DB::Event::Category; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | VM::EC2::DB::Event::Category - An RDS Database Event Category | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use VM::EC2; | ||
| 10 | |||
| 11 | $ec2 = VM::EC2->new(...); | ||
| 12 | $db_cat = $ec2->describe_event_categories(-source_type => 'db-instance'); | ||
| 13 | print $_,"\n" foreach $db_cat->EventCategories; | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | This object represents an RDS Event Category. It is the resultant output of | ||
| 18 | the VM::EC2->describe_event_categories() function. | ||
| 19 | |||
| 20 | =head1 STRING OVERLOADING | ||
| 21 | |||
| 22 | When used in a string context, this object will output the source type | ||
| 23 | followed by a comma delimited list of event categories. | ||
| 24 | |||
| 25 | =head1 SEE ALSO | ||
| 26 | |||
| 27 | L<VM::EC2> | ||
| 28 | L<VM::EC2::Generic> | ||
| 29 | L<VM::EC2::DB::Instance> | ||
| 30 | |||
| 31 | =head1 AUTHOR | ||
| 32 | |||
| 33 | Lance Kinley E<lt>lkinley@loyaltymethods.comE<gt>. | ||
| 34 | |||
| 35 | Copyright (c) 2013 Loyalty Methods, Inc. | ||
| 36 | |||
| 37 | This package and its accompanying libraries is free software; you can | ||
| 38 | redistribute it and/or modify it under the terms of the GPL (either | ||
| 39 | version 1, or at your option, any later version) or the Artistic | ||
| 40 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||
| 41 | please see DISCLAIMER.txt for disclaimers of warranty. | ||
| 42 | |||
| 43 | =cut | ||
| 44 | |||
| 45 | use strict; | ||
| 46 | use base 'VM::EC2::Generic'; | ||
| 47 | |||
| 48 | use overload '""' => sub { shift->as_string }, | ||
| 49 | fallback => 1; | ||
| 50 | |||
| 51 | sub valid_fields { | ||
| 52 | my $self = shift; | ||
| 53 | return qw(SourceType EventCategories); | ||
| 54 | } | ||
| 55 | |||
| 56 | sub EventCategories { | ||
| 57 | my $self = shift; | ||
| 58 | my $cats = $self->SUPER::EventCategories; | ||
| 59 | return unless $cats; | ||
| 60 | $cats = $cats->{EventCategory}; | ||
| 61 | return ref $cats eq 'ARRAY' ? @$cats : ($cats); | ||
| 62 | } | ||
| 63 | |||
| 64 | sub as_string { | ||
| 65 | my $self = shift; | ||
| 66 | $self->SourceType . ' : ' . join(',',$self->EventCategories) | ||
| 67 | } | ||
| 68 | |||
| 69 | 1; |