document

advertisement
Maximo OSLC REST Api
Quick Start Guide
April 2, 2014
1
Defining an OSLC Resource for Maximo Data
Object Structure Application
For those of you who primarily want to leverage the OSLC api to query and/or update data in Maximo, you can start by (Asset
data is used in this explanation):
1.
2.
selecting the existing MXASSET object structure within the Object Structures application and 'Duplicate' it.
Provide a new name, set the Consumed By to OSLC and optionally you can make any other changes that you
determine necessary such as removing/adding child objects and/or including/excluding object columns.
OSLC Resources Application
Once your object structure is defined you then can go to the OSLC Resources application under the Integration GOTO menu.
Here you can create a new OSLC Resource using the newly created object structure. The screen shot below shows a new
Resource creation where
1.
2.
the resource name is ASSET, and the object structure referenced in ASSETOSLC (created by duplicating MXASSET).
The Domain selected was SmarterPhysicalInfrastructure (the default domain for Maximo) and the Default Namespace
URI was set to http://jazz.net/ns/ism/asset/smarter_physical_infrastructure# (the default for Maximo).
As you can see in the screen shot below, the object structure had been updated to contain the ASSET and ASSETMETER
objects only. You need to set the default namespace for each child object in the object structure. All other fields on this screen
were defaulted by the application and do not require additional updating.
With just this configuration, you have created a resource and can now use the OSLC REST api to query and/or update this
resource.
Resource Shape (similar to XML schema)
2
If needed, you can access the Resource Shape using the URL: http://localhost/maximo/oslc/shapes/assetoslc (where
'assetoslc' is the name of the object structure you created above).
Querying a Resource
System Property
1.
You need to configure the host:port in OSLC webappurl system property (mxe.oslc.webappurl) based on your Maximo
deployment. REMINDER: After saving, make sure to select the property and do a Live Refresh.
Query a Resource Collection
2.
This URI can be used to query (HTTP GET) resources, http://localhost/maximo/oslc/os/assetoslc. The response of
this query will be in a JSON format and give you a resource URI for each resource (sample snippet of response JSON
data below)
{
"rdf:resource": "http://localhost/maximo/oslc/os/assetoslc/_QTgwMDYvQkVERk9SRA--"
},
{
"rdf:resource": "http://localhost/maximo/oslc/os/assetoslc/_TTsxMDSFkVRTOI99SOA--"
},
When querying a collection (0 to many) of resources you can use OSLC query parameters to control the content
returned by the query. These parameters are:
oslc.select - allows you to retrieve properties of the attribute (asset number, description etc) in addition to the URI
http://localhost/maximo/oslc/os/assetoslc?oslc.select=spi:assetnum,spi:description
oslc.where - allows you to limit the selection of resource based on resource (where site = BEDFORD)
http://localhost/maximo/oslc/os/assetoslc?oslc.where=spi:siteid="BEDFORD"
oslc.orderBy - allows you to control the sort order of the resources returned (order by asset type ascending)
http://localhost/maximo/oslc/os/assetoslc?oslc.orderBy=+spi:assettype
Query an Individual Resource
3.
This URI can be used to query a selected resource, http://localhost/maximo/oslc/os/assetoslc/123, where 123 is a the
resource ID.
The response of this query will give you all the resource properties defined within the object structure for that resource.
When querying a resource, you can use the oslc.properties parameter to control the content returned by the query (i.e.
limit the response content to include only asset number, site id and description properties).
http://localhost/maximo/oslc/os/assetoslc/_QTgwMDYvQkVERk9SRA-?oslc.properties=spi:assetnum,spi:siteid,spi:description (where' _QTgwMDYvQkVERk9SRA-- 'is the resource ID)
3
Creating a Resource
Creating a resource requires OSLC/JSON formatted data that includes, at a minimum, the fields that make up the primary
key of the root object of your object structure (resource). For example to create an Asset in Maximo you are required to
provide an Asset Number (assetnum) and Site (siteid).
Your JSON data would be in the body of an HTTP POST to the creationFactory URI of the resource (as found in the
Service Provider document), http://localhost/maximo/oslc/os/assetoslc (where assetoslc is your resource). Below is a
sample JSON document that will create a new asset.
{
"spi:status": "OPERATING",
"spi:changeby": "WILSON",
"spi:purchaseprice": 4600,
"spi:assetnum": "A8006TS4",
"spi:description": "Unix Server TS4",
"spi:siteid": "BEDFORD",
"prefixes":
{
"spi": "http://jazz.net/ns/ism/asset/smarter_physical_infrastructure#"
},
"spi:location": "COMP310",
"spi:serialnum": "GT-98556432",
"spi:assettype": "IT",
}
The response of the Create, if successful, will be a Status Code of 201 and will include URI in the HTTP header property
Location, to use for querying, updating or deleting the resource. Sample value in Location Header:
http://mx7vm:9080/maximo/oslc/os/assetoslc/_QTgwMDZUUzEvQkVERk9SRA--
4
Updating a Resource
Updating a resource requires OSLC/JSON formatted data that includes those fields that are being changed.
Your JSON data would be in the body of an HTTP PUT to the resource URI (as returned when querying the resource
collection or returned during the resource creation)
A sample Resource URI: http://mx7vm:9080/maximo/oslc/os/assetoslc/_QTgwMDZUUzEvQkVERk9SRA-where '_QTgwMDZUUzEvQkVERk9SRA--' is the resource identifier.
The JSON data in the HTTP Body could be formatted as below to change the Asset's description.
{
"spi:changeby": "WILSON",
"spi:description": "NEW DESCRIPTION ",
"prefixes":
{
"spi": "http://jazz.net/ns/ism/asset/smarter_physical_infrastructure#"
},
}
The response of the Update, if successful, will be a Status Code of 201.
Deleting a Resource
Deleting only requires the resource URI using in an HTTP DELETE request.
A sample Resource URI: http://mx7vm:9080/maximo/oslc/os/assetoslc/_QTgwMDZUUzEvQkVERk9SRA-where '_QTgwMDZUUzEvQkVERk9SRA--' is the resource identifier.
The response of the Delete, if successful, will be a Status Code of 204
Additional Information
You can find additional information on querying, creating and updating resources in:


the Integration Framework section of the Maximo Wiki
(https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20Maximo%20Asset%20Manage
ment/page/Accessing%20Resources)
the Integration Framework section of the Maximo Info Center
(http://pic.dhe.ibm.com/infocenter/tivihelp/v49r1/topic/com.ibm.mif.doc/gp_intfrmwk/oslc/c_ctr_create_oslc_resource.ht
ml)
5
Download