Skip to content

Commit af379cb

Browse files
Merging SLsthompson-master
2 parents fe4d003 + 9920efd commit af379cb

25 files changed

Lines changed: 1783 additions & 450 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.DS_Store
22
*.*~
33
*.gem
4+
5+
log/
6+
internal_examples/

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
language: ruby
2-
rvm:
2+
rvm:
3+
- "2.1.1"
34
- "2.1.0"
45
- "2.0.0"
56
- "1.9.3"
67
- "1.9.2"
7-
- "1.8.7"
8-
- jruby-18mode
98
- jruby-19mode

CHANGELOG.textile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
*2.0.0*
2+
* Switched the Ruby API client to use XML-RPC when calling the SoftLayer API rather than using the REST-like interface.
3+
* Result limits are now specified using @result_limit(offset,limit)@.
4+
The @result_offset@ API filter has been removed.
5+
* The @object_mask@ call modifier no longer accepts Ruby structures. It accepts strings that are Object Masks in the "Extended Object Mask":http://sldn.softlayer.com/article/Object-Masks format.
6+
* Changed the mechanism for obtaining services to include the Client class. This makes the Ruby API very similar to the API presented by the Python bindings. The old mechanism for obtaining services still works to preserve backward compatibility but you will receive deprecation warnings in debug mode.
7+
18
*1.0.8*
29
* Set a default User-Agent string to be sent with all requests to SoftLayer API. Provide interface to set a custom User-Agent string.
310

411
*1.0.7*
5-
* Calls to the @getObject@ method of any service should not take parameters. The gem now warns if you make this type of call and ignores the parameters. This prevents @SoftLayer_Virtual_Guest::getObject@ from accidentally creating (billable) CCI instances.
12+
* Calls to the @getObject@ method of any service should not take parameters. The gem now warns if you make this type of call and ignores the parameters. This prevents @SoftLayer_Virtual_Guest::getObject@ from accidentally creating (billable) VirtualServer instances.
613

714
*1.0.6*
815
* Make all API calls with either a @GET@ or a @POST@ as the HTTP verb.
@@ -14,6 +21,7 @@
1421
* Fixed a bug where the @result_limit@ and @result_offset@ object filters were just not working.
1522

1623
*1.0.3*
24+
<<<<<<< HEAD
1725
* Added a request filter to add result limits to request. Submitted by JN. Thanks!
1826

1927
*1.0.2*

Gemfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
source 'https://rubygems.org'
2-
gem 'json', '~> 1.8.1'
2+
33
gem 'rake'
4-
gem 'rspec'
4+
gem 'rspec'
5+
gem 'configparser', "~> 0.1.2", :require => false

Gemfile.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4+
configparser (0.1.2)
45
diff-lcs (1.2.5)
5-
json (1.8.1)
66
rake (10.1.1)
77
rspec (2.14.1)
88
rspec-core (~> 2.14.0)
99
rspec-expectations (~> 2.14.0)
1010
rspec-mocks (~> 2.14.0)
11-
rspec-core (2.14.7)
11+
rspec-core (2.14.8)
1212
rspec-expectations (2.14.5)
1313
diff-lcs (>= 1.1.3, < 2.0)
1414
rspec-mocks (2.14.6)
1515

1616
PLATFORMS
17+
java
1718
ruby
1819

1920
DEPENDENCIES
20-
json (~> 1.8.1)
21+
configparser (~> 0.1.2)
2122
rake
2223
rspec

README.textile

Lines changed: 116 additions & 66 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
require 'pp'
2626

2727
begin
28-
# use an account service to get a list of the open tickets and print their IDs and titles
29-
account_service = SoftLayer::Service.new("SoftLayer_Account",
30-
:username => "joecustomer" # enter your username here
31-
:api_key => "feeddeadbeefbadf00d...") # enter your api key here
28+
softlayer_client = SoftLayer::Client.new(
29+
:username => "joecustomer" # enter your username here
30+
:api_key => "feeddeadbeefbadf00d..." # enter your api key here
31+
)
3232

33+
# use an account service to get a list of the open tickets and print their IDs and titles
34+
account_service = softlayer_client['Account'];
3335
account = account_service.getObject
3436
pp account
3537
rescue Exception => exception
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@
2929
$SL_API_USERNAME = "joecustomer" # enter your username here
3030
$SL_API_KEY = "feeddeadbeefbadf00d..." # enter your api key here
3131

32+
softlayer_client = SoftLayer::Client.new()
3233
begin
3334
# use an account service to get the account ID of my account
34-
account_service = SoftLayer::Service.new("SoftLayer_Account")
35+
account_service = softlayer_client.service_named("Account")
3536
my_account_id = account_service.getCurrentUser['id']
3637

3738
# Use a ticket service to create a standard support ticket, assigned to me.
38-
ticket_service = SoftLayer::Service.new("SoftLayer_Ticket")
39+
# Note: calling for the Ticket service using the brackets is entirely equivalent
40+
# go calling service_named('Ticket')
41+
ticket_service = softlayer_client['Ticket']
3942
new_ticket = ticket_service.createStandardTicket(
4043
{
4144
"assignedUserId" => my_account_id,
@@ -47,7 +50,7 @@
4750
puts "Created a new ticket : #{new_ticket['id']} - #{new_ticket['title']}"
4851

4952
# add an update to the newly created ticket.
50-
pp ticket_service.object_with_id(new_ticket['id']).edit(nil, "This is a ticket update sent from the Ruby library")
53+
pp ticket_service.object_with_id(new_ticket['id']).edit({}, "This is a ticket update sent from the Ruby library")
5154
rescue Exception => exception
5255
$stderr.puts "An exception occurred while trying to complete the SoftLayer API calls #{exception}"
5356
end
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
$SL_API_USERNAME = "joecustomer" # enter your username here
2828
$SL_API_KEY = "feeddeadbeefbadf00d..." # enter your api key here
2929

30+
softlayer_client = SoftLayer::Client.new()
31+
3032
# use an account service to get a list of the open tickets and print their
3133
# IDs and titles
32-
account_service = SoftLayer::Service.new("SoftLayer_Account")
34+
account_service = softlayer_client.service_named("Account")
3335

3436
open_tickets = account_service.getOpenTickets
3537
open_tickets.each { |ticket| puts "#{ticket['id']} - #{ticket['title']}" }
@@ -38,11 +40,11 @@
3840
# information known about it. We've already collected this information above,
3941
# but this will demonstrate using an object mask to filter the results from
4042
# the server.
41-
ticket_service = SoftLayer::Service.new("SoftLayer_Ticket")
43+
ticket_service = softlayer_client["Ticket"]
4244
open_tickets.each do |ticket|
4345
begin
44-
pp ticket_service.object_with_id(ticket["id"]).object_mask( "id", "title", "createDate", "modifyDate", { "assignedUser" => ["id", "username", "email"] }).getObject
46+
pp ticket_service.object_with_id(ticket["id"]).object_mask("mask[id,title,createDate,modifyDate,assignedUser[id,username,email]]").getObject
4547
rescue Exception => exception
46-
puts "exception #{e}"
48+
puts "exception #{exception}"
4749
end
4850
end

examples/ticket_info.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@
2424
require 'softlayer_api'
2525
require 'pp'
2626

27-
ticket_service = SoftLayer::Service.new("SoftLayer_Ticket",
27+
softlayer_client = SoftLayer::Client.new(
2828
:username => "joecustomer", # enter your username here
29-
:api_key => "feeddeadbeefbadf00d...") # enter your api key here
29+
:api_key => "feeddeadbeefbadf00d..." # enter your api key here
30+
)
3031

3132
begin
32-
ticket_ref = ticket_service.object_with_id(1683973)
33+
ticket_service = softlayer_client.service_named("Ticket");
34+
ticket_ref = ticket_service.object_with_id(8172109)
3335

34-
ticket = ticket_ref.object_mask({"updates" => ["entry", "createDate"]},
35-
"assignedUserId",
36-
{"attachedHardware" => "datacenter"}).getObject
36+
ticket = ticket_ref.object_mask("mask[updates[entry,createDate],assignedUserId,attachedHardware.datacenter]".getObject
3737
pp ticket
3838
rescue Exception => exception
39-
puts "Unable to retrieve the ticket"
39+
puts "Unable to retrieve the ticket"
4040
end
4141

4242
# update the ticket
4343
begin
4444
updates = ticket_ref.addUpdate({"entry" => "An update from the Ruby client!"})
4545
puts "Update ticket 123456. The new update's id is #{updates[0]['id']}"
4646
rescue Exception => exception
47-
puts "Unable to update the ticket: #{exception}"
47+
puts "Unable to update the ticket: #{exception}"
4848
end

0 commit comments

Comments
 (0)