• B
    Balistar

    No need for MangoUI other than now and then do Admin stuff, We use our own Dashboards.

    0_1581995259249_Image 130.jpg

    The API will be used in device on-boarding. Admin creates User, JWT, DataSource (device). Sets new user role to DataSource. This info will be set in device, which creates its own DataPoints (15 to 50) and uploads measuring data to the system from then on.

    The JWT is not ideal from a security stand point, but good enough got us at the moment.

    0_1581995701589_Image 131.jpg

    posted in User help read more
  • B
    Balistar

    Thanks. My goal is to keep the API request JSON as small as possible, so I omitted as much as possible to the POST request to create a DP. Too much.

    You are right.

      "readPermission":"emon3175585",
      "setPermission":"emon3175585",
    

    needed to be added.

    {
      "name": "test12-test2",
      "xid": "test12-test2",
      "dataSourceXid" : "test12",
      "readPermission":"emon3175585",
      "setPermission":"emon3175585",
      "pointLocator" : {
           "startValue" : "0",
           "modelType" : "PL.VIRTUAL",
           "dataType" : "NUMERIC",
           "settable" : true,
           "changeType" : "NO_CHANGE",
           "max": 100,
           "maxChange": 0.01,
           "min": 0
        }
    }
    

    My concern is the API, so that is solved.

    The GUI DP creation permission may still have a problem as there is no SAVE button.

    posted in User help read more
  • B
    Balistar

    There is no console error because there is no SAVE button to press.

    Using the API with JWT issued to user emon3175585:

    curl --location --request POST 'http://xx.xx.xx.xx:8080/rest/v2/data-points' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer eyJhbGciOiJFUzUxMiJ9.eyJzdWIiOiJlbW9uMzE3NTU4NSIsImV4cCI6MTU4MTk5NjgxMywiaWQiOjQsInYiOjEsInR5cCI6ImF1dGgifQ.AClqeOT6yAQCjGMYfXaMlDVgAcVOftGy3TSCrjxWat-Iz2yFut5nP4wntnE1xas3VtieFbxVwffbhmXwngPhHi8VAEFPPoaCD11unJ5_VTVWJkwnx73Eq8L2sbI9abLVM_CXXXXXXXXXXXXXX' \
    --data-raw '{
      "name": "test12-test2",
      "xid": "test12-test2",
      "dataSourceXid" : "test12",
      "pointLocator" : {
           "startValue" : "0",
           "modelType" : "PL.VIRTUAL",
           "dataType" : "NUMERIC",
           "settable" : true,
           "changeType" : "NO_CHANGE",
           "max": 100,
           "maxChange": 0.01,
           "min": 0
        }
    }'
    

    Results in error: 422 Unprocessable Entity

    {
      "result": {
        "messages": [
          {
            "level": "ERROR",
            "message": "Must retain permission",
            "property": "readPermission"
          },
          {
            "level": "ERROR",
            "message": "Must retain permission",
            "property": "setPermission"
          }
        ]
      },
      "mangoStatusCode": 4002,
      "mangoStatusName": "VALIDATION_FAILED",
      "localizedMessage": "Validation failed"
    }
    

    posted in User help read more
  • B
    Balistar

    Naturally. But that was set already:

    0_1581992332387_Image 129.jpg

    posted in User help read more
  • B
    Balistar

    Thanks for your fast response.

    I am probably missing something.

    New DataSource created by Admin. User (emon3175585) given permission to edit the DataSource.

    0_1581985065225_Image 127.jpg

    Yet, when user (emon3175585) logs in, the user cannot create new DataPoint.

    0_1581985190960_Image 128.jpg

    posted in User help read more
  • B
    Balistar

    Fox. Running Core 3.7.3.

    Admin creates new USER. Admin creates DataSource and gives READ and WRITE access to new user ONLY for that DataPoint.

    New USER can EDIT DataSource, but cannot create DataPoints .Both through GUI and API with JWT.

    Once Admin Creates a new DataPoint for that DataSource new user can edit that DataPoint.

    The intent of Permission to a DataSource works correctly after Admin has created one and assigned read/write permissions for that DataSource to a User, that User has edit/set ability to all DataPoints of that DataSource without that user having explicit read/write permission to those DataPoints. I guess permission inheritance works for this.

    posted in User help read more
  • B
    Balistar

    A attempt will be awarded a 422 http code. "Must retain permission". Not a 401 "Not Authorized". So perhaps I am missing something.

    I am not sure if this makes sense. If the admin chooses to give a user edit access to a DataSource, it seems logical that that user should also be able to create DataPoints. If the admin is concerned with DataSource security, the admin should not give the user edit permission to the DataSource, but only to DataPoints.

    posted in User help read more
  • B
    Balistar

    Thanks Terry,

    Almost. Mango API needs double quotes around names and values. Anyway this works:

    {
      "name": "emon3175585-19",
      "xid": "emon3175585-19", <-- no need if you want Mango to auto create
      "dataSourceXid" : "emon3175585",
      "enabled": true,
      "pointLocator" : {
           "startValue" : "0",
           "modelType" : "PL.VIRTUAL",
           "dataType" : "NUMERIC",
           "settable" : true,
           "changeType" : "NO_CHANGE"
        }
    }
    

    To add a few more codes:
    201 - Created
    403 - no authorization

    posted in User help read more
  • B
    Balistar

    To start with there is nothing at http://MANGO-IP:8080/rest/v2/swagger/v2/api-docs

    Nor can I find any detailed information.

    Specifically I would like to know the required minimum json values for

    PUT /rest/v2/data-points (create data-point)

    The example in Swagger lists all values, but there is no indication which values are required and which values are set to default when left out. The full PUT request to create a point is (relatively) large 1634 bytes for the request data below.

    Also, I am looking for a list of error codes for each API.

    {
      "xid": "Dummy12345-1",
      "name": "Dummy12345-1",
      "enabled": true,
      "deviceName": "dummy12345",
      "readPermission": "",
      "setPermission": "",
      "pointFolderId": 0,
      "purgeOverride": false,
      "pointLocator": {
        "max": 100,
        "min": 0,
        "maxChange": 0.1,
        "startValue": "50",
        "modelType": "PL.VIRTUAL",
        "dataType": "NUMERIC",
        "settable": true,
        "changeType": "BROWNIAN",
        "values": []
      },
      "chartColour": "",
      "loggingProperties": {
        "cacheSize": 1,
        "loggingType": "INTERVAL",
        "tolerance": 0,
        "discardExtremeValues": false,
        "intervalLoggingType": "AVERAGE",
        "intervalLoggingPeriod": {
          "periods": 1,
          "type": "MINUTES"
        },
        "overrideIntervalLoggingSamples": false
      },
      "textRenderer": {
        "type": "textRendererAnalog",
        "format": "0.00",
        "suffix": "",
        "useUnitAsSuffix": false
      },
      "chartRenderer": {
        "type": "chartRendererImage",
        "timePeriod": {
          "periods": 1,
          "type": "DAYS"
        }
      },
      "rollup": "NONE",
      "simplifyType": "NONE",
      "simplifyTolerance": "NaN",
      "simplifyTarget": 1000,
      "templateXid": null,
      "dataSourceXid": "dummy12345",
      "tags": {},
      "plotType": "SPLINE",
      "dataSourceTypeName": "VIRTUAL"
    }
    

    posted in User help read more
  • B
    Balistar

    Solution is to use REST API instead.

    curl -X POST "http://192.168.1.2:8080/rest/v2/point-values?fireEvents=NEVER"

    API follows JSON syntax "Square brackets hold arrays and values are separated by ,(comma)"

    [
      {
        "annotation": "",
        "dataType": "NUMERIC",
        "timestamp": 1576117390000,
        "value": 227.1,
        "xid": "DP_a9b3bce6-98ea-493a-b840-2450f3ffc3ae"
      },
      {
        "annotation": "",
        "dataType": "NUMERIC",
        "timestamp": 1576117400000,
        "value": 228.1,
        "xid": "DP_a9b3bce6-98ea-493a-b840-2450f3ffc3ae"
      },
        {
        "annotation": "",
        "dataType": "NUMERIC",
        "timestamp": 1576117410000,
        "value": 229.1,
        "xid": "DP_a9b3bce6-98ea-493a-b840-2450f3ffc3ae"
      },
      {
        "annotation": "",
        "dataType": "NUMERIC",
        "timestamp": 1576117342000,
        "value": 220.1,
        "xid": "DP_a9b3bce6-98ea-493a-b840-2450f3ffc3ae"
      }
    ]
    

    Full CURL with this body:

    curl -X POST "http://192.168.1.2:8080/rest/v2/point-values?fireEvents=NEVER" -H "accept: application/json;charset=UTF-8" -H "Content-Type: application/json;charset=UTF-8" -H "X-XSRF-TOKEN: 58594b34-9a0d-4417-9b23-xxxx" -d "[ { \"annotation\": \"\", \"dataType\": \"NUMERIC\", \"timestamp\": 1576117390000, \"value\": 227.1, \"xid\": \"DP_a9b3bce6-98ea-493a-b840-2450f3ffc3ae\" }, { \"annotation\": \"\", \"dataType\": \"NUMERIC\", \"timestamp\": 1576117400000, \"value\": 228.1, \"xid\": \"DP_a9b3bce6-98ea-493a-b840-2450f3ffc3ae\" }, { \"annotation\": \"\", \"dataType\": \"NUMERIC\", \"timestamp\": 1576117410000, \"value\": 229.1, \"xid\": \"DP_a9b3bce6-98ea-493a-b840-2450f3ffc3ae\" }, { \"annotation\": \"\", \"dataType\": \"NUMERIC\", \"timestamp\": 1576117342000, \"value\": 220.1, \"xid\": \"DP_a9b3bce6-98ea-493a-b840-2450f3ffc3ae\" }]"
    

    posted in How-To read more