softlayer_api 3.0.2 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.textile +3 -0
  3. data/lib/softlayer/Account.rb +85 -8
  4. data/lib/softlayer/AccountPassword.rb +49 -49
  5. data/lib/softlayer/BareMetalServer.rb +33 -43
  6. data/lib/softlayer/BareMetalServerOrder.rb +17 -8
  7. data/lib/softlayer/BareMetalServerOrder_Package.rb +25 -7
  8. data/lib/softlayer/Client.rb +7 -7
  9. data/lib/softlayer/Config.rb +105 -49
  10. data/lib/softlayer/Datacenter.rb +10 -2
  11. data/lib/softlayer/DynamicAttribute.rb +1 -1
  12. data/lib/softlayer/ImageTemplate.rb +44 -61
  13. data/lib/softlayer/ModelBase.rb +2 -2
  14. data/lib/softlayer/NetworkComponent.rb +25 -3
  15. data/lib/softlayer/NetworkMessageDelivery.rb +25 -5
  16. data/lib/softlayer/NetworkMonitor.rb +333 -0
  17. data/lib/softlayer/NetworkService.rb +6 -4
  18. data/lib/softlayer/NetworkStorage.rb +42 -29
  19. data/lib/softlayer/NetworkStorageAllowedHost.rb +9 -3
  20. data/lib/softlayer/NetworkStorageCredential.rb +44 -29
  21. data/lib/softlayer/NetworkStorageGroup.rb +42 -10
  22. data/lib/softlayer/ObjectFilter.rb +54 -4
  23. data/lib/softlayer/ObjectMaskParser.rb +1 -1
  24. data/lib/softlayer/ProductItemCategory.rb +34 -5
  25. data/lib/softlayer/ProductPackage.rb +11 -7
  26. data/lib/softlayer/Server.rb +77 -5
  27. data/lib/softlayer/ServerFirewall.rb +12 -11
  28. data/lib/softlayer/Service.rb +1 -1
  29. data/lib/softlayer/Software.rb +35 -50
  30. data/lib/softlayer/SoftwarePassword.rb +92 -107
  31. data/lib/softlayer/Ticket.rb +37 -28
  32. data/lib/softlayer/UserCustomer.rb +56 -13
  33. data/lib/softlayer/UserCustomerExternalBinding.rb +18 -5
  34. data/lib/softlayer/VLANFirewall.rb +40 -9
  35. data/lib/softlayer/VLANFirewallOrder.rb +1 -1
  36. data/lib/softlayer/VirtualDiskImage.rb +38 -10
  37. data/lib/softlayer/VirtualServer.rb +75 -48
  38. data/lib/softlayer/VirtualServerOrder.rb +15 -8
  39. data/lib/softlayer/VirtualServerOrder_Package.rb +25 -7
  40. data/lib/softlayer/VirtualServerUpgradeOrder.rb +1 -1
  41. data/lib/softlayer/base.rb +1 -1
  42. data/lib/softlayer/object_mask_helpers.rb +1 -1
  43. data/lib/softlayer_api.rb +2 -0
  44. metadata +4 -3
@@ -14,15 +14,29 @@ module SoftLayer
14
14
  #
15
15
  class SoftwarePassword < ModelBase
16
16
  include ::SoftLayer::DynamicAttribute
17
+
18
+ ##
19
+ # :attr_reader: created_at
20
+ # The date this username/password pair was created.
21
+ sl_attr :created_at, 'createDate'
17
22
 
18
23
  ##
19
- # :attr_reader:
24
+ # :attr_reader: created
20
25
  # The date this username/password pair was created.
26
+ # DEPRECATION WARNING: This attribute is deprecated in favor of created_at
27
+ # and will be removed in the next major release.
21
28
  sl_attr :created, 'createDate'
22
29
 
23
30
  ##
24
- # :attr_reader:
31
+ # :attr_reader: modified_at
25
32
  # The date of the last modification to this username/password pair.
33
+ sl_attr :modified_at, 'modifyDate'
34
+
35
+ ##
36
+ # :attr_reader: modified
37
+ # The date of the last modification to this username/password pair.
38
+ # DEPRECATION WARNING: This attribute is deprecated in favor of modified_at
39
+ # and will be removed in the next major release.
26
40
  sl_attr :modified, 'modifyDate'
27
41
 
28
42
  ##
@@ -65,10 +79,17 @@ module SoftLayer
65
79
  # If no client can be found the routine will raise an error.
66
80
  #
67
81
  # You may filter the list returned by adding options:
68
- # * <b>+:datacenter+</b> (string) - Include software passwords from application delivery controllers matching this datacenter
69
- # * <b>+:name+</b> (string) - Include software passwords from application delivery controllers that matches this name
70
- # * <b>+:tags+</b> (Array) - Include software passwords from application delivery controllers that matches these tags
71
- # * <b>+:username+</b> (string) - Include software passwords that match this username
82
+ # * <b>+:datacenter+</b> (string/array) - Include software passwords from application delivery controllers matching this datacenter
83
+ # * <b>+:name+</b> (string/array) - Include software passwords from application delivery controllers that matches this name
84
+ # * <b>+:tags+</b> (string/array - Include software passwords from application delivery controllers that matches these tags
85
+ # * <b>+:username+</b> (string/array) - Include software passwords that match this username
86
+ #
87
+ # Additionally you may provide options related to the request itself:
88
+ # * <b>*:application_delivery_controller_object_filter*</b> (ObjectFilter) - Include software passwords from application delivery controllers
89
+ # that matches the criteria of this object filter
90
+ # * <b>*:software_password_object_filter*</b> (ObjectFilter) - Include software passwords that match the criteria of this object filter
91
+ # * <b>*:software_password_object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
92
+ # If not provided, the result will use the default object mask
72
93
  #
73
94
  def self.find_passwords_for_application_delivery_controllers(options_hash = {})
74
95
  softlayer_client = options_hash[:client] || Client.default_client
@@ -89,34 +110,27 @@ module SoftLayer
89
110
  end
90
111
 
91
112
  option_to_filter_path = {
92
- :advanced_mode => "applicationDeliveryControllers.advancedModeFlag",
93
- :datacenter => "applicationDeliveryControllers.datacenter.name",
94
- :name => "applicationDeliveryControllers.name",
95
- :tags => "applicationDeliveryControllers.tagReferences.tag.name",
96
- :software_password => {
113
+ :app_deliv_controller => {
114
+ :advanced_mode => "applicationDeliveryControllers.advancedModeFlag",
115
+ :datacenter => "applicationDeliveryControllers.datacenter.name",
116
+ :name => "applicationDeliveryControllers.name",
117
+ :tags => "applicationDeliveryControllers.tagReferences.tag.name"
118
+ },
119
+ :software_password => {
97
120
  :username => "password.username"
98
121
  }
99
122
  }
100
123
 
101
- application_delivery_controller_object_filter.modify { |filter| filter.accept(option_to_filter_path[:advanced_mode]).when_it is(true) }
124
+ application_delivery_controller_object_filter.modify { |filter| filter.accept(option_to_filter_path[:app_deliv_controller][:advanced_mode]).when_it is(true) }
125
+
126
+ option_to_filter_path[:app_deliv_controller].each do |option, filter_path|
127
+ next if option == :advanced_mode
102
128
 
103
- [ :datacenter, :name ].each do |option|
104
129
  if options_hash[option]
105
- application_delivery_controller_object_filter.modify { |filter| filter.accept(option_to_filter_path[option]).when_it is(options_hash[option]) }
130
+ application_delivery_controller_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) }
106
131
  end
107
132
  end
108
133
 
109
- if options_hash[:tags]
110
- application_delivery_controller_object_filter.set_criteria_for_key_path(option_to_filter_path[:tags],
111
- {
112
- 'operation' => 'in',
113
- 'options' => [{
114
- 'name' => 'data',
115
- 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
116
- }]
117
- })
118
- end
119
-
120
134
  option_to_filter_path[:software_password].each do |option, filter_path|
121
135
  software_password_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
122
136
  end
@@ -150,15 +164,24 @@ module SoftLayer
150
164
  # If no client can be found the routine will raise an error.
151
165
  #
152
166
  # You may filter the list returned by adding options:
153
- # * <b>+:datacenter+</b> (string) - Include software passwords from vlan firewalls matching this datacenter
154
- # * <b>+:vlan_name+</b> (Array) - Include software passwords from vlans that matches these names
155
- # * <b>+:vlan_numbers+</b> (Array) - Include software passwords from vlans that matches these numbers
156
- # * <b>+:vlan_space+</b> (symbol) - Include software passwords from vlans that match this space
157
- # * <b>+:vlan_tags+</b> (Array) - Include software passwords from vlans that matches these tags
158
- # * <b>+:vlan_fw_fqdn+</b> (string) - Include software passwords from vlan firewalls that match this fqdn
159
- # * <b>+:vlan_fw_tags+</b> (Array) - Include software passwords from vlan firewalls that matches these tags
160
- # * <b>+:vlan_fw_type+</b> (string) - Include software passwords from vlan firewalls that match this type
161
- # * <b>+:username+</b> (string) - Include software passwords that match this username
167
+ # * <b>+:datacenter+</b> (string/array) - Include software passwords from vlan firewalls matching this datacenter
168
+ # * <b>+:vlan_names+</b> (string/array) - Include software passwords from vlans that matches these names
169
+ # * <b>+:vlan_numbers+</b> (string/array) - Include software passwords from vlans that matches these numbers
170
+ # * <b>+:vlan_space+</b> (symbol) - Include software passwords from vlans that match this space
171
+ # * <b>+:vlan_tags+</b> (string/array) - Include software passwords from vlans that matches these tags
172
+ # * <b>+:vlan_fw_fqdn+</b> (string/array) - Include software passwords from vlan firewalls that match this fqdn
173
+ # * <b>+:vlan_fw_tags+</b> (string/array) - Include software passwords from vlan firewalls that matches these tags
174
+ # * <b>+:vlan_fw_type+</b> (string/array) - Include software passwords from vlan firewalls that match this type
175
+ # * <b>+:username+</b> (string/array) - Include software passwords that match this username
176
+ #
177
+ # Additionally you may provide options related to the request itself:
178
+ # * <b>*:software_password_object_filter*</b> (ObjectFilter) - Include software passwords that match the criteria of this object filter
179
+ # * <b>*:software_password_object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
180
+ # If not provided, the result will use the default object mask
181
+ # * <b>*:vlan_firewall_object_filter*</b> (ObjectFilter) - Include software passwords from vlan firewalls that match the
182
+ # criteria of this object filter
183
+ # * <b>*:vlan_object_filter*</b> (ObjectFilter) - Include software passwords from vlan firewalls whose vlans match the
184
+ # criteria of this object filter
162
185
  #
163
186
  def self.find_passwords_for_vlan_firewalls(options_hash = {})
164
187
  softlayer_client = options_hash[:client] || Client.default_client
@@ -195,16 +218,18 @@ module SoftLayer
195
218
  :software_password => {
196
219
  :username => "managementCredentials.username"
197
220
  },
198
- :vlan_dedicated_fw => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'dedicatedFirewallFlag' ].join },
199
- :vlan_names => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'name' ].join },
200
- :vlan_numbers => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'vlanNumber' ].join },
201
- :vlan_tags => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'tagReferences.tag.name' ].join },
221
+ :vlan => {
222
+ :vlan_dedicated_fw => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'dedicatedFirewallFlag' ].join },
223
+ :vlan_names => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'name' ].join },
224
+ :vlan_numbers => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'vlanNumber' ].join },
225
+ :vlan_tags => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'tagReferences.tag.name' ].join }
226
+ },
202
227
  :vlan_firewall => {
203
228
  :vlan_fw_datacenter => "networkVlanFirewall.datacenter.name",
204
229
  :vlan_fw_fqdn => "networkVlanFirewall.fullyQualifiedDomainName",
230
+ :vlan_fw_tags => "networkVlanFirewall.tagReferences.tag.name",
205
231
  :vlan_fw_type => "networkVlanFirewall.firewallType"
206
- },
207
- :vlan_fw_tags => "networkVlanFirewall.tagReferences.tag.name"
232
+ }
208
233
  }
209
234
 
210
235
  if options_hash[:vlan_space] && ! filter_label.keys.include?(options_hash[:vlan_space])
@@ -217,19 +242,11 @@ module SoftLayer
217
242
 
218
243
  vlan_space = options_hash[:vlan_space] || :all
219
244
 
220
- vlan_object_filter.modify { |filter| filter.accept(option_to_filter_path[:vlan_dedicated_fw].call(vlan_space)).when_it is(1) }
221
- vlan_object_filter.modify { |filter| filter.accept(option_to_filter_path[:vlan_name].call(vlan_space)).when_it is(options_hash[:vlan_name]) } if options_hash[:vlan_name]
245
+ option_to_filter_path[:vlan].keys.each do |option|
246
+ vlan_object_filter.modify { |filter| filter.accept(option_to_filter_path[:vlan][option].call(vlan_space)).when_it is(1) } if option == :vlan_dedicated_fw
222
247
 
223
- [ :vlan_names, :vlan_numbers, :vlan_tags ].each do |option|
224
- if options_hash[option]
225
- vlan_object_filter.set_criteria_for_key_path(option_to_filter_path[option].call(vlan_space),
226
- {
227
- 'operation' => 'in',
228
- 'options' => [{
229
- 'name' => 'data',
230
- 'value' => options_hash[option].collect{ |tag_value| tag_value.to_s }
231
- }]
232
- })
248
+ if options_hash[option] && option != :vlan_dedicated_fw
249
+ vlan_object_filter.modify { |filter| filter.accept(option_to_filter_path[:vlan][option].call(vlan_space)).when_it is(options_hash[option]) }
233
250
  end
234
251
  end
235
252
 
@@ -237,17 +254,6 @@ module SoftLayer
237
254
  vlan_firewall_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
238
255
  end
239
256
 
240
- if options_hash[:vlan_fw_tags]
241
- vlan_firewall_object_filter.set_criteria_for_key_path(option_to_filter_path[:vlan_fw_tags],
242
- {
243
- 'operation' => 'in',
244
- 'options' => [{
245
- 'name' => 'data',
246
- 'value' => options_hash[:vlan_fw_tags].collect{ |tag_value| tag_value.to_s }
247
- }]
248
- })
249
- end
250
-
251
257
  account_service = softlayer_client[:Account]
252
258
  account_service = account_service.object_filter(vlan_object_filter) unless vlan_object_filter.empty?
253
259
  account_service = account_service.object_mask("mask[id]")
@@ -293,14 +299,14 @@ module SoftLayer
293
299
  # If no client can be found the routine will raise an error.
294
300
  #
295
301
  # You may filter the list returned by adding options:
296
- # * <b>+:datacenter+</b> (string) - Include software passwords from software on hardware matching this datacenter
297
- # * <b>+:description+</b> (string) - Include software passwords from software that matches this description
298
- # * <b>+:domain+</b> (string) - Include software passwords from software on hardware matching this domain
299
- # * <b>+:hardware_type+</b> (string) - Include software passwords from software on hardware matching this hardware type
300
- # * <b>+:hostname+</b> (string) - Include software passwords from software on hardware matching this hostname
301
- # * <b>+:manufacturer+</b> (string) - Include software passwords from software that matches this manufacturer
302
- # * <b>+:name+</b> (string) - Include software passwords from software that matches this name
303
- # * <b>+:username+</b> (string) - Include software passwords for username matching this username
302
+ # * <b>+:datacenter+</b> (string/array) - Include software passwords from software on hardware matching this datacenter
303
+ # * <b>+:description+</b> (string/array) - Include software passwords from software that matches this description
304
+ # * <b>+:domain+</b> (string/array) - Include software passwords from software on hardware matching this domain
305
+ # * <b>+:hardware_type+</b> (symbol) - Include software passwords from software on hardware matching this hardware type
306
+ # * <b>+:hostname+</b> (string/array) - Include software passwords from software on hardware matching this hostname
307
+ # * <b>+:manufacturer+</b> (string/array) - Include software passwords from software that matches this manufacturer
308
+ # * <b>+:name+</b> (string/array) - Include software passwords from software that matches this name
309
+ # * <b>+:username+</b> (string/array) - Include software passwords for username matching this username
304
310
  #
305
311
  # You may use the following properties to provide hardware or software object filter instances:
306
312
  # * <b>+:hardware_object_filter+</b> (ObjectFilter) - Include software passwords from software on hardware that matches the criteria of this object filter
@@ -341,10 +347,12 @@ module SoftLayer
341
347
  }
342
348
 
343
349
  option_to_filter_path = {
344
- :datacenter => lambda { |hardware_type| return [ filter_label[hardware_type], '.datacenter.name' ].join },
345
- :domain => lambda { |hardware_type| return [ filter_label[hardware_type], '.domain' ].join },
346
- :hostname => lambda { |hardware_type| return [ filter_label[hardware_type], '.hostname' ].join },
347
- :tags => lambda { |hardware_type| return [ filter_label[hardware_type], '.tagReferences.tag.name' ].join },
350
+ :hardware => {
351
+ :datacenter => lambda { |hardware_type| return [ filter_label[hardware_type], '.datacenter.name' ].join },
352
+ :domain => lambda { |hardware_type| return [ filter_label[hardware_type], '.domain' ].join },
353
+ :hostname => lambda { |hardware_type| return [ filter_label[hardware_type], '.hostname' ].join },
354
+ :tags => lambda { |hardware_type| return [ filter_label[hardware_type], '.tagReferences.tag.name' ].join }
355
+ },
348
356
  :software => {
349
357
  :description => "softwareComponents.softwareDescription.longDescription",
350
358
  :manufacturer => "softwareComponents.softwareDescription.manufacturer",
@@ -362,23 +370,12 @@ module SoftLayer
362
370
  end
363
371
  end
364
372
 
365
- [ :datacenter, :domain, :hostname ].each do |option|
373
+ option_to_filter_path[:hardware].keys.each do |option|
366
374
  if options_hash[option]
367
- hardware_object_filter.modify { |filter| filter.accept(option_to_filter_path[option].call(options_hash[:hardware_type] || :hardware)).when_it is(options_hash[option]) }
375
+ hardware_object_filter.modify { |filter| filter.accept(option_to_filter_path[:hardware][option].call(options_hash[:hardware_type] || :hardware)).when_it is(options_hash[option]) }
368
376
  end
369
377
  end
370
378
 
371
- if options_hash[:tags]
372
- hardware_object_filter.set_criteria_for_key_path(option_to_filter_path[:tags].call(options_hash[:hardware_type] || :hardware),
373
- {
374
- 'operation' => 'in',
375
- 'options' => [{
376
- 'name' => 'data',
377
- 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
378
- }]
379
- })
380
- end
381
-
382
379
  option_to_filter_path[:software].each do |option, filter_path|
383
380
  software_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
384
381
  end
@@ -436,13 +433,13 @@ module SoftLayer
436
433
  # If no client can be found the routine will raise an error.
437
434
  #
438
435
  # You may filter the list returned by adding options:
439
- # * <b>+:datacenter+</b> (string) - Include software passwords from software on virtual servers matching this datacenter
440
- # * <b>+:description+</b> (string) - Include software passwords from software that matches this description
441
- # * <b>+:domain+</b> (string) - Include software passwords from software on virtual servers matching this domain
442
- # * <b>+:hostname+</b> (string) - Include software passwords from software on virtual servers matching this hostname
443
- # * <b>+:manufacturer+</b> (string) - Include software passwords from software that matches this manufacturer
444
- # * <b>+:name+</b> (string) - Include software passwords from software that matches this name
445
- # * <b>+:username+</b> (string) - Include software passwords for username matching this username
436
+ # * <b>+:datacenter+</b> (string/array) - Include software passwords from software on virtual servers matching this datacenter
437
+ # * <b>+:description+</b> (string/array) - Include software passwords from software that matches this description
438
+ # * <b>+:domain+</b> (string/array) - Include software passwords from software on virtual servers matching this domain
439
+ # * <b>+:hostname+</b> (string/array) - Include software passwords from software on virtual servers matching this hostname
440
+ # * <b>+:manufacturer+</b> (string/array) - Include software passwords from software that matches this manufacturer
441
+ # * <b>+:name+</b> (string/array) - Include software passwords from software that matches this name
442
+ # * <b>+:username+</b> (string/array) - Include software passwords for username matching this username
446
443
  #
447
444
  # You may use the following properties to provide virtual server or software object filter instances:
448
445
  # * <b>+:virtual_server_object_filter+</b> (ObjectFilter) - Include software passwords from software on virtual servers that matches the criteria of this object filter
@@ -493,19 +490,7 @@ module SoftLayer
493
490
  }
494
491
  }
495
492
 
496
- if options_hash[:tags]
497
- virtual_server_object_filter.set_criteria_for_key_path(option_to_filter_path[:virtual_server][:tags],
498
- {
499
- 'operation' => 'in',
500
- 'options' => [{
501
- 'name' => 'data',
502
- 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
503
- }]
504
- })
505
- end
506
-
507
493
  option_to_filter_path[:virtual_server].each do |option, filter_path|
508
- next if option == :tags
509
494
  virtual_server_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
510
495
  end
511
496
 
@@ -5,7 +5,7 @@
5
5
  #++
6
6
 
7
7
  module SoftLayer
8
- class Ticket < SoftLayer::ModelBase
8
+ class Ticket < SoftLayer::ModelBase
9
9
 
10
10
  ##
11
11
  # :attr_reader:
@@ -17,9 +17,17 @@ module SoftLayer
17
17
  # The ticket system maintains a fixed set of subjects for tickets that are used to ensure tickets make it to the right folks quickly
18
18
  sl_attr :subject
19
19
 
20
+ ##
21
+ # :attr_reader: last_edited_at
22
+ # The date the ticket was last updated.
23
+ sl_attr :last_edited_at, 'lastEditDate'
24
+
20
25
  ##
21
26
  # :attr_reader:
22
27
  # The date the ticket was last updated.
28
+ #
29
+ # DEPRECATION WARNING: This attribute is deprecated in favor of last_edited_at
30
+ # and will be removed in the next major release.
23
31
  sl_attr :lastEditDate
24
32
 
25
33
  ##
@@ -35,12 +43,12 @@ module SoftLayer
35
43
  self['serverAdministrationFlag'] != 0
36
44
  end
37
45
 
38
- ##
39
- # Add an update to this ticket.
40
- #
41
- def update(body = nil)
42
- self.service.edit(self.softlayer_hash, body)
43
- end
46
+ ##
47
+ # Add an update to this ticket.
48
+ #
49
+ def update(body = nil)
50
+ self.service.edit(self.softlayer_hash, body)
51
+ end
44
52
 
45
53
  ##
46
54
  # Override of service from ModelBase. Returns the SoftLayer_Ticket service
@@ -52,7 +60,7 @@ module SoftLayer
52
60
  ##
53
61
  # Override from model base. Requests new details about the ticket
54
62
  # from the server.
55
- def softlayer_properties(object_mask = nil)
63
+ def softlayer_properties(object_mask = nil)
56
64
  my_service = self.service
57
65
 
58
66
  if(object_mask)
@@ -62,12 +70,12 @@ module SoftLayer
62
70
  end
63
71
 
64
72
  my_service.getObject()
65
- end
73
+ end
66
74
 
67
75
  ##
68
76
  # Returns the default object mask,as a hash, that is used when
69
77
  # retrieving ticket information from the SoftLayer server.
70
- def self.default_object_mask
78
+ def self.default_object_mask
71
79
  {
72
80
  "mask" => [
73
81
  'id', # This is an internal ticket ID, not the one usually seen in the portal
@@ -84,23 +92,23 @@ module SoftLayer
84
92
  'serverAdministrationFlag', # This comes in from the server as an integer :-(
85
93
  ]
86
94
  }.to_sl_object_mask
87
- end
95
+ end
88
96
 
89
97
  ##
90
98
  # Queries the SoftLayer API to retrieve a list of the valid
91
99
  # ticket subjects.
92
- def self.ticket_subjects(client = nil)
93
- @ticket_subjects ||= nil
100
+ def self.ticket_subjects(client = nil)
101
+ @ticket_subjects ||= nil
94
102
 
95
- if !@ticket_subjects
103
+ if !@ticket_subjects
96
104
  softlayer_client = client || Client.default_client
97
105
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
98
106
 
99
- @ticket_subjects = softlayer_client[:Ticket_Subject].getAllObjects();
100
- end
107
+ @ticket_subjects = softlayer_client[:Ticket_Subject].getAllObjects();
108
+ end
101
109
 
102
- @ticket_subjects
103
- end
110
+ @ticket_subjects
111
+ end
104
112
 
105
113
  ##
106
114
  # Find the ticket with the given ID and return it
@@ -112,19 +120,20 @@ module SoftLayer
112
120
  # If a client is not provided then the routine will search Client::default_client
113
121
  # If Client::default_client is also nil the routine will raise an error.
114
122
  #
115
- def self.ticket_with_id(ticket_id, options = {})
123
+ # Additionally you may provide options related to the request itself:
124
+ # * <b>*:object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
125
+ # If not provided, the result will use the default object mask
126
+ def self.ticket_with_id(ticket_id, options = {})
116
127
  softlayer_client = options[:client] || Client.default_client
117
128
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
118
129
 
119
- if options.has_key?(:object_mask)
120
- object_mask = options[:object_mask]
121
- else
122
- object_mask = default_object_mask.to_sl_object_mask
123
- end
130
+ ticket_service = softlayer_client[:Ticket].object_with_id(ticket_id)
131
+ ticket_service = ticket_service.object_mask(default_object_mask.to_sl_object_mask)
132
+ ticket_service = ticket_service.object_mask(options[:object_mask]) if options[:object_mask]
124
133
 
125
- ticket_data = softlayer_client[:Ticket].object_with_id(ticket_id).object_mask(object_mask).getObject()
134
+ ticket_data = ticket_service.getObject()
126
135
 
127
- return new(softlayer_client, ticket_data)
136
+ return Ticket.new(softlayer_client, ticket_data)
128
137
  end
129
138
 
130
139
  ##
@@ -167,5 +176,5 @@ module SoftLayer
167
176
  ticket_data = softlayer_client[:Ticket].createStandardTicket(new_ticket, body)
168
177
  return new(softlayer_client, ticket_data)
169
178
  end
170
- end
171
- end
179
+ end
180
+ end
@@ -16,17 +16,24 @@ module SoftLayer
16
16
  include ::SoftLayer::DynamicAttribute
17
17
 
18
18
  ##
19
- # :attr_reader:
19
+ # :attr_reader: alternate_phone
20
20
  # A portal user's secondary phone number.
21
21
  sl_attr :alternate_phone, 'alternatePhone'
22
22
 
23
23
  ##
24
- # :attr_reader:
24
+ # :attr_reader: created_at
25
25
  # The date a portal user's record was created.
26
+ sl_attr :created_at, 'createDate'
27
+
28
+ ##
29
+ # :attr_reader: created
30
+ # The date a portal user's record was created.
31
+ # DEPRECATION WARNING: This attribute is deprecated in favor of created_at
32
+ # and will be removed in the next major release.
26
33
  sl_attr :created, 'createDate'
27
34
 
28
35
  ##
29
- # :attr_reader:
36
+ # :attr_reader: display_name
30
37
  # The portal user's display name.
31
38
  sl_attr :display_name, 'displayName'
32
39
 
@@ -36,32 +43,39 @@ module SoftLayer
36
43
  sl_attr :email
37
44
 
38
45
  ##
39
- # :attr_reader:
46
+ # :attr_reader: first_name
40
47
  # A portal user's first name.
41
48
  sl_attr :first_name, 'firstName'
42
49
 
43
50
  ##
44
- # :attr_reader:
51
+ # :attr_reader: last_name
45
52
  # A portal user's last name.
46
53
  sl_attr :last_name, 'lastName'
47
54
 
48
55
  ##
49
- # :attr_reader:
56
+ # :attr_reader: modified_at
57
+ # The date a portal user's record was last modified.
58
+ sl_attr :modified_at, 'modifyDate'
59
+
60
+ ##
61
+ # :attr_reader: modified
50
62
  # The date a portal user's record was last modified.
63
+ # DEPRECATION WARNING: This attribute is deprecated in favor of modified_at
64
+ # and will be removed in the next major release.
51
65
  sl_attr :modified, 'modifyDate'
52
66
 
53
67
  ##
54
- # :attr_reader:
68
+ # :attr_reader: office_phone
55
69
  # A portal user's office phone number.
56
70
  sl_attr :office_phone, 'officePhone'
57
71
 
58
72
  ##
59
- # :attr_reader:
73
+ # :attr_reader: password_expires
60
74
  # The expiration date for the user's password.
61
75
  sl_attr :password_expires, 'passwordExpireDate'
62
76
 
63
77
  ##
64
- # :attr_reader:
78
+ # :attr_reader: status_changed
65
79
  # The date a portal users record's last status change.
66
80
  sl_attr :status_changed, 'statusDate'
67
81
 
@@ -71,8 +85,10 @@ module SoftLayer
71
85
  sl_attr :username
72
86
 
73
87
  ##
74
- # A portal user's additional email addresses.
88
+ # Retrieve a portal user's additional email addresses.
75
89
  # These email addresses are contacted when updates are made to support tickets.
90
+ # :call-seq:
91
+ # additional_emails(force_update=false)
76
92
  sl_dynamic_attr :additional_emails do |resource|
77
93
  resource.should_update? do
78
94
  #only retrieved once per instance
@@ -86,8 +102,10 @@ module SoftLayer
86
102
  end
87
103
 
88
104
  ##
89
- # A portal user's API Authentication keys.
105
+ # Retrieve a portal user's API Authentication keys.
90
106
  # There is a max limit of two API keys per user.
107
+ # :call-seq:
108
+ # api_authentication_keys(force_update=false)
91
109
  sl_dynamic_attr :api_authentication_keys do |resource|
92
110
  resource.should_update? do
93
111
  #only retrieved once per instance
@@ -100,7 +118,9 @@ module SoftLayer
100
118
  end
101
119
 
102
120
  ##
103
- # The external authentication bindings that link an external identifier to a SoftLayer user.
121
+ # Retrieve the external authentication bindings that link an external identifier to a SoftLayer user.
122
+ # :call-seq:
123
+ # external_bindings(force_update=false)
104
124
  sl_dynamic_attr :external_bindings do |resource|
105
125
  resource.should_update? do
106
126
  #only retrieved once per instance
@@ -109,7 +129,30 @@ module SoftLayer
109
129
 
110
130
  resource.to_update do
111
131
  external_bindings = self.service.object_mask(UserCustomerExternalBinding.default_object_mask).getExternalBindings
112
- external_bindings.collect { |external_binding| UserCustomerExternalBinding.new(soflayer_client, external_binding) }
132
+ external_bindings.collect { |external_binding| UserCustomerExternalBinding.new(softlayer_client, external_binding) }
133
+ end
134
+ end
135
+
136
+ ##
137
+ # Retrieve the user customer associated with the specified username
138
+ #
139
+ def self.user_customer_with_username(username, client = nil)
140
+ softlayer_client = client || Client.default_client
141
+ raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
142
+ raise "#{__method__} requires a user customer username but none was given" if !username || username.empty?
143
+
144
+ user_customer_object_filter = ObjectFilter.new()
145
+
146
+ user_customer_object_filter.modify { |filter| filter.accept('users.username').when_it is(username) }
147
+
148
+ account_service = Account.account_for_client(softlayer_client).service
149
+ account_service = account_service.object_filter(user_customer_object_filter)
150
+ account_service = account_service.object_mask(UserCustomer.default_object_mask)
151
+
152
+ user_customer_data = account_service.getUsers
153
+
154
+ if user_customer_data.length == 1
155
+ UserCustomer.new(softlayer_client, user_customer_data.first)
113
156
  end
114
157
  end
115
158