In a previous blog, “What are the IBM SmartCloud Enterprise APIs?” I explained the types of APIs provided by the IBM SmartCloud Enterprise. Now, I explain in more detail the Java API that is provided by the IBM SmartCloud Enterprise platform. The Java APIs are downloadable from the Support tab of the IBM SmartCloud Enterprise portal. This blog also contains a video that demonstrates the IBM SmartCloud Enterprise Java API.
Java API description
The Java APIs are very simple; they are based on an interface DeveloperCloudClient, which holds a number of methods to manage the IBM SmartCloud Enterprise platform and a number of plain old Java objects (POJO), which represent each type of resource and object managed by the IBM SmartCloud Enterprise.
The Java API uses the RESTful API behind the scene. It is faster than the CLI API because there is no need to launch a new Java Virtual Machine for each method.
To access the IBM SmartCloud Enterprise, you have to create a client object, which is easy to do as follows:
That’s it. Now you are ready to call methods and take several actions on the IBM SmartCloud Enterprise, such as:
Considerations for automation
The same remark as in my previous blog about CLI API can be done on the Java API. Some Java APIs are asynchronous. For example, if you call a method to create a new instance createInstance, the method returns a list of instance objects directly after the request has been posted to the IBM SmartCloud Enterprise platform and not after the instance has been completely created. You have to take this into account while writing your program and thus monitor the completion of the request before launching the next method, of course, if this method needs the resource created by the first one
To support you on this, I created a number of handy methods that can be useful while you are writing your own program. One of these methods is waitInstancesStatus, which waits until a given list of instances reaches a given status.
Create a HandyDeveloperCloudClient instead of a DeveloperCloudClient object and use that object to call the method provided by the IBM SmartCloud Enterprise and the additional methods provided by the handy command-lines and Java Libraries.
The handy command-lines and Java library contains managers such as InstanceManager and ImageManager. You can instantiate these manager and provide them a DeveloperCloudClient object to generate the connection and then use the method provided by each manager.
Read the developerWorks article that explains this asset:
The createInstance method requires a Map<String,Object> object in which you will set all parameters defined in the parameters.xml image . Unfortunately, the IBM SmartCloud Enterprise Java API doesn’t provide an API to manage the image parameters. However, it is very easy to create a Java package to manipulate the parameters.xml file and read all available parameters to create our Map object, because we have the parameters.xsd, and using JAXB to create the Java package is straight forward. To find out how to create such a package, follow the developerWorks article: http://www.ibm.com/developerworks/cloud/library/cl-parameterizejaxb
You can download the parameters.xsd as follows:
On the Support page, click View asset catalog.
Clear the filter and enter parameters.xsdin the search field:
Open the asset and click Content and you will see:
Using Java API through proxy
You can access the command-line tool through a proxy by changing the environment.properties in the DeveloperCloud_API_Client_JAR.jar file:
# Proxy setting for API request through a proxy server. Set proxy.enabled as true to enable proxy setting
# Host name or IP address for proxy sever.
# Port for proxy sever.
# Optional, Username of Proxy Server
# Optional, Password of Proxy Server
Download the Java API
To download the Java API, you must first have access to the IBM SmartCloud Enterprise. (If you don’t have access, go to http://www.ibm.com/cloud-computing or contact your local IBM representative.)
Select the Support tab and click Java REST API Client.
You land on the correct asset in the Rational Asset Catalog; select Content.
A list of JAR files is displayed that you have to download and put in your CLASSPATH. You may also download the Javadoc information.
Example of an Application that deeply use the Java API
You can download the deployment utility from the following location. You may use the deployment utility to deploy a complex infrastructure on the IBM SmartCloud Enterprise. This tool deeply uses the Java API provided by the IBM SmartCloud Enterprise. The asset contains also videos.
I had the opportunity to visit a number of telecommunications clients using IBM Netcool over the last year. We frequently discussed the benefits of have a geographically mapped view of topology. Not just because it was nice “eye candy” in the Network Operations Center (NOC), but because it gives an important geographically-based view of network […]
IT managers, does this sound familiar? Just when everything is running smoothly, you encounter the release management process in place for upgrading business applications in the production environment. You get an error notification in one of the workflows running the release management process. It can be especially frustrating when the error is coming from the […]
We just released the latest release of WebSphere Liberty, 188.8.131.52. It includes many new enhancements to its security, database management and overall performance. Interested in what’s new? Join our webcast on January 11, 2017. Why? Read on. I used to take time to reflect on the year behind me as the calendar year closed out, […]