class SFRest::Profile

Work with installation profiles.

Public Class Methods

new(conn) click to toggle source

@param [SFRest::Connection] conn

# File lib/sfrest/profile.rb, line 7
def initialize(conn)
  @conn = conn
end

Public Instance Methods

disable(name, stack_id: nil) click to toggle source

Disables an installation profile.

@param [String] name @param [Integer] stack_id Required if the factory is multistack.

# 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) click to toggle source

Enables an installation profile.

@param [String] name @param [Integer] stack_id Required if the factory is multistack.

# 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) click to toggle source

Gets a list of installation profiles.

@param [Hash] params Given as URL parameters. @option params [Integer] :stack_id A stack id to filter by. @option params [Boolean] :is_enabled True to filter by enabled profiles. False

to filter by disabled profiles.

@return [Hash] Profile info formatted like so: {

  'profiles' => [{
    'name' => 'testing',
    'description' => 'Some description',
    'stack_id' => 1,
    'rest_api_default' => false,
    'enabled' => true
  }],
  'count' => 1,
  'time' => '2021-03-12T02:26:34+00:00'
}
# 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) click to toggle source

Sets the default installation profile for use with other REST endpoints.

@param [String] name @param [Integer] stack_id Required if the factory is multistack.

# 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