Class: Ciflows::GraphqlV2

Inherits:
Object
  • Object
show all
Defined in:
lib/ciflows/graphql_v2.rb

Constant Summary collapse

HTTP =
GraphQL::Client::HTTP.new('https://api.circleci.com/graphql-unstable') do
  def headers(_context)
    { "User-Agent": 'My Client', 'Authorization': Ciflows::CI_TOKEN }
  end
end
Schema =
GraphQL::Client.load_schema(HTTP)
Client =
GraphQL::Client.new(schema: Schema, execute: HTTP)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow_id, job_name) ⇒ GraphqlV2

Returns a new instance of GraphqlV2.



21
22
23
24
# File 'lib/ciflows/graphql_v2.rb', line 21

def initialize(workflow_id, job_name)
  @workflow_id = workflow_id
  @job_name = job_name
end

Instance Attribute Details

#approve_jobObject

Returns the value of attribute approve_job.



19
20
21
# File 'lib/ciflows/graphql_v2.rb', line 19

def approve_job
  @approve_job
end

#clientObject (readonly)

Returns the value of attribute client.



18
19
20
# File 'lib/ciflows/graphql_v2.rb', line 18

def client
  @client
end

#jobObject

Returns the value of attribute job.



19
20
21
# File 'lib/ciflows/graphql_v2.rb', line 19

def job
  @job
end

#job_nameObject (readonly)

Returns the value of attribute job_name.



18
19
20
# File 'lib/ciflows/graphql_v2.rb', line 18

def job_name
  @job_name
end

#schemaObject (readonly)

Returns the value of attribute schema.



18
19
20
# File 'lib/ciflows/graphql_v2.rb', line 18

def schema
  @schema
end

#workflowObject

Returns the value of attribute workflow.



19
20
21
# File 'lib/ciflows/graphql_v2.rb', line 19

def workflow
  @workflow
end

#workflow_idObject (readonly)

Returns the value of attribute workflow_id.



18
19
20
# File 'lib/ciflows/graphql_v2.rb', line 18

def workflow_id
  @workflow_id
end

Instance Method Details

#get_workflowObject



30
31
32
# File 'lib/ciflows/graphql_v2.rb', line 30

def get_workflow
  @workflow ||= Client.query(Query::WorkflowQuery, variables: { id: workflow_id })
end