Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding DeleteEndpoint, GetEndpointAttributes and SetEndpointAttributes #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions lib/Amazon/SNS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ sub DeleteTopic
});
}

sub DeleteEndpoint
{
my ($self, $endpointarn) = @_;

return $self->dispatch({
'Action' => 'DeleteEndpoint',
'EndpointArn' => $endpointarn,
});
}

sub ListTopics
{
my ($self, $name) = @_;
Expand Down Expand Up @@ -251,6 +261,52 @@ use JSON;

__PACKAGE__->mk_accessors(qw/ sns arn /);

sub GetEndpointAttributes
{
my ($self) = @_;

my $r = $self->sns->dispatch({
'Action' => 'GetEndpointAttributes',
'EndpointArn' => $self->arn,
});

my $entry = $r->{'GetEndpointAttributesResult'}{'Attributes'}{'entry'};

my %attributes = map {
$_ => $entry->{$_}->{value}
} keys %{$entry};

return \%attributes;
}

sub SetEndpointAttributes
{
my ($self, $attr) = @_;

my $attributes = undef;

if (defined($attr) and ref($attr) eq 'HASH') {
my $i = 1;

foreach my $key (keys %$attr) {

$attributes->{"Attributes.entry.$i.key"} = $key;
$attributes->{"Attributes.entry.$i.value"} = $attr->{$key};

$i++;
}
}

my $r = $self->sns->dispatch({
'Action' => 'SetEndpointAttributes',
'Attributes' => $attributes,
'EndpointArn' => $self->arn,
});

# return message id on success, undef on error
return $r ? $r->{'ResponseMetadata'}{'RequestId'} : undef;
}

sub Publish
{
my ($self, $msg, $subj, $attr) = @_;
Expand Down