class SFRest::Stage

Find Staging envs and stage a set of sites

Public Class Methods

new(conn) click to toggle source

@param [SFRest::Connection] conn

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

Public Instance Methods

enhanced_stage(env: 'test', sites: [], email_site_status: false, wipe_target_environment: false, synchronize_all_users: true, wipe_stacks: []) click to toggle source

Stage a site using the new method @param [String] to_env the name of of target env. defaults to test @param [Array] sites Array of site nids to stage @param [Boolean] email_site_status send an email about the staging status of each site @param [Boolean] wipe_target_environment recreate the target stage wiping all data @param [synchronize_all_users] only stage the user accounts required for the related collections and groups @param [Array] Stacks Array of stack ids to wipe

@return [Integer] Id of the staging task created. rubocop:disable Metrics/ParameterLists

# File lib/sfrest/stage.rb, line 39
def enhanced_stage(env: 'test',
                   sites: [],
                   email_site_status: false,
                   wipe_target_environment: false,
                   synchronize_all_users: true,
                   wipe_stacks: [])
  raise InvalidApiVersion, staging_versions unless staging_versions.include? 2

  payload = { 'to_env' => env, 'sites' => sites,
              'detailed_status' => email_site_status,
              'wipe_target_environment' => wipe_target_environment,
              'synchronize_all_users' => synchronize_all_users,
              'wipe_stacks' => wipe_stacks }.to_json
  @conn.post('/api/v2/stage', payload)
end
list_staging_environments() click to toggle source

Query for available staging environments

@return environments

# File lib/sfrest/stage.rb, line 59
def list_staging_environments
  current_path = "/api/v#{staging_versions.sample}/stage"
  @conn.get(current_path)
end
stage(to_env = 'test', sites = nil, email_site_status = false, skip_gardener = false) click to toggle source

Stage a site @param [String] to_env the name of of target env. defaults to test @param [Array] sites Array of site nids to stage @param [Boolean] email_site_status send an email about the staging status of each site @param [Boolean] skip_gardener skip staging the gardener and only stage the sites

@return [Integer] Id of the staging task created. rubocop: disable Style/OptionalBooleanParameter

# File lib/sfrest/stage.rb, line 19
def stage(to_env = 'test', sites = nil, email_site_status = false, skip_gardener = false)
  raise InvalidApiVersion, staging_versions unless staging_versions.include? 1

  payload = { 'to_env' => to_env, 'sites' => sites,
              'detailed_status' => email_site_status,
              'skip_gardener' => skip_gardener }.to_json
  @conn.post('/api/v1/stage', payload)
end
staging_versions() click to toggle source

determine what version are available for staging @return [Array] Array of available api endpoints

# File lib/sfrest/stage.rb, line 66
def staging_versions
  possible_versions = [1, 2]
  @versions ||= []
  possible_versions.each do |version|
    @conn.get "/api/v#{version}/stage"
    @versions.push version
  rescue SFRest::InvalidResponse
    nil
  end
  @versions
end