Class: Jatai::Commands::Redis
- Inherits:
-
Thor
- Object
- Thor
- Jatai::Commands::Redis
- Defined in:
- lib/jatai/commands/redis.rb
Constant Summary collapse
- MEMORY_TO_PLAN =
{ 256 => "starter", 512 => "pro", 1024 => "business" }.freeze
Instance Method Summary collapse
Instance Method Details
#disable ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/jatai/commands/redis.rb', line 50 def disable slug = helper.app_slug prompt = TTY::Prompt.new unless prompt.yes?("Remover Redis? Todos os dados em cache serão perdidos.") helper.info("Operação cancelada.") return end helper.info("Removendo Redis...") helper.api.delete("/api/v1/apps/#{slug}/addons/cache") helper.success("Redis removido com sucesso!") rescue Api::Client::ApiError => e helper.error("Erro: #{e.}") end |
#enable ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jatai/commands/redis.rb', line 33 def enable slug = helper.app_slug plan = MEMORY_TO_PLAN[[:memory]] unless plan helper.error("Memória inválida. Use: 256, 512 ou 1024") return end helper.info("Habilitando Redis com #{[:memory]}MB (plano #{plan})...") result = helper.api.post("/api/v1/apps/#{slug}/addons", body: { addon: { slug: "cache", plan: plan } }) helper.success("Redis habilitado! Status: #{result["status"]}") rescue Api::Client::ApiError => e helper.error("Erro: #{e.}") end |
#status ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jatai/commands/redis.rb', line 17 def status slug = helper.app_slug addon = helper.api.get("/api/v1/apps/#{slug}/addons/cache") puts helper.pastel.bold("Redis de #{slug}") puts " Status: #{addon["status"]}" puts " Plano: #{addon["plan"]}" puts " Memória: #{addon.dig("config", "memory_mb")}MB" puts " Custo: R$ #{addon["monthly_cost_brl"]}/mês" rescue Api::Client::ApiError => e helper.error("Erro: #{e.}") end |