Class: ActionAgent::Api::InstanceTiersController
- Inherits:
-
ActionAgent::ApplicationController
- Object
- ActionController::Base
- ActionAgent::ApplicationController
- ActionAgent::Api::InstanceTiersController
- Defined in:
- app/controllers/action_agent/api/instance_tiers_controller.rb
Instance Method Summary collapse
-
#index ⇒ Object
GET /api/instance_tiers List all available instance tiers.
-
#pricing ⇒ Object
GET /api/instance_tiers/pricing Get pricing comparison.
-
#recommend ⇒ Object
GET /api/instance_tiers/recommend Get recommended tier for a sandbox type.
-
#show ⇒ Object
GET /api/instance_tiers/:id Get a specific instance tier.
Methods inherited from ActionAgent::ApplicationController
Instance Method Details
#index ⇒ Object
GET /api/instance_tiers List all available instance tiers
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/action_agent/api/instance_tiers_controller.rb', line 10 def index tiers = SandboxInstanceTier.available # Filter by category if provided if params[:category].present? tiers = tiers.select { |t| t.category == params[:category] } end # Filter by GPU if requested if params[:gpu] == "true" tiers = tiers.select(&:has_gpu?) elsif params[:gpu] == "false" tiers = tiers.reject(&:has_gpu?) end render json: { tiers: tiers.map(&:as_json), categories: [ { id: "free", name: "Free", description: "Basic instances for testing" }, { id: "pro", name: "Pro", description: "Standard instances for production" }, { id: "enterprise", name: "Enterprise", description: "High-performance instances" } ] } end |
#pricing ⇒ Object
GET /api/instance_tiers/pricing Get pricing comparison
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/controllers/action_agent/api/instance_tiers_controller.rb', line 68 def pricing tiers = SandboxInstanceTier.available render json: { cpu_tiers: tiers.select { |t| !t.has_gpu? }.map { |t| { id: t.id, name: t.name, specs: t.display_specs, hourly: t.hourly_cost.to_f, monthly: t.monthly_cost.to_f, category: t.category } }, gpu_tiers: tiers.select(&:has_gpu?).map { |t| { id: t.id, name: t.name, specs: t.display_specs, hourly: t.hourly_cost.to_f, monthly: t.monthly_cost.to_f, category: t.category } }, currency: "USD", billing_increment: "per second" } end |
#recommend ⇒ Object
GET /api/instance_tiers/recommend Get recommended tier for a sandbox type
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/action_agent/api/instance_tiers_controller.rb', line 43 def recommend sandbox_type = params[:sandbox_type] || "default" recommended = case sandbox_type when "playwright_mcp" SandboxInstanceTier.find(:cpu_medium) when "research" SandboxInstanceTier.find(:cpu_small) when "terminal" SandboxInstanceTier.find(:free) else SandboxInstanceTier.find(:cpu_small) end alternatives = SandboxInstanceTier.available.reject { |t| t.id == recommended.id }.take(3) render json: { recommended: recommended.as_json, alternatives: alternatives.map(&:as_json), sandbox_type: sandbox_type } end |
#show ⇒ Object
GET /api/instance_tiers/:id Get a specific instance tier
37 38 39 |
# File 'app/controllers/action_agent/api/instance_tiers_controller.rb', line 37 def show render json: { tier: @tier.as_json } end |