IBM http://www.aliyun.com/zixun/aggregation/13696.html ">smartcloud enterprise+ users can use an integrated service-managed (ISM)-based Web Portal to create and manage virtual assets. Most portal features can be used through APIs. By using these APIs, you can use a program to control the creation and maintenance of SmartCloud enterprise+ resources. SmartCloud enterprise+ Cloud Solutions can be automatically provisioned, extended, and reconfigured.
The SmartCloud enterprise+ API is implemented as a representational state transfer (REST) call that can be obtained at predefined endpoint URLs. (The endpoint URL is communicated to the IBM customer during the SmartCloud enterprise+ operations training, so the example in this article replaces the actual endpoint URL with a endpoint_url placeholder.) These APIs provide 3 main features:
SmartCloud enterprise+ Metadata and resources for administrative resources (user, Team, project, and approval) management for SmartCloud enterprise+ virtual servers, patches, and snapshots
This article discusses the use of APIs in all 3 categories and provides examples. Our code example uses the CURL command-line utility, which enables you to transfer data using simple HTTP commands. We also demonstrate the REST invocation parameters in each CURL call.
Calling syntax
SmartCloud enterprise+ REST API requests can pass invocation parameters in the HTTP request header and body. For the request pass parameter in the message body, you need to content-type the header element, its value is Application/xml or Application/json. Depending on the content type, in the body of the request, you should place an XML or JavaScript object representation (JSON) element that contains all the properties of the resource being created. You can also use the Accept header to specify the response format (also Application/xml or Application/json) of the request.
A REST query (an HTTP GET request) that returns a collection of elements may have additional URL parameters that specify the filter criteria for the query (for example, get Baseurl/users?first_name=john). Similarly, a GET query can request sorting or truncating results. For more information, see the IBM smartcloud enterprise+ API specifications documentation, which you can obtain during SmartCloud enterprise+ operations training.
View, create, and maintain SmartCloud enterprise+ project and server instances
Next, we'll show you how to use these APIs to programmatically control the view, creation, and maintenance of SmartCloud Enterprise+ project and server instances.
Retrieving resource metadata
Figure 1 is the structure diagram of the SmartCloud enterprise+ resource model:
Figure 1. SmartCloud enterprise+ Resource Model
In Figure 1, the arrows represent a dependency between resources or a reference from one resource to another. In this model, you can see what types of resources are required to create an instance (SmartCloud enterprise+ server). instance is bound to a group. A grouping is an abstract resource grouping, and its only physical implementation in SmartCloud enterprise+ is a project. The project is then composed of a team that contains users. You must first create teams, users, and groups before you can associate instances with them.
In addition, users and instances must be associated with a certain number of existing SmartCloud enterprise+ resources, so you must extract the metadata for those resources. For example, a user needs a role, which is a unique smartcloud enterprise+ resource.
A smartcloud enterprise+ user can have up to two roles. To get the user's role metadata, you can issue a REST get command:
Curl-k-x get-u johntester@test.com:johnspasswd https://endpoint_URL/roles
An example response to the above command is:
<roles> <role> <id>53</id> <name>Administrator</name> <role_group> iaas-user</role_group> </role> <role> <id>54</id> <name>business manager</ name> <role_group>IaaS-User</role_group> </role></roles>
You can also emit a REST get command in the browser because the browser emits an HTTP GET request by default. Type the REST call URL:
Https://endpoint_URL/roles
The browser then displays the default XML format response.
Create a user
To create a user, you must specify:
user ID (user's e-mail address) display name First name surname role reference List language area