Skip to content

Migrate redisctl commands to use typed API clients (dogfooding) #24

@joshrotenberg

Description

@joshrotenberg

Summary

Migrate redisctl human-friendly commands to use our typed API client libraries instead of raw JSON. This will help us dogfood our own libraries and discover improvements.

Motivation

  • Dogfooding: Using our own libraries will help us find issues and improve them
  • Type Safety: Catch errors at compile time rather than runtime
  • Better Error Messages: Typed errors are more informative than JSON parsing errors
  • Field Validation: Discover fields that should be Optional, missing derives, etc.

Implementation Strategy

Keep Raw for API Commands

// redisctl cloud api GET /subscriptions/123/databases
// These continue using raw JSON passthrough for maximum compatibility
client.get_raw("/subscriptions/123/databases").await?

Use Typed for Human Commands

// redisctl cloud database list
// These use typed APIs for better validation
let databases = client.database().list(subscription_id).await?;
let value = serde_json::to_value(databases)?; // Convert for output

Benefits We'll Discover

  1. Missing Optional fields - Fields that can be null but aren't marked as Option<T>
  2. Missing derives - Debug, Clone, Default, etc.
  3. API ergonomics - Methods that would make the API easier to use
  4. Validation gaps - Places where we should validate input
  5. Documentation needs - Missing or unclear documentation

Migration Checklist

Cloud Commands to Migrate

  • database list - List databases
  • database get - Get database details
  • subscription list - List subscriptions
  • subscription get - Get subscription details
  • user list - List users
  • backup list - List backups

Enterprise Commands to Migrate

  • database list - List databases (bdbs)
  • database get - Get database details
  • cluster info - Get cluster information
  • node list - List nodes
  • user list - List users
  • alert list - List alerts

Handler Updates Needed

  • Add .to_value() or similar methods to convert typed responses to JSON Value
  • Ensure all handlers return consistent types
  • Add proper error context when conversions fail

Success Criteria

  • Commands using typed APIs have better error messages
  • We identify at least 5 improvements to make to the libraries
  • Performance impact is negligible (per our benchmarks)
  • All tests continue to pass

Notes

Per our benchmarks (#23), the performance difference is negligible for typical API responses, so we're not sacrificing performance for type safety.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions