Class: SoftLayer::Ticket
Instance Attribute Summary
Attributes inherited from ModelBase
Class Method Summary collapse
-
.create_standard_ticket(options = {}) ⇒ Object
Create and submit a new support Ticket to SoftLayer.
-
.default_object_mask ⇒ Object
Returns the default object mask,as a hash, that is used when retrieving ticket information from the SoftLayer server.
-
.open_tickets(options = {}) ⇒ Object
Returns the set of currently open tickets.
-
.ticket_subjects(client = nil) ⇒ Object
Queries the SoftLayer API to retrieve a list of the valid ticket subjects.
-
.ticket_with_id(ticket_id, options = {}) ⇒ Object
Find the ticket with the given ID and return it.
Instance Method Summary collapse
-
#has_updates? ⇒ Boolean
Returns true if the ticket has “unread” updates.
-
#lastEditDate ⇒ Object
:attr_reader: The date the ticket was last updated.
-
#server_admin_ticket? ⇒ Boolean
Returns true if the ticket is a server admin ticket.
-
#service ⇒ Object
Override of service from ModelBase.
-
#softlayer_properties(object_mask = nil) ⇒ Object
Override from model base.
-
#subject ⇒ Object
:attr_reader: The ticket system maintains a fixed set of subjects for tickets that are used to ensure tickets make it to the right folks quickly.
-
#title ⇒ Object
:attr_reader: The title is an identifying string set when the ticket is created.
-
#update(body = nil) ⇒ Object
Add an update to this ticket.
Methods inherited from ModelBase
#[], #has_sl_property?, #initialize, #refresh_details, sl_attr, #to_ary
Constructor Details
This class inherits a constructor from SoftLayer::ModelBase
Class Method Details
.create_standard_ticket(options = {}) ⇒ Object
Create and submit a new support Ticket to SoftLayer.
The options parameter should contain:
:client
- The client used to connect to the API
If no client is given, then the routine will try to use Client.default_client If no client can be found the routine will raise an error.
The options should also contain:
-
:title
(String) - The user provided title for the ticket. -
:body
(String) - The content of the ticket -
:subject_id
(Int) - The id of a subject to use for the ticket. A list of ticket subjects can be returned by SoftLayer::Ticket.ticket_subjects -
:assigned_user_id
(Int) - The id of a user to whom the ticket should be assigned
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/softlayer/Ticket.rb', line 185 def self.create_standard_ticket( = {}) softlayer_client = [:client] || SoftLayer::Client.default_client raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client title = [:title] body = [:body] subject_id = [:subject_id] assigned_user_id = [:assigned_user_id] if(nil == assigned_user_id) current_user = softlayer_client["Account"].object_mask("id").getCurrentUser() assigned_user_id = current_user["id"] end new_ticket = { 'subjectId' => subject_id, 'contents' => body, 'assignedUserId' => assigned_user_id, 'title' => title } ticket_data = softlayer_client["Ticket"].createStandardTicket(new_ticket, body) return new(softlayer_client, ticket_data) end |
.default_object_mask ⇒ Object
Returns the default object mask,as a hash, that is used when retrieving ticket information from the SoftLayer server.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/softlayer/Ticket.rb', line 86 def self.default_object_mask { "mask" => [ 'id', # This is an internal ticket ID, not the one usually seen in the portal 'serviceProvider', 'serviceProviderResourceId', # This is the ticket ID usually seen in the portal 'title', 'subject', {'assignedUser' => ['username', 'firstName', 'lastName'] }, 'status.id', 'createDate', 'lastEditDate', 'newUpdatesFlag', # This comes in from the server as a Boolean value 'awaitingUserResponseFlag', # This comes in from the server as a Boolean value 'serverAdministrationFlag', # This comes in from the server as an integer :-( ] } end |
.open_tickets(options = {}) ⇒ Object
Returns the set of currently open tickets
Options should contain:
:client
- the client in which to search for the ticket
If a client is not provided then the routine will search Client::default_client If Client::default_client is also nil the routine will raise an error.
130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/softlayer/Ticket.rb', line 130 def self.open_tickets( = {}) softlayer_client = [:client] || Client.default_client raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client if .has_key?(:object_mask) object_mask = [:object_mask] else object_mask = default_object_mask.to_sl_object_mask end open_tickets_data = softlayer_client["Account"].object_mask(object_mask).getOpenTickets open_tickets_data.collect { |ticket_data| new(softlayer_client, ticket_data) } end |
.ticket_subjects(client = nil) ⇒ Object
Queries the SoftLayer API to retrieve a list of the valid ticket subjects.
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/softlayer/Ticket.rb', line 108 def self.ticket_subjects(client = nil) @ticket_subjects ||= nil if !@ticket_subjects softlayer_client = client || Client.default_client raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client @ticket_subjects = softlayer_client['Ticket_Subject'].getAllObjects(); end @ticket_subjects end |
.ticket_with_id(ticket_id, options = {}) ⇒ Object
Find the ticket with the given ID and return it
Options should contain:
:client
- the client in which to search for the ticket
If a client is not provided then the routine will search Client::default_client If Client::default_client is also nil the routine will raise an error.
154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/softlayer/Ticket.rb', line 154 def self.ticket_with_id(ticket_id, = {}) softlayer_client = [:client] || Client.default_client raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client if .has_key?(:object_mask) object_mask = [:object_mask] else object_mask = default_object_mask.to_sl_object_mask end ticket_data = softlayer_client["Ticket"].object_with_id(ticket_id).object_mask(object_mask).getObject() return new(softlayer_client, ticket_data) end |
Instance Method Details
#has_updates? ⇒ Boolean
Returns true if the ticket has “unread” updates
43 44 45 |
# File 'lib/softlayer/Ticket.rb', line 43 def has_updates? self["newUpdatesFlag"] end |
#lastEditDate ⇒ Object
:attr_reader: The date the ticket was last updated.
39 |
# File 'lib/softlayer/Ticket.rb', line 39 sl_attr :lastEditDate |
#server_admin_ticket? ⇒ Boolean
Returns true if the ticket is a server admin ticket
49 50 51 52 |
# File 'lib/softlayer/Ticket.rb', line 49 def server_admin_ticket? # note that serverAdministrationFlag comes from the server as an Integer (0, or 1) self["serverAdministrationFlag"] != 0 end |
#service ⇒ Object
Override of service from ModelBase. Returns the SoftLayer_Ticket service set up to talk to the ticket with my ID.
64 65 66 |
# File 'lib/softlayer/Ticket.rb', line 64 def service return softlayer_client["Ticket"].object_with_id(self.id) end |
#softlayer_properties(object_mask = nil) ⇒ Object
Override from model base. Requests new details about the ticket from the server.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/softlayer/Ticket.rb', line 71 def softlayer_properties(object_mask = nil) my_service = self.service if(object_mask) my_service = service.object_mask(object_mask) else my_service = service.object_mask(self.class.default_object_mask.to_sl_object_mask) end my_service.getObject() end |
#subject ⇒ Object
:attr_reader: The ticket system maintains a fixed set of subjects for tickets that are used to ensure tickets make it to the right folks quickly
34 |
# File 'lib/softlayer/Ticket.rb', line 34 sl_attr :subject |
#title ⇒ Object
:attr_reader: The title is an identifying string set when the ticket is created
29 |
# File 'lib/softlayer/Ticket.rb', line 29 sl_attr :title |
#update(body = nil) ⇒ Object
Add an update to this ticket.
57 58 59 |
# File 'lib/softlayer/Ticket.rb', line 57 def update(body = nil) self.service.edit(self.softlayer_hash, body) end |