Module: Legion::Extensions::ServiceNow::Change::Runners::Change
Instance Method Summary
collapse
-
#calculate_conflicts(id:) ⇒ Object
-
#create_change_task(id:, short_description:) ⇒ Object
-
#create_emergency(short_description:, description: nil, assignment_group: nil) ⇒ Object
-
#create_normal(short_description:, description: nil, assignment_group: nil, start_date: nil, end_date: nil) ⇒ Object
-
#create_standard(short_description:, description: nil, assignment_group: nil) ⇒ Object
-
#delete_change(id:) ⇒ Object
-
#delete_change_task(id:, task_id:) ⇒ Object
-
#get_approvals(id:) ⇒ Object
-
#get_change(id:) ⇒ Object
-
#get_conflicts(id:) ⇒ Object
-
#list_change_tasks(id:) ⇒ Object
-
#list_changes(sysparm_limit: 100, sysparm_offset: 0, sysparm_query: nil) ⇒ Object
-
#update_change(id:, short_description: nil, description: nil, state: nil, assignment_group: nil, start_date: nil, end_date: nil) ⇒ Object
-
#update_change_task(id:, task_id:, short_description: nil, state: nil, assigned_to: nil) ⇒ Object
#connection, #fetch_oauth2_token, #handle_response
Instance Method Details
#calculate_conflicts(id:) ⇒ Object
98
99
100
101
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 98
def calculate_conflicts(id:, **)
resp = connection(**).post("/api/sn_chg_rest/change/#{id}/conflict", {})
{ conflicts: resp.body['result'] }
end
|
#create_change_task(id:, short_description:) ⇒ Object
73
74
75
76
77
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 73
def create_change_task(id:, short_description:, **)
body = { short_description: short_description }
resp = connection(**).post("/api/sn_chg_rest/change/#{id}/task", body)
{ task: resp.body['result'] }
end
|
#create_emergency(short_description:, description: nil, assignment_group: nil) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 29
def create_emergency(short_description:, description: nil, assignment_group: nil, **)
body = { short_description: short_description }
body[:description] = description if description
body[:assignment_group] = assignment_group if assignment_group
resp = connection(**).post('/api/sn_chg_rest/change/emergency', body)
{ change: resp.body['result'] }
end
|
#create_normal(short_description:, description: nil, assignment_group: nil, start_date: nil, end_date: nil) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 18
def create_normal(short_description:, description: nil, assignment_group: nil,
start_date: nil, end_date: nil, **)
body = { short_description: short_description }
body[:description] = description if description
body[:assignment_group] = assignment_group if assignment_group
body[:start_date] = start_date if start_date
body[:end_date] = end_date if end_date
resp = connection(**).post('/api/sn_chg_rest/change/normal', body)
{ change: resp.body['result'] }
end
|
#create_standard(short_description:, description: nil, assignment_group: nil) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 37
def create_standard(short_description:, description: nil, assignment_group: nil, **)
body = { short_description: short_description }
body[:description] = description if description
body[:assignment_group] = assignment_group if assignment_group
resp = connection(**).post('/api/sn_chg_rest/change/standard', body)
{ change: resp.body['result'] }
end
|
#delete_change(id:) ⇒ Object
63
64
65
66
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 63
def delete_change(id:, **)
resp = connection(**).delete("/api/sn_chg_rest/change/#{id}")
{ deleted: resp.status == 204, id: id }
end
|
#delete_change_task(id:, task_id:) ⇒ Object
88
89
90
91
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 88
def delete_change_task(id:, task_id:, **)
resp = connection(**).delete("/api/sn_chg_rest/change/#{id}/task/#{task_id}")
{ deleted: resp.status == 204, task_id: task_id }
end
|
#get_approvals(id:) ⇒ Object
103
104
105
106
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 103
def get_approvals(id:, **)
resp = connection(**).get("/api/sn_chg_rest/change/#{id}/approvals")
{ approvals: resp.body['result'] }
end
|
#get_change(id:) ⇒ Object
45
46
47
48
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 45
def get_change(id:, **)
resp = connection(**).get("/api/sn_chg_rest/change/#{id}")
{ change: resp.body['result'] }
end
|
#get_conflicts(id:) ⇒ Object
93
94
95
96
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 93
def get_conflicts(id:, **)
resp = connection(**).get("/api/sn_chg_rest/change/#{id}/conflict")
{ conflicts: resp.body['result'] }
end
|
#list_change_tasks(id:) ⇒ Object
68
69
70
71
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 68
def list_change_tasks(id:, **)
resp = connection(**).get("/api/sn_chg_rest/change/#{id}/task")
{ tasks: resp.body['result'] }
end
|
#list_changes(sysparm_limit: 100, sysparm_offset: 0, sysparm_query: nil) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 11
def list_changes(sysparm_limit: 100, sysparm_offset: 0, sysparm_query: nil, **)
params = { sysparm_limit: sysparm_limit, sysparm_offset: sysparm_offset }
params[:sysparm_query] = sysparm_query if sysparm_query
resp = connection(**).get('/api/sn_chg_rest/change', params)
{ changes: resp.body['result'] }
end
|
#update_change(id:, short_description: nil, description: nil, state: nil, assignment_group: nil, start_date: nil, end_date: nil) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 50
def update_change(id:, short_description: nil, description: nil, state: nil,
assignment_group: nil, start_date: nil, end_date: nil, **)
body = {}
body[:short_description] = short_description if short_description
body[:description] = description if description
body[:state] = state if state
body[:assignment_group] = assignment_group if assignment_group
body[:start_date] = start_date if start_date
body[:end_date] = end_date if end_date
resp = connection(**).patch("/api/sn_chg_rest/change/#{id}", body)
{ change: resp.body['result'] }
end
|
#update_change_task(id:, task_id:, short_description: nil, state: nil, assigned_to: nil) ⇒ Object
79
80
81
82
83
84
85
86
|
# File 'lib/legion/extensions/service_now/change/runners/change.rb', line 79
def update_change_task(id:, task_id:, short_description: nil, state: nil, assigned_to: nil, **)
body = {}
body[:short_description] = short_description if short_description
body[:state] = state if state
body[:assigned_to] = assigned_to if assigned_to
resp = connection(**).patch("/api/sn_chg_rest/change/#{id}/task/#{task_id}", body)
{ task: resp.body['result'] }
end
|