Class: NeetoDeploy::CLI::Maintenance::Base

Inherits:
Base
  • Object
show all
Includes:
Session
Defined in:
lib/neeto_deploy/cli/maintenance/base.rb

Constant Summary

Constants included from Session

Session::CONSOLE_EXECUTABLE

Instance Attribute Summary collapse

Attributes inherited from Base

#ui

Instance Method Summary collapse

Methods included from Session

#auth_headers, #console_executable_name, #json_auth_headers, #os, require_app_option, #send_delete_request, #send_get_request, #send_patch_request, #send_post_request

Methods inherited from Base

#create_config_dir

Constructor Details

#initialize(app_slug) ⇒ Base

Returns a new instance of Base.



13
14
15
16
# File 'lib/neeto_deploy/cli/maintenance/base.rb', line 13

def initialize(app_slug)
  super()
  @app_slug = app_slug
end

Instance Attribute Details

#app_slugObject (readonly)

Returns the value of attribute app_slug.



11
12
13
# File 'lib/neeto_deploy/cli/maintenance/base.rb', line 11

def app_slug
  @app_slug
end

Instance Method Details

#disableObject



39
40
41
# File 'lib/neeto_deploy/cli/maintenance/base.rb', line 39

def disable
  toggle(false)
end

#enableObject



35
36
37
# File 'lib/neeto_deploy/cli/maintenance/base.rb', line 35

def enable
  toggle(true)
end

#showObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/neeto_deploy/cli/maintenance/base.rb', line 22

def show
  ui.execute_with_loading("Fetching maintenance mode status...") do
    @response = send_get_request(url, { app_slug: })
  end

  return ui.error(@response["error"] || @response.message) unless @response.success?

  mm = JSON.parse(@response.body)["maintenance_mode"]
  status = mm["enabled"] ? "enabled".colorize(:red) : "disabled".colorize(:green)
  ui.info("Maintenance mode: #{status}")
  ui.info("Type: #{mm["mode_type"]}") if mm["mode_type"]
end

#urlObject



18
19
20
# File 'lib/neeto_deploy/cli/maintenance/base.rb', line 18

def url
  "#{NEETO_DEPLOY_CLI_API_BASE_URL}/maintenance_mode"
end