ticket_abstractor_client 1.29.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +199 -159
- data/lib/ticket_abstractor_client.rb +11 -39
- data/lib/ticket_abstractor_client/base/attachment.rb +52 -0
- data/lib/ticket_abstractor_client/base/client.rb +54 -0
- data/lib/ticket_abstractor_client/base/comment.rb +35 -0
- data/lib/ticket_abstractor_client/base/errors.rb +25 -0
- data/lib/ticket_abstractor_client/base/fields_filter.rb +15 -0
- data/lib/ticket_abstractor_client/base/response_handler.rb +28 -0
- data/lib/ticket_abstractor_client/base/ticket.rb +79 -0
- data/lib/ticket_abstractor_client/client_helper.rb +29 -0
- data/lib/ticket_abstractor_client/configuration.rb +61 -0
- data/lib/ticket_abstractor_client/jira/attachment.rb +42 -0
- data/lib/ticket_abstractor_client/jira/client.rb +83 -0
- data/lib/ticket_abstractor_client/jira/comment.rb +35 -0
- data/lib/ticket_abstractor_client/jira/errors.rb +25 -0
- data/lib/ticket_abstractor_client/jira/fields_meta.rb +36 -0
- data/lib/ticket_abstractor_client/jira/params_builder.rb +96 -0
- data/lib/ticket_abstractor_client/jira/ticket.rb +131 -0
- data/lib/ticket_abstractor_client/service_now/attachment.rb +41 -0
- data/lib/ticket_abstractor_client/service_now/client.rb +78 -0
- data/lib/ticket_abstractor_client/service_now/comment.rb +30 -0
- data/lib/ticket_abstractor_client/service_now/errors.rb +25 -0
- data/lib/ticket_abstractor_client/service_now/params_builder.rb +56 -0
- data/lib/ticket_abstractor_client/service_now/ticket.rb +120 -0
- data/lib/ticket_abstractor_client/version.rb +1 -1
- metadata +52 -9
- data/lib/ticket_abstractor_client/brouha_client.rb +0 -33
- data/lib/ticket_abstractor_client/client.rb +0 -31
- data/lib/ticket_abstractor_client/i_logger_client.rb +0 -5
- data/lib/ticket_abstractor_client/itrc_client.rb +0 -33
- data/lib/ticket_abstractor_client/jira_client.rb +0 -128
- data/lib/ticket_abstractor_client/service_now_client.rb +0 -61
- data/lib/ticket_abstractor_client/sev_one_client.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f77ae69e14119d1c04b675f194ab509d4ef4811
|
4
|
+
data.tar.gz: 91ee14717bae9af3f5509f126adc953b35c3d657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e7bfd5ec20c8c895578c8c5ace59cca3d0ead66752ec77040cb1ef29e6a89221428386f449ee5be1e7deb062b4faaa2961601a2fa4236073867c11d2b932daa
|
7
|
+
data.tar.gz: 8ba2f3595bd40ef1b19068ae3c07102ba75cca7028fdf61eb939e85fba1e79f5eb1413c4bf6a52b09c667c642bd586b641173db3f9ada2c931da183c2b69f34e
|
data/README.md
CHANGED
@@ -2,11 +2,21 @@
|
|
2
2
|
|
3
3
|
Client for accessing to a TicketAbstractor service.
|
4
4
|
|
5
|
-
##
|
5
|
+
## <a name="content"></a> Table of contents
|
6
|
+
|
7
|
+
* [Installation](#installation)
|
8
|
+
* [Upgrading](#upgrading)
|
9
|
+
* [Configuration](#configuration)
|
10
|
+
* [Usage](#usage)
|
11
|
+
* [Filtering fields](#fields_filters)
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
## <a name="installation"></a> Installation
|
6
16
|
|
7
17
|
Add this line to your application's Gemfile:
|
8
18
|
|
9
|
-
gem 'ticket_abstractor_client'
|
19
|
+
gem 'ticket_abstractor_client', '>= 2.0.0'
|
10
20
|
|
11
21
|
And then execute:
|
12
22
|
|
@@ -14,247 +24,277 @@ And then execute:
|
|
14
24
|
|
15
25
|
Or install it yourself as:
|
16
26
|
|
17
|
-
$ gem install ticket_abstractor_client
|
27
|
+
$ gem install ticket_abstractor_client -v '2.x'
|
18
28
|
|
19
|
-
|
29
|
+
[[table of contents](#content)]
|
20
30
|
|
21
|
-
|
31
|
+
---
|
22
32
|
|
23
|
-
## Upgrading
|
33
|
+
## <a name="upgrading"></a> Upgrading
|
24
34
|
|
25
|
-
Since version
|
26
|
-
instead of `TicketAbstractorClient` class.
|
35
|
+
Since version 2.0.0, you operate with ticket as **PORO**.
|
27
36
|
|
28
|
-
|
37
|
+
[[table of contents](#content)]
|
29
38
|
|
30
|
-
|
39
|
+
---
|
31
40
|
|
32
|
-
|
41
|
+
## <a name="configuration"></a> Configuration
|
33
42
|
|
34
|
-
|
43
|
+
**Base configuration options:**
|
35
44
|
|
36
|
-
|
45
|
+
TicketAbstractorClient.configuration do |config|
|
46
|
+
config.ticket_abstractor_url = 'http://localhost:4567'
|
47
|
+
config.security_token = 'security_token_1'
|
48
|
+
end
|
37
49
|
|
38
|
-
|
50
|
+
**SSL options:**
|
39
51
|
|
40
|
-
|
52
|
+
`DEFAULT_SSL_OPTIONS = { verify_ssl: true }`
|
41
53
|
|
42
|
-
|
54
|
+
For more available ssl options see **[SSL/TLS support](https://github.com/rest-client/rest-client#ssltls-support
|
55
|
+
"RestClient SSL/TLS support")**
|
43
56
|
|
44
|
-
|
45
|
-
client.brouha
|
46
|
-
client.itrc
|
47
|
-
client.ilogger
|
48
|
-
client.sev_one
|
49
|
-
client.service_now
|
57
|
+
**JIRA specific options:**
|
50
58
|
|
51
|
-
|
59
|
+
`jira_fields_meta` stores meta information about each JIRA field.
|
60
|
+
Meta information is refreshed automatically after `jira_meta_expiration_period` (**604800**
|
61
|
+
seconds by default, one week).
|
52
62
|
|
53
|
-
|
63
|
+
Meta information can be manually updated:
|
54
64
|
|
55
|
-
|
65
|
+
TicketAbstractorClient.configuration.jira_fields_meta = TicketAbstractorClient::ClientHelper.get_jira_fields_meta
|
56
66
|
|
57
|
-
|
67
|
+
**ServiceNow specific options:**
|
58
68
|
|
59
|
-
|
60
|
-
|
69
|
+
`snow_display_value`,
|
70
|
+
based on this value, the display value and/or the actual value in the database are retrieved.
|
61
71
|
|
62
|
-
|
72
|
+
* `SNOW_DISPLAY_VALUE_TRUE` returns display values for all of the fields.
|
73
|
+
* `SNOW_DISPLAY_VALUE_FALSE` returns actual values from the database. If a value is not specified,
|
74
|
+
this parameter defaults to false.
|
75
|
+
* `SNOW_DISPLAY_VALUE_ALL` returns both actual and display values.
|
63
76
|
|
64
|
-
client.jira.get_issue 'IFS-123'
|
65
|
-
client.jira.get_issue_status 'IFS-123'
|
66
77
|
|
67
|
-
|
78
|
+
TicketAbstractorClient.snow_display_value = TicketAbstractorClient::Configuration::SNOW_DISPLAY_VALUE_ALL
|
68
79
|
|
69
|
-
|
70
|
-
client.jira.get_issues_by_filter jira_filter_id #=> [{ issue_1 }, { issue_2 }, ...]
|
71
|
-
client.jira.get_issues_by_filter jira_filter_id, page, per_page, show_total: true #=> { total: 2, issues: [...] }
|
80
|
+
[[table of contents](#content)]
|
72
81
|
|
73
|
-
|
82
|
+
---
|
74
83
|
|
75
|
-
|
76
|
-
client.jira.create_issue options
|
84
|
+
## <a name="usage"></a> Usage
|
77
85
|
|
78
|
-
|
86
|
+
* [Jira](#jira)
|
87
|
+
* [ServiceNow](#snow)
|
79
88
|
|
80
|
-
|
81
|
-
attachment = File.new('file.png', 'rb')
|
82
|
-
client.jira.create_issue options, attachment
|
89
|
+
### <a name="jira"></a>Jira
|
83
90
|
|
84
|
-
|
91
|
+
Get ticket by id:
|
85
92
|
|
86
|
-
|
87
|
-
|
88
|
-
client.jira.raw_create_issue options, attachment
|
93
|
+
# get issue from default Jira instance (T&P)
|
94
|
+
TicketAbstractorClient::Jira::Ticket.fetch_by_id(ticket_id: 'ISSUE-1')
|
89
95
|
|
90
|
-
|
96
|
+
# get Jira endpoints
|
97
|
+
TicketAbstractorClient::Jira::Client.new.endpoints
|
91
98
|
|
92
|
-
|
99
|
+
# get issue from specific endpoint
|
100
|
+
TicketAbstractorClient::Jira::Ticket.fetch_by_id(ticket_id: 'ISSUE-1', endpoint: :tp)
|
93
101
|
|
94
|
-
|
102
|
+
Get tickets by query:
|
95
103
|
|
96
|
-
|
97
|
-
client.jira.update_issue({ issuekey: 'IFS-123' }, attachment)
|
104
|
+
TicketAbstractorClient::Jira::Ticket.fetch_tickets_by_jql(query: 'project=ISSUE', endpoint: :tp)
|
98
105
|
|
99
|
-
|
106
|
+
Get ticket's comments:
|
100
107
|
|
101
|
-
|
102
|
-
|
103
|
-
customfield_1: {id: "22"},
|
104
|
-
customfield_2: {value: "No Impact"}
|
105
|
-
}}
|
106
|
-
client.jira.create_tvx_issue options
|
108
|
+
ticket = TicketAbstractorClient::Jira::Ticket.fetch_by_id(ticket_id: 'ISSUE-1')
|
109
|
+
ticket.comments
|
107
110
|
|
108
|
-
|
111
|
+
# or
|
109
112
|
|
110
|
-
|
113
|
+
ticket_id = 'ISSUE-1'
|
114
|
+
endpoint = 'tp'
|
115
|
+
comments = TicketAbstractorClient::Jira::Comment.fetch(ticket_id, endpoint)
|
111
116
|
|
112
|
-
|
113
|
-
opts should containt {generator: { id:, display_name:}, event_id:}
|
117
|
+
Get ticket's attachments:
|
114
118
|
|
115
|
-
|
116
|
-
|
117
|
-
id: 'https://intel.xcal.tv',
|
118
|
-
display_name: 'OIV'
|
119
|
-
},
|
120
|
-
event_id: '23456'
|
121
|
-
)
|
119
|
+
ticket = TicketAbstractorClient::Jira::Ticket.fetch(ticket_id: 'ISSUE-1')
|
120
|
+
ticket.attachments
|
122
121
|
|
123
|
-
|
122
|
+
# or
|
124
123
|
|
125
|
-
|
124
|
+
ticket_id = 'ISSUE-1'
|
125
|
+
endpoint = 'tp'
|
126
|
+
attachments = TicketAbstractorClient::Jira::Attachment.fetch_by_id(ticket_id, endpoint)
|
126
127
|
|
127
|
-
|
128
|
+
Create ticket:
|
128
129
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
desk: 'incident desk',
|
140
|
-
opened_by: 'incident manager',
|
141
|
-
start_time: 'incident start time'
|
130
|
+
ticket_opts = {
|
131
|
+
endpoint: 'tp'
|
132
|
+
project: 'ISSUE'
|
133
|
+
fields: {
|
134
|
+
summary: "Example of ticket's summary",
|
135
|
+
description: "Example of ticket's description",
|
136
|
+
severity: 'Sev2',
|
137
|
+
priority: 'P2',
|
138
|
+
...
|
139
|
+
}
|
142
140
|
}
|
143
141
|
|
144
|
-
|
142
|
+
ticket = TicketAbstractorClient::Jira::Ticket.new(ticket_opts)
|
143
|
+
ticket.sync!
|
144
|
+
ticket.ticket_id # => ISSUE-111
|
145
145
|
|
146
|
-
|
146
|
+
Update ticket:
|
147
147
|
|
148
|
-
|
148
|
+
ticket_opts: {
|
149
|
+
endpoint: 'tp'
|
150
|
+
ticket_id: 'ISSUE-111'
|
151
|
+
fields: {
|
152
|
+
description: "Updated example of ticket's description",
|
153
|
+
severity: 'Sev3',
|
154
|
+
...
|
155
|
+
}
|
156
|
+
}
|
149
157
|
|
150
|
-
|
158
|
+
ticket = TicketAbstractorClient::Jira::Ticket.new(ticket_opts)
|
159
|
+
ticket.sync!
|
160
|
+
ticket.description # => "Updated example of ticket's description"
|
151
161
|
|
152
|
-
|
153
|
-
options = {
|
154
|
-
id: 23,
|
155
|
-
alarm_url: 'http://server.domain/alarms/'
|
156
|
-
}
|
162
|
+
Update ticket's status:
|
157
163
|
|
158
|
-
|
164
|
+
ticket = TicketAbstractorClient::Jira::Ticket.new(ticket_id: 'ISSUE-111', endpoint: 'tp')
|
165
|
+
ticket.status = 'IN_PROGRESS'
|
166
|
+
ticket.sync!
|
159
167
|
|
160
|
-
###
|
168
|
+
### <a name="snow"></a>ServiceNow
|
161
169
|
|
162
|
-
|
170
|
+
Get ticket by id:
|
163
171
|
|
164
|
-
|
165
|
-
|
172
|
+
# get ServiceNow endpoints
|
173
|
+
TicketAbstractorClient::ServiceNow::Client.new.endpoints
|
166
174
|
|
167
|
-
|
175
|
+
# get issue from specific endpoint
|
176
|
+
ticket_opts = { ticket_id: 'INC001', endpoint: :dev, project: 'incident' }
|
177
|
+
TicketAbstractorClient::ServiceNow::Ticket.fetch_by_id(ticket_opts)
|
168
178
|
|
169
|
-
|
170
|
-
client.itrc.find_app_group 'app-mgmt-tools'
|
179
|
+
Get tickets by query:
|
171
180
|
|
172
|
-
|
181
|
+
ticket_opts = { query: 'numberIN(INC001,INC002,INC010)', endpoint: :test, project: 'incident' }
|
182
|
+
TicketAbstractorClient::ServiceNow::Ticket.fetch_tickets_by_query(ticket_opts)
|
173
183
|
|
174
|
-
|
175
|
-
client.itrc.find_business_unit 3
|
184
|
+
Get ticket's comments:
|
176
185
|
|
177
|
-
|
186
|
+
ticket_opts = { ticket_id: 'INC001', endpoint: :dev, project: 'incident' }
|
187
|
+
ticket = TicketAbstractorClient::ServiceNow::Ticket.fetch_by_id(ticket_opts)
|
188
|
+
ticket.comments
|
178
189
|
|
179
|
-
|
180
|
-
client.itrc.find_department 4
|
190
|
+
# or
|
181
191
|
|
182
|
-
|
192
|
+
ticket_id = 'INC001'
|
193
|
+
endpoint = 'default'
|
194
|
+
project = 'incident'
|
195
|
+
comments = TicketAbstractorClient::ServiceNow::Comment.fetch(ticket_id, endpoint, project)
|
183
196
|
|
184
|
-
|
197
|
+
Get ticket's attachments:
|
185
198
|
|
186
|
-
|
199
|
+
ticket_opts = { ticket_id: 'INC001', endpoint: :dev, project: :incident }
|
200
|
+
ticket = TicketAbstractorClient::ServiceNow::Ticket.fetch_by_id(ticket_opts)
|
201
|
+
ticket.attachments
|
187
202
|
|
188
|
-
|
203
|
+
# or
|
189
204
|
|
190
|
-
|
205
|
+
ticket_id = 'INC001'
|
206
|
+
endpoint = 'test'
|
207
|
+
project = 'incident'
|
208
|
+
attachments = TicketAbstractorClient::ServiceNow::Attachment.fetch(ticket_id, endpoint, project)
|
191
209
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
210
|
+
Create ticket:
|
211
|
+
|
212
|
+
ticket_opts = {
|
213
|
+
endpoint: 'prod'
|
214
|
+
project: 'incident'
|
215
|
+
fields: {
|
216
|
+
short_title: "Example of ticket's summary",
|
217
|
+
title: "Example of ticket's description",
|
218
|
+
u_severity: 'Sev2',
|
219
|
+
u_priority: 'P2',
|
220
|
+
...
|
200
221
|
}
|
201
222
|
}
|
202
223
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
## query which fetch data for last 5 minutes
|
207
|
-
client.sev_one.report_get_data_from_graph(params.merge(timespan: { simple_timespan: "past 5 minutes" }))
|
224
|
+
ticket = TicketAbstractorClient::ServiceNow::Ticket.new(ticket_opts)
|
225
|
+
ticket.sync!
|
226
|
+
ticket.ticket_id # => INC011
|
208
227
|
|
209
|
-
|
228
|
+
Update ticket:
|
210
229
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
230
|
+
ticket_opts = {
|
231
|
+
endpoint: 'prod'
|
232
|
+
project: 'incident'
|
233
|
+
ticket_id: 'INC011'
|
234
|
+
fields: {
|
235
|
+
title: "Updated example of ticket's description",
|
236
|
+
u_severity: 'Sev3',
|
237
|
+
...
|
219
238
|
}
|
220
239
|
}
|
221
240
|
|
222
|
-
|
223
|
-
|
241
|
+
ticket = TicketAbstractorClient::ServiceNow::Ticket.new(ticket_opts)
|
242
|
+
ticket.sync!
|
243
|
+
ticket.short_title # => "Updated example of ticket's description"
|
224
244
|
|
225
|
-
|
245
|
+
Update ticket's status:
|
226
246
|
|
227
|
-
|
228
|
-
|
247
|
+
ticket_opts = { ticket_id: 'INC011', endpoint: 'tp', project: :prod }
|
248
|
+
ticket = TicketAbstractorClient::ServiceNow::Ticket.new(ticket_opts)
|
249
|
+
ticket.status = 'IN_PROGRESS'
|
250
|
+
ticket.sync!
|
229
251
|
|
230
|
-
# service_desk - is assigment_group in ServiceNow API. It should be escaped
|
231
|
-
# states - get incidents included in this states. It should be integers separated by comma
|
232
|
-
client.service_now.get_all_incidents(service_desk: 'T%26P+Prod+Support', states: '1,2,9,10,11')
|
233
252
|
|
234
|
-
|
235
|
-
# :incident_id is a required parameter
|
236
|
-
client.service_now.get_incident(incident_id: '', table_name: 'incident')
|
253
|
+
[[table of contents](#content)]
|
237
254
|
|
238
|
-
|
239
|
-
# :incident_params is a required parameter
|
240
|
-
client.service_now.create_incident(incident_params: {}, table_name: 'incident')
|
255
|
+
---
|
241
256
|
|
242
|
-
|
243
|
-
# :incident_params and :sys_id is a required parameters
|
244
|
-
client.service_now.update_incident(incident_params: {}, sys_id: '', table_name: 'incident')
|
257
|
+
## <a name="fields_filters"></a> Filtering fields
|
245
258
|
|
246
|
-
|
247
|
-
|
248
|
-
|
259
|
+
There is a situation when you need to convert some values, like datetimes, or skip any other values and so on,
|
260
|
+
before you start working with fetched ticket.
|
261
|
+
All you have to do is create a class that is inherited from `TicketAbstractorClient::Base::FieldsFilter`
|
262
|
+
and implement a `filter_fields` method, after that configure the gem to use your class.
|
249
263
|
|
250
|
-
|
251
|
-
client.service_now.get_all_groups()
|
252
|
-
client.service_now.get_all_groups(query: 'activeIStrue', limit: '100', fields: 'name,sys_id')
|
264
|
+
**ServiceNow example:**
|
253
265
|
|
254
|
-
|
266
|
+
class MyServiceNowTicketsFilter < TicketAbstractorClient::Base::FieldsFilter
|
267
|
+
def initialize(raw_fields)
|
268
|
+
super(raw_fields)
|
269
|
+
end
|
270
|
+
|
271
|
+
def filter_fields
|
272
|
+
self.raw_fields.each_with_object([]) |raw_field, filtered_fields|
|
273
|
+
# do some filtering here
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
Add a line to configuration
|
279
|
+
|
280
|
+
...
|
281
|
+
config.snow_fields_filter_class = MyServiceNowTicketsFilter
|
282
|
+
...
|
283
|
+
|
284
|
+
That's it.
|
285
|
+
|
286
|
+
JIRA is supported as well.
|
287
|
+
|
288
|
+
[[table of contents](#content)]
|
289
|
+
|
290
|
+
---
|
291
|
+
|
292
|
+
## <a name="contributing"></a> Contributing
|
255
293
|
|
256
294
|
1. Fork it
|
257
295
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
258
296
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
259
297
|
4. Push to the branch (`git push origin my-new-feature`)
|
260
298
|
5. Create new Pull Request
|
299
|
+
|
300
|
+
[[table of contents](#content)]
|