Class: Gleis::Domain
- Inherits:
-
Object
- Object
- Gleis::Domain
- Defined in:
- lib/gleis/domain.rb
Overview
The class implements the methods required to manage the domain names of a gleis app
Class Method Summary collapse
Class Method Details
.add(app_name, name) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/gleis/domain.rb', line 4 def self.add(app_name, name) token = Token.check body = API.request('post', 'domains', token, 'name': app_name, 'domain': name) if body['success'] == 1 puts "Successfully added domain to #{app_name}." else puts "Failed to add domain: #{body['message']}" end end |
.list(app_name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gleis/domain.rb', line 14 def self.list(app_name) token = Token.check body = API.request('get', "domains/#{app_name}", token) puts "Your app is available under the URL: https://#{body['fqdn']}\n\n" domains = body ['data'] if domains.any? puts "Domain list for #{app_name}:\n\n" domains.each do |domain| puts "\t#{domain['name']}" end else puts 'No domains defined yet.' end end |
.remove(app_name, name) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/gleis/domain.rb', line 29 def self.remove(app_name, name) token = Token.check body = API.request('delete', "domains/#{app_name}/#{name}", token) if body['success'] == 1 puts "Successfully removed domain name from #{app_name}." else puts "Failed to remove domain name: #{body['message']}" end end |