Sha256: 78bfa48e54c77b50878d3ef3dfe2817720fb4a8696eb806e93446ab1a8757f2e

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require "thor"

require_relative "../session"
require_relative "./constants"

module NeetoDeploy
  class CLI
    module Addon
      class ScheduledExportsSettings < CLI::Base
        include Constants
        include Session

        attr_reader :app_name

        def initialize(options)
          super()
          @app_name = options[:app_name]
        end

        def run
          ui.execute_with_loading("Fetching info...") do
            send_request
          end
          print_output
        end

        private

          def send_request
            @response = send_get_request("#{NEETO_DEPLOY_CLI_API_BASE_URL}/scheduled_exports/#{app_name}", {app_slug: app_name})
          end

          def print_output
            ui.error(@response["error"]) and return unless @response.success?

            scheduled_exports = JSON.parse(@response.body)["scheduled_exports_enabled"]
            if scheduled_exports.nil?
              ui.error("App doesn't seem to have a primary database addon")
            else
              ui.info("Scheduled exports is turned #{scheduled_exports ? "\u001b[32mon\u001b[0m" : "\u001b[31moff\u001b[0m"} for #{app_name}'s primary database")
            end
          end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
neetodeploy-1.1.10 lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb
neetodeploy-1.1.9 lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb
neetodeploy-1.1.8 lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb
neetodeploy-1.1.7 lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb
neetodeploy-1.1.6 lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb