Skip to content

Commit a96f036

Browse files
author
SoftLayer
committedMay 20, 2010
Added README and LICENSE files.
1 parent 9ce221c commit a96f036

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed
 

Diff for: ‎LICENSE.textile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright (c) 2009 - 2010, "SoftLayer Technologies, Inc.":http://www.softlayer.com/ All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7+
* Neither SoftLayer Technologies, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
8+
9+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Diff for: ‎README.textile

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
h1. A SoftLayer API PHP client.
2+
3+
h2. Overview
4+
5+
The SoftLayer API PHP client classes provide a simple method for connecting to and making calls from the SoftLayer API and provides support for many of the SoftLayer API's features. Method calls and client management are handled by the PHP SOAP and XML-RPC extensions.
6+
7+
Currently the SoftLayer API only allows connections from within the SoftLayer private network. The system using this class must be either directly connected to the SoftLayer private network (eg. purchased from SoftLayer) or has access to the SoftLayer private network via a VPN connection.
8+
9+
Making API calls using the SoftLayer_SoapClient or SoftLayer_XmlrpcClient class is done in the following steps:
10+
11+
# Instantiate a new SoftLayer_SoapClient or SoftLayer_XmlrpcClient object using the SoftLayer_SoapClient::getClient() or SoftLayer_XmlrpcClient::getClient() methods. Provide the name of the service that you wish to query, an optional id number of the object that you wish to instantiate, your SoftLayer API username, and your SoftLayer API key.
12+
# Define and add optional headers to the client, such as object masks and result limits.
13+
# Call the API method you wish to call as if it were local to your client object. This class throws exceptions if it's unable to execute a query, so it's best to place API method calls in try / catch statements for proper error handling.
14+
15+
Once your method is executed you may continue using the same client if you need to conenct to the same service or define another client object if you wish to work with multiple services at once.
16+
17+
The most up to date version of this library can be found on the SoftLayer github public repositories: "http://github.com/softlayer/":http://github.com/softlayer/ . Please post to the SoftLayer forums <"http://forums.softlayer.com/":http://forums.softlayer.com/> or open a support ticket in the SoftLayer customer portal if you have any questions regarding use of this library.
18+
19+
h2. System Requirements
20+
21+
The SoftLayer_SoapClient class requires at least PHP 5.2.3 and the PHP SOAP enxtension installed. The SoftLayer_Xmlrpc class requires PHP at least PHP 5 and the PHP XML-RPC extension installed.
22+
23+
A connection to the SoftLayer private network and a valid SoftLayer API username and key are required to call the SoftLayer API.
24+
25+
h2. Installation
26+
27+
Download and copy the SoftLayer API client to a directory local to your PHP project or a path within your PHP installation's include_path.
28+
29+
h2. Usage
30+
31+
These examples use the SoftLayer_SoapClient class. If you wish to use the XML-RPC API then replace mentions of SoapClient.class.php with XmlrpcClient.class.php and SoftLayer_SoapClient with SoftLayer_XmlrpcClient.
32+
33+
Here's a simple usage example that retrieves account information by calling the "getObject()":http://sldn.softlayer.com/wiki/index.php/SoftLayer_Account::getObject method in the "SoftLayer_Account":http://sldn.softlayer.com/wiki/index.php/SoftLayer_Account service:
34+
35+
<pre><code>
36+
<?php
37+
38+
require_once dirname(__FILE__) . '/SoftLayer/SoapClient.class.php';
39+
40+
$apiUsername = 'set me';
41+
$apiKey = 'set me too';
42+
43+
// Initialize an API client for the SoftLayer_Account service.
44+
$client = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, $apiUsername, $apiKey);
45+
46+
// Retrieve our account record
47+
try {
48+
$account = $client->getObject();
49+
print_r($account);
50+
} catch (Exception $e) {
51+
die('Unable to retrieve account information: ' . $e->getMessage());
52+
}
53+
</code></pre>
54+
55+
For a more complex example we'll retrieve a support ticket with id 123456 along with the ticket's updates, the user it's assigned to, the servers attached to it, and the datacenter those servers are in. We'll retrieve our extra information using a nested object mask. After we have the ticket we'll update it with the text 'Hello!'.
56+
57+
<pre><code>
58+
<?php
59+
60+
require_once dirname(__FILE__) . '/SoftLayer/SoapClient.class.php';
61+
62+
$apiUsername = 'set me';
63+
$apiKey = 'set me too';
64+
65+
// Initialize an API client for ticket 123456
66+
$client = SoftLayer_SoapClient::getClient('SoftLayer_Ticket', 123456, $apiUsername, $apiKey);
67+
68+
// Create an object mask and assign it to our API client.
69+
$objectMask = new SoftLayer_ObjectMask();
70+
$objectMask->updates;
71+
$objectMask->assignedUser;
72+
$objectMask->attachedHardware->datacenter;
73+
$client->setObjectMask($objectMask);
74+
75+
// Retrieve the ticket record
76+
try {
77+
$ticket = $client->getObject();
78+
} catch (Exception $e) {
79+
die('Unable to retrieve ticket record: ' . $e->getMessage());
80+
}
81+
82+
// Update the ticket
83+
$update = new stdClass();
84+
$update->entry = 'Hello!';
85+
86+
try {
87+
$update = $client->addUpdate($update);
88+
echo "Updated ticket 123456. The new update's id is " . $update->id . '.');
89+
} catch (Exception $e) {
90+
die('Unable to update ticket: ' . $e->getMessage());
91+
}
92+
</code></pre>
93+
94+
h2. Author
95+
96+
This software is written by the SoftLayer Development Team <"sldn@softlayer.com":mailto:sldn@softlayer.com>.
97+
98+
h2. Copyright
99+
100+
This software is Copyright (c) 2009 - 2010 "SoftLayer Technologies, Inc":http://www.softlayer.com/. See the bundled LICENSE.textile file for more information.

0 commit comments

Comments
 (0)
Please sign in to comment.