Performing AWS Requests
To perform API operations via the AWS REST or Query interfaces, our service client implementations will perform the following steps:
Create a URI specifying the service resource the request will act upon.
Build a request message containing all the information the service will need to perform the request.
Generate a request description string that summarizes the request message.
Authenticate the request by generating a signature from the request description string and attaching it to the request.
Transmit the HTTP request message to the service and receive a response.
Determine whether the request succeeded or failed. Raise a ServiceError if it failed.
Interpret the response sent by the service and obtain the result information specific to that operation.
The work required to perform the first two steps, which construct a request message, and the last step, in which the service’s response is interpreted, vary greatly across the different interfaces and operations. These steps will be performed by the service client implementations we will define in later chapters. The middle four steps, on the other hand, can be implemented once for each of the REST and Query interfaces, and they may be reused by all the services that use these interfaces.
In this section we will add methods to the AWS module that prepare and transmit requests for both the REST and Query interfaces. These methods will be generic enough to be reused by multiple AWS client implementations.
REST API Implementation ...
Get Programming Amazon Web Services now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.