Ctrl + K
DocumentationLog inGet started

tessl/pypi-aws-requests-auth

tessl install tessl/pypi-aws-requests-auth@0.4.0

AWS 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%

task.mdevals/scenario-2/

AWS Service Health Monitor

Build a health monitoring utility that periodically checks the status of AWS Elasticsearch Service endpoints by making authenticated HTTP requests.

Requirements

Your solution should:

  1. 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.

  2. The function should return a dictionary containing:

    • status: The cluster health status (e.g., "green", "yellow", "red")
    • cluster_name: The name of the cluster
    • number_of_nodes: Number of nodes in the cluster
  3. Create 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:

    • Accept document as a Python dictionary
    • POST to /{index_name}/_doc endpoint
    • Return the response status code
  4. Handle authentication errors appropriately by returning None when authentication fails.

Test Cases

  • The GET request to /_cluster/health endpoint returns the correct health status @test
  • The POST request to add a document receives a successful status code (200 or 201) @test
  • Multiple sequential requests with the same auth object work correctly @test

Implementation

@generates

API

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
    """
    pass

Dependencies { .dependencies }

requests { .dependency }

Provides HTTP request functionality.

aws-requests-auth { .dependency }

Provides AWS Signature Version 4 authentication for requests.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/aws-requests-auth@0.4.x
tile.json