1package VM::EC2::DB::SecurityGroup;
2
3=head1 NAME
4
5VM::EC2::DB::SecurityGroup - An RDS Database Security Group
6
7=head1 SYNOPSIS
8
9 $ec2     = VM::EC2->new(...);
10 @sg = $ec2->describe_db_security_groups;
11 foreach $group (@sg) {
12   print $_,"\n" foreach $group->IPRanges;
13   print $_->group_name,"\n" foreach $group->EC2SecurityGroups;
14 }
15
16=head1 METHODS
17
18 DBSecurityGroupDescription    -- The description of the DB security group
19
20 DBSecurityGroupName           -- The name of the DB security group
21
22 EC2SecurityGroups             -- EC2 security groups enabled in the DB group
23
24 IPRanges                      -- IP Ranges enabled in the DB group
25
26 OwnerId                       -- The Owner ID of the DB security group
27
28 VpcId                         -- The VPC ID of the DB security group
29
30 ec2_security_groups           -- Alias for EC2SecurityGroups
31
32 ip_ranges                     -- Alias for IPRanges
33
34=head1 DESCRIPTION
35
36This object represents a DB Security Group.  It is the resultant
37output of the VM::EC2->describe_db_security_groups(),
38VM::EC2->authorize_db_security_group_ingress(),
39VM::EC2->create_db_security_group(),
40and VM::EC2->revoke_db_security_group_ingress() calls.
41
42=head1 STRING OVERLOADING
43
44When used in a string context, this object outputs the DB Security Group Name.
45
46=head1 SEE ALSO
47
48L<VM::EC2>
49L<VM::EC2::Generic>
50L<VM::EC2::DB::Instance>
51
52=head1 AUTHOR
53
54Lance Kinley E<lt>lkinley@loyaltymethods.comE<gt>.
55
56Copyright (c) 2013 Loyalty Methods, Inc.
57
58This package and its accompanying libraries is free software; you can
59redistribute it and/or modify it under the terms of the GPL (either
60version 1, or at your option, any later version) or the Artistic
61License 2.0.  Refer to LICENSE for the full license text. In addition,
62please see DISCLAIMER.txt for disclaimers of warranty.
63
64=cut
65
66use strict;
67use base 'VM::EC2::Generic';
68use VM::EC2::DB::EC2SecurityGroup;
69use VM::EC2::DB::IPRange;
70
71use overload '""' => sub { shift->DBSecurityGroupName },
72    fallback => 1;
73
74sub valid_fields {
75    my $self = shift;
76    return qw(DBSecurityGroupDescription DBSecurityGroupName EC2SecurityGroups IPRanges OwnerId VpcId);
77}
78
79sub EC2SecurityGroups {
80    my $self = shift;
81    my $groups = $self->SUPER::EC2SecurityGroups;
82    return unless $groups;
83    $groups = $groups->{EC2SecurityGroup};
84    return ref $groups eq 'HASH' ?
85        (VM::EC2::DB::EC2SecurityGroup->new($groups,$self->aws)) :
86        map { VM::EC2::DB::EC2SecurityGroup->new($_,$self->aws) } @$groups;
87}
88
89sub IPRanges {
90    my $self = shift;
91    my $ranges = $self->SUPER::IPRanges;
92    return unless $ranges;
93    $ranges = $ranges->{IPRange};
94    return ref $ranges eq 'HASH' ?
95        (VM::EC2::DB::IPRange->new($ranges,$self->aws)) :
96        map { VM::EC2::DB::IPRange->new($_,$self->aws) } @$ranges;
97}
98
99sub ec2_security_groups { shift->EC2SecurityGroups }
100
101sub ip_ranges { shift->IPRanges }
102
1031;
104