softlayer_api 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -79,9 +79,9 @@ table{position:relative;left:2em;width:80%}.
79
79
  Here is an example, analogous to the one for global variables, which provides the username and API key as hash arguments. This example also changes the endpoint with the @:endpoint_url@ symbol so that the service will use the API on the SoftLayer Private Network:
80
80
 
81
81
  <pre style="border:1pt solid black;background:#eee;padding:0.5em;margin:0.5em"><code style="font-family:Menlo,Monaco,monospace;font-size:9pt">account_service = SoftLayer::Service.new("SoftLayer_Account",
82
- :username => "joeusername",
83
- :api_key => "omitted_for_brevity",
84
- :endpoint_url => API_PRIVATE_ENDPOINT)
82
+ :username => "joeusername",
83
+ :api_key => "omitted_for_brevity",
84
+ :endpoint_url => API_PRIVATE_ENDPOINT)
85
85
  </code></pre>
86
86
 
87
87
  h3. Calling Service Methods
@@ -96,12 +96,12 @@ If the method requires arguments, you can supply them as arguments to the method
96
96
  <pre style="border:1pt solid black;background:#eee;padding:0.5em;margin:0.5em"><code style="font-family:Menlo,Monaco,monospace;font-size:9pt">#authentication information will be found in the global variables
97
97
  ticket_service = SoftLayer::Service.new("SoftLayer_Ticket")
98
98
  new_ticket = ticket_service.createStandardTicket(
99
- {
99
+ {
100
100
  "assignedUserId" => my_account_id,
101
101
  "subjectId" => 1022,
102
102
  "notifyUserOnUpdateFlag" => true
103
- },
104
- "This is a test ticket created from a Ruby client")
103
+ },
104
+ "This is a test ticket created from a Ruby client")
105
105
  </code></pre>
106
106
 
107
107
  h4. Identifying Particular Objects
@@ -114,13 +114,13 @@ Some method calls in the SoftLayer API are made on particular objects, rather th
114
114
  The @object_with_id@ call returns an object that you can use as a reference to a particular object through the service. This allows you to reuse that object multiple times without having to repeatedly tack @object_with_id@ on to all your requests. For example, if you want to find a ticket with the id 98765 and add an update to it if it's assigned to user 123456, you might write code like this:
115
115
 
116
116
  <pre style="border:1pt solid black;background:#eee;padding:0.5em;margin:0.5em"><code style="font-family:Menlo,Monaco,monospace;font-size:9pt">begin
117
- ticket_ref = ticket_service.object_with_id(98765)
118
- ticket = ticket_ref.object_mask("assignedUserId").getObject
119
- if ticket['assignedUserId'] == 123456
120
- updates = ticket_ref.addUpdate({"entry" => "Get to work on these tickets!"})
121
- end
117
+ ticket_ref = ticket_service.object_with_id(98765)
118
+ ticket = ticket_ref.object_mask("assignedUserId").getObject
119
+ if ticket['assignedUserId'] == 123456
120
+ updates = ticket_ref.addUpdate({"entry" => "Get to work on these tickets!"})
121
+ end
122
122
  rescue Exception => exception
123
- puts "An error occurred while updating the ticket: #{exception}"
123
+ puts "An error occurred while updating the ticket: #{exception}"
124
124
  end
125
125
  </code></pre>
126
126
 
@@ -137,15 +137,15 @@ To look at some examples, consider the following object from the server. It has
137
137
  The assignedUser entity has three properties, id, username, and health.
138
138
 
139
139
  <pre style="border:1pt solid black;background:#eee;padding:0.5em;margin:0.5em"><code style="font-family:Menlo,Monaco,monospace;font-size:9pt">{
140
- "id"=>1736473,
141
- "title"=>"VM Polling Failure - unable to login",
142
- "createDate"=>"2010-04-22T00:12:36-05:00",
143
- "modifyDate"=>"2010-06-09T06:44:18-05:00"
144
- "assignedUser"=> {
145
- "id"=>14
146
- "username"=>"AlfredQHacker",
147
- "health"=>"Fantastic"
148
- },
140
+ "id"=>1736473,
141
+ "title"=>"VM Polling Failure - unable to login",
142
+ "createDate"=>"2010-04-22T00:12:36-05:00",
143
+ "modifyDate"=>"2010-06-09T06:44:18-05:00"
144
+ "assignedUser"=> {
145
+ "id"=>14
146
+ "username"=>"AlfredQHacker",
147
+ "health"=>"Fantastic"
148
+ },
149
149
  }
150
150
  </code></pre>
151
151
 
@@ -199,15 +199,15 @@ require 'softlayer_api'
199
199
  require 'pp'
200
200
 
201
201
  begin
202
- # use an account service to get a list of the open tickets and print their IDs and titles
203
- account_service = SoftLayer::Service.new("SoftLayer_Account",
204
- :username => "joecustomer" # enter your username here
205
- :api_key => "feeddeadbeefbadf00d...") # enter your api key here
202
+ # use an account service to get a list of the open tickets and print their IDs and titles
203
+ account_service = SoftLayer::Service.new("SoftLayer_Account",
204
+ :username => "joecustomer", # enter your username here
205
+ :api_key => "feeddeadbeefbadf00d...") # enter your api key here
206
206
 
207
- account = account_service.getObject
208
- pp account
207
+ account = account_service.getObject
208
+ pp account
209
209
  rescue Exception => exception
210
- puts "Unable to retrieve account information: #{exception}"
210
+ puts "Unable to retrieve account information: #{exception}"
211
211
  end
212
212
  </code></pre>
213
213
 
@@ -219,26 +219,26 @@ require 'softlayer_api'
219
219
  require 'pp'
220
220
 
221
221
  ticket_service = SoftLayer::Service.new("SoftLayer_Ticket",
222
- :username => "joecustomer", # enter your username here
223
- :api_key => "feeddeadbeefbadf00d...") # enter your api key here
222
+ :username => "joecustomer", # enter your username here
223
+ :api_key => "feeddeadbeefbadf00d...") # enter your api key here
224
224
 
225
225
  begin
226
- ticket_ref = ticket_service.object_with_id(1683973)
226
+ ticket_ref = ticket_service.object_with_id(123456)
227
227
 
228
- ticket = ticket_ref.object_mask({"updates" => ["entry", "createDate"]},
229
- "assignedUserId",
230
- {"attachedHardware" => "datacenter"}).getObject
231
- pp ticket
228
+ ticket = ticket_ref.object_mask({"updates" => ["entry", "createDate"]},
229
+ "assignedUserId",
230
+ {"attachedHardware" => "datacenter"}).getObject
231
+ pp ticket
232
232
  rescue Exception => exception
233
233
  puts "Unable to retrieve the ticket"
234
234
  end
235
235
 
236
236
  # update the ticket
237
237
  begin
238
- updates = ticket_ref.addUpdate({"entry" => "An update from the Ruby client!"})
239
- puts "Update ticket 123456. The new update's id is #{updates[0]['id']}"
238
+ updates = ticket_ref.addUpdate({"entry" => "An update from the Ruby client!"})
239
+ puts "Update ticket 123456. The new update's id is #{updates[0]['id']}"
240
240
  rescue Exception => exception
241
- puts "Unable to update the ticket: #{exception}"
241
+ puts "Unable to update the ticket: #{exception}"
242
242
  end
243
243
  </code></pre>
244
244
 
@@ -248,4 +248,4 @@ This software is written by the SoftLayer Development Team <"sldn@softlayer.com"
248
248
 
249
249
  h2. Copyright
250
250
 
251
- This software is Copyright (c) 2010 "SoftLayer Technologies, Inc":http://www.softlayer.com/. See the bundled LICENSE.textile file for more information.
251
+ This software is Copyright (c) 2010 "SoftLayer Technologies, Inc":http://www.softlayer.com/. See the bundled LICENSE.textile file for more information.
@@ -36,7 +36,7 @@
36
36
  #
37
37
 
38
38
  module SoftLayer
39
- VERSION = "1.0.2" # version history at the bottom of the file.
39
+ VERSION = "1.0.3" # version history at the bottom of the file.
40
40
 
41
41
  # The base URL of the SoftLayer API's REST-like endpoints available to the public internet.
42
42
  API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/rest/v3/'
@@ -68,7 +68,10 @@ end # module SoftLayer
68
68
  # posted up to rubygems.org and the 1.0.1 release came about because of that
69
69
  # confusion. There should be no real functionality differences there.
70
70
  #
71
- # 1.0.2 - We have some API routines that start with "get" but expect arguments
71
+ # 1.0.2 - We have some API routines that start with 'get' but expect arguments
72
72
  # anyway. The code now uses HTTP POST to send requests for which the user
73
73
  # has provided arguments regardless of the name of the routine.
74
- #
74
+ #
75
+ # 1.0.3 - Added a request filter to add result limits to request. Submitted by
76
+ # JN. Thanks!
77
+ #
@@ -81,6 +81,28 @@ module SoftLayer
81
81
  merged_object.parameters = @parameters.merge({ :object_mask => args }) if args && !args.empty?
82
82
  merged_object
83
83
  end
84
+
85
+ def result_limit(limit)
86
+ merged_object = APIParameterFilter.new;
87
+ merged_object.target = self.target
88
+ merged_object.parameters = @parameters.merge({ :result_limit => limit })
89
+ merged_object
90
+ end
91
+
92
+ def server_result_limit
93
+ self.parameters[:result_limit]
94
+ end
95
+
96
+
97
+ def result_offset(offset)
98
+ self.parameters[:result_offset] = offset
99
+ self
100
+ end
101
+
102
+ def server_result_offset
103
+ self.parameters[:result_offset]
104
+ end
105
+
84
106
 
85
107
  def method_missing(method_name, *args, &block)
86
108
  return @target.call_softlayer_api_with_params(method_name, self, args, &block)
@@ -184,6 +206,12 @@ module SoftLayer
184
206
 
185
207
  return proxy.object_mask(*args)
186
208
  end
209
+
210
+ def result_limit(limit)
211
+ proxy = APIParameterFilter.new
212
+ proxy.target = self
213
+ return proxy.result_limit=limit
214
+ end
187
215
 
188
216
  # This is the primary mechanism by which requests are made. If you call
189
217
  # the service with a method it doesn't understand, it will send a call to
@@ -395,6 +423,18 @@ module SoftLayer
395
423
  mask_value = parameters.server_object_mask.to_sl_object_mask.map { |mask_key| URI.encode(mask_key.to_s.strip) }.join(";")
396
424
  query_string = "objectMask=#{mask_value}"
397
425
  end
426
+
427
+ if (parameters && parameters.server_result_limit)
428
+ resultLimit = parameters.server_result_limit
429
+ resultOffset = parameters.server_result_offset
430
+ resultOffset = 0 if resultOffset.nil?
431
+ limit_string = "resultLimit=#{resultOffset},#{resultLimit}"
432
+ if query_string.nil?
433
+ query_string = limit_string
434
+ else
435
+ query_string << "&#{limit_string}"
436
+ end
437
+ end
398
438
 
399
439
  uri.query = query_string
400
440
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softlayer_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - SoftLayer Development Team
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-10 00:00:00 -05:00
18
+ date: 2011-01-31 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency