You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

To support XML content type for CPS API's



References

CPS-2071


Let's say Sample XML Data
<?xml version='1.0' encoding='UTF-8'?>
<bookstore xmlns="org:onap:ccsdk:sample">
    <bookstore-name>Chapters</bookstore-name>
    <categories>
        <code>1</code>
        <name>SciFi</name>
        <books>
            <title>A Space Odyssey</title>
            <lang>en</lang>
            <authors>
                Iain M. Banks
            </authors>
            <pub_year>1994</pub_year>
            <price>895</price>
        </books>
    </categories>
</bookstore> 



Issues & Decisions

APIXpathExpected Output
1. Get a node : GET /v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/node /
Output Response
<?xml version='1.0' encoding='UTF-8'?>
<bookstore xmlns="org:onap:ccsdk:sample">
    <bookstore-name>Chapters</bookstore-name>
    <categories>
        <code>1</code>
        <name>SciFi</name>
        <books>
            <title> A Space Odyssey</title>
            <lang>en</lang>
            <authors>
                Iain M. Banks
            </authors>
            <pub_year>1994</pub_year>
            <price>895</price>
        </books>
    </categories>
</bookstore>
2. Update node leaves : PATCH /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes/bookstore/categories[@code=1]
Output Response
<?xml version='1.0' encoding='UTF-8'?>
<bookstore xmlns="org:onap:ccsdk:sample">
      <code>1</code>
      <name>some-name</name>
</bookstore>

3. Replace a node with descendants: PUT /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes

/bookstore/categories[@code=1]

Here node will be replaced by child nodes

4. Add list element(s):  POST /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/list-nodes

/bookstore/categories[@code=1]


Output Response
<?xml version='1.0' encoding='UTF-8'?>
<bookstore xmlns="org:onap:ccsdk:sample">
    <bookstore-name>Chapters</bookstore-name>
    <categories>
        <code>1</code>
        <name>SciFi</name>
        <books>
            <title>A Space Odyssey</title>
            <lang>en</lang>
            <authors>
                Iain M. Banks
            </authors>
            <pub_year>1994</pub_year>
            <price>895</price>
            <title>unknown</title>
            <lang>english</lang>
            <authors>
                Maxwell
            </authors>
            <pub_year>1998</pub_year>
            <price>1000</price>
       </books>
    </categories>

5. Replace list content:  PUT /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/list-nodes

 /bookstore/categories[@code=1]
Output Response
<?xml version='1.0' encoding='UTF-8'?>
<bookstore xmlns="org:onap:ccsdk:sample">
    <bookstore-name>Chapters</bookstore-name>
    <categories>
        <code>1</code>
        <name>SciFi</name>
        <books>
            <title> A Space Odyssey</title>
            <lang>Economics</lang>
            <authors>
                John smith
            </authors>
            <pub_year>1997</pub_year>
            <price>995</price>
        </books>
    </categories>
</bookstore>

6. Query data nodes: GET /v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes/query

//books[@title=" A Space Odyssey"]

Output Response
<?xml version='1.0' encoding='UTF-8'?>
<bookstore xmlns="org:onap:ccsdk:sample">
        <books>
            <title> A Space Odyssey</title>
            <lang>en</lang>
            <authors>
                Iain M. Banks
            </authors>
            <pub_year>1994</pub_year>
            <price>895</price>
        </books>
</bookstore>

7. Query data nodes across anchors: GET /v2/dataspaces/{dataspace-name}/nodes/query

//books[@title=" A Space Odyssey"]

Output Response
<?xml version='1.0' encoding='UTF-8'?>
<bookstore xmlns="org:onap:ccsdk:sample">
        <books>
            <title> A Space Odyssey</title>
            <lang>en</lang>
            <authors>
                Iain M. Banks
            </authors>
            <pub_year>1994</pub_year>
            <price>895</price>
        </books>
</bookstore>
  • No labels