Skip to content

Oms API Read Run Microdata value

amc1999 edited this page May 22, 2023 · 5 revisions

Read a "page" of microdata values from model run.

Page is part of microdata values defined by zero-based "start" row number and row count. If row count <= 0 then all rows below start row number returned.

Enum-based microdata attributes returned as enum codes.

Method verb must be POST and Content-Type header "application/json". JSON body POSTed to specify microdata name, page size, row count, filters and row order. It is expected to be JSON representation of db.ReadLayout structure from Go library.

Method:

POST /api/model/:model/run/:run/microdata/value

For example:

curl -v -X POST -H "Content-Type: application/json" http://localhost:4040/api/model/modelOne/run/Microdata%20in%20database/microdata/value -d @test.json
curl -v -X POST -H "Content-Type: application/json" http://localhost:4040/api/model/modelOne/run/2016_08_17_21_07_55_123/microdata/value -d @test.json

Arguments:

:model - (required) model digest or model name

Model can be identified by digest or by model name. It is recommended to use digest because it is uniquely identifies model. It is possible to use model name, which is more human readable than digest, but if there are multiple models with same name in database than result is undefined.

:run - (required) model run digest, run stamp or run name

Model run can be identified by run digest, run stamp or run name. It is recommended to use digest because it is uniquely identifies model run. Run stamp, if not explicitly specified as model run option, automatically generated as timestamp string, ex.: 2016_08_17_21_07_55_123. It is also possible to use name, which is more human readable than digest, but if there are multiple runs with same name in database than result is undefined.

JSON body arguments:

For example:

{
  "Name": "Person",
  "Offset": 8,
  "Size": 16,
  "IsFullPage": true,
  "Filter": [{
      "Name": "Age",
      "Op": "BETWEEN",
      "Values": ["21", "65"]
    }, {
      "Name": "Province",
      "Op": "IN",
      "Values": ["BC", "QC"]
    }, {
      "Name": "Sex",
      "Op": "=",
      "Values": ["F"]
    }
  ],
  "OrderBy": [{
      "IndexOne": 5
    }, {
      "IndexOne": 6,
      "IsDesc": true
    }
  ]
}
Name       - (required) microdata name
Offset     - (optional) zero-based start row to select microdata values
Size       - (optional) max row count to select microdata values, if size <= 0 then all rows selected
IsFullPage - (optional) if true then always return non-empty last page of data.
Filter     - (optional) conditions to filter attribute values, if attribute is enum-based then filter by enum code(s).
OrderBy    - (optional) list of columns indexes (one based) to order by

Filter conditions joined by AND and can have following operations:

=       - value equal to:         Age = 20
!=      - value not equal to:     Age <> 20
>       - value greater than:     Age > 20
>=      - value greater or equal: Age >= 20
<       - value less than:        Age < 20
<=      - value less or equal:    Age <= 20
IN      - in the list of codes:   Province IN ("BC", "QC", "ON")
BETWEEN - between min and max:    Age BETWEEN 20 AND 40
IN_AUTO - automatically choose most suitable: = or != or IN or BETWEEN

Order by specified by one-based column(s) index(es) in result. In case of microdata columns are:

  SELECT entity_key, attr0, attr1, ..., value FROM microdataTable ORDER BY 1, 2,...

For enum-based attribute column always contain enum id's, not enum codes and therefore result ordered by id's

JSON response:

{
  Layout: {
    Offset:     actual first row number of the page data (zero-base),
    Size:       actual data page row count,
    IsLastPage: true if this is last page of data
  },
  Page: [....page of data...]
}

Example 1:

JSON body:

{
  "Name": "Person",
  "Offset": 8,
  "Size": 2
}

Result:

< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Fri, 13 Jan 2023 22:25:27 GMT
< Content-Length: 1299
<
{
    "Page": [{
            "Key": 8,
            "Attr": [{
                    "IsNull": false,
                    "Value": "39"
                }, {
                    "IsNull": false,
                    "Value": "30-40"
                }, {
                    "IsNull": false,
                    "Value": "237539"
                }
            ]
        }, {
            "Key": 9,
            "Attr": [{
                    "IsNull": false,
                    "Value": "30"
                }, {
                    "IsNull": false,
                    "Value": "30-40"
                }, {
                    "IsNull": false,
                    "Value": "245730"
                }
            ]
        }
    ],
    "Layout": {
        "Offset": 8,
        "Size": 2,
        "IsFullPage":false,
        "IsLastPage": false
    }
}

Example 2:

JSON body:

{
  "Name": "Person",
  "Offset": 0,
  "Size": 3,
  "Filter": [{
      "Name": "AgeGroup",
      "Op": "IN",
      "Values": ["20-30", "40+"]
    }, {
      "Name": "Sex",
      "Op": "=",
      "Values": ["F"]
    }
  ],
  "OrderBy": [{
      "IndexOne": 5
    }, {
      "IndexOne": 6,
      "IsDesc": true
    }
  ]
}

Result:

< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Fri, 13 Jan 2023 22:49:06 GMT
< Content-Length: 1000
<
{
    "Page": [{
            "Key": 844424930131977,
            "Attr": [{
                    "IsNull": false,
                    "Value": "83"
                }, {
                    "IsNull": false,
                    "Value": "40+"
                }, {
                    "IsNull": false,
                    "Value": "F"
                }, {
                    "IsNull": false,
                    "Value": "23000"
                }, {
                    "IsNull": false,
                    "Value": "0"
                }, {
                    "IsNull": false,
                    "Value": "L"
                }, {
                    "IsNull": false,
                    "Value": "Part"
                }, {
                    "IsNull": false,
                    "Value": "true"
                }, {
                    "IsNull": false,
                    "Value": "23000"
                }
            ]
        }, {
            "Key": 562949953421322,
            "Attr": [{
                    "IsNull": false,
                    "Value": "83"
                }, {
                    "IsNull": false,
                    "Value": "40+"
                }, {
                    "IsNull": false,
                    "Value": "F"
                }, {
                    "IsNull": false,
                    "Value": "23000"
                }, {
                    "IsNull": false,
                    "Value": "0"
                }, {
                    "IsNull": false,
                    "Value": "L"
                }, {
                    "IsNull": false,
                    "Value": "Part"
                }, {
                    "IsNull": false,
                    "Value": "true"
                }, {
                    "IsNull": false,
                    "Value": "23000"
                }
            ]
        }, {
            "Key": 281474976710667,
            "Attr": [{
                    "IsNull": false,
                    "Value": "83"
                }, {
                    "IsNull": false,
                    "Value": "40+"
                }, {
                    "IsNull": false,
                    "Value": "F"
                }, {
                    "IsNull": false,
                    "Value": "23000"
                }, {
                    "IsNull": false,
                    "Value": "0"
                }, {
                    "IsNull": false,
                    "Value": "L"
                }, {
                    "IsNull": false,
                    "Value": "Part"
                }, {
                    "IsNull": false,
                    "Value": "true"
                }, {
                    "IsNull": false,
                    "Value": "23000"
                }
            ]
        }
    ],
    "Layout": {
        "Offset": 0,
        "Size": 3,
        "IsFullPage":false,
        "IsLastPage": false
    }
}

Home

Getting Started

Model development in OpenM++

Using OpenM++

Model Development Topics

OpenM++ web-service: API and cloud setup

Using OpenM++ from Python and R

Docker

OpenM++ Development

OpenM++ Design, Roadmap and Status

OpenM++ web-service API

GET Model Metadata

GET Model Extras

GET Model Run results metadata

GET Model Workset metadata: set of input parameters

Read Parameters, Output Tables or Microdata values

GET Parameters, Output Tables or Microdata values

GET Parameters, Output Tables or Microdata as CSV

GET Modeling Task metadata and task run history

Update Model Profile: set of key-value options

Update Model Workset: set of input parameters

Update Model Runs

Update Modeling Tasks

Run Models: run models and monitor progress

Download model, model run results or input parameters

Upload model runs or worksets (input scenarios)

User: manage user settings and data

Model run jobs and service state

Administrative: manage web-service state

Clone this wiki locally