or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/gcloud@0.7.x
tile.json

tessl/pypi-gcloud

tessl install tessl/pypi-gcloud@0.7.0

Python client library for Google Cloud Platform services including Datastore, Storage, and Pub/Sub

Agent Success

Agent success rate when using this tile

93%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.19x

Baseline

Agent success rate without this tile

78%

task.mdevals/scenario-7/

Cloud Storage Blob Metadata Manager

Build a utility that manages blob uploads and metadata in Google Cloud Storage.

Requirements

Your task is to implement a blob metadata manager that:

  1. Uploads text content to a specified blob in a bucket with custom metadata
  2. Downloads blob content and retrieves its metadata
  3. Updates blob metadata without re-uploading the content
  4. Sets content properties including content type and cache control headers

The implementation should handle:

  • Uploading string content as blob data
  • Attaching custom key-value metadata pairs to blobs
  • Setting appropriate content types for different file formats
  • Configuring cache control directives
  • Downloading and inspecting blob properties

Test Cases

  • Uploading a text file with content "Hello, World!" to blob "test.txt" creates a blob that can be downloaded with the same content @test
  • Setting custom metadata {"author": "John", "version": "1.0"} on a blob allows retrieval of the same metadata values @test
  • Setting content-type "text/plain" and cache-control "public, max-age=3600" on a blob makes these properties retrievable @test
  • Updating metadata on an existing blob preserves the blob content while changing metadata values @test

Implementation

@generates

API

class BlobManager:
    """Manages blob uploads and metadata in Google Cloud Storage."""

    def __init__(self, project_id: str, bucket_name: str):
        """
        Initialize the blob manager.

        Args:
            project_id: Google Cloud project ID
            bucket_name: Name of the storage bucket
        """
        pass

    def upload_with_metadata(self, blob_name: str, content: str,
                            metadata: dict = None, content_type: str = None,
                            cache_control: str = None) -> None:
        """
        Upload string content to a blob with optional metadata and properties.

        Args:
            blob_name: Name of the blob to create
            content: String content to upload
            metadata: Optional dictionary of custom metadata key-value pairs
            content_type: Optional content type (e.g., "text/plain")
            cache_control: Optional cache control directive
        """
        pass

    def download_blob(self, blob_name: str) -> str:
        """
        Download blob content as a string.

        Args:
            blob_name: Name of the blob to download

        Returns:
            Blob content as string
        """
        pass

    def get_metadata(self, blob_name: str) -> dict:
        """
        Retrieve custom metadata from a blob.

        Args:
            blob_name: Name of the blob

        Returns:
            Dictionary of custom metadata key-value pairs
        """
        pass

    def get_properties(self, blob_name: str) -> dict:
        """
        Retrieve blob properties including content type and cache control.

        Args:
            blob_name: Name of the blob

        Returns:
            Dictionary with 'content_type' and 'cache_control' keys
        """
        pass

    def update_metadata(self, blob_name: str, metadata: dict) -> None:
        """
        Update metadata on an existing blob without modifying content.

        Args:
            blob_name: Name of the blob
            metadata: Dictionary of metadata key-value pairs to set
        """
        pass

Dependencies { .dependencies }

gcloud { .dependency }

Provides Google Cloud Storage client for blob operations.

@satisfied-by