Class: Jatai::Commands::Domains
- Inherits:
-
Thor
- Object
- Thor
- Jatai::Commands::Domains
- Defined in:
- lib/jatai/commands/domains.rb
Instance Method Summary collapse
Instance Method Details
#add(hostname) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/jatai/commands/domains.rb', line 30 def add(hostname) slug = helper.app_slug result = helper.api.post("/api/v1/apps/#{slug}/domains", body: { domain: { hostname: hostname } }) app = helper.api.get("/api/v1/apps/#{slug}") helper.success("Domínio #{hostname} adicionado.") helper.info("Token de verificação: #{result["verification_token"]}") helper.info("Adicione um registro CNAME apontando para #{app["subdomain"]}.usebrasa.com.br") rescue Api::Client::ValidationError => e helper.error("Erro: #{e.}") rescue Api::Client::ApiError => e helper.error("Erro: #{e.}") end |
#list ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jatai/commands/domains.rb', line 10 def list slug = helper.app_slug domains = helper.api.get("/api/v1/apps/#{slug}/domains") if domains.nil? || domains.empty? helper.info("Nenhum domínio configurado.") return end domains.each do |domain| status_icon = domain["status"] == "active" ? helper.pastel.green("●") : helper.pastel.yellow("○") puts "#{status_icon} #{helper.pastel.bold(domain["hostname"])} (#{domain["status"]})" puts " Token: #{domain["verification_token"]}" if domain["status"] == "pending" end rescue Api::Client::ApiError => e helper.error("Erro: #{e.}") end |
#remove(hostname) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/jatai/commands/domains.rb', line 45 def remove(hostname) slug = helper.app_slug domains = helper.api.get("/api/v1/apps/#{slug}/domains") domain = domains&.find { |d| d["hostname"] == hostname } unless domain helper.error("Domínio #{hostname} não encontrado.") return end helper.api.delete("/api/v1/apps/#{slug}/domains/#{domain["id"]}") helper.success("Domínio #{hostname} removido.") rescue Api::Client::ApiError => e helper.error("Erro: #{e.}") end |
#verify(hostname) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/jatai/commands/domains.rb', line 63 def verify(hostname) slug = helper.app_slug domains = helper.api.get("/api/v1/apps/#{slug}/domains") domain = domains&.find { |d| d["hostname"] == hostname } unless domain helper.error("Domínio #{hostname} não encontrado.") return end result = helper.api.post("/api/v1/apps/#{slug}/domains/#{domain["id"]}/verify") if result["status"] == "active" helper.success("Domínio #{hostname} verificado com sucesso!") else helper.error("Verificação falhou. Certifique-se de que o registro DNS está configurado.") end rescue Api::Client::ApiError => e helper.error("Erro: #{e.}") end |