Skip to content

Commit 04a627e

Browse files
committed
Cleanup rdoc for available options, object mask, and result limit and add result limit where it was missing
1 parent 7a52596 commit 04a627e

10 files changed

Lines changed: 129 additions & 76 deletions

lib/softlayer/Account.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def self.account_for_client(client = nil)
283283

284284
account_service = softlayer_client[:Account]
285285
network_hash = account_service.getObject()
286-
new(softlayer_client, network_hash)
286+
Account.new(softlayer_client, network_hash)
287287
end
288288

289289
##

lib/softlayer/AccountPassword.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,19 @@ def password=(password)
7979
# * <b>+:datacenter+</b> (string/array) - Include network storage account passwords from servers matching this datacenter
8080
# * <b>+:domain+</b> (string/array) - Include network storage account passwords from servers matching this domain
8181
# * <b>+:hostname+</b> (string/array) - Include network storage account passwords from servers matching this hostname
82-
# * <b>+:network_storage_server_type+</b> (string) - Include network storage account passwords attached to this server type
83-
# * <b>+:network_storage_type+</b> (string) - Include network storage account passwords from devices of this storage type
82+
# * <b>+:network_storage_server_type+</b> (symbol) - Include network storage account passwords attached to this server type
83+
# * <b>+:network_storage_type+</b> (symbol) - Include network storage account passwords from devices of this storage type
8484
# * <b>+:tags+</b> (string/array) - Include network storage account passwords from servers matching these tags
8585
# * <b>+:username+</b> (string/array) - Include network storage account passwords with this username only
8686
#
87+
# Additionally you may provide options related to the request itself:
88+
# * <b>*:account_password_object_filter*</b> (ObjectFilter) - Include network storage account passwords for account passwords that match the
89+
# criteria of this object filter
90+
# * <b>*:account_password_object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
91+
# If not provided, the result will use the default object mask
92+
# * <b>*:network_storage_object_filter*</b> (ObjectFilter) - Include network storage account passwords from network storage that matches the
93+
# criteria of this object filter
94+
#
8795
def self.find_network_storage_account_passwords(options_hash = {})
8896
softlayer_client = options_hash[:client] || Client.default_client
8997
raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
@@ -197,11 +205,19 @@ def self.find_network_storage_account_passwords(options_hash = {})
197205
# * <b>+:datacenter+</b> (string/array) - Include network storage webcc passwords from servers matching this datacenter
198206
# * <b>+:domain+</b> (string/array) - Include network storage webcc passwords from servers matching this domain
199207
# * <b>+:hostname+</b> (string/array) - Include network storage webcc passwords from servers matching this hostname
200-
# * <b>+:network_storage_server_type+</b> (string) - Include network storage webcc passwords attached to this server type
201-
# * <b>+:network_storage_type+</b> (string) - Include network storage webcc passwords from devices of this storage type
208+
# * <b>+:network_storage_server_type+</b> (symbol) - Include network storage webcc passwords attached to this server type
209+
# * <b>+:network_storage_type+</b> (symbol) - Include network storage webcc passwords from devices of this storage type
202210
# * <b>+:tags+</b> (string/array) - Include network storage webcc passwords from servers matching these tags
203211
# * <b>+:username+</b> (string/array) - Include network storage webcc passwords with this username only
204212
#
213+
# Additionally you may provide options related to the request itself:
214+
# * <b>*:network_storage_object_filter*</b> (ObjectFilter) - Include network storage account passwords from network storage that matches the
215+
# criteria of this object filter
216+
# * <b>*:webcc_password_object_filter*</b> (ObjectFilter) - Include network storage account passwords for webcc passwords that match the
217+
# criteria of this object filter
218+
# * <b>*:webcc_password_object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
219+
# If not provided, the result will use the default object mask
220+
#
205221
def self.find_network_storage_webcc_passwords(options_hash = {})
206222
softlayer_client = options_hash[:client] || Client.default_client
207223
raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client

lib/softlayer/BareMetalServer.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ def firewall_port_speed
155155
#
156156
# If no client is given, then the routine will try to use Client.default_client
157157
# If no client can be found the routine will raise an error.
158+
#
159+
# Additionally you may provide options related to the request itself:
160+
# * <b>*:object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
161+
# If not provided, the result will use the default object mask
158162
def self.server_with_id(server_id, options = {})
159163
softlayer_client = options[:client] || Client.default_client
160164
raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
@@ -194,9 +198,11 @@ def self.server_with_id(server_id, options = {})
194198
# * <b>+:private_ip+</b> (string/array) - same as :public_ip, but for private IP addresses
195199
#
196200
# Additionally you may provide options related to the request itself:
197-
#
198-
# * <b>+:object_mask+</b> (string, hash, or array) - The object mask of properties you wish to receive for the items returned If not provided, the result will use the default object mask
199-
# * <b>+:result_limit+</b> (hash with :limit, and :offset keys) - Limit the scope of results returned.
201+
# * <b>*:object_filter*</b> (ObjectFilter) - Include hardware servers for servers that matche the
202+
# criteria of this object filter
203+
# * <b>+:object_mask+</b> (string, hash, or array) - The object mask of properties you wish to receive for the items returned.
204+
# If not provided, the result will use the default object mask
205+
# * <b>+:result_limit+</b> (hash with :limit, and :offset keys) - Limit the scope of results returned.
200206
#
201207
def self.find_servers(options_hash = {})
202208
softlayer_client = options_hash[:client] || Client.default_client
@@ -231,16 +237,10 @@ def self.find_servers(options_hash = {})
231237
account_service = softlayer_client[:Account]
232238
account_service = account_service.object_filter(object_filter) unless object_filter.empty?
233239
account_service = account_service.object_mask(default_object_mask.to_sl_object_mask)
240+
account_service = account_service.object_mask(options_hash[:object_mask]) if options_hash[:object_mask]
234241

235-
if(options_hash.has_key? :object_mask)
236-
account_service = account_service.object_mask(options_hash[:object_mask])
237-
end
238-
239-
if options_hash.has_key?(:result_limit)
240-
offset = options[:result_limit][:offset]
241-
limit = options[:result_limit][:limit]
242-
243-
account_service = account_service.result_limit(offset, limit)
242+
if options_hash[:result_limit] && options_hash[:result_limit][:offset] && options_hash[:result_limit][:limit]
243+
account_service = account_service.result_limit(options_hash[:result_limit][:offset], options_hash[:result_limit][:limit])
244244
end
245245

246246
bare_metal_data = account_service.getHardware()

lib/softlayer/ImageTemplate.rb

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ def softlayer_properties(object_mask = nil)
212212
# * <b>+:name+</b> (string/array) - Return templates with the given name
213213
# * <b>+:global_id+</b> (string/array) - Return templates with the given global identifier
214214
# * <b>+:tags+</b> (string/array) - Return templates with the tags
215+
#
216+
# Additionally you may provide options related to the request itself:
217+
#
218+
# * <b>*:object_filter*</b> (ObjectFilter) - Include private image templates for templates that matche the
219+
# criteria of this object filter
220+
# * <b>+:object_mask+</b> (string, hash, or array) - The object mask of properties you wish to receive for the items returned.
221+
# If not provided, the result will use the default object mask
222+
# * <b>+:result_limit+</b> (hash with :limit, and :offset keys) - Limit the scope of results returned.
215223
def self.find_private_templates(options_hash = {})
216224
softlayer_client = options_hash[:client] || Client.default_client
217225
raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
@@ -239,20 +247,14 @@ def self.find_private_templates(options_hash = {})
239247
account_service = softlayer_client[:Account]
240248
account_service = account_service.object_filter(object_filter) unless object_filter.empty?
241249
account_service = account_service.object_mask(default_object_mask)
250+
account_service = account_service.object_mask(options_hash[:object_mask]) if options_hash[:object_mask]
242251

243-
if options_hash.has_key? :object_mask
244-
account_service = account_service.object_mask(options_hash[:object_mask])
245-
end
246-
247-
if options_hash.has_key?(:result_limit)
248-
offset = options[:result_limit][:offset]
249-
limit = options[:result_limit][:limit]
250-
251-
account_service = account_service.result_limit(offset, limit)
252+
if options_hash[:result_limit] && options_hash[:result_limit][:offset] && options_hash[:result_limit][:limit]
253+
account_service = account_service.result_limit(options_hash[:result_limit][:offset], options_hash[:result_limit][:limit])
252254
end
253255

254256
templates_data = account_service.getPrivateBlockDeviceTemplateGroups
255-
templates_data.collect { |template_data| new(softlayer_client, template_data) }
257+
templates_data.collect { |template_data| ImageTemplate.new(softlayer_client, template_data) }
256258
end
257259

258260
##
@@ -269,6 +271,14 @@ def self.find_private_templates(options_hash = {})
269271
# * <b>+:name+</b> (string/array) - Return templates with the given name
270272
# * <b>+:global_id+</b> (string/array) - Return templates with the given global identifier
271273
# * <b>+:tags+</b> (string/array) - Return templates with the tags
274+
#
275+
# Additionally you may provide options related to the request itself:
276+
#
277+
# * <b>*:object_filter*</b> (ObjectFilter) - Include public image templates for templates that matche the
278+
# criteria of this object filter
279+
# * <b>+:object_mask+</b> (string, hash, or array) - The object mask of properties you wish to receive for the items returned.
280+
# If not provided, the result will use the default object mask
281+
# * <b>+:result_limit+</b> (hash with :limit, and :offset keys) - Limit the scope of results returned.
272282
def self.find_public_templates(options_hash = {})
273283
softlayer_client = options_hash[:client] || Client.default_client
274284
raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
@@ -296,20 +306,14 @@ def self.find_public_templates(options_hash = {})
296306
template_service = softlayer_client[:Virtual_Guest_Block_Device_Template_Group]
297307
template_service = template_service.object_filter(object_filter) unless object_filter.empty?
298308
template_service = template_service.object_mask(default_object_mask)
309+
template_service = template_service.object_mask(options_hash[:object_mask]) if options_hash[:object_mask]
299310

300-
if options_hash.has_key? :object_mask
301-
template_service = template_service.object_mask(options_hash[:object_mask])
302-
end
303-
304-
if options_hash.has_key?(:result_limit)
305-
offset = options[:result_limit][:offset]
306-
limit = options[:result_limit][:limit]
307-
308-
template_service = template_service.result_limit(offset, limit)
311+
if options_hash[:result_limit] && options_hash[:result_limit][:offset] && options_hash[:result_limit][:limit]
312+
template_service = template_service.result_limit(options_hash[:result_limit][:offset], options_hash[:result_limit][:limit])
309313
end
310314

311315
templates_data = template_service.getPublicImages
312-
templates_data.collect { |template_data| new(softlayer_client, template_data) }
316+
templates_data.collect { |template_data| ImageTemplate.new(softlayer_client, template_data) }
313317
end
314318

315319
##
@@ -337,7 +341,7 @@ def self.template_with_id(id, options_hash = {})
337341
end
338342

339343
template_data = service.getObject
340-
new(softlayer_client, template_data)
344+
ImageTemplate.new(softlayer_client, template_data)
341345
end
342346

343347
##

lib/softlayer/NetworkStorage.rb

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,20 @@ def remove_credential(username)
196196
# If no client can be found the routine will raise an error.
197197
#
198198
# You may filter the list returned by adding options:
199-
# * <b>+:datacenter+</b> (string) - Include network storage associated with servers matching this datacenter
200-
# * <b>+:domain+</b> (string) - Include network storage associated with servers matching this domain
201-
# * <b>+:hostname+</b> (string) - Include network storage associated with servers matching this hostname
202-
# * <b>+:network_storage_server_type+</b> (string) - Include network storage associated with this server type
203-
# * <b>+:network_storage_type+</b> (string) - Include network storage from devices of this storage type
204-
# * <b>+:service+</b> (string) - Include network storage from devices with this service fqdn
205-
# * <b>+:tags+</b> (Array) - Include network storage associated with servers matching these tags
199+
# * <b>+:datacenter+</b> (string/array) - Include network storage associated with servers matching this datacenter
200+
# * <b>+:domain+</b> (string/array) - Include network storage associated with servers matching this domain
201+
# * <b>+:hostname+</b> (string/array) - Include network storage associated with servers matching this hostname
202+
# * <b>+:network_storage_server_type+</b> (symbol) - Include network storage associated with this server type
203+
# * <b>+:network_storage_type+</b> (symbol) - Include network storage from devices of this storage type
204+
# * <b>+:service+</b> (string/array) - Include network storage from devices with this service fqdn
205+
# * <b>+:tags+</b> (string/array) - Include network storage associated with servers matching these tags
206+
#
207+
# Additionally you may provide options related to the request itself:
208+
# * <b>*:network_storage_object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
209+
# If not provided, the result will use the default object mask
210+
# * <b>*:network_storage_object_filter*</b> (ObjectFilter) - Include network storage credentials from network storage that matches the
211+
# criteria of this object filter
212+
# * <b>+:result_limit+</b> (hash with :limit, and :offset keys) - Limit the scope of results returned.
206213
#
207214
def self.find_network_storage(options_hash = {})
208215
softlayer_client = options_hash[:client] || Client.default_client
@@ -231,11 +238,11 @@ def self.find_network_storage(options_hash = {})
231238
}
232239

233240
option_to_filter_path = {
234-
:datacenter => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.datacenter.name' ].join },
235-
:domain => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.domain' ].join },
236-
:hostname => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.hostname' ].join },
237-
:service => lambda { |storage_type| return [ filter_label[storage_type], '.serviceResource.backendIpAddress' ].join },
238-
:tags => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.tagReferences.tag.name' ].join },
241+
:datacenter => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.datacenter.name' ].join },
242+
:domain => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.domain' ].join },
243+
:hostname => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.hostname' ].join },
244+
:service => lambda { |storage_type| return [ filter_label[storage_type], '.serviceResource.backendIpAddress' ].join },
245+
:tags => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.tagReferences.tag.name' ].join },
239246
}
240247

241248
if options_hash[:network_storage_type]
@@ -278,6 +285,10 @@ def self.find_network_storage(options_hash = {})
278285
account_service = account_service.object_mask(NetworkStorage.default_object_mask)
279286
account_service = account_service.object_mask(options_hash[:network_storage_object_mask]) if options_hash[:network_storage_object_mask]
280287

288+
if options_hash[:result_limit] && options_hash[:result_limit][:offset] && options_hash[:result_limit][:limit]
289+
account_service = account_service.result_limit(options_hash[:result_limit][:offset], options_hash[:result_limit][:limit])
290+
end
291+
281292
case options_hash[:network_storage_type]
282293
when :evault
283294
network_storage_data = account_service.getEvaultNetworkStorage

0 commit comments

Comments
 (0)