AWS-ARN
view release on metacpan or search on metacpan
lib/AWS/ARN.pm view on Meta::CPAN
message { "$_ is not a valid ARN" }
);
my $ArnRegion = declare(
as Str,
where { m{^$regionRe$} },
message { "$_ is not a valid AWS Region" }
);
my $ArnPartition = declare(
as Str,
where { m{^$partitionRe$} },
message { "$_ is not a valid AWS Partitition" }
);
my $ArnService = declare(
as Str,
where { m{^$serviceRe$} },
message { "$_ is not a valid AWS Service" }
);
my $ArnAccountID = declare(
as Str,
where { m{^$account_idRe$} },
message { "$_ is not a valid AWS Account ID" }
);
my $ArnResourceID = declare(
as Str,
where { m{^$resource_idRe$} },
message { "$_ is not a valid AWS Resource" },
);
sub _split_arn {
my $self = shift;
my ($index) = @_;
return "" unless $self->_has_arn;
my @parts = split( /:/, $self->arn, 6 );
return $parts[$index||0]||"";
}
has arn => (
is => 'rw',
isa => $Arn,
lazy => 1,
builder => '_build_arn',
clearer => '_clear_arn',
predicate => '_has_arn',
trigger => 1,
);
has partition => (
is => 'rw',
isa => $ArnPartition,
lazy => 1,
builder => '_build_partition',
clearer => '_clear_partition',
default => 'aws',
trigger => sub { shift->_clear_arn },
);
has service => (
is => 'rw',
isa => $ArnService,
lazy => 1,
required => 1,
builder => '_build_service',
clearer => '_clear_service',
trigger => sub { shift->_clear_arn },
);
has region => (
is => 'rw',
isa => $ArnRegion,
lazy => 1,
builder => '_build_region',
clearer => '_clear_region',
trigger => sub { shift->_clear_arn },
);
has account_id => (
is => 'rw',
isa => $ArnAccountID,
lazy => 1,
builder => '_build_account_id',
clearer => '_clear_account_id',
trigger => sub { shift->_clear_arn },
);
has resource_id => (
is => 'rw',
isa => $ArnResourceID,
lazy => 1,
builder => '_build_resource_id',
clearer => '_clear_resource_id',
trigger => sub { shift->_clear_arn },
);
sub _build_arn {
my $self = shift;
my $arn = join( ':',
'arn',
$self->partition,
$self->service,
$self->region,
$self->account_id,
$self->resource_id,
);
}
sub _build_partition {
shift->_split_arn( 1 )
}
sub _build_service {
shift->_split_arn( 2 )
}
sub _build_region {
shift->_split_arn( 3 )
}
sub _build_account_id {
shift->_split_arn( 4 )
}
sub _build_resource_id {
shift->_split_arn( 5 )
}
sub _trigger_arn {
( run in 0.965 second using v1.01-cache-2.11-cpan-98e64b0badf )