Class: Zenaton::Services::GraphQL::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/zenaton/services/graph_ql/client.rb

Overview

Small client to interact with Zenaton’s GraphQL API

Constant Summary collapse

ZENATON_GATEWAY_URL =

Gateway url

'https://gateway.zenaton.com/api'

Instance Method Summary collapse

Constructor Details

#initialize(http:) ⇒ Client

Setup the GraphQL client with the HTTP client to use



23
24
25
# File 'lib/zenaton/services/graph_ql/client.rb', line 23

def initialize(http:)
  @http = http
end

Instance Method Details

#find_workflow(name, custom_id, credentials) ⇒ Object

Search for a workflow with a custom ID



84
85
86
87
88
# File 'lib/zenaton/services/graph_ql/client.rb', line 84

def find_workflow(name, custom_id, credentials)
  app_env = credentials['app_env']
  query = WorkflowQuery.new(name, custom_id, app_env)
  execute(query, credentials)
end

#kill_workflow(name, custom_id, credentials) ⇒ Object

Stopping an existing workflow



56
57
58
59
60
# File 'lib/zenaton/services/graph_ql/client.rb', line 56

def kill_workflow(name, custom_id, credentials)
  app_env = credentials['app_env']
  mutation = KillWorkflowMutation.new(name, custom_id, app_env)
  execute(mutation, credentials)
end

#pause_workflow(name, custom_id, credentials) ⇒ Object

Pausing an existing workflow



63
64
65
66
67
# File 'lib/zenaton/services/graph_ql/client.rb', line 63

def pause_workflow(name, custom_id, credentials)
  app_env = credentials['app_env']
  mutation = PauseWorkflowMutation.new(name, custom_id, app_env)
  execute(mutation, credentials)
end

#resume_workflow(name, custom_id, credentials) ⇒ Object

Resuming a paused workflow



70
71
72
73
74
# File 'lib/zenaton/services/graph_ql/client.rb', line 70

def resume_workflow(name, custom_id, credentials)
  app_env = credentials['app_env']
  mutation = ResumeWorkflowMutation.new(name, custom_id, app_env)
  execute(mutation, credentials)
end

#schedule_task(task, cron, credentials) ⇒ Object

Scheduling a task



35
36
37
38
39
# File 'lib/zenaton/services/graph_ql/client.rb', line 35

def schedule_task(task, cron, credentials)
  app_env = credentials['app_env']
  mutation = CreateTaskScheduleMutation.new(task, cron, app_env)
  execute(mutation, credentials)
end

#schedule_workflow(workflow, cron, credentials) ⇒ Object

Scheduling a workflow



28
29
30
31
32
# File 'lib/zenaton/services/graph_ql/client.rb', line 28

def schedule_workflow(workflow, cron, credentials)
  app_env = credentials['app_env']
  mutation = CreateWorkflowScheduleMutation.new(workflow, cron, app_env)
  execute(mutation, credentials)
end

#send_event(name, custom_id, event, credentials) ⇒ Object

Sending an event to an existing workflow



77
78
79
80
81
# File 'lib/zenaton/services/graph_ql/client.rb', line 77

def send_event(name, custom_id, event, credentials)
  app_env = credentials['app_env']
  mutation = SendEventMutation.new(name, custom_id, event, app_env)
  execute(mutation, credentials)
end

#start_task(task, credentials) ⇒ Object

Dispatching a single task



42
43
44
45
46
# File 'lib/zenaton/services/graph_ql/client.rb', line 42

def start_task(task, credentials)
  app_env = credentials['app_env']
  mutation = DispatchTaskMutation.new(task, app_env)
  execute(mutation, credentials)
end

#start_workflow(workflow, credentials) ⇒ Object

Dispatching a workflow



49
50
51
52
53
# File 'lib/zenaton/services/graph_ql/client.rb', line 49

def start_workflow(workflow, credentials)
  app_env = credentials['app_env']
  mutation = DispatchWorkflowMutation.new(workflow, app_env)
  execute(mutation, credentials)
end