Module: Legion::Extensions::ServiceNow::CiRelationship::Runners::CiRelationship
Instance Method Summary
collapse
#connection, #fetch_oauth2_token, #handle_response
Instance Method Details
#create_ci_relationship(parent:, child:, type:) ⇒ Object
34
35
36
37
38
|
# File 'lib/legion/extensions/service_now/ci_relationship/runners/ci_relationship.rb', line 34
def create_ci_relationship(parent:, child:, type:, **)
body = { parent: parent, child: child, type: type }
resp = connection(**).post('/api/now/table/cmdb_rel_ci', body)
{ relationship: resp.body['result'] }
end
|
#delete_ci_relationship(sys_id:) ⇒ Object
40
41
42
43
|
# File 'lib/legion/extensions/service_now/ci_relationship/runners/ci_relationship.rb', line 40
def delete_ci_relationship(sys_id:, **)
resp = connection(**).delete("/api/now/table/cmdb_rel_ci/#{sys_id}")
{ deleted: resp.status == 204, sys_id: sys_id }
end
|
#get_relationship_type(sys_id:) ⇒ Object
17
18
19
20
|
# File 'lib/legion/extensions/service_now/ci_relationship/runners/ci_relationship.rb', line 17
def get_relationship_type(sys_id:, **)
resp = connection(**).get("/api/now/table/cmdb_rel_type/#{sys_id}")
{ relationship_type: resp.body['result'] }
end
|
#list_ci_relationships(sysparm_limit: 100, sysparm_offset: 0, parent: nil, child: nil, sysparm_query: nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/legion/extensions/service_now/ci_relationship/runners/ci_relationship.rb', line 22
def list_ci_relationships(sysparm_limit: 100, sysparm_offset: 0,
parent: nil, child: nil, sysparm_query: nil, **)
params = { sysparm_limit: sysparm_limit, sysparm_offset: sysparm_offset }
query_parts = []
query_parts << "parent=#{parent}" if parent
query_parts << "child=#{child}" if child
query_parts << sysparm_query if sysparm_query
params[:sysparm_query] = query_parts.join('^') unless query_parts.empty?
resp = connection(**).get('/api/now/table/cmdb_rel_ci', params)
{ relationships: resp.body['result'] }
end
|
#list_relationship_types(sysparm_limit: 100, sysparm_offset: 0) ⇒ Object
11
12
13
14
15
|
# File 'lib/legion/extensions/service_now/ci_relationship/runners/ci_relationship.rb', line 11
def list_relationship_types(sysparm_limit: 100, sysparm_offset: 0, **)
params = { sysparm_limit: sysparm_limit, sysparm_offset: sysparm_offset }
resp = connection(**).get('/api/now/table/cmdb_rel_type', params)
{ relationship_types: resp.body['result'] }
end
|