Class: Escobar::Heroku::PipelinePromotion
- Inherits:
-
Object
- Object
- Escobar::Heroku::PipelinePromotion
- Defined in:
- lib/escobar/heroku/pipeline_promotion.rb
Overview
Class reperesenting a Heroku Pipeline Promotion
Defined Under Namespace
Classes: MissingContextsError, RequiresTwoFactorError
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
-
#second_factor ⇒ Object
readonly
Returns the value of attribute second_factor.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #body ⇒ Object
- #create ⇒ Object
-
#initialize(client, pipeline, source, targets, second_factor) ⇒ PipelinePromotion
constructor
A new instance of PipelinePromotion.
- #promotion_path ⇒ Object
- #raise_2fa_error ⇒ Object
Constructor Details
#initialize(client, pipeline, source, targets, second_factor) ⇒ PipelinePromotion
Returns a new instance of PipelinePromotion.
7 8 9 10 11 12 13 14 |
# 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 |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion.rb', line 5 def client @client end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion.rb', line 5 def name @name end |
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion.rb', line 5 def pipeline @pipeline end |
#second_factor ⇒ Object (readonly)
Returns the value of attribute second_factor.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion.rb', line 5 def second_factor @second_factor end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion.rb', line 5 def source @source end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion.rb', line 5 def targets @targets end |
Instance Method Details
#body ⇒ Object
48 49 50 51 52 53 54 |
# 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 ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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 ⇒ Object
16 17 18 |
# File 'lib/escobar/heroku/pipeline_promotion.rb', line 16 def promotion_path "/pipeline-promotions" end |
#raise_2fa_error ⇒ Object
43 44 45 46 |
# File 'lib/escobar/heroku/pipeline_promotion.rb', line 43 def raise_2fa_error = "Pipeline requires second factor: #{pipeline.name}" raise RequiresTwoFactorError.new_from_build_request(self, ) end |