Class: ElasticDot::Command::Domains

Inherits:
Base
  • Object
show all
Defined in:
lib/elasticdot/command/domains.rb

Class Method Summary collapse

Class Method Details

.add(args, opts) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/elasticdot/command/domains.rb', line 2

def self.add(args, opts)
  domain = args.shift
  validate_domain! 'add', domain

  app    = opts[:app]
  find_app! opts

  puts "Adding #{domain} to #{@app}..."

  api.post "/domains/#{@app}/aliases", alias: domain
end

.clear(opts) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/elasticdot/command/domains.rb', line 26

def self.clear(opts)
  find_app! opts

  domains = api.get("/domains/#{@app}")['aliases']

  puts "Removing all domain names from #{@app}..."
  domains.each do |d|
    next if d['factory']
    api.delete "/domains/#{@app}/aliases/#{d['name']}"
  end
end

.list(opts) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/elasticdot/command/domains.rb', line 38

def self.list(opts)
  find_app! opts

  domains = api.get("/domains/#{@app}")['aliases']

  puts "=== #{@app} Domain Names"
  domains.each {|d| puts d['name'] }
end

.remove(args, opts) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/elasticdot/command/domains.rb', line 14

def self.remove(args, opts)
  domain = args.shift
  validate_domain! 'remove', 'domain'

  app    = opts[:app]
  find_app! opts

  puts "Removing #{domain} from #{@app}..."

  api.delete "/domains/#{@app}/aliases/#{domain}"
end