Class: GitlabQuality::TestTooling::GitlabClient::WorkItemsClient
Instance Method Summary
collapse
-
#add_labels(work_item_id:, label_ids:) ⇒ Object
-
#create_discussion(id:, note:) ⇒ Object
-
#create_discussion_note(work_item_id:, discussion_id:, text:) ⇒ Object
-
#create_linked_items(work_item_id:, item_ids:, link_type:) ⇒ Object
-
#group_work_items(labels: [], cursor: '', state: 'opened', created_after: nil, extras: [:work_item_fields]) ⇒ Object
-
#paginated_call(method_name, args) ⇒ Object
-
#update_note(note_id:, body:) ⇒ Object
-
#work_item(workitem_iid:, widgets: [:notes, :linked_items, :labels, :hierarchy]) ⇒ Object
#initialize, #post
Instance Method Details
#add_labels(work_item_id:, label_ids:) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/gitlab_quality/test_tooling/gitlab_client/work_items_client.rb', line 100
def add_labels(work_item_id:, label_ids:)
query =
" mutation WorkItemUpdate {\n workItemUpdate(input: { id: \"\#{work_item_id}\", labelsWidget: { addLabelIds: [\#{label_ids.map { |id| \"\\\"\#{id}\\\"\" }.join(', ')}] } }) {\n clientMutationId\n errors\n }\n }\n GQL\n post(query)\nend\n"
|
#create_discussion(id:, note:) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/gitlab_quality/test_tooling/gitlab_client/work_items_client.rb', line 44
def create_discussion(id:, note:)
post(
" mutation CreateDiscussion {\n createDiscussion(input: {noteableId: \"\#{id}\", body: \"\#{note}\"}) {\n clientMutationId\n errors\n note {\n \#{note_fields}\n }\n }\n }\n GQL\n )\nend\n"
|
#create_discussion_note(work_item_id:, discussion_id:, text:) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/gitlab_quality/test_tooling/gitlab_client/work_items_client.rb', line 60
def create_discussion_note(work_item_id:, discussion_id:, text:)
query = " mutation CreateNote {\n createNote(input: { discussionId: \"\#{discussion_id}\", noteableId: \"\#{work_item_id}\", body: \"\#{text}\" }) {\n clientMutationId\n errors\n note {\n \#{note_fields}\n }\n }\n }\n GQL\n post(query)\nend\n"
|
#create_linked_items(work_item_id:, item_ids:, link_type:) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/gitlab_quality/test_tooling/gitlab_client/work_items_client.rb', line 87
def create_linked_items(work_item_id:, item_ids:, link_type:)
query = " mutation WorkItemAddLinkedItems {\n workItemAddLinkedItems(\n input: { id: \"\#{work_item_id}\", workItemsIds: [\#{item_ids.map { |id| \"\\\"\#{id}\\\"\" }.join(', ')}], linkType: \#{link_type} }\n ) {\n clientMutationId\n }\n }\n GQL\n post(query)\nend\n"
|
#group_work_items(labels: [], cursor: '', state: 'opened', created_after: nil, extras: [:work_item_fields]) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/gitlab_quality/test_tooling/gitlab_client/work_items_client.rb', line 21
def group_work_items(labels: [], cursor: '', state: 'opened', created_after: nil, extras: [:work_item_fields])
query = " query {\n group(fullPath: \"\#{group}\") {\n workItems(after: \"\#{cursor}\",\#{created_after ? \" createdAfter: \\\"\#{created_after}\\\",\" : ''} labelName: [\#{labels.map { |label| \"\\\"\#{label}\\\"\" }.join(', ')}], state: \#{state}) {\n nodes {\n \#{construct_extras(extras)}\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n GQL\n begin\n post(query)[:workItems]\n rescue StandardError => e\n puts \"Error: \#{e}\"\n end\nend\n"
|
#paginated_call(method_name, args) ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/gitlab_quality/test_tooling/gitlab_client/work_items_client.rb', line 113
def paginated_call(method_name, args)
results = []
raise ArgumentError, "Unknown method: #{method_name}" unless respond_to?(method_name, true)
method_obj = method(method_name)
loop do
response = method_obj.call(**args)
break unless response
results += response[:nodes]
break unless response[:pageInfo][:hasNextPage]
args[:cursor] = response[:pageInfo][:endCursor]
end
results
end
|
#update_note(note_id:, body:) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/gitlab_quality/test_tooling/gitlab_client/work_items_client.rb', line 75
def update_note(note_id:, body:)
query = " mutation UpdateNote {\n updateNote(input: { body: \"\#{body}\", id: \"\#{note_id}\" }) {\n clientMutationId\n errors\n }\n }\n GQL\n post(query)\nend\n"
|
#work_item(workitem_iid:, widgets: [:notes, :linked_items, :labels, :hierarchy]) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/gitlab_quality/test_tooling/gitlab_client/work_items_client.rb', line 7
def work_item(workitem_iid:, widgets: [:notes, :linked_items, :labels, :hierarchy])
query = " query {\n namespace(fullPath: \"\#{group}\") {\n workItem(iid: \"\#{workitem_iid}\") {\n \#{work_item_fields}\n \#{work_item_widgets(widgets)}\n }\n }\n }\n GQL\n post(query)[:workItem]\nend\n"
|