<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SLDN &#187; Implementations</title>
	<atom:link href="http://sldn.softlayer.com/category/implementations/feed/" rel="self" type="application/rss+xml" />
	<link>http://sldn.softlayer.com</link>
	<description>SoftLayer API Developer Network</description>
	<lastBuildDate>Fri, 23 Jul 2010 21:36:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The SoftLayer Mobile Client: A New Perspective</title>
		<link>http://sldn.softlayer.com/06/2010/the-softlayer-mobile-client-a-new-perspective/</link>
		<comments>http://sldn.softlayer.com/06/2010/the-softlayer-mobile-client-a-new-perspective/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 18:03:19 +0000</pubDate>
		<dc:creator>Scott Thompson</dc:creator>
				<category><![CDATA[Implementations]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile Client]]></category>

		<guid isPermaLink="false">http://sldn.softlayer.com/?p=204</guid>
		<description><![CDATA[Much of the development work that goes on here centers on the SoftLayer Customer Portal. The Customer Portal is a traditional Web application that links your browser to the powerful back-end systems that our engineers have crafted over the course of many years. Most of the engineers around here are first rate hands at web [...]]]></description>
			<content:encoded><![CDATA[<p>Much of the development work that goes on here centers on the <a href="https://manage.softlayer.com/">SoftLayer Customer Portal</a>. The Customer Portal is a traditional Web application that links your browser to the powerful back-end systems that our engineers have crafted over the course of many years. Most of the engineers around here are first rate hands at web application technologies like PHP, JavaScript, and HTML.</p>
<p>I don&#8217;t know much HTML. I know even less PHP. I spent many years working on desktop Macintosh applications in C and C++.  With the introduction of the iPhone SDK, a new job opportunity made me an iPhone developer. The leap from the Cocoa framework, on the desktop Mac OS, to the Cocoa Touch framework of the iPhone was not difficult at all. The two frameworks share a lot in common and the parts that are different still share a lot of design patterns. All in all, making the transition to a company whose primary focus is web development was a lot more intimidating than picking up the iPhone API.</p>
<p>I joined SoftLayer specifically to work on the Mobile Client. The goal of the <a href="http://www.softlayer.com/resources/mobile-apps/">SoftLayer Mobile Client</a> is pretty straightforward, put the essential parts of the SoftLayer Customer Portal in the palm of your hand, on your favorite mobile device. We wanted to move beyond the mobile web applications the team had already created, and craft an application with a look and feel only a native applications can provide, a first rate user experience.</p>
<p>At the same time, all the attention to detail you can possibly give the front end doesn&#8217;t matter unless you have some way to communicate with the server. That&#8217;s where the SoftLayer v3 API comes into play.</p>
<p>The smart folks on the the web application development team work behind the scenes on the server, enjoying full access to the complex machine behind the SoftLayer Customer Portal. Their target has been a traditional web browser, running on a computer with Gigabytes of available RAM, Gigahertz of processing power, and several Megabits per second of network connectivity.</p>
<p>Comparatively, on the Mobile Applications development team, we live across the wire on tiny computers with small pipes. Mobile devices have limited memory constraints, run on a &#8220;slow&#8221; 3G networks, and have processors running at less than 1/3 of the speed of their desktop counterparts.</p>
<p>With such vast differences between the environment of a desktop computer&#8217;s browser and an application running on a mobile device, SoftLayer could have crafted a custom API to give our mobile applications access tailored access to the machine behind the SoftLayer Customer Portal.</p>
<p>But we didn&#8217;t want to do that.</p>
<p>With great pride of principle, our mobile applications team makes it a point to use the same API that SoftLayer presents to you, the third party developers of the SLDN network. We don&#8217;t want to use back doors, and we don&#8217;t want to use secret calls. Consuming our own API, &#8220;eating our own dog food&#8221; as the saying goes, gives us a unique vantage point which we hope to use to improve the API for all SLDN developers.</p>
<p>In the course of developing the Mobile Client on a variety of platforms, the mobile team has found that most aspects of the SoftLayer API work very well!  We&#8217;ve also found some that presented challenges to our mobile devices. Lucky for you, however, we&#8217;re working very closely with the web development team to remove those challenges.</p>
<p>We plan to bring new functionality that results from our experience directly to you. In the course of the next few months, look for some changes (large and small) to the services we provide. We hope you will find them a benefit to your application development regardless of where your application runs. </p>
]]></content:encoded>
			<wfw:commentRss>http://sldn.softlayer.com/06/2010/the-softlayer-mobile-client-a-new-perspective/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Our Python client is out!</title>
		<link>http://sldn.softlayer.com/04/2010/our-python-client-is-out/</link>
		<comments>http://sldn.softlayer.com/04/2010/our-python-client-is-out/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 22:22:08 +0000</pubDate>
		<dc:creator>Kevin Laude</dc:creator>
				<category><![CDATA[Implementations]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://sldn.softlayer.com/?p=185</guid>
		<description><![CDATA[Lately I&#8217;ve seen a lot of people around me writing and hacking in Python. Way back when API v1 was out we noted that Python has built-in XML-RPC support. Built-in XML-RPC support is great. It makes calling our API, especially our latest API, a snap. Some of y&#8217;all on our forums have been doing very [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve seen a lot of people around me writing and hacking in <a href="http://www.python.org/">Python</a>. Way back when API v1 was out we <a href="http://sldn.softlayer.com/06/2007/api-hacking-fun-with-python/">noted</a> that Python has built-in XML-RPC support. Built-in XML-RPC support is great. It makes calling our API, especially our latest API, a snap. Some of y&#8217;all on our <a href="http://forums.softlayer.com/">forums</a> have been doing very cool things with our API in Python. </p>
<p>Python hackers and users, we&#8217;ve just made your lives easier. I&#8217;m pleased to present our latest language tool for your API toolbox, a <b><a href="http://github.com/softlayer/softlayer-api-python-client/">Python library for the SoftLayer API</a></b>. This library functions very similarly to our <a href="http://github.com/softlayer/softlayer-api-php-client">PHP</a> and <a href="http://github.com/softlayer/softlayer-api-perl-client">Perl</a> clients. Before you had to juggle API call headers to pass along things like initialization parameters and object masks to your API calls. Now you all you have to do is declare an API client object and run methods on it. It&#8217;s much easier and saves a lot of coding on your part.</p>
<p>I&#8217;ve been talking to a lot of people who are building dynamic Cloud Computing Instances using our API. I wrote a simple example for one of our forum users a while back to accomplish this task in Python using it&#8217;s built-in XML-RPC support:</p>
<p>&nbsp;<br />
<script src="http://gist.github.com/328806.js"></script><br />
</p>
<p>Here&#8217;s that same functionality using our new Python library:</p>
<p>&nbsp;<br />
<script src="http://gist.github.com/374419.js"></script><br />
</p>
<p>This saved 20 lines of code and is much easier to read. Our client is supported in both Python 2 and Python 3 and has a handy installation script. Please download it, go nuts, and speak up on our forums, IRC channel, or a support ticket if you have any questions. As always, we&#8217;re happy to hear your feedback. Thanks, everyone!<br />
</p>
<p><b><a href="http://github.com/softlayer/softlayer-api-python-client/">http://github.com/softlayer/softlayer-api-python-client/</a></b></p>
]]></content:encoded>
			<wfw:commentRss>http://sldn.softlayer.com/04/2010/our-python-client-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Something new for your API Toolbox</title>
		<link>http://sldn.softlayer.com/02/2010/something-new-for-your-api-toolbox/</link>
		<comments>http://sldn.softlayer.com/02/2010/something-new-for-your-api-toolbox/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 05:51:13 +0000</pubDate>
		<dc:creator>Kevin Laude</dc:creator>
				<category><![CDATA[Implementations]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://sldn.softlayer.com/?p=149</guid>
		<description><![CDATA[pre { display: block; background:#dddddd; border: 1px solid #999999; padding: 5px; }
An interesting facet of the development and systems administration business is the number of 80% projects that build up over time. An 80% project is that awesome library, script, rewrite, new system, or what have you that&#8217;s cooling on your back burner. It&#8217;s almost [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">pre { display: block; background:#dddddd; border: 1px solid #999999; padding: 5px; }</style>
<p>An interesting facet of the development and systems administration business is the number of 80% projects that build up over time. An 80% project is that awesome library, script, rewrite, new system, or what have you that&#8217;s cooling on your back burner. It&#8217;s almost done but it&#8217;s missing the finishing touches. Maybe it needs a few code tweaks. Maybe it needs a little more documentation. Maybe you&#8217;re still finalizing settings and playing with patches. Don&#8217;t lie; we know you&#8217;ve got these projects hanging around. I&#8217;ve got a list of 80% projects as long as my arm.</p>
<p>It&#8217;s time to check something off my 80% projects list. I&#8217;ve finally finished documenting and am happy to release the SoftLayer API Perl client library! This module will make Perl API hackers&#8217; lives a whole lot easier. Previously you had to build SOAP API calls manually using the <a href="http://www.soaplite.com/">SOAP::Lite</a> module and parse the response into something easier to handle.  Now you can accomplish the same thing with a series of easy to use helper methods. Functionality is very similar to our <a href="http://github.com/softlayer/softlayer-api-php-client">PHP client</a> but with a Perl twist. For instance, you can do clever one liners!</p>
<pre>
use SoftLayer::API::SOAP;

# Grab my account information.
my $account = SoftLayer::API::SOAP->new(
    'SoftLayer_Account',
    undef,
    'my API username',
    'my API key')->getObject();
</pre>
<p>Check out our <a href="http://github.com/softlayer/softlayer-api-perl-client/blob/master/README.pod">README</a> for many and more comprehensive examples. Download the library from our <a href="http://github.com/softlayer">github page</a> at:</p>
<p>&nbsp;<br />
<br />
<b><a href="http://github.com/softlayer/softlayer-api-perl-client">http://github.com/softlayer/softlayer-api-perl-client</a></b><br />
<br />&nbsp;<br />
</p>
<p>As with all of our projects we&#8217;re very open to feedback, so please comment or post on our <a href="http://forums.softlayer.com/">forums</a> and let us know what you think. I can&#8217;t wait knock a few more 80% projects off the ol&#8217; list. You&#8217;re going to love them. <img src='http://sldn.softlayer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  See y&#8217;all next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://sldn.softlayer.com/02/2010/something-new-for-your-api-toolbox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Object Masks and Filters in C Sharp</title>
		<link>http://sldn.softlayer.com/02/2010/object-masks-and-filters-in-c-sharp/</link>
		<comments>http://sldn.softlayer.com/02/2010/object-masks-and-filters-in-c-sharp/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 21:43:31 +0000</pubDate>
		<dc:creator>William Francis</dc:creator>
				<category><![CDATA[Implementations]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[ObjectMask]]></category>

		<guid isPermaLink="false">http://sldn.softlayer.com/?p=124</guid>
		<description><![CDATA[pre { display: block; background:#dddddd; border: 1px solid #999999; padding: 5px; }
Object Masks, Filters, and Other V3 Black Magic
Everyone has heard the age old saying for any given job you need to have the right tool. Just as most of us have tried to use the flat rounded edge of a butter knife a time [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">pre { display: block; background:#dddddd; border: 1px solid #999999; padding: 5px; }</style>
<p><strong>Object Masks, Filters, and Other V3 Black Magic</strong></p>
<p>Everyone has heard the age old saying for any given job you need to have the right tool. Just as most of us have tried to use the flat rounded edge of a butter knife a time or two when what we desperately needed was a screw driver. Does that mean you weren&#8217;t able to open that little compartment on whatever gizmo and replace the batteries? Probably not. In most cases it is possible to use a butter knife when a screw driver is the tool of choice; it&#8217;s just more painful and a lot less effective.</p>
<p>The same can said of the <a href="http://sldn.softlayer.com/wiki/index.php/The_SoftLayer_API">SoftLayer API</a> (SLAPI). It&#8217;s a toolset. A very flexible set of tools allowing a developer to manage every aspect of dedicated hosting from accounting and billing to physical status of remote hardware. And yet there are so many tools in the V3 API toolbox, a number of them only subtlety different from their binary brethren ( at least on the surface), it&#8217;s tempting just to reach your hand into the bag, find the first thing that resembles a screw driver, and begin turning.</p>
<p>I know. I&#8217;m speaking from my own experiences. As a developer who largely works on SoftLayer&#8217;s back end systems, somewhere between the bottom of TCP/IP stack and the top edge of the kernel, recently getting to do production user portal code was a new experience for me. Sure I wrote some demos, dabbled a little here and there, but when I started doing my first &#8220;real&#8221; V3/SLAPI intensive project I realized my prior attempts had entirely missed the true power and elegance of SLAPI. The magic if you will. A little something called ORM.</p>
<p>Those of you who spend your days toiling in the world or relational databases are probably fairly familiar with the term ORM. But for someone like me who usually comes no closer to a database than reading an I/O address from the Windows registry, I was only vaguely aware of what the acronym even stood for. I turned to Webopedia. There I discovered the following. &#8220;Short for object role modeling, ORM is a conceptual database design methodology that allows the user to express information as an object and explore how it relates to other information objects&#8221;.</p>
<p>So there we have it. Database. Objects. Relations. I learn hands on—so none of that amounts to a hill of beans without some real code I can see and type and run for myself. So rather than regurgitate the SLDN documentation, I will just share a simple yet real life example. Then, in the second part of the article, we can expand that example to show some of the more powerful and less documented features of the V3 SLAPI.</p>
<p>The code that follows is written in Microsoft C Sharp using Visual Studio 2008 Professional Edition. I am not going to step through the basics of connecting a WSDL and generating a SOAP wrapper in this article. If you need help with that, there is an SLDN blog I did a while back which covers those steps entitled, &#8220;Dot Net? You Bet!&#8221;. It is still available under the implementations section of the SLDN website. True to my MO, I am not a big GUI guy so the code I am presenting runs as a Windows console application.</p>
<p>For the sake of making the example clear, I am going to simplify my task. In the example in both this article, and the next in the series, we will be playing the role of a developer who needs to count how many of his or her servers are running the Microsoft Windows operating system, as opposed to one of the many Linux variants SoftLayer also offers its customers. For our first code sample, we require two WSDLs: the <a href="http://sldn.softlayer.com/wiki/index.php/SoftLayer_Account">SoftLayer_Account</a> service as well as the <a href="http://sldn.softlayer.com/wiki/index.php/SoftLayer_Hardware_Server">SoftLayer_Hardware_Server</a> service. The console program below will get us connected to the SoftLayer application servers, as well as provide us some timing metrics.</p>
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SLDN_Magic
{
   class Program
   {
       static void Main(string[] args)
       {
           //global timing vars
           DateTime stopwatch;
           TimeSpan elapsed;

           //replace with your username and api key
           string user_name = "Replace With Your User Name";
           string api_key = "Replace With Your API Key";

           Console.Write("Establishing connection to SLDN service...");

           //time it
           stopwatch = DateTime.Now;
           //declare the services
           SLDN_ACCT.SoftLayer_AccountService acct = new
               SLDN_ACCT.SoftLayer_AccountService();
           SLDN_SVR.SoftLayer_Hardware_ServerService svr = new
               SLDN_SVR.SoftLayer_Hardware_ServerService(); 

           //create an authentification object for each
           SLDN_ACCT.authenticate credentials_a = new
               SLDN_ACCT.authenticate();
           SLDN_SVR.authenticate credentials_b = new
               SLDN_SVR.authenticate();

           //assign credentials
           credentials_a.username = credentials_b.username = user_name;
           credentials_a.apiKey = credentials_b.apiKey = api_key;

           //authenticate
           acct.authenticateValue = credentials_a;
           svr.authenticateValue = credentials_b;

           elapsed = DateTime.Now.Subtract(stopwatch);
           Console.WriteLine("done (" +  elapsed.TotalSeconds.ToString() + " seconds)");

           Console.WriteLine("\nPress <enter> to exit.");
           Console.ReadLine();
       }
   }
}</pre>
<p>At this point, we can go ahead and run our code. It doesn&#8217;t really do anything all that useful. But never the less you should get an output similar to this.</p>
<p><img src="/wp-content/sldn/124/Blog_orm_console_1.png" /></p>
<p>While writing this article I connected to the SoftLayer API servers numerous times from my home. My connection times were pretty consistent. It took somewhere in the neighborhood of 20 seconds to get everything set up. That seems like a lot. But keep in mind that you only incur the overhead of connecting your services one time. Plus as we get a little further along in this article I will show you how we can use ORM to get rid of one of the references entirely. For now though, let&#8217;s move on.</p>
<p>For someone of my background and mindset, what seemed the most straight-forward and correct way to find out which servers were running MS Windows was to access the public method &#8220;<a href="http://sldn.softlayer.com/wiki/index.php/SoftLayer_Hardware_Server::isWindowsServer">isWindowsServer()</a>&#8220;. This is a method off the server class. That&#8217;s why we needed to import the SoftLayer_Hardware_Server service. But we don&#8217;t want to check the OS on a single server. We want to recurse through all the servers for an account. Which is why we brought in the SoftLayer_Account service and its attractive public offering &#8220;<a href="http://sldn.softlayer.com/wiki/index.php/SoftLayer_Account::getAllHardware">getAllHardware()</a>&#8220;.</p>
<p>Keeping this plan in mind, let&#8217;s go ahead and implement it in our console application.</p>
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SLDN_Magic
{
   class Program
   {
       static void Main(string[] args)
       {
           //global timing vars
           DateTime stopwatch;
           TimeSpan elapsed;

           //global container
           SLDN_ACCT.SoftLayer_Hardware[] hw;

           //replace with your username and api key
           string user_name = "Replace With Your User Name";
           string api_key = "Replace With Your API Key";

           Console.Write("Establishing connection to SLDN service...");

           //time it
           stopwatch = DateTime.Now;

           //declare the services
           SLDN_ACCT.SoftLayer_AccountService acct = new
               SLDN_ACCT.SoftLayer_AccountService();
           SLDN_SVR.SoftLayer_Hardware_ServerService svr = new
               SLDN_SVR.SoftLayer_Hardware_ServerService(); 

           //create an authentification object for each
           SLDN_ACCT.authenticate credentials_a = new
               SLDN_ACCT.authenticate();
           SLDN_SVR.authenticate credentials_b = new
               SLDN_SVR.authenticate();

           //assign credentials
           credentials_a.username = credentials_b.username = user_name;
           credentials_a.apiKey = credentials_b.apiKey = api_key;

           //authenticate
           acct.authenticateValue = credentials_a;
           svr.authenticateValue = credentials_b;

           elapsed = DateTime.Now.Subtract(stopwatch);
           Console.WriteLine("done (" + elapsed.TotalSeconds.ToString() + " seconds)");

           //butter knife method

           Console.Write("Retrieving hardware using method 1...");

           //get time stamp
           stopwatch = DateTime.Now;

           hw = null;
           try
           {
               hw = acct.getHardware();
           }
           catch (Exception e)
           {
               Console.WriteLine("Exception encountered [" + e.Message + "]");
               hw = null;
           }

           int cnt = 0;

           foreach (SLDN_ACCT.SoftLayer_Hardware server in hw)
           {
               try
               {
                   SLDN_SVR.SoftLayer_Hardware_ServerInitParameters box = new
                       SLDN_SVR.SoftLayer_Hardware_ServerInitParameters();
                   box.id = (int)server.id;
                   svr.SoftLayer_Hardware_ServerInitParametersValue = box;
                   if (svr.isWindowsServer())
                   {
                       cnt++;
                   }
               }
               catch (NullReferenceException)
               {
                   //ignore...this server has not had the
                   //OS loaded on it yet!
               }
           }

           elapsed = DateTime.Now.Subtract(stopwatch);

           Console.WriteLine("done (" + elapsed.TotalSeconds.ToString() + " seconds)");
           Console.WriteLine("counted " + cnt.ToString() + " MS Windows licenses");
           Console.WriteLine("\nPress <enter> to exit.");
           Console.ReadLine();
       }
   }
}</pre>
<p>That&#8217;s it. Pretty straight forward stuff possibly with the exception of the way SLAPI allows you to reinitialize the server (or any object) on the fly by use of:&#8221;SoftLayer_Hardware_ServerInitParameters&#8221;. If this confuses you, again I&#8217;ll refer you to the blog &#8220;Dot Net? You Bet!&#8221;. At this point, I think we are ready for another test run.</p>
<p><img src="/wp-content/sldn/124/BlogOrmConsole2.png" /></p>
<p>Once again we find ourselves in the twenty second range both for connecting the services and counting the hardware. What you can&#8217;t tell from looking at this output is that the account I was using for testing had about 100 servers on it. So basically we are talking 1/5 of a second per server. It&#8217;s certainly doable with a handful of servers, but this would obviously never work if you were trying to present this information real time to users if you managed 500 or 5,000 or 50,000 servers. So you are probably asking yourself the same thing I did. What gives? If SoftLayer wishes its customers success on an enterprise level, why create an API that comes to its knees when you start trying to manage more than a few hundred servers?</p>
<p>Luckily, the architects of SLAPI were a lot more web / database savvy than me. The above implementation, while correct syntactically, is a gross misuse of the SLAPI. It&#8217;s the butter knife, when what we really need is the screwdriver. What we need are object masks. But exactly what are object masks and how do they relate to ORM?</p>
<p>The best way I have found to understand ORM and object masks, is to think of the SLAPI data objects, as a self supporting entities. Each object provides its own methods and exposes some properties specific to that object. Yet thanks to ORM, most objects can actually get to properties in related objects, through a process called tapping. You simply tap each object down the chain until you find the property or properties you are interested in, prior to retrieving an instance or instances of the object. Then the set of objects returned will expose any relevant properties in the same manner you tapped them.</p>
<p>For example in our case the SLDN architecture relates a server to an operating system in the following manner.</p>
<p><img src="/wp-content/sldn/124/BlogOrm3.png" /></p>
<p>The diagram shows us that essentially, as long as we can get a hardware object, we can tap all the way down to the software description — which as the SLDN documentation states has a &#8220;name&#8221; property. There by we eliminate two of our most time consuming tasks from our original application. First off we no longer need to instantiate the SoftLayer_Hardware_Server service, since we can get to server from hardware and hardware can be retrieved via the account class. Secondly, if when we return the hardware it already contains the name of the operating system, we no longer have a need to call the &#8220;isWindows()&#8221; method. Take a look.</p>
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SLDN_Magic
{
   class Program
   {
       static void Main(string[] args)
       {
           //global timing vars
           DateTime stopwatch;
           TimeSpan elapsed;

           //global container
           SLDN_ACCT.SoftLayer_Hardware[] hw;

           //replace with your username and api key
           string user_name = "Your User Name Here";
           string api_key = "Your Api Key Here";

           Console.Write("Establishing connection to SLDN service...");

           //time it
           stopwatch = DateTime.Now;

           //declare the services
           SLDN_ACCT.SoftLayer_AccountService acct = new
               SLDN_ACCT.SoftLayer_AccountService();

           //create an authentification object
           SLDN_ACCT.authenticate credentials_a = new
               SLDN_ACCT.authenticate();

           //assign credentials
           credentials_a.username = user_name;
           credentials_a.apiKey = api_key;

           //authenticate
           acct.authenticateValue = credentials_a;

           elapsed = DateTime.Now.Subtract(stopwatch);
           Console.WriteLine("done (" + elapsed.TotalSeconds.ToString() + " seconds)");

           //method 2
           Console.Write("Retrieving hardware using method 2...");

           //get time stamp
           stopwatch = DateTime.Now;

           hw = null;
           //attempt to pull a hardware list for this user
           try
           {
               acct.SoftLayer_AccountObjectMaskValue = new
                   SLDN_ACCT.SoftLayer_AccountObjectMask();
               acct.SoftLayer_AccountObjectMaskValue.mask = new
                   SLDN_ACCT.SoftLayer_Account();
               acct.SoftLayer_AccountObjectMaskValue.mask.hardware = new
                   SLDN_ACCT.SoftLayer_Hardware_Server[1];
               acct.SoftLayer_AccountObjectMaskValue.mask.hardware[0] = new
                   SLDN_ACCT.SoftLayer_Hardware_Server();
               acct.SoftLayer_AccountObjectMaskValue.mask.hardware[0].operatingSystem = new
                   SLDN_ACCT.SoftLayer_Software_Component();
               acct.SoftLayer_AccountObjectMaskValue.mask.hardware[0].operatingSystem.softwareLicense = new
                   SLDN_ACCT.SoftLayer_Software_License();
               acct.SoftLayer_AccountObjectMaskValue.mask.hardware[0].operatingSystem.softwareLicense.softwareDescription = new
                   SLDN_ACCT.SoftLayer_Software_Description();
               hw = acct.getHardware();
           }
           catch (Exception e)
           {
               Console.WriteLine("Exception encountered [" + e.Message + "]");
               hw = null;
           }

           cnt = 0;

           foreach (SLDN_ACCT.SoftLayer_Hardware server in hw)
           {
               try
               {
                   if (server.operatingSystem.softwareLicense.
                                   softwareDescription.name.ToLower().
                                   Contains("windows"))
                   {
                       cnt++;
                   }
               }
               catch (NullReferenceException)
               {
                   //ignore...this server has not
                   //had the OS loaded on it yet!!!
               }
           }

           elapsed = DateTime.Now.Subtract(stopwatch);

           Console.WriteLine("done ("+ elapsed.TotalSeconds.ToString()+" seconds)");
           Console.WriteLine("counted " + cnt.ToString() + " MS Windows licenses");

           Console.WriteLine("\nPress <enter> to exit.");
           Console.ReadLine();
       }
   }
}</pre>
<p>You should notice right away all the references to SoftLayer_AccountObjectMaskValue prior to calling the &#8220;getHardware()&#8221; method. This is the object mask. Essentially we must create a new instance of each entity we want to include down the chain. Then when the target object is retrieved, in our case the hardware, all related objects which we have made room for will get created for that specific instance of hardware, assuming of course a record exists. You must instantiate each object down the chain. If you skip any link your result set will not conatain the property or method you were trying to get to. Some less structured langagues, like PHP, do not have this requirement. But with V3 and dot NET there is no getting around it. You&#8217;re probably thinking this version of the code looks far more cluttered and is not as straight-forward to read. You&#8217;re right. But I contend this is the electric screwdriver in the SLDN toolbox. See for yourself.</p>
<p><img src="/wp-content/sldn/124/Image004.png" /></p>
<p>As you can see the connection overhead dropped in half, which is to be expected since we are only authenticating to half the number of services. But take a look at the second number, the number of seconds it takes to count the servers with Windows installed. It dropped from 20 seconds, to under 2 seconds. That&#8217;s a 10 times speed gain. And wait there&#8217;s more&#8211; because we are only making one call to the SLDN application servers to retrieve those records what you see is what you get. Meaning you should not expect that time to increase noticeably whether you have a hundred servers or a hundred thousand servers! That my friend is the magic of V3. The power of ORM.</p>
<p>Following this article I will include the entire code base, in a combined application that lets you run the tests sequentially so you can see the amazing difference object masks make for yourself. In the second part to this article, we&#8217;ll continue with the sample so if you download it keep it handy. In part two I&#8217;ll discuss the next best thing to object masks—object filters. With object filters we&#8217;ll be able to streamline this code even more. Until then…happy SLDNing!</p>
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SLDN_Magic
{
   class Program
   {
       static void Main(string[] args)
       {
           //global timing vars
           DateTime stopwatch;
           TimeSpan elapsed;

           //global container
           SLDN_ACCT.SoftLayer_Hardware[] hw;

           //replace with your username and api key
           string user_name = "";
           string api_key = "";

           Console.Write("Establishing connection to SLDN service...");

           //time it
           stopwatch = DateTime.Now;

           //declare the services
           SLDN_ACCT.SoftLayer_AccountService acct = new SLDN_ACCT.SoftLayer_AccountService();
           SLDN_SVR.SoftLayer_Hardware_ServerService svr = new SLDN_SVR.SoftLayer_Hardware_ServerService(); 

           //create an authentification object for each
           SLDN_ACCT.authenticate credentials_a = new SLDN_ACCT.authenticate();
           SLDN_SVR.authenticate credentials_b = new SLDN_SVR.authenticate();

           //assign credentials
           credentials_a.username = credentials_b.username = user_name;
           credentials_a.apiKey = credentials_b.apiKey = api_key;

           //authenticate
           acct.authenticateValue = credentials_a;
           svr.authenticateValue = credentials_b;

           elapsed = DateTime.Now.Subtract(stopwatch);
           Console.WriteLine("done (" + elapsed.TotalSeconds.ToString() + " seconds)");

           //method 1

           Console.Write("Retrieving hardware using method 1...");

           //get time stamp
           stopwatch = DateTime.Now;

           hw = null;
           try
           {
               hw = acct.getHardware();
           }
           catch (Exception e)
           {
               Console.WriteLine("Exception encountered [" + e.Message + "]");
               hw = null;
           }

           int cnt = 0;

           foreach (SLDN_ACCT.SoftLayer_Hardware server in hw)
           {
               try
               {
                   SLDN_SVR.SoftLayer_Hardware_ServerInitParameters box = new SLDN_SVR.SoftLayer_Hardware_ServerInitParameters();
                   box.id = (int)server.id;
                   svr.SoftLayer_Hardware_ServerInitParametersValue = box;
                   if (svr.isWindowsServer())
                   {
                       cnt++;
                   }
               }
               catch (NullReferenceException)
               {
                   //ignore...this server has not had the OS loaded on it yet
               }
           }

           elapsed = DateTime.Now.Subtract(stopwatch);

           Console.WriteLine("done (" + elapsed.TotalSeconds.ToString() + " seconds)");
           Console.WriteLine("counted " + cnt.ToString() + " MS Windows licenses");

           //method 2
           Console.Write("Retrieving hardware using method 2...");

           //get time stamp
           stopwatch = DateTime.Now;

           hw = null;
           //attempt to pull a hardware list for this user
           try
           {
               acct.SoftLayer_AccountObjectMaskValue = new SLDN_ACCT.SoftLayer_AccountObjectMask();
               acct.SoftLayer_AccountObjectMaskValue.mask = new SLDN_ACCT.SoftLayer_Account();
               acct.SoftLayer_AccountObjectMaskValue.mask.hardware = new SLDN_ACCT.SoftLayer_Hardware_Server[1];
               acct.SoftLayer_AccountObjectMaskValue.mask.hardware[0] = new SLDN_ACCT.SoftLayer_Hardware_Server();
               acct.SoftLayer_AccountObjectMaskValue.mask.hardware[0].operatingSystem = new SLDN_ACCT.SoftLayer_Software_Component();
               acct.SoftLayer_AccountObjectMaskValue.mask.hardware[0].operatingSystem.softwareLicense = new SLDN_ACCT.SoftLayer_Software_License();
               acct.SoftLayer_AccountObjectMaskValue.mask.hardware[0].operatingSystem.softwareLicense.softwareDescription = new SLDN_ACCT.SoftLayer_Software_Description();
               hw = acct.getHardware();
           }
           catch (Exception e)
           {
               Console.WriteLine("Exception encountered [" + e.Message + "]");
               hw = null;
           }

           cnt = 0;

           foreach (SLDN_ACCT.SoftLayer_Hardware server in hw)
           {
               try
               {
                   if (server.operatingSystem.softwareLicense.softwareDescription.name.ToLower().Contains("windows"))
                   {
                       cnt++;
                   }
               }
               catch (NullReferenceException)
               {
                   //ignore...this server has not had the OS loaded on it yet
               }
           }

           elapsed = DateTime.Now.Subtract(stopwatch);

           Console.WriteLine("done ("+elapsed.TotalSeconds.ToString()+" seconds)");
           Console.WriteLine("counted " + cnt.ToString() + " MS Windows licenses");

           Console.WriteLine("\nPress <enter> to exit.");
           Console.ReadLine();
       }
   }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://sldn.softlayer.com/02/2010/object-masks-and-filters-in-c-sharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using CURL to access CloudLayer Storage</title>
		<link>http://sldn.softlayer.com/07/2009/79/</link>
		<comments>http://sldn.softlayer.com/07/2009/79/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 19:57:56 +0000</pubDate>
		<dc:creator>Nathan Day</dc:creator>
				<category><![CDATA[Implementations]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[CloudLayer Storage]]></category>
		<category><![CDATA[curl]]></category>

		<guid isPermaLink="false">http://sldn.softlayer.com/?p=79</guid>
		<description><![CDATA[CloudLayer Storage is billed as providing &#8220;anytime, anywhere access to your data&#8221;.  This isn’t just referring to human interfaces, but also includes automated interfaces.
One easy way to automate access to CloudLayer Storage is through curl.  Curl is available as a command-line tool in most every operating system and is typically used for transferring [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.softlayer.com/cloudlayer_storage.html">CloudLayer Storage</a> is billed as providing &#8220;anytime, anywhere access to your data&#8221;.  This isn’t just referring to human interfaces, but also includes automated interfaces.</p>
<p>One easy way to automate access to CloudLayer Storage is through <a href="http://curl.haxx.se/">curl</a>.  Curl is available as a command-line tool in most every operating system and is typically used for transferring files.  In this post I’ll show some examples on how to use curl to add, get, delete, or otherwise manipulate files in CloudLayer Storage.  Note that this isn’t using the SoftLayer API, but instead interfaces directly with CloudLayer Storage.</p>
<p>Upload a file named &#8220;DSC1012.jpg&#8221; to an account owned by username &#8220;user@example.com&#8221; with a password of &#8220;PaSsWoRd&#8221;:</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee"># curl –F filename=@DSC1012.jpg –u user@example.com:PaSsWoRd \</p>
<p>https://storage.cloudlayer.com/v1/files/</code></p>
<p>The command will return some XML tags.  The items of interest are &#8220;FileID&#8221; and &#8220;lockID&#8221;.  These values are important for future operations on the file.</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee"><br />
&lt;fileID&gt;102C9C28-65C3-11DE-1234-2BE68BA216C2&lt;/fileID&gt;<br />
&lt;lockID&gt;6CDCEEB2-6B38-11DE-A510-123F439A2728&lt;/lockID&gt;<br />
&lt;lockDuration&gt;120&lt;/lockDuration&gt;<br />
</code></p>
<p>The lock is to protect a file form reading or being manipulated during the upload process.  The lock will expire in &#8220;lockDuration&#8221; seconds or the user can disable the lock manually.</p>
<p>Here is how to disable the lock using the lockID  and the fileID generated from the upload operation:</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee"># curl –d \<br />
   'action=unlock&#038;lockid=6CDCEEB2-6B38-11DE-A510-123F439A2728' \<br />
   –u user@example.com:PaSsWoRd \</p>
<p>https://storage.cloudlayer.com/v1/files/102C9C28-65C3-11DE-1234-2BE68BA216C2/lock</code></p>
<p>If you ever lose track of the FileID, you can use this command to retrieve a listing of the files and containers (directories) in an account along with the FileIDs which are listed as an &#8220;oid&#8221; XML tag.</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee"># curl –u user@example.com:PaSsWoRd \</p>
<p>https://storage.cloudlayer.com/v1/files/list</code></p>
<p>To get the list of files in a container, just append the container oid to the URL.</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee"># curl –u user@example.com:PaSsWoRd \</p>
<p>https://storage.cloudlayer.com/v1/files/list?oid=37D0F2AC-08FC-11DE-1234-3FA3A91CD1B4</code></p>
<p>To retrieve the file from CloudLayer Storage, use the FileID to retrieve it.</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee"># curl  -u user@example.com:PaSsWoRd \<br />
https://storage.cloudlayer.com/v1/files/37D0F2AC-08FC-11DE-1234-3FA3A91CD1B4/ -o outputfilename</code></p>
<p>Alternatively, you could use &#8220;<a href="http://www.gnu.org/software/wget/">wget</a>&#8221; to retrieve the file</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee"># wget –http-user=user@example.com -–http-password=PaSsWoRd  \<br />
https://storage.cloudlayer.com/v1/files/37D0F2AC-08FC-11DE-1234-3FA3A91CD1B4/ -O outputfilename</code></p>
<p>To delete a file just add the POST form variable &#8220;action&#8221; with the value &#8220;delete&#8221;.</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee"># curl –d 'action=delete' –u user@example.com:PaSsWoRd \</p>
<p>https://storage.cloudlayer.com/v1/files/37D0F2AC-08FC-11DE-1234-3FA3A91CD1B4/</code></p>
<p>Each of the commands listed above return data in XML format.  If you would prefer json format, add a query parameter &#8220;output=json&#8221; to the query string.</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee"># curl –u user@example.com:PaSsWoRd \</p>
<p>https://storage.cloudlayer.com/v1/files/list?output=json</code></p>
<p>In order to create a public URL for a file, just send a POST variable of &#8220;action=create&#8221; to the &#8220;token&#8221; endpoint.</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee"># curl -d 'action=create' -u user@example.com:PaSsWoRd \</p>
<p>https://storage.cloudlayer.com/v1/files/37D0F2AC-08FC-11DE-1234-3FA3A91CD1B4/token/</code></p>
<p>The long string &#8220;37D0F2&#8230;&#8221; is the oid (a.k.a FileID) of the file that you can get from the XML returned when the file was uploaded, or retrived using the file listing example above.</p>
<p>In the XML (or JSON) data that is returned, there will be a &#8220;token&#8221;.</p>
<p><code style="display: block; margin: 5px; padding: 5px; border: 1px solid #aaaaaa; background-color: #eeeeee">&lt;token&gt;B2891F7B054EF2DF764801E1CFF0079057291234&lt;/token&gt;</code></p>
<p>That token can be combined with the oid to create a URL that anyone can use to retrieve the file.</p>
<p>The URL looks like this: </p>
<p>https://storage.cloudlayer.com/v1/public/{oid}/{token}</p>
<p>In our example it would be: </p>
<p>https://storage.cloudlayer.com/v1/public/37D0F2AC-08FC-11DE-1234-3FA3A91CD1B4/B2891F7B054EF2DF764801E1CFF0079057291234</p>
<p>If you are accessing CloudLayer Storage from inside a SoftLayer datacenter, you can access the storage over the SoftLayer private network (no bandwidth fees!).  Just use &#8220;scs.service.softlayer.com&#8221; instead of &#8220;storage.cloudlayer.com&#8221;. </p>
<p>You can use the information above in conjunction with the curl libraries in <a href="http://www.php.net/curl">PHP</a>, <a href="http://curlpp.org/">C++</a>, or one of many other programming languages with <a href="http://curl.haxx.se/libcurl/bindings.html">curl bindings</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://sldn.softlayer.com/07/2009/79/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The start of something good</title>
		<link>http://sldn.softlayer.com/02/2009/the-start-of-something-good/</link>
		<comments>http://sldn.softlayer.com/02/2009/the-start-of-something-good/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 17:18:42 +0000</pubDate>
		<dc:creator>Kevin Laude</dc:creator>
				<category><![CDATA[Implementations]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://sldn.softlayer.com/?p=62</guid>
		<description><![CDATA[I&#8217;ve been working with quite a few PHP users on our forums over the past few months. One thing I love is the sheer variety of tasks you guys are accomplishing. One thing I don&#8217;t really love is how y&#8217;all use the sample code we provided when we launched our new API last year. Our [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with quite a few PHP users on our <a href="http://forums.softlayer.com/">forums</a> over the past few months. One thing I love is the sheer variety of tasks you guys are accomplishing. One thing I don&#8217;t really love is how y&#8217;all use the <a href="htp://sldn.softlayer.com/wiki/index.php/Migrating_API_v1_applications_to_v3#Examples">sample code</a> we provided when we launched our new API last year. Our examples work great for API v1 to API v3 migrations, but those simple functions don&#8217;t really do our current API justice. </p>
<p>To that end I&#8217;ve written a new PHP API client. This small library will let you take real advantage of the features our API has to offer (like <a href="htp://sldn.softlayer.com/wiki/index.php/Object_mask">object masks</a>, <a href="http://sldn.softlayer.com/wiki/index.php/Using_Result_Limits_in_the_SoftLayer_API">result limits</a>, proper exception catching, and the like) in both SOAP and XML-RPC. Please <a href="http://github.com/softlayer/softlayer-api-php-client/tree/master">download it</a> from our new presence on the <a href="http://github.com/">github</a> social code hosting site. Come check us out at:</p>
<p><a href="http://github.com/softlayer/"><b>http://github.com/softlayer/</b></a></p>
<p>Right now all that&#8217;s up there is our PHP API client. We&#8217;ll put more client libraries and projects up as we make them. We&#8217;ve got a a few in the works right now. If you&#8217;ve already got a github account come find us! We love to meet those who want to use and modify our work. If you have a favorite language that you want to see a client library for please let us know and we&#8217;ll see what we can do. The next language on my hit list is Python 2.6. See y&#8217;all next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://sldn.softlayer.com/02/2009/the-start-of-something-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dot Net? You Bet!</title>
		<link>http://sldn.softlayer.com/03/2008/dot-net-you-bet/</link>
		<comments>http://sldn.softlayer.com/03/2008/dot-net-you-bet/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 21:00:50 +0000</pubDate>
		<dc:creator>William Francis</dc:creator>
				<category><![CDATA[Implementations]]></category>

		<guid isPermaLink="false">http://sldn.softlayer.com/03/2008/dot-net-you-bet/</guid>
		<description><![CDATA[Greetings fellow SLAPI enthusiasts!  When the call went out for examples I figured why not cowboy up and try my hand at with a .NET example.  After all, being an MCP in a largely PHP shop makes me as qualified as anyone.  Plus I am constantly pushing the Microsoft Kool-Aid around the [...]]]></description>
			<content:encoded><![CDATA[<p>Greetings fellow SLAPI enthusiasts!  When the call went out for examples I figured why not cowboy up and try my hand at with a .NET example.  After all, being an MCP in a largely PHP shop makes me as qualified as anyone.  Plus I am constantly pushing the Microsoft Kool-Aid around the office so this was a chance to put my money where my mouth is.</p>
<p>Unfortunately, there was just one catch—I’m not a .NET programmer.  I’ve got 10 years of experience writing drivers, protocol suites, and firmware.  In other words,   C/C++ with a little bit of assembler thrown in when push comes to shove.  Sure I can write a c-sharp application, but I’m pretty green at it and until a month ago if someone had told me they had a problem with their WSDL (pronounced wiz’duhl) I would have wondered why they were telling me instead of their urologist!</p>
<p>That said, what follows is a pretty basic SLAPI example, done in both C# and VB.NET (because I’m ambi-dot-dextrous).   Don’t expect anything more than a DOS-style command console for the UI.  I’m used to letting the Microsoft’s control panel give the user any feedback and usually consider my code to be ready to ship if it can run for 24 hours without blue-screening the box!</p>
<p>My chops are on display at the <a href="http://sldn.softlayer.com/wiki/index.php/Implementing_SOAP_in_.NET">SLDN API Wiki</a>. Let me know what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://sldn.softlayer.com/03/2008/dot-net-you-bet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perls of Wisdom</title>
		<link>http://sldn.softlayer.com/03/2008/perls-of-wisdom/</link>
		<comments>http://sldn.softlayer.com/03/2008/perls-of-wisdom/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 22:00:40 +0000</pubDate>
		<dc:creator>Kevin Laude</dc:creator>
				<category><![CDATA[Implementations]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://sldn.softlayer.com/03/2008/perls-of-wisdom/</guid>
		<description><![CDATA[It&#8217;s been a little over a week since our API launch. I haven&#8217;t heard from anyone who doesn&#8217;t like it, so that must mean we&#8217;re doing it right. We&#8217;ve been spending time lately catching up on little quirks and documentation bugs. Our first example is up. Its for you Perl jockeys, and really exemplifies the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a little over a week since our API launch. I haven&#8217;t heard from anyone who doesn&#8217;t like it, so that must mean we&#8217;re doing it right. We&#8217;ve been spending time lately catching up on little quirks and documentation bugs. Our <a href="http://sldn.softlayer.com/wiki/index.php/Implementing_SOAP_in_Perl">first example</a> is up. Its for you Perl jockeys, and really exemplifies the flexibility and power of <a href="http://sldn.softlayer.com/wiki/index.php/Using_Object_Masks_in_the_SoftLayer_API">object masks</a> in your API handling code. We&#8217;ve got a .NET one coming up soon. You guys are going to love how easy it is to use this in Visual Studio. We&#8217;ve got plans for PHP and Java coming up too. If there&#8217;s a language or implementation you want to see please let us know!</p>
<p> In other news, SoftLayer has recently launched a shiny new <a href="http://www.facebook.com/group.php?gid=6934851257">Facebook group</a>. Sign in and join up to talk with us and get your hands-on exclusive content (which currently is videos of me rambling about the API). As always, we&#8217;re here if you have questions, concerns, or just want to chat. See you next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://sldn.softlayer.com/03/2008/perls-of-wisdom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Time for some morning Java</title>
		<link>http://sldn.softlayer.com/06/2007/time-for-some-morning-java/</link>
		<comments>http://sldn.softlayer.com/06/2007/time-for-some-morning-java/#comments</comments>
		<pubDate>Thu, 28 Jun 2007 15:00:58 +0000</pubDate>
		<dc:creator>Kevin Laude</dc:creator>
				<category><![CDATA[Implementations]]></category>

		<guid isPermaLink="false">http://sldn.softlayer.com/06/2007/time-for-some-morning-java/</guid>
		<description><![CDATA[(This post refers to SoftLayer API version 1. Check out API version 3 for our latest updates.)
We&#8217;ve put a Java SOAP example up on our downloads page. This was written in Eclipse 3.2.2, and for your convenience the example package contains our Eclipse project files. The code should run on JVM version 1.4 and above. [...]]]></description>
			<content:encoded><![CDATA[<p>(This post refers to SoftLayer API version 1. Check out <a href="http://sldn.softlayer.com/03/2008/and-now-for-something-completely-different/">API version 3</a> for our latest updates.)</p>
<p>We&#8217;ve put a Java SOAP example up on our <a href="/downloads">downloads</a> page. This was written in <a href="http://www.eclipse.org">Eclipse</a> 3.2.2, and for your convenience the example package contains our Eclipse project files. The code should run on JVM version 1.4 and above. We&#8217;d love to hear your feedback on this example. Reply here or post on our <a href="http://forums.softlayer.com/forumdisplay.php?f=27">forums</a> and let us know what you think. See ya&#8217;ll later!</p>
]]></content:encoded>
			<wfw:commentRss>http://sldn.softlayer.com/06/2007/time-for-some-morning-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>API Hacking Fun With Python</title>
		<link>http://sldn.softlayer.com/06/2007/api-hacking-fun-with-python/</link>
		<comments>http://sldn.softlayer.com/06/2007/api-hacking-fun-with-python/#comments</comments>
		<pubDate>Thu, 21 Jun 2007 15:00:28 +0000</pubDate>
		<dc:creator>Shawn Boles</dc:creator>
				<category><![CDATA[Implementations]]></category>

		<guid isPermaLink="false">http://sldn.softlayer.com/06/2007/api-hacking-fun-with-python/</guid>
		<description><![CDATA[(This post refers to SoftLayer API version 1. Check out API version 3 for our latest updates.)
Hello!  I&#8217;m Shawn, one of new &#8220;Code Writing Professionals&#8221; at SoftLayer. When a call went out for examples using SoftLayer&#8217;s new API, I immediately signed up to write the INTERCAL, Prolog, and Apollo Guidance Computer modules. I was [...]]]></description>
			<content:encoded><![CDATA[<p>(This post refers to SoftLayer API version 1. Check out <a href="http://sldn.softlayer.com/03/2008/and-now-for-something-completely-different/">API version 3</a> for our latest updates.)</p>
<p>Hello!  I&#8217;m Shawn, one of new &#8220;Code Writing Professionals&#8221; at SoftLayer. When a call went out for examples using SoftLayer&#8217;s new API, I immediately signed up to write the <a href="http://en.wikipedia.org/wiki/Intercal">INTERCAL</a>, <a href="http://en.wikipedia.org/wiki/Prolog">Prolog</a>, and <a href="http://en.wikipedia.org/wiki/Apollo_Guidance_Computer">Apollo Guidance Computer</a> modules. I was told to make those <strong>low</strong> priority projects, and to perhaps focus on hacking with <a href="http://www.python.org/">Python</a> instead. If you just want to see the finished code without all the Python evangelization, skip to the end of the post. For those of you who haven&#8217;t hacked with Python yet, follow along for the ride!</p>
<p>In case you don&#8217;t know, Python is an incredibly simple and clean looking programming language. Many people have picked it up in just a few minutes! If you already program in another programming language (like C, Java, PHP, SH, or Perl (shiver)), Python may look a bit strange. But it&#8217;s not too strange at all. In fact, the only &#8220;strange&#8221; bits in Python are it&#8217;s reliance on whitespace (you have to line up your code) and the lack of braces.</p>
<p>Any good FORTRAN coder will tell you that whitespace is good.</p>
<p>If you run a flavor of UNIX, Linux, or BSD, you most likely have Python already installed. If you are running Windows or if your distribution doesn&#8217;t come with a recent Python package installed you will need to install Python. You Linux guys can install it with your favorite package manager (it&#8217;s usually named<strong> python</strong>). Windows users (or UNIX haxxors who prefer tarballs), pick up the latest version of Python from <a href="http://www.activestate.com/Products/activepython/">ActiveState</a>. (You will also want to check out ActiveState&#8217;s free(!) Komodo Edit)</p>
<p>Install Python and we are ready to go!</p>
<p>Open up a UNIX Terminal or the Windows command line (Start-&gt;Run&#8230; type CMD {enter}), then type &#8220;python&#8221;. This boots up the Interactive Python Interpreter. One of the cool things about Python is that you can whip up a Python Interpreter and just start typing in program fragments. It&#8217;s like the &#8220;immediate&#8221; mode in QBASIC for DOS, but neater. You should see something like this:<br />
&nbsp;<br />
<a href="http://sldn.softlayer.com/wp-content/sldn/20/01-python-cmd.png" target="_blank"><img src="http://sldn.softlayer.com/wp-content/sldn/20/01-python-cmd-thumb.png" border="0" width="152" height="100" /></a><br />
&nbsp;<br />
The first step is to <em>import</em> the XML-RPC library for Python. In keeping with Python&#8217;s &#8220;Batteries Included&#8221; approach, the most useful libraries come standard with any complete download of the Python interpreter, and this includes the standard XML-RPC library. To do this, type:<br />
&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">xmlrpclib</span></pre></div></div>

<p>&nbsp;<br />
Now Python has all the functionality needed to make and receive XML-RPC calls loaded into the interpreter.  Let&#8217;s set up some variables to make hacking with the library much easier. In the interpreter, type:<br />
&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">url = <span style="color: #483d8b;">&quot;http://api.service.softlayer.com/xmlrpc/v1/SL-Service.html&quot;</span>
key = <span style="color: #483d8b;">&quot;YOUR SOFTLAYER API KEY&quot;</span>
usr = <span style="color: #483d8b;">&quot;YOUR SOFTLAYER API USERNAME&quot;</span></pre></div></div>

<p>&nbsp;<br />
Now we need to set up a Server Proxy. This is an object that we can make method calls against that does all the dirty work of compiling the XML and parsing the data&#8230; all the boring stuff. Using the proxy we get to make XML-RPC calls as if all the work was being done on the local machine. This is easy to do. Type this into the interpreter:<br />
&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">server = <span style="color: #dc143c;">xmlrpclib</span>.<span style="color: black;">ServerProxy</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span></pre></div></div>

<p>&nbsp;<br />
Now you have your proxy. If you print out the server variable (<em>print server</em>) you will see that server is an instance of the ServerProxy class made to communicate with the SoftLayer XML-RPC server.  Now, let&#8217;s actually do something!<br />
&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">serverList = server.<span style="color: black;">getServerList</span><span style="color: black;">&#40;</span>key, usr<span style="color: black;">&#41;</span></pre></div></div>

<p>&nbsp;<br />
This invokes the XML-RPC <em>getServerList</em> method, which retrieves your list of servers and stashes it into <strong>serverList</strong>. Let&#8217;s see what you got:<br />
&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">print</span> serverList</pre></div></div>

<p>&nbsp;<br />
The data is returned as a LIST of DICTIONARIES, with one DICTIONARY per server. Let&#8217;s loop through this list and display the servername of all your servers:<br />
&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">for</span> thisServer <span style="color: #ff7700;font-weight:bold;">in</span> serverList:
  <span style="color: #ff7700;font-weight:bold;">print</span> thisServer<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;SERVERNAME&quot;</span><span style="color: black;">&#93;</span></pre></div></div>

<p>&nbsp;<br />
The two space indentation at the beginning of the second line are required or else the code won&#8217;t work. Hit enter twice, and Python will print out the Servername (hostname + domain name) for all servers in your account. You can pull more data out of the dictionary easily:<br />
&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">for</span> thisServer <span style="color: #ff7700;font-weight:bold;">in</span> serverList:
  <span style="color: #ff7700;font-weight:bold;">print</span> thisServer<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;SERVERNAME&quot;</span><span style="color: black;">&#93;</span>, thisServer<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;PUBLIC_IP_ADDRESS&quot;</span><span style="color: black;">&#93;</span></pre></div></div>

<p>&nbsp;<br />
You can make all the method calls listed in the SoftLayer API Documentation by calling them as methods of the server class:<br />
&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">server.<span style="color: black;">getBandwidthList</span><span style="color: black;">&#40;</span>key, usr, <span style="color: #483d8b;">&quot;192.168.1.1&quot;</span><span style="color: black;">&#41;</span>
server.<span style="color: black;">getServerNetworkDetails</span><span style="color: black;">&#40;</span>key, usr, <span style="color: #483d8b;">&quot;192.168.1.1&quot;</span><span style="color: black;">&#41;</span>
server.<span style="color: black;">rebootServer</span><span style="color: black;">&#40;</span>key, usr, <span style="color: #483d8b;">&quot;192.168.1.1&quot;</span>, <span style="color: #483d8b;">&quot;Soft Reboot&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>&nbsp;<br />
Python is easy to pick up and play with, and with it&#8217;s XML-RPC library, it&#8217;s probably the fastest way for people to hack with the SoftLayer API.  The complete code listing to display all your servernames is below:<br />
&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># Quickie Python XML-RPC Demo for the SoftLayer API</span>
<span style="color: #808080; font-style: italic;"># Written by Shawn Boles, SoftLayer Development</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># API Connection Details</span>
url = <span style="color: #483d8b;">&quot;http://api.service.softlayer.com/xmlrpc/v1/SL-Service.html&quot;</span>
key = <span style="color: #483d8b;">&quot;PUT YOUR SOFTLAYER API KEY HERE...&quot;</span>
usr = <span style="color: #483d8b;">&quot;PUT YOUR API USERNAME HERE...&quot;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># This is the XML-RPC Library for Python.  It comes standard!</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">xmlrpclib</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Set up the proxy object for the SoftLayer server.  You can make</span>
<span style="color: #808080; font-style: italic;"># calls against this object as if the processing is local.</span>
server = <span style="color: #dc143c;">xmlrpclib</span>.<span style="color: black;">ServerProxy</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Make a method call on getServerList from the API.</span>
<span style="color: #808080; font-style: italic;"># Don't forget to pass the key and usr variables as the first</span>
<span style="color: #808080; font-style: italic;"># two parameters, in that order!</span>
serverList = server.<span style="color: black;">getServerList</span><span style="color: black;">&#40;</span>key, usr<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Loop through all servers, displaying their servernames.</span>
<span style="color: #ff7700;font-weight:bold;">for</span> myserver <span style="color: #ff7700;font-weight:bold;">in</span> serverList:
    <span style="color: #ff7700;font-weight:bold;">print</span> myserver<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;SERVERNAME&quot;</span><span style="color: black;">&#93;</span></pre></div></div>

<p>&nbsp;<br />
Only 8 lines of code, ignoring comments and empty lines. Hacking indeed! When a new API method comes out you can pop open a command line and slap together a test case in a minute or two to try it out!</p>
<p>Extra Credit:  Let&#8217;s do something a little more useful with our new |33+ Python API Hacking Skilz:<br />
&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># Display all my servers and IP addresses, using the SoftLayer API</span>
<span style="color: #808080; font-style: italic;"># Written by Shawn Boles, SoftLayer Development</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># API Connection Details</span>
url = <span style="color: #483d8b;">&quot;http://api.service.softlayer.com/xmlrpc/v1/SL-Service.html&quot;</span>
key = <span style="color: #483d8b;">&quot;PUT YOUR SOFTLAYER API KEY HERE...&quot;</span>
usr = <span style="color: #483d8b;">&quot;PUT YOUR API USERNAME HERE...&quot;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># This is the XML-RPC Library for Python.  It comes standard!</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">xmlrpclib</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Set up the proxy object for the SoftLayer server.  You can make</span>
<span style="color: #808080; font-style: italic;"># calls against this object as if the processing is local.</span>
server = <span style="color: #dc143c;">xmlrpclib</span>.<span style="color: black;">ServerProxy</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Make a method call on getServerList from the API.</span>
<span style="color: #808080; font-style: italic;"># Don't forget to pass the key and usr variables as the first</span>
<span style="color: #808080; font-style: italic;"># two parameters, in that order!</span>
serverList = server.<span style="color: black;">getServerList</span><span style="color: black;">&#40;</span>key, usr<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Loop through all servers, displaying their servernames.</span>
<span style="color: #ff7700;font-weight:bold;">for</span> myserver <span style="color: #ff7700;font-weight:bold;">in</span> serverList:
    <span style="color: #808080; font-style: italic;"># Get the list of Server Details from the API for each server:</span>
    serverDetail = server.<span style="color: black;">getServerDetails</span><span style="color: black;">&#40;</span>key, usr, myserver<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;ID&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># &quot;Unfold&quot; the Server Details data structure and give us access</span>
    <span style="color: #808080; font-style: italic;"># to only the IP information...</span>
    prettyServerDetail = serverDetail<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> myserver<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;SERVERNAME&quot;</span><span style="color: black;">&#93;</span>, \
            <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>Public IP:&quot;</span>, prettyServerDetail<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;PRIMARY_PUBLIC_IP&quot;</span><span style="color: black;">&#93;</span>, \
            <span style="color: #483d8b;">&quot;(&quot;</span>, prettyServerDetail<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;PUBLIC_PORT_SPEED&quot;</span><span style="color: black;">&#93;</span>, <span style="color: #483d8b;">&quot;),&quot;</span>, \
            <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>Private IP:&quot;</span>, prettyServerDetail<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;PRIMARY_PRIVATE_IP&quot;</span><span style="color: black;">&#93;</span>, \
            <span style="color: #483d8b;">&quot;(&quot;</span>, prettyServerDetail<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;PRIVATE_PORT_SPEED&quot;</span><span style="color: black;">&#93;</span>, <span style="color: #483d8b;">&quot;),&quot;</span>, \
            <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>Manage IP:&quot;</span>, prettyServerDetail<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;MGMT_IP&quot;</span><span style="color: black;">&#93;</span>, <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">KeyError</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;NONE<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">pass</span></pre></div></div>

<p>&nbsp;<br />
Here&#8217;s a <a href="http://sldn.softlayer.com/wp-content/sldn/20/api_example-python.zip">direct link</a> to the sample file for your editing pleasure.</p>
<p>In no time at all you will be hacking apps for your API no sweat!  And you aren&#8217;t locked down to command line tools, either.  Python comes with just about every GUI kit, can be used to make your own Python-powered control panel&#8230;</p>
<p>Have fun hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://sldn.softlayer.com/06/2007/api-hacking-fun-with-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
