Posts Tagged 'Method'

December 19, 2012

SoftLayer API: Streamline. Simplify.

Building an API is a bit of a balancing act. You want your API to be simple and easy to use, and you want it to be feature-rich and completely customizable. Because those two desires happen to live on opposite ends of the spectrum, every API finds a different stasis in terms of how complex and customizable they are. The SoftLayer API was designed to provide customers with granular control of every action associated with any product or service on our platform; anything you can do in our customer portal can be done via our API. That depth of functionality might be intimidating to developers looking to dive in quickly and incorporate the SoftLayer platform into their applications, so our development team has been working to streamline and simplify some of the most common API services to make them even more accessible.

SoftLayer API

To get an idea of what their efforts look like in practice, Phil posted an SLDN blog with a perfect example of how they simplified cloud computing instance (CCI) creation via the API. The traditional CCI ordering process required developers to define nineteen data points:

Hostname
Domain name
complexType
Package Id
Location Id
Quantity to order
Number of cores
Amount of RAM
Remote management options
Port speeds
Public bandwidth allotment
Primary subnet size
Disk size
Operating system
Monitoring
Notification
Response
VPN Management - Private Network
Vulnerability Assessments & Management

While each of those data points is straightforward, you still have to define nineteen of them. You have all of those options when you check out through our shopping cart, so it makes sense that you'd have them in the API, but when it comes to ordering through the API, you don't necessarily need all of those options. Our development team observed our customers' API usage patterns, and they created the slimmed-down and efficient SoftLayer_Virtual_Guest::createObject — a method that only requires seven data points:

Hostname
Domain name
Number of cores
Amount of RAM
Hourly/monthly billing
Local vs SAN disk
Operating System

Without showing you a single line of code, you see the improvement. Default values were established for options like Port speeds and Monitoring based on customer usage patterns, and as a result, developers only have to provide half the data to place a new CCI order. Because each data point might require multiple lines of code, the volume of API code required to place an order is slimmed down even more. The best part is that if you find yourself needing to modify one of the now-default options like Port speeds or Monitoring, you still can!

As the development team finds other API services and methods that can be streamlined and simplified like this one, they'll ninja new solutions to make the API even more accessible. Have you tried coding to the SoftLayer API yet? If not, what's the biggest roadblock for you? If you're already a SLAPI coder, what other methods do you use often that could be streamlined?

-@khazard

December 27, 2011

186,282.4 Miles Per Second

Let's say there are 2495 miles separating me and the world's foremost authority on orthopedics who lives in Vancouver, Canada. If I needed some medical advice for how to remove a screwdriver from the palm of my hand that was the result of a a Christmas toy with "some assembly required," I'd be pretty happy I live in the year 2011. Here are a few of the communication methods that I may have settled with in years past:

On Foot: The average human walks 3.5 mph sustainable. Using this method it would take a messenger 29.7 days to get a description of the problem and a drawing of the damage to that doctor if the messenger walked non-stop. Because the doctor in this theoretical scenario is the only person on the planet who knows how to perform the screwdriver removal surgery, the doctor would have to accompany the messenger back to Texas, and I am fairly sure by the time they arrived, they'd have to visit a grave with a terrible epitaph like "He got screwed," or they'd find me answering to a crass nickname like "Stumpy."

On Horseback: The average speed of a galloping horse is around 30 mph sustainable, so with the help of a couple equestrian friends, the message could reach the doctor in 3.5 days if the horse were to run the whole journey without stopping, the doctor could saddle up and hit the trail back to Houston, getting here in about 7 days. In that span of time, I'd only be able to wave to him with one hand, given the inevitable amputation.

Via High-Speed Rail: With an average speed of 101 mph, it would take a mere 24.7 hour to get from Houston to Vancouver, so if this means of communication were the only one used, I could have the doctor at my bedside in a little over 48 hours. That turnaround time might mean my hand would be saved, but the delay would still yield a terrible headache and a lot of embarrassment ... Seeing as how a screwdriver in your hand is relatively noticeable at Christmas parties.

Via Commercial Flight: If the message was taken by plane and the doctor returned by plane, the round trip would be around 12.4 hours at an average rate of 400 mph ... I'd only have to endure half a day of mockery.

Via E-mail: With the multimedia capabilities of email, the doctor could be sent a picture of the damage instantly and a surgeon in Houston could be instructed on how to best save my hand. There would be little delay, but there are no guarantees that the stand-in surgeon would be able to correctly execute on the instructions given by this theoretical world's only orthopedic surgeon.

Via Video Chat: In milliseconds, a video connection could be made between the stand-in surgeon and the orthopedic specialist. The specialist could watch and instruct the stand-in surgeon on how to complete the surgery, and I'd be using both hands again by Christmas morning. Technology is also getting to a point where the specialist could perform parts of the surgery remotely ... Let's just hope they use a good network connection on both end since any latency would be pretty significant.

I started thinking about the amazing speed with which we access information when I met with CTO Duke Skarda. He gave a few examples of our customers that piqued his interested, given to the innovative nature of their business, and one in particular made me realize how far we've come when I considered the availability and speed of our access to information:

The company facilitated advertisements on the Internet by customizing the advertising experience to each visitor by auctioning off ad space to companies that fit that particular visitor's profile. In the simplest sense, a website has a blank area for an advertisment, the site sends non-sensitive information about the visitor to an advertising network. The advertising network then distributes that information to multiple advertisers who process it, generate targeted ads and place a bid to "purchase" the space for that visitor. The winner of the auction is determined, and the winner's ad would be populated on the website.

All of this is done in under a second, before the visitor even knows the process took place.

We live in a time of instant access. We are only limited by the speed of light, a blazing 186,282.4 miles/second. That means you could, theoretically, send a message around the world in .03 milliseconds. Businesses use this speed to create and market products and services to the global market, I can't wait to see what tomorrow holds ... Maybe some kind of technology that prevents screwdrivers from piercing hands?

-Clayton

Categories: 
August 16, 2011

SLDN 2.0 - The Development Network Evolved

SoftLayer is in a constant state of change ... It's not that bad change we all fear; it's the type of change that allows you to stretch the boundaries of your normal experience and run like a penguin ... Because I got some strange looks when coworkers read "run like a penguin," I should explain that I recently visited Moody Gardens in Galveston and saw penguins get crazy excited when they were about to get fed, so that's the best visual I could come up with. Since I enjoy a challenge (and enjoy running around like a penguin), when I was asked to design the new version of SLDN, I was excited.

The goal was simple: Take our already amazing documentation software infrastructure and make it better. A large part of this was to collapse our multi-site approach down into a single unified user experience. Somewhere along the way, "When is the proposal going to be ready?" became "When is the site going to be ready?", at this point I realized that all of the hurdles I had been trampling over in my cerebral site building were now still there, standing, waiting for me on my second lap.

I recently had the honor to present our ideas, philosophy and share some insight into the technical details of the site at OSCON 2011, and KHazzy had the forethought to record it for all of you!

It's a difficult balance to provide details and not bore the audience with tech specs, so I tried to keep the presentation relatively light to encourage attendees (and now viewers) to ask questions about areas they want a little more information about. If you're looking at a similar project in the future, feel free to bounce ideas off me, and I'll steer you clear of a few land mines I happened upon.

-Phil

March 1, 2011

API Basics: REST API - "Hello World"

Learning SoftLayer's API
When I first started to look at SoftLayer's API, I favored the SOAP programming interface because I liked the strictly formatted XML responses, the good separation of concerns (using the server as proxy for data retrieval) and the increased security. All of these are great reasons to use the SOAP interface, but once I saw how easy and direct the REST interface is, I decided that I would use it as my cornerstone for learning the SoftLayer API.

REST API
Although the REST software archetype is a difficult concept to explain, its practice has become natural to those of us who use the internet daily. Imagine that the information that you want to know is saved as a web page somewhere and all you have to do is type in the URL, it will prompt you for a username and password, and you will see the information that you requested.

Authentication
Before making a request you will need to find your API authentication token. To do this, log into your customer account and click API under the Support tab. Click the "Manage API Access" link. At the bottom of the next page you will see a drop-down menu that says "Select a User" and above it a tag that says "Generate a new API access key." Select a user and click the "Generate API Key" button. You will see your username and the generated API key for that user. Copy this API key, as you'll need it to send commands SoftLayer's API.

"Hello World"
Unfortunately, there is no specific "Hello World" command in SoftLayer's API, but there are some commands that are very simple and don't require any variables, like the getObject() method. APIs are like component libraries, split into web services and methods of that service. The SLDN has a full list of SoftLayer's web services to choose from. I am going to use the getObject() method from the SoftLayer_Account service in this example:

https://api.softlayer.com/rest/v3/SoftLayer_Account.xml

  • You will be prompted for your username and API access key
  • XML data type output

https://USERNAME:PASSWORD@api.softlayer.com/rest/v3/SoftLayer_Account.json

  • Automatic authentication
  • JSON data type output

The Request
Here is the basic REST request structure:

<code>https://<u><em>username</em></u>:<u><em>API key</em></u>@api.service.softlayer.com/rest/v3/<u><em>serviceName</em></u>/<u><em>InitializationParameter</em></u>.<u><em>returnDatatype</em></u></code>
  • All requests are sent via secure transfer (https://)
  • Listing your username and API key before the URL allows for automatic HTTP authentication
  • Service and serviceName both refer to the web service you are trying to access
  • InitializationParameter is only used if the method you are calling requires an initialization Parameter
  • SoftLayer's REST API can respond with either JSON or XML data types; replace returnDatatype with the type you would like to receive.

The Data
Looking at the first link above, your browser should be able to output the response data in XML format, showing information about your account. More information about the format of the data can be found on the SLDN wiki.

REST Basics
When you start integrating this into a website you will want to get/make a function or library to handle advanced requests and to properly receive and disperse the response; I recommend using JQuery. This is the most basic example of a function call for SoftLayer's API, I hope that it will help you get a feel for the information that you will need to pass to our server and the kind of response that you will receive.

-Kevin

Subscribe to method