IBM Maximo: Dicas de APIs Rest: Difference between revisions

From Wiki
 
(36 intermediate revisions by the same user not shown)
Line 17: Line 17:


= URLs =
= URLs =
* '''/maximo/oas3/maximoapis.html'''-> Maximo RESTful API By Category
* '''/maximo/oas3/api.html'''-> Maximo RESTful API - Swagger
* '''/maximo/oslc/oas?includeactions=1'''->  Maximo RESTful API - Swagger  include actions


* '''maximo/oslc/login''' or '''/j_security_check'''
* '''maximo/oslc/login''' or '''/j_security_check'''
** [[IBM Maximo: REST API Authentication]]
** [[IBM Maximo: REST API Authentication]]


* '''/maximo/oas3/api.html'''-> Maximo RESTful API - Swagger
 
* '''/maximo/oslc/oas?includeactions=1'''->  Maximo RESTful API - Swagger  include actions


* '''/maximo/oslc/''' -> Default uri os oslc
* '''/maximo/oslc/''' -> Default uri os oslc
Line 28: Line 32:
* '''/maximo/oslc/apimeta''' -> APIs Metadata. Metadata for all the object structures that are API eligible
* '''/maximo/oslc/apimeta''' -> APIs Metadata. Metadata for all the object structures that are API eligible
* '''/maximo/oslc/license''' -> License Keys
* '''/maximo/oslc/license''' -> License Keys
* '''/maximo/oslc/log'''
** [[IBM Maximo: REST API Troubleshooting]]
* '''/maximo/oslc/members''' -> Server Members, API for the Maximo Management Interface (MMI).
* '''/maximo/oslc/members''' -> Server Members, API for the Maximo Management Interface (MMI).
* '''/maximo/oslc/members/thisserver''' ->This Server
* '''/maximo/oslc/members/thisserver''' ->This Server
Line 34: Line 42:
* '''/maximo/oslc/version''' -> Version
* '''/maximo/oslc/version''' -> Version
* '''/maximo/oslc/whoami''' -> Who am I
* '''/maximo/oslc/whoami''' -> Who am I
* '''/maximo/oslc/sp''' -> Service Provider


* '''/maximo/oslc/service/system'''
** [[IBM Maximo: REST API working with system properties]]


* '''/maximo/oslc/sp''' -> Service Provider


= Object Structures =


* '''/maximo/oslc/os/MXINTOBJECT'''
* '''/maximo/oslc/os/MXINTOBJECT'''
Line 44: Line 55:
*'''/maximo/oslc/os/MXOBJECTCFG'''
*'''/maximo/oslc/os/MXOBJECTCFG'''
** [[IBM Maximo: Get the attributes of Object Structures using REST API]]
** [[IBM Maximo: Get the attributes of Object Structures using REST API]]
*'''/maximo/oslc/os/mxapiasset?attributesearch=[SPEED:>=50;AREA;ELEV:=300]'''
** Classification attribute search.


* '''/maximo/oslc/jsonschema/<object structure>'''
* '''/maximo/oslc/jsonschema/<object structure>'''
Line 53: Line 61:
** Support child object schemas GET jsonschema/mxapiasset/assetmeter
** Support child object schemas GET jsonschema/mxapiasset/assetmeter
** Support schema views - Get jsonschema/mxapiasset?oslc.select=attr1,rel1.attr2
** Support schema views - Get jsonschema/mxapiasset?oslc.select=attr1,rel1.attr2
* POST '''/maximo/oslc/os/mxasset'''{id}?action=wsmethod:changeStatus
:: Chama actions
{
  "rollToAllChildren": true,
  "removeFromActiveSP": true,
  "removeFromActiveRoutes": true,
  "status": "string",
  "changePMStatus": true
}


= Headers =
= Headers =
Line 78: Line 74:
| Accept=application/json || - || -
| Accept=application/json || - || -
|-
|-
| '''properties'''=*<br>'''properties'''=attr1,attr2 || usado no POST || Usar o header de properties elimina a necessidade de fazer um GET extra após um create ou update
| '''properties'''=*<br>'''properties'''=attr1,attr2 || usado no POST || Usar o header de properties elimina a necessidade de fazer um GET extra após um create ou update. Dever estar definido na variável mxe.oslc.aclallowheaders
|-
|-
| '''x-method-override: PATCH'''|| usado no POST || informa ao servidor que será um update
| '''x-method-override: PATCH'''|| usado no POST || informa ao servidor que será um update
|-
|-
| '''x-method-override: PATCH'''<br>'''patchtype: MERGE'''|| usado no POST || informa ao servidor que será um update e atualiza os filhos
| '''x-method-override: PATCH'''<br>'''patchtype: MERGE'''|| usado no POST || informa ao servidor que será um update e atualiza os filhos
|-
| '''batcherror: 1'''|| usado no POST || Suportado a partir do 7.6.1.2. ???
|-
| '''x-method-override: SYNC'''<br>'''patchtype: MERGE'''|| usado no POST || informa ao servidor que será um update e atualiza os filhos
|-
| '''filetype'''|| usado no POST || Usado na importação de arquivos (<os>?action=importfile), os valores são FLAT ou XML
|-
| '''delimiter: ,'''|| usado no POST || Usado na importação de arquivos (<os>?action=importfile). Delimitador de CSV
|-
| '''textqualifier: "'''|| usado no POST || Usado na importação de arquivos (<os>?action=importfile). Delimitador de texto em CSV
|-
| '''msgtype: '''|| usado no POST || Usado na importação de arquivos (<os>?action=importfile). The message type Sync,Create,Update or default (null) to be used for this import
|-
| '''preview: 1'''|| usado no POST || Usado na importação de arquivos (<os>?action=importfile). API is running in preview mode
|-
| '''transactionid: NNNNN'''|| usado no POST || Avoid duplicating the transaction processing.
|}
|}


Line 93: Line 105:
| uri?'''lean'''=1 || simple notation
| uri?'''lean'''=1 || simple notation
|-
|-
| uri?'''oslc.select''' || especifica o conjunto de atributos a serem buscados nas estruturas de objetos, bem como nos objetos relacionados. Veja seção '''os.select''' abaixo.
| uri?'''oslc.select''' || especifica o conjunto de atributos a serem buscados nas estruturas de objetos, bem como nos objetos relacionados. Veja seção [[IBM Maximo: Dicas de APIs Rest#OSLC.SELECT|OSLC.SELECT]] abaixo.
|-
|-
| /os/mxapiasset?'''distinct=siteid'''&oslc.where=... || select DISTINCT site
| uri?'''oslc.where''' || especifica a cláusula WHERE para filtrar o conjunto de resultados de uma consulta. Veja seção [[IBM Maximo: Dicas de APIs Rest#OSLC.WHERE|OSLC.WHERE]] abaixo.
|-
|-
| uri?'''oslc.where''' || especifica a cláusula WHERE para filtrar o conjunto de resultados de uma consulta. Veja seção '''oslc.where''' abaixo.
| uri?'''actions'''=name || veja seção [[IBM Maximo: Dicas de APIs Rest#ACTIONS|ACTIONS]] abaixo
|-
|-
| uri?'''oslc.orderBy'''<br>uri?'''oslc.orderBy'''=-attr1,+attr2 || especifica como os resultados de uma consulta são ordenados. O sinal de '''(-)''' para ordem decrescente e sinal de '''(+)''' para ordem crescente, sendo que o sinal + deve estar encoded.
| uri?'''oslc.orderBy'''<br>uri?'''oslc.orderBy'''=-attr1,+attr2 || especifica como os resultados de uma consulta são ordenados. O sinal de '''(-)''' para ordem decrescente e sinal de '''(+)''' para ordem crescente, sendo que o sinal + deve estar encoded.
Line 111: Line 123:
** '''mxe.oslc.maxpagesize''': define o valor para todos as Object Structures
** '''mxe.oslc.maxpagesize''': define o valor para todos as Object Structures
** '''mxe.oslc.<os name in lower case>.maxpagesize''': define o valor para uma Object Structures, sobrepõe mxe.oslc.maxpagesize
** '''mxe.oslc.<os name in lower case>.maxpagesize''': define o valor para uma Object Structures, sobrepõe mxe.oslc.maxpagesize
|-
| POST uri?'''interactive'''=1 || Handling Yes/No/Cancel interactions
|-
|uri?'''collectioncount'''=1 ||retorna o totalCount e totalPages na reposta<br>Set mxe.oslc.collectioncount system property to 1, the totalCount and totalPages parameters are included by default as part of the responseInfo.
"responseInfo": {
        ...
        "totalCount": 1
    }
|-
| uri?'''ignorecollectionref'''=1 || Stop to return collectionref like the following:
{
"woactivity_collectionref": "...",
"locations_collectionref": "...",
|-
| uri?'''relativeuri'''=1 || returns a relative url instead of the complete url.
Default
{
"localref": "<nowiki>http://server/maximo/</nowiki>oslc/os/mxapisr/_SUV.....g0",
}
with '''relativeuri'''=1
{
"localref": "oslc/os/mxapisr/_SUV.....g0",
}
|-
| uri?'''inlinedoc'''=1 || getting attachments inline as part of a json document.
|-
| uri?'''internalvalues'''=1 || ???
|-
|-
| uri?'''savedQuery'''=name || Saved query can be SQL, Java, Auto Script. /apimeta/<os name> lists all saved queries for an Object Structure
| uri?'''addschema'''=1 || ???
|-
|-
| uri?'''actions'''=name || veja seção '''Actions''' abaixo
| uri?'''docdownloadid'''=1 || ???
|}
 
 
{| class="wikitable sortable"
|-
! Key !! Description
|-
| uri?'''savedQuery'''=name || Saved query can be SQL, Java, Auto Script. <br>'''/apimeta/<os name>''' lists all saved queries for an Object Structure. <br>savedQuery=KPI:ASSETKPI
|-
|-
| uri?'''tlrange'''=-3M&'''tlattribute'''=dateattr[=indexdate]
| uri?'''tlrange'''=-3M&'''tlattribute'''=dateattr[=indexdate]
Line 127: Line 178:
Aggregation APIs.
Aggregation APIs.
Also supports date histograms – yearly/quarterly/monthly/weekly. <br>For example: <br>GET /mxapiwodetail? gbcols=year$statusdate,quarter$statusdate,sum.actlabhrs
Also supports date histograms – yearly/quarterly/monthly/weekly. <br>For example: <br>GET /mxapiwodetail? gbcols=year$statusdate,quarter$statusdate,sum.actlabhrs
|-
|uri?'''collectioncount'''=1 ||retorna o totalCount e totalPages na reposta<br>Set mxe.oslc.collectioncount system property to 1, the totalCount and totalPages parameters are included by default as part of the responseInfo.
|-
|-
|uri?'''count'''=1 ||only the total count of records that match the query and not the records
|uri?'''count'''=1 ||only the total count of records that match the query and not the records
Line 134: Line 183:
|uri?'''_dropnulls'''=0 ||To force the response to add null value attributes, API response skips the null value attributes by default
|uri?'''_dropnulls'''=0 ||To force the response to add null value attributes, API response skips the null value attributes by default
|-
|-
|uri?'''_format'''=xml<br>uri?'''_format'''=csv || type of output
|uri?'''_format'''=xml<br>uri?'''_format'''=csv || Usado no export de arquivos
|-
| uri/<os>?'''distinct'''=attr1&oslc.where=... || select DISTINCT Exemplo: <br>/os/mxapiasset?distinct=siteid&oslc.where=...
|-
| uri/<os>?'''attributesearch'''=[CLASSIFICATION] || Classification attribute search. <br>/maximo/oslc/os/mxapiasset?attributesearch=[SPEED:>=50;AREA;ELEV:=300]
|}
|}




=== oslc.select ===
 
=== OSLC.SELECT ===
{| class="wikitable sortable"
{| class="wikitable sortable"
|-
|-
Line 164: Line 218:
|}
|}


=== oslc.where ===
=== OSLC.WHERE ===
{| class="wikitable sortable"
{| class="wikitable sortable"
|-
|-
Line 192: Line 246:
! Key !!  Description
! Key !!  Description
|-
|-
| uri?oslc.where=attr1 in ["val1","val2"] and attr2>200|| -   
| uri/<os>/{id}?'''action=wsmethod:changeStatus'''
||
Chama actions. Exemplo:
 
POST uri/mxasset/{id}?action=wsmethod:changeStatus
{
  "rollToAllChildren": true,
  "removeFromActiveSP": true,
  "removeFromActiveRoutes": true,
  "status": "string",
  "changePMStatus": true
}
|-
| uri/<os>/{id}?'''action=workflow:<workflow name>
||
This invokes the named workflow in the context of the MBO that is identified in the URI.
POST uri/<os>/{id}?'''action=workflow:<workflow name>'''
X-method-override: PATCH
|-
| uri/<os>?'''action=listreports'''
||
Get the list of available reports for a given user and a given application.
  GET uri/mxapiwodetail?action=listreports
|-
|-
| POST /oslc/os/<os name>/{rest id}?'''action=workflow:<workflow name>'''<br>X-method-override: PATCH|| -  
| uri/<os>?'''action=genreport&reportname=<reportname>'''
 
||
Generate a report for a given set of mbos
  GET uri/MXAPIWODETAIL?action=genreport&reportname=woprint.rptdesign
|}
|}



Latest revision as of 20:34, 12 May 2023

Arquitetura

  • BO/OS: BO/Object Structure
  • MMI: Maximo Management Interface

Documentação, Artigos e Technotes

URLs

  • /maximo/oas3/maximoapis.html-> Maximo RESTful API By Category
  • /maximo/oas3/api.html-> Maximo RESTful API - Swagger
  • /maximo/oslc/oas?includeactions=1-> Maximo RESTful API - Swagger include actions



  • /maximo/oslc/ -> Default uri os oslc
  • /maximo/oslc/apimeta -> APIs Metadata. Metadata for all the object structures that are API eligible
  • /maximo/oslc/license -> License Keys
  • /maximo/oslc/members -> Server Members, API for the Maximo Management Interface (MMI).
  • /maximo/oslc/members/thisserver ->This Server
  • /maximo/oslc/products -> Installed Products
  • /maximo/oslc/systeminfo -> System Info
  • /maximo/oslc/version -> Version
  • /maximo/oslc/whoami -> Who am I
  • /maximo/oslc/sp -> Service Provider

Object Structures

  • /maximo/oslc/jsonschema/<object structure>
    • GET jsonschema/mxapiwodetail – gets the schema for the OS, but one object at a time.
    • GET jsonschema/mxapiwodetail?oslc.select=* - gets the full schema
    • Support child object schemas GET jsonschema/mxapiasset/assetmeter
    • Support schema views - Get jsonschema/mxapiasset?oslc.select=attr1,rel1.attr2

Headers

Key Value Description
maxauth=base64(username:password) required Username and Password encoded as base64
Content-Type=application/json - -
Accept=application/json - -
properties=*
properties=attr1,attr2
usado no POST Usar o header de properties elimina a necessidade de fazer um GET extra após um create ou update. Dever estar definido na variável mxe.oslc.aclallowheaders
x-method-override: PATCH usado no POST informa ao servidor que será um update
x-method-override: PATCH
patchtype: MERGE
usado no POST informa ao servidor que será um update e atualiza os filhos
batcherror: 1 usado no POST Suportado a partir do 7.6.1.2. ???
x-method-override: SYNC
patchtype: MERGE
usado no POST informa ao servidor que será um update e atualiza os filhos
filetype usado no POST Usado na importação de arquivos (<os>?action=importfile), os valores são FLAT ou XML
delimiter: , usado no POST Usado na importação de arquivos (<os>?action=importfile). Delimitador de CSV
textqualifier: " usado no POST Usado na importação de arquivos (<os>?action=importfile). Delimitador de texto em CSV
msgtype: usado no POST Usado na importação de arquivos (<os>?action=importfile). The message type Sync,Create,Update or default (null) to be used for this import
preview: 1 usado no POST Usado na importação de arquivos (<os>?action=importfile). API is running in preview mode
transactionid: NNNNN usado no POST Avoid duplicating the transaction processing.

Parameters

Key Description
uri?lean=1 simple notation
uri?oslc.select especifica o conjunto de atributos a serem buscados nas estruturas de objetos, bem como nos objetos relacionados. Veja seção OSLC.SELECT abaixo.
uri?oslc.where especifica a cláusula WHERE para filtrar o conjunto de resultados de uma consulta. Veja seção OSLC.WHERE abaixo.
uri?actions=name veja seção ACTIONS abaixo
uri?oslc.orderBy
uri?oslc.orderBy=-attr1,+attr2
especifica como os resultados de uma consulta são ordenados. O sinal de (-) para ordem decrescente e sinal de (+) para ordem crescente, sendo que o sinal + deve estar encoded.
uri?oslc.paging=true -
uri?oslc.pageSize=N
uri?oslc.pageSize=N&stablepaging=true

especifica os recursos para cada página de uma consulta.

  • Stable Paging – good for downloading large data sets.
  • Auto paging – Helps prevent OOM for large dataset requests when no page size specified. Default 1000 records
  • Limit Paging – Helps prevent OOM for large dataset requests when high page size specified.
    • mxe.oslc.maxpagesize: define o valor para todos as Object Structures
    • mxe.oslc.<os name in lower case>.maxpagesize: define o valor para uma Object Structures, sobrepõe mxe.oslc.maxpagesize
POST uri?interactive=1 Handling Yes/No/Cancel interactions
uri?collectioncount=1 retorna o totalCount e totalPages na reposta
Set mxe.oslc.collectioncount system property to 1, the totalCount and totalPages parameters are included by default as part of the responseInfo.
"responseInfo": {
       ...
       "totalCount": 1
   }
uri?ignorecollectionref=1 Stop to return collectionref like the following:
{ 
"woactivity_collectionref": "...",
"locations_collectionref": "...",
uri?relativeuri=1 returns a relative url instead of the complete url.

Default {

"localref": "http://server/maximo/oslc/os/mxapisr/_SUV.....g0",
}

with relativeuri=1

{
"localref": "oslc/os/mxapisr/_SUV.....g0",
}
uri?inlinedoc=1 getting attachments inline as part of a json document.
uri?internalvalues=1 ???
uri?addschema=1 ???
uri?docdownloadid=1 ???


Key Description
uri?savedQuery=name Saved query can be SQL, Java, Auto Script.
/apimeta/<os name> lists all saved queries for an Object Structure.
savedQuery=KPI:ASSETKPI
uri?tlrange=-3M&tlattribute=dateattr[=indexdate]
  • tlattribute - the timeline attribute to which the range applies. If no index data specified, its defaulted to the current date-time.
  • tlrange – The range in Months (M)/Years (Y)/ Week (W)/ Days (D)/ Hour (h)/Min (m)/ Seconds (s). + and - indicates whether to add or substract from tlattribute date-time.
POST uri?interactive=1 Handling Yes/No/Cancel interactions
GET uri?gbcols=status,count.*,sum.attr1&gbsortby=-count.*

Aggregation APIs. Also supports date histograms – yearly/quarterly/monthly/weekly.
For example:
GET /mxapiwodetail? gbcols=year$statusdate,quarter$statusdate,sum.actlabhrs

uri?count=1 only the total count of records that match the query and not the records
uri?_dropnulls=0 To force the response to add null value attributes, API response skips the null value attributes by default
uri?_format=xml
uri?_format=csv
Usado no export de arquivos
uri/<os>?distinct=attr1&oslc.where=... select DISTINCT Exemplo:
/os/mxapiasset?distinct=siteid&oslc.where=...
uri/<os>?attributesearch=[CLASSIFICATION] Classification attribute search.
/maximo/oslc/os/mxapiasset?attributesearch=[SPEED:>=50;AREA;ELEV:=300]


OSLC.SELECT

Key Description
oslc.select=assetnum,locationmylocation Apelido para atributo, para resolver conflitos de mesmo nome. Senão adicionado retorna $alias_this_attr$
oslc.select=attr1,attr2,child{attr4,attr5,grandchild{*}} -
oslc.select=attr1,rel1.attr1,rel.rel2{attr1,attr2},rel.rel3.os {*}
  • rel1.attr1 – 1:1 relations. Results in a JSON Object for property named “rel1”.
  • rel.rel2 {attr1,attr2} – 1:* relations. Results in a JSON Array for property named “rel2”.
  • rel.rel3.os {*} – 1:* relations. Results in a JSON Array with OS json (for the named os) as array members.
/oslc/os/mxasset?oslc.select=assetnum,status,exp.myreplacecost

create a object formula called MYREPLACECOST for asset object by using the Object Formula action in the Database Configuration application. The formula is purchaseprice/NVL(priority,1).

/oslc/os/mxasset/{id}?oslc.select=assetnum,openwo.actlabhrs._dbmax, ...

database aggregation (max,min,avg,sum,count, and exists) functions on related MboSets, must add _db prefix.

oslc.select=assetnum,status&internalvalues=1

Domain internal values. Returns as <attribute name>_maxvalue property.

OSLC.WHERE

Key Description
uri?oslc.where=attr1 in ["val1","val2"] and attr2>200 -
uri?oslc.where=status in ["OPERATING","ACTIVE"] and priority=3 and statusdate>"ISO date string" and linear=false -
uri?oslc.where=objectname IN ["WORKORDER","WOACTIVITY] -
uri?oslc.where=priority in [1,2,3] -
uri?oslc.where=status="%APPR%" like "%APPR%", aceita também "APPR%" e "%APPR"
uri?oslc.where=status="*" status is not null
uri?oslc.where=status!="*" status is null
uri?oslc.where=usewith="INTEGRATION" -

ACTIONS

Key Description
uri/<os>/{id}?action=wsmethod:changeStatus

Chama actions. Exemplo:

POST uri/mxasset/{id}?action=wsmethod:changeStatus
{
 "rollToAllChildren": true,
 "removeFromActiveSP": true,
 "removeFromActiveRoutes": true,
 "status": "string",
 "changePMStatus": true
} 
uri/<os>/{id}?action=workflow:<workflow name>

This invokes the named workflow in the context of the MBO that is identified in the URI.

POST uri/<os>/{id}?action=workflow:<workflow name>
X-method-override: PATCH
uri/<os>?action=listreports

Get the list of available reports for a given user and a given application.

GET uri/mxapiwodetail?action=listreports
uri/<os>?action=genreport&reportname=<reportname>

Generate a report for a given set of mbos

GET uri/MXAPIWODETAIL?action=genreport&reportname=woprint.rptdesign

Response Data

{
   "members": [{
           "href": "uri"
       }
       ...
   ],
   "responseInfo": {
       "nextPage": {
           "href": "next page uri"
       },
       "href": "request uri",
       "pagenum": 1
   }
}

Ver também