Class: ForemanPatch::Ticket::ChangeRequest
- Inherits:
-
Object
- Object
- ForemanPatch::Ticket::ChangeRequest
show all
- Includes:
- API
- Defined in:
- app/services/foreman_patch/ticket/change_request.rb
Defined Under Namespace
Classes: Jail
Instance Attribute Summary collapse
Attributes included from API
#request
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from API
#create_request, #delete, #get, #host, #post, #proxy, #put, #send_request, #url
Constructor Details
Returns a new instance of ChangeRequest.
13
14
15
16
17
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 13
def initialize(window)
@window = window
@hash = {}
reload
end
|
Instance Attribute Details
#affected_items ⇒ Object
Returns the value of attribute affected_items.
6
7
8
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 6
def affected_items
@affected_items
end
|
#response ⇒ Object
Returns the value of attribute response.
6
7
8
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 6
def response
@response
end
|
#window ⇒ Object
Returns the value of attribute window.
6
7
8
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 6
def window
@window
end
|
Class Method Details
.publish(window) ⇒ Object
8
9
10
11
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 8
def self.publish(window)
ticket = Ticket.new(window)
ticket.save
end
|
Instance Method Details
#[](key) ⇒ Object
68
69
70
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 68
def [](key)
ticket[key]
end
|
#id ⇒ Object
50
51
52
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 50
def id
ticket.fetch(Setting[:ticket_id_field], window.ticket_id)
end
|
#keys ⇒ Object
64
65
66
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 64
def keys
ticket.keys
end
|
#label ⇒ Object
54
55
56
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 54
def label
ticket.fetch(Setting[:ticket_label_field], window.name)
end
|
#link ⇒ Object
58
59
60
61
62
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 58
def link
return "#" if id.blank?
Setting[:ticket_api_host] + Setting[:ticket_web_ui_path].gsub(':id', id)
end
|
#payload ⇒ Object
46
47
48
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 46
def payload
@payload ||= Payload.new(window)
end
|
#reload ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 19
def reload
return if window.ticket_id.blank?
get(path)
@affected_items = AffectedItems.new(self)
ticket
end
|
#save ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/services/foreman_patch/ticket/change_request.rb', line 29
def save
if window.ticket_id.blank?
post(path, payload)
else
put(path, payload)
end
unless response.empty?
@affected_items = AffectedItems.new(self)
@affected_items.set(window.hosts)
end
window.update(ticket_id: id)
ticket
end
|