Class: SnapCiManualTrigger::Service
- Inherits:
-
Object
- Object
- SnapCiManualTrigger::Service
- Defined in:
- lib/snap_ci_manual_trigger/service.rb
Constant Summary collapse
- CONNECTION_URL =
'https://api.snap-ci.com'
- HEADERS =
{ 'Accept' => 'application/vnd.snap-ci.com.v1+json', 'Content-type' => 'application/json', }
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#branch_name ⇒ Object
readonly
Returns the value of attribute branch_name.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user:, api_key:, owner:, repository:, branch_name:, connection: nil) ⇒ Service
constructor
A new instance of Service.
- #manual_stage(pipeline:, stage:) ⇒ Object
- #manual_stage_on_new_pipeline(stage) ⇒ Object
- #new_pipeline ⇒ Object
Constructor Details
#initialize(user:, api_key:, owner:, repository:, branch_name:, connection: nil) ⇒ Service
Returns a new instance of Service.
13 14 15 16 17 18 19 20 |
# File 'lib/snap_ci_manual_trigger/service.rb', line 13 def initialize(user:, api_key:, owner:, repository:, branch_name:, connection: nil) @user = user @api_key = api_key @owner = owner @repository = repository @branch_name = branch_name @connection = connection || build_connection end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
11 12 13 |
# File 'lib/snap_ci_manual_trigger/service.rb', line 11 def api_key @api_key end |
#branch_name ⇒ Object (readonly)
Returns the value of attribute branch_name.
11 12 13 |
# File 'lib/snap_ci_manual_trigger/service.rb', line 11 def branch_name @branch_name end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
11 12 13 |
# File 'lib/snap_ci_manual_trigger/service.rb', line 11 def connection @connection end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
11 12 13 |
# File 'lib/snap_ci_manual_trigger/service.rb', line 11 def owner @owner end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
11 12 13 |
# File 'lib/snap_ci_manual_trigger/service.rb', line 11 def repository @repository end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
11 12 13 |
# File 'lib/snap_ci_manual_trigger/service.rb', line 11 def user @user end |
Instance Method Details
#manual_stage(pipeline:, stage:) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/snap_ci_manual_trigger/service.rb', line 31 def manual_stage(pipeline:, stage:) response = call_manual_stage pipeline, stage (response) check_not_found(response, pipeline, stage) parsed_response = parse_response response parsed_response['_embedded']['_links']['self']['href'] end |
#manual_stage_on_new_pipeline(stage) ⇒ Object
40 41 42 43 |
# File 'lib/snap_ci_manual_trigger/service.rb', line 40 def manual_stage_on_new_pipeline(stage) pipeline_id = new_pipeline manual_stage pipeline: pipeline_id, stage: stage end |
#new_pipeline ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/snap_ci_manual_trigger/service.rb', line 22 def new_pipeline response = call_new_pipeline (response) check_not_found(response) parsed_response = parse_response response parsed_response['counter'] end |