Class: Neetob::CLI::Cloudflare::DnsProxyStatus

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/cloudflare/dns_proxy_status.rb

Constant Summary

Constants inherited from Base

Base::NEETO_DEPLOY_DOCS, Base::ZONE_IDS

Constants inherited from Base

Base::NEETO_APPS_LIST_LINK

Instance Attribute Summary collapse

Attributes inherited from Base

#ui

Instance Method Summary collapse

Methods inherited from Base

#process

Methods included from Utils

#camel_case_to_slug, #is_upper?, #symbolize_keys

Constructor Details

#initialize(domain) ⇒ DnsProxyStatus

Returns a new instance of DnsProxyStatus.



11
12
13
14
# File 'lib/neetob/cli/cloudflare/dns_proxy_status.rb', line 11

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

Instance Attribute Details

#domainObject

Returns the value of attribute domain.



9
10
11
# File 'lib/neetob/cli/cloudflare/dns_proxy_status.rb', line 9

def domain
  @domain
end

Instance Method Details

#runObject

Raises:

  • (StandardError)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/neetob/cli/cloudflare/dns_proxy_status.rb', line 16

def run
  zone_id = ZONE_IDS[domain.to_sym]
  raise(StandardError, "Domain '#{domain}' not found.") if zone_id.nil?

  url = create_url(zone_id, "dns_records")
  response = get(url)

  raise(StandardError, "No DNS records found") if response[:result].empty?

  response[:result].each do |record|
    if record[:proxiable]
      ui.info(
        "DNS proxy is turned #{record[:proxied] ? print_success("on") : print_failure("off")} " \
                        "for #{record[:type]} record #{record[:name]}")
    end
  end
end