class Escobar::Heroku::PipelinePromotion

Class reperesenting a Heroku Pipeline Promotion

Attributes

client[R]
id[R]
name[R]
pipeline[R]
second_factor[R]
source[R]
targets[R]

Public Class Methods

new(client, pipeline, source, targets, second_factor) click to toggle source
# File lib/escobar/heroku/pipeline_promotion.rb, line 7
def initialize(client, pipeline, source, targets, second_factor)
  @id = pipeline.id
  @client = client
  @source = source
  @targets = targets
  @pipeline = pipeline
  @second_factor = second_factor
end

Public Instance Methods

body() click to toggle source
# File lib/escobar/heroku/pipeline_promotion.rb, line 48
def body
  {
    pipeline: { id: id },
    source: { app: { id: source.id } },
    targets: targets.map { |t| { app: { id: t.id } } }
  }
end
create() click to toggle source
# File lib/escobar/heroku/pipeline_promotion.rb, line 20
def create
  response = client.heroku.post(promotion_path, body, second_factor)
  case response["id"]
  when Escobar::UUID_REGEX
    results = Escobar::Heroku::PipelinePromotionTargets.new(
      self, response
    )
    results.releases
  when "two_factor"
    raise_2fa_error
  else
    raise ArgumentError, response.to_json
  end
end
promotion_path() click to toggle source
# File lib/escobar/heroku/pipeline_promotion.rb, line 16
def promotion_path
  "/pipeline-promotions"
end
raise_2fa_error() click to toggle source
# File lib/escobar/heroku/pipeline_promotion.rb, line 43
def raise_2fa_error
  message = "Pipeline requires second factor: #{pipeline.name}"
  raise RequiresTwoFactorError.new_from_build_request(self, message)
end