Class: KnapsackPro::Client::API::V1::Queues

Inherits:
Base
  • Object
show all
Defined in:
lib/knapsack_pro/client/api/v1/queues.rb

Constant Summary collapse

CODE_ATTEMPT_CONNECT_TO_QUEUE_FAILED =
'ATTEMPT_CONNECT_TO_QUEUE_FAILED'

Class Method Summary collapse

Class Method Details

.queue(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/knapsack_pro/client/api/v1/queues.rb', line 11

def queue(args)
  request_hash = {
    :fixed_queue_split => KnapsackPro::Config::Env.fixed_queue_split,
    :can_initialize_queue => args.fetch(:can_initialize_queue),
    :attempt_connect_to_queue => args.fetch(:attempt_connect_to_queue),
    :commit_hash => args.fetch(:commit_hash),
    :branch => args.fetch(:branch),
    :node_total => args.fetch(:node_total),
    :node_index => args.fetch(:node_index),
    :node_build_id => KnapsackPro::Config::Env.ci_node_build_id,
    :user_seat => KnapsackPro::Config::Env.masked_user_seat,
  }

  if request_hash[:can_initialize_queue] && !request_hash[:attempt_connect_to_queue]
    request_hash.merge!({
      :test_files => args.fetch(:test_files),
      :build_author => KnapsackPro::RepositoryAdapters::GitAdapter.new.build_author,
      :commit_authors => KnapsackPro::RepositoryAdapters::GitAdapter.new.commit_authors,
    })
  end

  action_class.new(
    endpoint_path: '/v1/queues/queue',
    http_method: :post,
    request_hash: request_hash
  )
end