ticket_abstractor_client 1.29.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +199 -159
  3. data/lib/ticket_abstractor_client.rb +11 -39
  4. data/lib/ticket_abstractor_client/base/attachment.rb +52 -0
  5. data/lib/ticket_abstractor_client/base/client.rb +54 -0
  6. data/lib/ticket_abstractor_client/base/comment.rb +35 -0
  7. data/lib/ticket_abstractor_client/base/errors.rb +25 -0
  8. data/lib/ticket_abstractor_client/base/fields_filter.rb +15 -0
  9. data/lib/ticket_abstractor_client/base/response_handler.rb +28 -0
  10. data/lib/ticket_abstractor_client/base/ticket.rb +79 -0
  11. data/lib/ticket_abstractor_client/client_helper.rb +29 -0
  12. data/lib/ticket_abstractor_client/configuration.rb +61 -0
  13. data/lib/ticket_abstractor_client/jira/attachment.rb +42 -0
  14. data/lib/ticket_abstractor_client/jira/client.rb +83 -0
  15. data/lib/ticket_abstractor_client/jira/comment.rb +35 -0
  16. data/lib/ticket_abstractor_client/jira/errors.rb +25 -0
  17. data/lib/ticket_abstractor_client/jira/fields_meta.rb +36 -0
  18. data/lib/ticket_abstractor_client/jira/params_builder.rb +96 -0
  19. data/lib/ticket_abstractor_client/jira/ticket.rb +131 -0
  20. data/lib/ticket_abstractor_client/service_now/attachment.rb +41 -0
  21. data/lib/ticket_abstractor_client/service_now/client.rb +78 -0
  22. data/lib/ticket_abstractor_client/service_now/comment.rb +30 -0
  23. data/lib/ticket_abstractor_client/service_now/errors.rb +25 -0
  24. data/lib/ticket_abstractor_client/service_now/params_builder.rb +56 -0
  25. data/lib/ticket_abstractor_client/service_now/ticket.rb +120 -0
  26. data/lib/ticket_abstractor_client/version.rb +1 -1
  27. metadata +52 -9
  28. data/lib/ticket_abstractor_client/brouha_client.rb +0 -33
  29. data/lib/ticket_abstractor_client/client.rb +0 -31
  30. data/lib/ticket_abstractor_client/i_logger_client.rb +0 -5
  31. data/lib/ticket_abstractor_client/itrc_client.rb +0 -33
  32. data/lib/ticket_abstractor_client/jira_client.rb +0 -128
  33. data/lib/ticket_abstractor_client/service_now_client.rb +0 -61
  34. 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: 8ded94f5c8180e052cbbba7965f0b6b6f7bd94b7
4
- data.tar.gz: 32c5b422fc531494a18993ffd332e50468c0dce2
3
+ metadata.gz: 2f77ae69e14119d1c04b675f194ab509d4ef4811
4
+ data.tar.gz: 91ee14717bae9af3f5509f126adc953b35c3d657
5
5
  SHA512:
6
- metadata.gz: 5d57ad91f99f3627d536db958c38badeaa534b75b7ad1077a2c52b2226918531d61a22c03bcccafd33afe0ac89f223cb95c29168aa0bee21c70ae2c16729820d
7
- data.tar.gz: 53c287a4c36de38fdbec00005fb1294bbc72f67e977199246760abaa29409e3e405d8cd910d4c8b92b47683cb78ccda312a5af0b03ed0fad0140aaaebe8d486f
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
- ## Installation
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
- ## API
29
+ [[table of contents](#content)]
20
30
 
21
- [API Documentation](http://rubydoc.info/gems/ticket_abstractor_client/frames)
31
+ ---
22
32
 
23
- ## Upgrading
33
+ ## <a name="upgrading"></a> Upgrading
24
34
 
25
- Since version 1.5.0, `TicketAbstractorClient.initialize_client` returns an instance of `TicketAbstractorClient::Base`
26
- instead of `TicketAbstractorClient` class.
35
+ Since version 2.0.0, you operate with ticket as **PORO**.
27
36
 
28
- ## Usage
37
+ [[table of contents](#content)]
29
38
 
30
- Initialize:
39
+ ---
31
40
 
32
- require 'ticket_abstractor_client'
41
+ ## <a name="configuration"></a> Configuration
33
42
 
34
- without security token:
43
+ **Base configuration options:**
35
44
 
36
- client = TicketAbstractorClient.initialize_client('http://ticket.abstractor.url')
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
- with security token:
50
+ **SSL options:**
39
51
 
40
- client = TicketAbstractorClient.initialize_client('http://ticket.abstractor.url', 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3')
52
+ `DEFAULT_SSL_OPTIONS = { verify_ssl: true }`
41
53
 
42
- Access clients:
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
- client.jira
45
- client.brouha
46
- client.itrc
47
- client.ilogger
48
- client.sev_one
49
- client.service_now
57
+ **JIRA specific options:**
50
58
 
51
- ### Jira
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
- Get list of Jira endpoints:
63
+ Meta information can be manually updated:
54
64
 
55
- client.jira.endpoints #=> { 'endpoint_name_1' => 'http://www.jira-endpoint.com', 'endpoint_name_2' => '... }
65
+ TicketAbstractorClient.configuration.jira_fields_meta = TicketAbstractorClient::ClientHelper.get_jira_fields_meta
56
66
 
57
- Get access to specific Jira instance:
67
+ **ServiceNow specific options:**
58
68
 
59
- client.jira.get_issue ... #=> default Jira instance (T&P)
60
- client.jira('endpoint_name_1').get_issue ... #=> Jira at 'http://www.jira-endpoint.com'
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
- Grab issue:
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
- Get issues by filter:
78
+ TicketAbstractorClient.snow_display_value = TicketAbstractorClient::Configuration::SNOW_DISPLAY_VALUE_ALL
68
79
 
69
- jira_filter_id = 2145
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
- Create issue (project, summary, description and issuetype fields are required):
82
+ ---
74
83
 
75
- options = { project: "IFS", summary: "Summary", description: "Desc", issuetype: "Bug"}
76
- client.jira.create_issue options
84
+ ## <a name="usage"></a> Usage
77
85
 
78
- Create issue with an attachment:
86
+ * [Jira](#jira)
87
+ * [ServiceNow](#snow)
79
88
 
80
- options = { project: "IFS", summary: "Summary", description: "Desc", issuetype: "Bug"}
81
- attachment = File.new('file.png', 'rb')
82
- client.jira.create_issue options, attachment
89
+ ### <a name="jira"></a>Jira
83
90
 
84
- Create issue using Jira params:
91
+ Get ticket by id:
85
92
 
86
- options = { fields: { project: { key: "IFS" }, summary: "Summary", issuetype: { id: 82 } } }
87
- attachment = File.new('file.png', 'rb')
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
- Update issue (issuekey field is required):
96
+ # get Jira endpoints
97
+ TicketAbstractorClient::Jira::Client.new.endpoints
91
98
 
92
- client.jira.update_issue(issuekey: 'IFS-123', description: 'new description')
99
+ # get issue from specific endpoint
100
+ TicketAbstractorClient::Jira::Ticket.fetch_by_id(ticket_id: 'ISSUE-1', endpoint: :tp)
93
101
 
94
- Attach the file to issue:
102
+ Get tickets by query:
95
103
 
96
- attachment = File.new('file.png', 'rb')
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
- Create incident (project, summary, description and issuetype fields are required):
106
+ Get ticket's comments:
100
107
 
101
- options = { project: "IFS", summary: "Summary", description: "Desc", issuetype: {id: "3"},
102
- customfields: {
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
- Add comment to the issue (issuekey and comment fields are required):
111
+ # or
109
112
 
110
- client.jira.add_comment(issuekey: 'IFS-123', comment: 'comment to ticket')
113
+ ticket_id = 'ISSUE-1'
114
+ endpoint = 'tp'
115
+ comments = TicketAbstractorClient::Jira::Comment.fetch(ticket_id, endpoint)
111
116
 
112
- Add an actiity to the issue (issuekey, comment and opts fields are required):
113
- opts should containt {generator: { id:, display_name:}, event_id:}
117
+ Get ticket's attachments:
114
118
 
115
- client.jira.add_activity(issuekey: 'IFS-123', comment: 'activity comment to ticket',
116
- generator: {
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
- ### Brouha
122
+ # or
124
123
 
125
- Grab issue:
124
+ ticket_id = 'ISSUE-1'
125
+ endpoint = 'tp'
126
+ attachments = TicketAbstractorClient::Jira::Attachment.fetch_by_id(ticket_id, endpoint)
126
127
 
127
- client.brouha.get_issue '12'
128
+ Create ticket:
128
129
 
129
- Create issue:
130
-
131
- options = {
132
- severity: 'Severity 5',
133
- title: 'incident title',
134
- bridge: '123456789',
135
- summary: 'incident description',
136
- product: 'Xfinity Voice',
137
- service: 'voicemail',
138
- division: 'incident division',
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
- client.brouha.create_issue options
142
+ ticket = TicketAbstractorClient::Jira::Ticket.new(ticket_opts)
143
+ ticket.sync!
144
+ ticket.ticket_id # => ISSUE-111
145
145
 
146
- List products and services:
146
+ Update ticket:
147
147
 
148
- client.brouha.list_product_services
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
- Update issue:
158
+ ticket = TicketAbstractorClient::Jira::Ticket.new(ticket_opts)
159
+ ticket.sync!
160
+ ticket.description # => "Updated example of ticket's description"
151
161
 
152
- issue_key = 23
153
- options = {
154
- id: 23,
155
- alarm_url: 'http://server.domain/alarms/'
156
- }
162
+ Update ticket's status:
157
163
 
158
- client.brouha.update_issue issue_key, options
164
+ ticket = TicketAbstractorClient::Jira::Ticket.new(ticket_id: 'ISSUE-111', endpoint: 'tp')
165
+ ticket.status = 'IN_PROGRESS'
166
+ ticket.sync!
159
167
 
160
- ### iTRC
168
+ ### <a name="snow"></a>ServiceNow
161
169
 
162
- Find apps:
170
+ Get ticket by id:
163
171
 
164
- client.itrc.list_apps
165
- client.itrc.find_app 'itrc'
172
+ # get ServiceNow endpoints
173
+ TicketAbstractorClient::ServiceNow::Client.new.endpoints
166
174
 
167
- Find app_groups:
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
- client.itrc.list_app_groups
170
- client.itrc.find_app_group 'app-mgmt-tools'
179
+ Get tickets by query:
171
180
 
172
- Find business units:
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
- client.itrc.list_business_units
175
- client.itrc.find_business_unit 3
184
+ Get ticket's comments:
176
185
 
177
- Find departments:
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
- client.itrc.list_departments
180
- client.itrc.find_department 4
190
+ # or
181
191
 
182
- ### ILogger
192
+ ticket_id = 'INC001'
193
+ endpoint = 'default'
194
+ project = 'incident'
195
+ comments = TicketAbstractorClient::ServiceNow::Comment.fetch(ticket_id, endpoint, project)
183
196
 
184
- Grab incidents:
197
+ Get ticket's attachments:
185
198
 
186
- client.ilogger.get_incidents 'owner=brouha&incident_desk=ASD&limit=10&offset=0'
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
- ### SevOne
203
+ # or
189
204
 
190
- Get data from graph:
205
+ ticket_id = 'INC001'
206
+ endpoint = 'test'
207
+ project = 'incident'
208
+ attachments = TicketAbstractorClient::ServiceNow::Attachment.fetch(ticket_id, endpoint, project)
191
209
 
192
- ## :graph => :data_sources is required
193
- ## :timespan => :start_time and :end_time is required
194
- params = {
195
- graph: {
196
- data_sources: [
197
- { device_name: "ccprtr-br-a1-p", object_name: "ae1", indicator: "ifHCOutOctets" },
198
- { device_name: "ccprtr-br-a2-p", object_name: "ae1", indicator: "ifHCOutOctets" }
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
- ## query which fetch data for period(time in UNIX timestamp)
204
- client.sev_one.report_get_data_from_graph(params.merge(timespan: { start_time: 1423242600.0, end_time: 1423242900.0 }))
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
- Get data from flowfalcon graph:
228
+ Update ticket:
210
229
 
211
- ## :graph => :data_sources is required
212
- ## :timespan => :start_time and :end_time is required
213
- params = {
214
- graph: {
215
- data_sources: [
216
- { device_name: "68.87.7.129" },
217
- { device_name: "68.87.7.130" }
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
- ## query which fetch data for period(time in UNIX timestamp)
223
- client.sev_one.flowfalcon_get_data_from_graph(params.merge(timespan: { start_time: 1423242600.0, end_time: 1423242900.0 }))
241
+ ticket = TicketAbstractorClient::ServiceNow::Ticket.new(ticket_opts)
242
+ ticket.sync!
243
+ ticket.short_title # => "Updated example of ticket's description"
224
244
 
225
- ### Service Now
245
+ Update ticket's status:
226
246
 
227
- ## get all incidents:
228
- client.service_now.get_all_incidents(limit: '1000', offset: '0', table_name: 'incident')
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
- # get incident:
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
- # create incident:
239
- # :incident_params is a required parameter
240
- client.service_now.create_incident(incident_params: {}, table_name: 'incident')
255
+ ---
241
256
 
242
- # update incident
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
- # get comments
247
- # :incident_id is required parameter.
248
- client.service_now.get_comments(incident_id: '', table_name: 'incident', display_value: false)
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
- # get all assignment groups:
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
- ## Contributing
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)]