class GoodData::LCM2::EnsureTechnicalUsersProject

Constants

DESCRIPTION
PARAMS
RESULT_HEADER

Public Class Methods

call(params) click to toggle source
# File lib/gooddata/lcm/actions/ensure_technical_users_project.rb, line 43
def call(params)
  client = params.gdc_gd_client

  technical_users = params.technical_users || params.technical_user || []
  new_users = technical_users.map do |technical_user|
    {
      login: technical_user,
      role: 'admin'
    }
  end

  results = params.synchronize.pmap do |synchronize_info|
    synchronize_info[:to].pmap do |entry|
      ensure_users(client, entry[:pid], new_users)
    end
  end.flatten

  results += params.clients.pmap { |input_client| input_client[:project] }.compact.pmap { |pid| ensure_users(client, pid, new_users) }.flatten if params.clients

  results
end

Private Class Methods

ensure_users(client, project_id, new_users) click to toggle source
# File lib/gooddata/lcm/actions/ensure_technical_users_project.rb, line 67
def ensure_users(client, project_id, new_users)
  project = client.projects(project_id)
  res = project.create_users(new_users)

  new_users.zip(res).map do |f, s|
    {
      project: project.title,
      pid: project.pid,
      login: f[:login],
      role: f[:role],
      result: s[:type],
      message: s[:message],
      url: s[:user]
    }
  end
end