tessl install tessl/pypi-aws-requests-auth@0.4.0AWS signature version 4 signing process for the python requests module
Agent Success
Agent success rate when using this tile
84%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.11x
Baseline
Agent success rate without this tile
76%
Build a Python HTTP client utility that can make authenticated requests to multiple AWS services using AWS Signature Version 4 authentication.
Your client should support making authenticated HTTP requests to two different AWS services:
The client should:
es, API Gateway uses execute-api)us-east-1@test
eu-west-1{"message": "hello"}execute-api service@test
@generates
class AWSMultiServiceClient:
"""
A client for making authenticated requests to multiple AWS services.
"""
def __init__(self, aws_access_key_id: str, aws_secret_access_key: str):
"""
Initialize the client with AWS credentials.
Args:
aws_access_key_id: AWS access key ID
aws_secret_access_key: AWS secret access key
"""
pass
def query_elasticsearch(self, host: str, region: str, path: str) -> dict:
"""
Make a GET request to an AWS Elasticsearch endpoint.
Args:
host: The Elasticsearch endpoint (e.g., 'search-domain.us-east-1.es.amazonaws.com')
region: AWS region (e.g., 'us-east-1')
path: The request path (e.g., '/index/_search')
Returns:
Response as a dictionary
"""
pass
def invoke_api_gateway(self, host: str, region: str, path: str, payload: dict) -> dict:
"""
Make a POST request to an AWS API Gateway endpoint.
Args:
host: The API Gateway endpoint (e.g., 'api123.execute-api.us-east-1.amazonaws.com')
region: AWS region (e.g., 'us-east-1')
path: The request path (e.g., '/prod/resource')
payload: JSON payload as a dictionary
Returns:
Response as a dictionary
"""
passProvides AWS Signature Version 4 authentication for HTTP requests.
HTTP library for making requests to AWS services.