Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Updating all data trees under an anchor with root node xPath "/"

    CURL request to update all data trees

    Code Block
    curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2F' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0iyclt1syzfqj28jzo5qc5gks1.node0' \
    --data '{
      "multiple-data-tree:interface-A": {
        "host-name": "host-A",
        "interface": [
          {
            "name": "Interface-A",
            "address": "10.10.10.100",         //Updated Value
            "subnet-mask": "255.255.255.25",
            "enabled": false
          }
        ],
        "domain": "true"
      },
      "multiple-data-tree:interface-B": {
        "interface": [
          {
            "name": "Interface-B",
            "address": "10.10.10.1100",
            "subnet-mask": "255.255.255.0"
          }
        ]
      }
    }'

    Response: 500 Server Error

    Code Block
    {
        "status": "500 INTERNAL_SERVER_ERROR",
        "message": "could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement",
        "details": "Check logs for details."
    }


    On performing Get operation we get the following JSON data

    Code Block
    [
        {
            "int:interface-A": {
                "domain": "false",
                "host-name": "host",
                "interface": [
                    {
                        "name": "Interface-A",
                        "address": "10.10.10.1",
                        "enabled": false,
                        "subnet-mask": "255.255.255.0"
                    }
                ]
            }
        },
        {
            "int:interface-B": {
                "interface": [
                    {
                        "name": "Interface-B",
                        "address": "10.10.10.1",
                        "subnet-mask": "255.255.255.0"
                    }
                ]
            }
        }
    ]


  2. Updating the first data tree
    CURL request to update first data tree

    Code Block
    curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2Finterface-A' \
    --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0iyclt1syzfqj28jzo5qc5gks1.node0' \
    --data '{
            "int:interface": {
                "name": "Interface-A",
                "address": "10.10.10.200",
                "enabled": true,
                "subnet-mask": "255.255.255.0"
            }
        }'

    Response 200 OK
    Updated data after making get request

    Code Block
    [
      {
        "int:interface-A": {
          "domain": "false",
          "host-name": "host",
          "interface": [
            {
              "name": "Interface-A",
              "address": "10.10.10.200",
              "enabled": true,
              "subnet-mask": "255.255.255.0"
            }
          ]
        }
      }
    ]


  3. Updating the second data tree
    CURL request to update second data tree

    Code Block
    curl --location --request PATCH 'http://localhost:8080/cps/api/v1/dataspaces/testDataspace/anchors/sample/nodes?xpath=%2Finterface-B' \
    --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic Y3BzdXNlcjpjcHNyMGNrcyE=' --header 'Cookie: JSESSIONID=node0iyclt1syzfqj28jzo5qc5gks1.node0' \
    --data '{
            "int:interface": {
                "name": "Interface-B",
                "address": "10.10.10.200",
                "subnet-mask": "255.255.255.10"
            }
        }'

    Response 200 OK
    Updated data after making get request

    Code Block
    [
      {
        "int:interface-B": {
          "interface": [
            {
              "name": "Interface-B",
              "address": "10.10.10.200",
              "subnet-mask": "255.255.255.10"
            }
          ]
        }
      }
    ]