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 health monitoring utility that periodically checks the status of AWS Elasticsearch Service endpoints by making authenticated HTTP requests.
Your solution should:
Create a function check_elasticsearch_health(host, region, access_key, secret_key) that makes an authenticated GET request to the /_cluster/health endpoint of an AWS Elasticsearch cluster and returns the health status.
The function should return a dictionary containing:
status: The cluster health status (e.g., "green", "yellow", "red")cluster_name: The name of the clusternumber_of_nodes: Number of nodes in the clusterCreate a function update_index(host, region, access_key, secret_key, index_name, document) that makes an authenticated POST request to add a document to a specified index. The function should:
document as a Python dictionary/{index_name}/_doc endpointHandle authentication errors appropriately by returning None when authentication fails.
/_cluster/health endpoint returns the correct health status @test@generates
def check_elasticsearch_health(host: str, region: str, access_key: str, secret_key: str) -> dict:
"""
Check the health status of an AWS Elasticsearch cluster.
Args:
host: The Elasticsearch endpoint (e.g., 'search-domain.region.es.amazonaws.com')
region: AWS region (e.g., 'us-east-1')
access_key: AWS access key ID
secret_key: AWS secret access key
Returns:
Dictionary with cluster health information or None if authentication fails
"""
pass
def update_index(host: str, region: str, access_key: str, secret_key: str,
index_name: str, document: dict) -> int:
"""
Add a document to an Elasticsearch index with AWS authentication.
Args:
host: The Elasticsearch endpoint
region: AWS region
access_key: AWS access key ID
secret_key: AWS secret access key
index_name: Name of the index
document: Document to add as a dictionary
Returns:
HTTP status code of the response
"""
passProvides HTTP request functionality.
Provides AWS Signature Version 4 authentication for requests.