Class: Ciflows::Graphql
- Inherits:
-
Object
- Object
- Ciflows::Graphql
- Defined in:
- lib/ciflows/graphql.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#failed_jobs ⇒ Object
Returns the value of attribute failed_jobs.
-
#job ⇒ Object
Returns the value of attribute job.
-
#job_name ⇒ Object
readonly
Returns the value of attribute job_name.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#workflow ⇒ Object
Returns the value of attribute workflow.
-
#workflow_id ⇒ Object
readonly
Returns the value of attribute workflow_id.
Instance Method Summary collapse
- #approve_job ⇒ Object
- #get_jobs(status) ⇒ Object
- #get_workflow ⇒ Object
-
#initialize(workflow_id, job_name) ⇒ Graphql
constructor
A new instance of Graphql.
- #rerun_workflow_from(from = 'failed') ⇒ Object
Constructor Details
#initialize(workflow_id, job_name) ⇒ Graphql
Returns a new instance of Graphql.
12 13 14 15 16 17 18 19 20 |
# File 'lib/ciflows/graphql.rb', line 12 def initialize(workflow_id, job_name) @workflow_id = workflow_id @job_name = job_name @client = Graphlient::Client.new(BASE_URL, headers: { 'Authorization' => Ciflows::CI_TOKEN, }) @schema = @client.schema end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/ciflows/graphql.rb', line 9 def client @client end |
#failed_jobs ⇒ Object
Returns the value of attribute failed_jobs.
10 11 12 |
# File 'lib/ciflows/graphql.rb', line 10 def failed_jobs @failed_jobs end |
#job ⇒ Object
Returns the value of attribute job.
10 11 12 |
# File 'lib/ciflows/graphql.rb', line 10 def job @job end |
#job_name ⇒ Object (readonly)
Returns the value of attribute job_name.
9 10 11 |
# File 'lib/ciflows/graphql.rb', line 9 def job_name @job_name end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
9 10 11 |
# File 'lib/ciflows/graphql.rb', line 9 def schema @schema end |
#workflow ⇒ Object
Returns the value of attribute workflow.
10 11 12 |
# File 'lib/ciflows/graphql.rb', line 10 def workflow @workflow end |
#workflow_id ⇒ Object (readonly)
Returns the value of attribute workflow_id.
9 10 11 |
# File 'lib/ciflows/graphql.rb', line 9 def workflow_id @workflow_id end |
Instance Method Details
#approve_job ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/ciflows/graphql.rb', line 22 def approve_job client.query(id: job.id) do mutation(id: :ID!) do approveJob(id: :id) end end end |
#get_jobs(status) ⇒ Object
54 55 56 |
# File 'lib/ciflows/graphql.rb', line 54 def get_jobs(status) @failed_jobs ||= workflow.data.workflow.jobs.select { |job| job.status.eql?(status) } end |
#get_workflow ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ciflows/graphql.rb', line 30 def get_workflow @workflow ||= client.query(id: workflow_id) do query(id: :ID!) do workflow(id: :id) do status jobs do id name type status end end end end end |
#rerun_workflow_from(from = 'failed') ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/ciflows/graphql.rb', line 46 def rerun_workflow_from(from = 'failed') client.query(id: workflow_id, from: from.upcase) do mutation(id: :ID!, from: :RerunWorkflowFromOption) do rerunWorkflow(id: :id, from: :from) end end end |