Class: SFRest::Profile
- Inherits:
-
Object
- Object
- SFRest::Profile
- Defined in:
- lib/sfrest/profile.rb
Overview
Work with installation profiles.
Instance Method Summary collapse
-
#disable(name, stack_id: nil) ⇒ Object
Disables an installation profile.
-
#enable(name, stack_id: nil) ⇒ Object
Enables an installation profile.
-
#initialize(conn) ⇒ Profile
constructor
A new instance of Profile.
-
#profile_list(**params) ⇒ Hash
Gets a list of installation profiles.
-
#set_default(name, stack_id: nil) ⇒ Object
Sets the default installation profile for use with other REST endpoints.
Constructor Details
#initialize(conn) ⇒ Profile
Returns a new instance of Profile.
7 8 9 |
# File 'lib/sfrest/profile.rb', line 7 def initialize(conn) @conn = conn end |
Instance Method Details
#disable(name, stack_id: nil) ⇒ Object
Disables an installation profile.
52 53 54 55 56 |
# File 'lib/sfrest/profile.rb', line 52 def disable(name, stack_id: nil) target_url = "/api/v1/profiles/#{name}/disable" target_url += "?stack_id=#{stack_id}" unless stack_id.nil? @conn.post(target_url, '{}') end |
#enable(name, stack_id: nil) ⇒ Object
Enables an installation profile.
42 43 44 45 46 |
# File 'lib/sfrest/profile.rb', line 42 def enable(name, stack_id: nil) target_url = "/api/v1/profiles/#{name}/enable" target_url += "?stack_id=#{stack_id}" unless stack_id.nil? @conn.post(target_url, '{}') end |
#profile_list(**params) ⇒ Hash
Gets a list of installation profiles.
}
28 29 30 31 32 33 34 35 36 |
# File 'lib/sfrest/profile.rb', line 28 def profile_list(**params) target_url = '/api/v1/profiles' # Generate a string like "stack_id=3&is_enabled=true" url_params = params.each.map { |k, v| "#{k}=#{v}" }.join('&') target_url += "?#{url_params}" unless url_params.empty? # Output is already well-formed, so return it. @conn.get(target_url) end |
#set_default(name, stack_id: nil) ⇒ Object
Sets the default installation profile for use with other REST endpoints.
62 63 64 65 66 |
# File 'lib/sfrest/profile.rb', line 62 def set_default(name, stack_id: nil) target_url = "/api/v1/profiles/#{name}/set_default" target_url += "?stack_id=#{stack_id}" unless stack_id.nil? @conn.post(target_url, '{}') end |