CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-cloudinary

Python and Django SDK for Cloudinary, a cloud-based image and video management service with comprehensive transformation, optimization, and delivery capabilities

Overall
score

94%

Overview
Eval results
Files

task.mdevals/scenario-8/

Secure Asset Search Service

Build a service that generates secure, time-limited search URLs for querying cloud-based assets. The service should create signed URLs that can be used by client applications to search for assets without exposing API credentials.

Requirements

Your service should provide functionality to:

  1. Generate signed search URLs with configurable expiration times
  2. Support different time-to-live (TTL) values for different use cases
  3. Ensure URLs are properly secured with cryptographic signatures
  4. Handle search query parameters correctly

Implementation

@generates

API

def generate_search_url(query: str, ttl: int = 300) -> str:
    """
    Generate a signed search URL for querying assets.

    Args:
        query: The search expression (e.g., "resource_type:image AND tags:sunset")
        ttl: Time-to-live in seconds (default: 300)

    Returns:
        A signed URL string that can be used to execute the search
    """
    pass

def generate_short_lived_url(query: str) -> str:
    """
    Generate a signed search URL with a 60-second expiration.

    Args:
        query: The search expression

    Returns:
        A signed URL string with 60-second TTL
    """
    pass

def generate_long_lived_url(query: str) -> str:
    """
    Generate a signed search URL with a 1-hour expiration.

    Args:
        query: The search expression

    Returns:
        A signed URL string with 3600-second TTL
    """
    pass

Tests

Generates signed URL with default TTL

  • Calling generate_search_url("resource_type:image") returns a valid URL string @test
  • The generated URL contains signature parameters @test

Generates signed URL with custom TTL

  • Calling generate_search_url("tags:landscape", ttl=600) generates a URL with 10-minute expiration @test
  • Calling generate_search_url("format:jpg", ttl=120) generates a URL with 2-minute expiration @test

Convenience methods work correctly

  • Calling generate_short_lived_url("resource_type:video") generates a URL that expires in 60 seconds @test
  • Calling generate_long_lived_url("uploaded_at>2024-01-01") generates a URL that expires in 1 hour @test

Dependencies { .dependencies }

cloudinary { .dependency }

Provides cloud-based asset management and secure URL generation capabilities.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-cloudinary

tile.json