Class: RHC::Rest::Domain
Instance Method Summary
collapse
Methods included from Membership
#compact_members, #default_member_role, #delete_members, included, #leave, #members, #owner, #supports_members?, #supports_update_members?, #update_members
Methods inherited from Base
#add_message, #has_param?, #initialize, #link_href, #links, #rest_method, #supports?
#define_attr, #model_name
Methods included from Attributes
#attribute, #attributes, #attributes=, #clear_attribute
Instance Method Details
#add_application(name, options) ⇒ Object
Add Application to this domain options cartridge template scale gear_profile
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/rhc/rest/domain.rb', line 37
def add_application(name, options)
debug "Adding application #{name} to domain #{id}"
payload = {:name => name}
options.each{ |key, value| payload[key.to_sym] = value }
cartridges = Array(payload.delete(:cartridge)).concat(Array(payload.delete(:cartridges))).map do |cart|
if cart.is_a? String or cart.respond_to? :[]
cart
else
cart.url ? {:url => cart.url} : cart.name
end
end.compact.uniq
if cartridges.any?{ |c| c.is_a?(Hash) and c[:url] } and !has_param?('ADD_APPLICATION', 'cartridges[][url]')
raise RHC::Rest::DownloadingCartridgesNotSupported, "The server does not support downloading cartridges."
end
if client.api_version_negotiated >= 1.3
payload[:cartridges] = cartridges
else
raise RHC::Rest::MultipleCartridgeCreationNotSupported, "The server only supports creating an application with a single web cartridge." if cartridges.length > 1
payload[:cartridge] = cartridges.first
end
if payload[:initial_git_url] and !has_param?('ADD_APPLICATION', 'initial_git_url')
raise RHC::Rest::InitialGitUrlNotSupported, "The server does not support creating applications from a source repository."
end
options = {:timeout => options[:scale] && 0 || nil}
rest_method "ADD_APPLICATION", payload, options
end
|
#applications(options = {}) ⇒ Object
70
71
72
73
|
# File 'lib/rhc/rest/domain.rb', line 70
def applications(options = {})
debug "Getting all applications for domain #{id}"
rest_method "LIST_APPLICATIONS", options
end
|
82
83
84
85
|
# File 'lib/rhc/rest/domain.rb', line 82
def configure(payload, options={})
self.attributes = rest_method("UPDATE", payload, options).attributes
self
end
|
#destroy(force = false) ⇒ Object
Also known as:
delete
87
88
89
90
|
# File 'lib/rhc/rest/domain.rb', line 87
def destroy(force=false)
debug "Deleting domain #{id}"
rest_method "DELETE", :force => force
end
|
11
12
13
|
# File 'lib/rhc/rest/domain.rb', line 11
def id
id_and_name.first
end
|
#id_and_name ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/rhc/rest/domain.rb', line 17
def id_and_name
id = @id || attributes['id']
name = @name || attributes['name']
if name.present?
if id == name
[nil, name]
else
[id, name]
end
else
[nil, id]
end
end
|
14
15
16
|
# File 'lib/rhc/rest/domain.rb', line 14
def name
id_and_name.last
end
|
#rename(new_id) ⇒ Object
Also known as:
update
75
76
77
78
79
|
# File 'lib/rhc/rest/domain.rb', line 75
def rename(new_id)
debug "Updating domain #{id} to #{new_id}"
rest_method "UPDATE", {:id => new_id}, {:timeout => 0}
end
|
#supports_add_application_with_env_vars? ⇒ Boolean
93
94
95
|
# File 'lib/rhc/rest/domain.rb', line 93
def supports_add_application_with_env_vars?
has_param?('ADD_APPLICATION', 'environment_variables')
end
|