Amazon...:Simple(3pm)

πŸ’– Amazon::SQS::Simple β€” the manual page, but make it a group chat πŸ’–

okay bestie so this is Amazon...:Simple(3pm), part of the User Contributed Perl Documentation crew, and it's genuinely one of those pages that's lowkey iconic once you get past the vibe check. buckle up, we're doing OO API for the Amazon Simple Queue Service and we're doing it together. 🫢


✨ NAME ✨

Amazon::SQS::Simple β€” it's an OO API for accessing the Amazon Simple Queue Service. that's the whole name. short, sweet, slays. πŸ’…


🌸 SYNOPSIS 🌸

here's the whole thing in action, no cap:

use Amazon::SQS::Simple;

my $access_key = 'foo'; # Your AWS Access Key ID
my $secret_key = 'bar'; # Your AWS Secret Key

# Create an SQS object
my $sqs = new Amazon::SQS::Simple(AWSAccessKeyId => $access_key, SecretKey => $secret_key);

# Create a new queue
my $q = $sqs->CreateQueue('queue_name');

# Send a message
my $response = $q->SendMessage('Hello world!');

    # Send multiple messages
    my @responses = $q->SendMessageBatch(['Hello world', 'Farewell cruel world']);

# Retrieve a message
my $msg = $q->ReceiveMessage();
print $msg->MessageBody() # Hello world!

# Delete the message
$q->DeleteMessage($msg->ReceiptHandle());
    # or
$q->DeleteMessage($msg);

# Delete the queue
$q->Delete();

# Purge the queue
$q->Purge();

like… create queue, send message, receive message, delete message, delete queue, purge queue. the entire life cycle of a queue, served. πŸ“


πŸ¦‹ INTRODUCTION πŸ¦‹

Amazon::SQS::Simple is an OO API for the Amazon Simple Queue Service. that's it, that's the intro, she's concise and she knows it. ✨


πŸ’€ IMPORTANT πŸ’€

okay this part matters, bestie, don't skip it:

This version of Amazon::SQS::Simple defaults to work against version 2009-02-01 of the SQS API.

and, respectfully:

Earlier API versions may or may not work.

"may or may not" is doing SO much heavy lifting there, not gonna lie. 😭


πŸ‘‘ CONSTRUCTOR πŸ‘‘

new($access_key, $secret_key, [%opts])

constructs a new Amazon::SQS::Simple object. main character energy, she's born. πŸ’…

$access_key is your Amazon Web Services access key. $secret_key is your Amazon Web Services secret key. and if you don't have either of these credentials, bestie, go visit <http://aws.amazon.com/>. we can't help you there, that's a you-and-AWS situation. πŸ™ˆ

options for new:

  • Timeout => SECONDS β€” sets the HTTP user agent's timeout. the default is 180 seconds. (yes, three whole minutes of patience. she's chill.) 🧘
  • Version => VERSION_STRING β€” specifies the SQS API version you wish to use. for example:
my $sqs = new Amazon::SQS::Simple($access_key, $secret_key, Version => '2008-01-01');

πŸ”₯ METHODS πŸ”₯

GetQueue($queue_endpoint)

gets the queue with the given endpoint. returns a Amazon::SQS::Simple::Queue object. (see Amazon::SQS::Simple::Queue for details.) πŸŽ€

CreateQueue($queue_name, [%opts])

creates a new queue with the given name. returns a Amazon::SQS::Simple::Queue object. (see Amazon::SQS::Simple::Queue for details.) ✨

options for CreateQueue:

  • DefaultVisibilityTimeout => SECONDS β€” sets the default visibility timeout for this queue. 🌈

ListQueues([%opts])

gets a list of all your current queues. returns an array of Amazon::SQS::Simple::Queue objects. (see Amazon::SQS::Simple::Queue for details.) πŸ’œ

options for ListQueues:

  • QueueNamePrefix => STRING β€” only those queues whose name begins with the specified string are returned. it's giving "filter by vibes." πŸ¦‹

⭐ FUNCTIONS ⭐

so here's the tea: no functions are exported by default. if you want to use them, you gotta export them in your use line:

use Amazon::SQS::Simple qw( timestamp );

timestamp($seconds)

takes a time in seconds since the epoch and returns a formatted timestamp suitable for using in a Timestamp or Expires optional method parameter. that's her whole job and she does it flawlessly. πŸ’…


πŸ’œ STANDARD OPTIONS πŸ’œ

these following options can be supplied with any of the listed methods. universal. versatile. iconic. ✨

  • AWSAccessKeyId => STRING β€” the AWS Access Key Id to use with the method call. if not provided, Amazon::SQS::Simple uses the value passed to the constructor. πŸŽ€
  • SecretKey => STRING β€” the Secret Key to use with the method call. if not provided, Amazon::SQS::Simple uses the value passed to the constructor. πŸ”
  • Timestamp => TIMESTAMP β€” all methods are automatically given a timestamp of the time at which they are called, but you can override this value if you need to. the value for this key should be a timestamp as returned by the Amazon::SQS::Simple::timestamp() function.
you generally do not need to supply this option. πŸ™ˆ
  • Expires => TIMESTAMP β€” all methods are automatically given a timestamp of the time at which they are called. you can alternatively set an expiry time by providing an Expires option. the value for this key should be a timestamp as returned by the Amazon::SQS::Simple::timestamp() function.
you generally do not need to supply this option. πŸ™ˆ

🫢 ACKNOWLEDGEMENTS 🫢

shoutout time, because we always credit the girls who built the house:

  • Bill Alford wrote the code to support basic functionality of older API versions in release 0.9. πŸ‘‘
  • James Neal provided the proxy support code in release 2.0. πŸ”₯
  • Roland Walker provided support for the newer signature version in release 2.0. ✨
  • Chris Jones provied the batch message code in release 2.0. πŸ’…
  • Rusty Conover provided the V4 signature support in release 2.05. 🌟

🌈 AUTHOR 🌈

Copyright 2007-2008 Simon Whitaker <swhitaker@cpan.org>

Copyright 2013-2017 Mike (no relation) Whitaker <penfold@cpan.org>

"(no relation)" is genuinely sending me, that's so real of them. 😭

and the legal bit, bestie, don't scroll past it:

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

and that's the page!! this was perl v5.32.0, dated 2021-01-09, and it lives under Amazon...:Simple(3pm) in the User Contributed Perl Documentation. periodt. πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from