Writing our first client
Let's start with an example to demonstrate a typical usage pattern.
program ListQueues;
{$APPTYPE CONSOLE}
uses
AWS.SQS,
System.SysUtils;
var
SQS: ISQSClient;
begin
try
SQS := TSQSClient.Create;
var Response := SQS.ListQueues;
for var QueueUrl in Response.QueueUrls do
Writeln(QueueUrl);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
The key points to note are:
- We use the relevant service unit
AWS.SQS. - We declare a variable for the client
SQS: ISQSClient. - We create a
TSQSClientwith default options and assign it toSQS. - We make a
ListQueuesrequest and store theResponsewhich will be aISQSListQueuesResponse. - We enumerate the
QueueUrlswriting each out to the console. It's worth noting that each client implementation has a corresponding interface and implementation pair like theISQSClientandTSQSClientas seen in the previous example. You are not required to use the I* interface but if not you will need to manually free the client once you are done using a try/finally block as with any other Delphi object.