Module: Nucleus::Adapters::V1::CloudControl::Domains
- Included in:
- Nucleus::Adapters::V1::CloudControl
- Defined in:
- lib/nucleus/adapters/v1/cloud_control/domains.rb
Overview
cloud control, CRUD operations for the application’s domain object
Constant Summary collapse
- CC_URLS =
cloud control URLs that are automatically assigned to applications as domain but can’t be managed
%w(cloudcontrolapp.com cloudcontrolled.com)
Instance Method Summary collapse
- #create_domain(application_id, domain) ⇒ Object
- #delete_domain(application_id, alias_name) ⇒ Object
- #domain(application_id, alias_name) ⇒ Object
- #domains(application_id) ⇒ Object
Instance Method Details
#create_domain(application_id, domain) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nucleus/adapters/v1/cloud_control/domains.rb', line 30 def create_domain(application_id, domain) # check if name is available if domain?(application_id, domain[:name]) fail Errors::SemanticAdapterRequestError, "Domain '#{domain[:name]}' is already assigned to the application" end # no conversion needed, cc domains already have :name value cc_domain = post("/app/#{application_id}/deployment/#{NUCLEUS_DEPLOYMENT}/alias", body: { name: domain[:name] }).body log.info("Please use this code to verify your custom application domain: #{cc_domain[:verification_code]}") log.info('More information about the domain verification can be found at: '\ 'https://www.cloudcontrol.com/dev-center/add-on-documentation/alias') to_nucleus_domain(cc_domain) end |
#delete_domain(application_id, alias_name) ⇒ Object
47 48 49 |
# File 'lib/nucleus/adapters/v1/cloud_control/domains.rb', line 47 def delete_domain(application_id, alias_name) delete("/app/#{application_id}/deployment/#{NUCLEUS_DEPLOYMENT}/alias/#{alias_name}") end |
#domain(application_id, alias_name) ⇒ Object
23 24 25 26 27 |
# File 'lib/nucleus/adapters/v1/cloud_control/domains.rb', line 23 def domain(application_id, alias_name) # no conversion needed, cc domains already have :name value cc_domain = get("/app/#{application_id}/deployment/#{NUCLEUS_DEPLOYMENT}/alias/#{alias_name}").body to_nucleus_domain(cc_domain) end |
#domains(application_id) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nucleus/adapters/v1/cloud_control/domains.rb', line 11 def domains(application_id) # no conversion needed, cc domains already have :name value cc_domains = get("/app/#{application_id}/deployment/#{NUCLEUS_DEPLOYMENT}/alias").body # the domain shall NOT be a CC system domain cc_domains = cc_domains.find_all do |domain| !CC_URLS.any? { |cc_domain| domain[:name].include? cc_domain } end # the list does not include the timestamps, fetch all cc_domains.compact.collect { |domain| domain(application_id, domain[:name]) } end |