Reference 360 > Reference 360 REST API > Using REST APIs to manage hierarchies
  

Using REST APIs to manage hierarchies

You can use the Reference 360 REST APIs to manage hierarchies.

REST APIs to manage hierarchies

You can use a set of REST APIs to list hierarchies, list hierarchy details, list hierarchy model relationships, and import hierarchy relationships.
The following table describes the REST APIs for managing hierarchies:
REST API
Description
List hierarchies
Retrieves all hierarchies.
List hierarchy details
Retrieves the details of a hierarchy, such as the properties and status.
List hierarchy model relationships
Retrieves the relationships in a hierarchy model.
List hierarchy relationships
Imports top-level code values and relationships into a hierarchy.

Managing hierarchies

You can create hierarchies to show hierarchical relationships between code values in multiple code lists. A hierarchy consists of two components: the hierarchy model and the hierarchy tree. In the hierarchy model, you define the top-level code list and add relationships to other code lists. Then based on the hierarchy model, you can create the hierarchy tree and define relationships between the code values in the code lists.
For example, you might create a location hierarchy. First, you define the hierarchy model. You define the Region code list as the top-level code list. Then you create a parent-child relationship from the Region code list to the Enterprise Country Codes code list. Based on this hierarchy model, in the hierarchy, you create a hierarchy relationship from the North America code value to the United States code value. You create a hierarchy relationship from the North America code value to the Canada code value.
To create and manage hierarchies, perform the following actions:
  1. 1In Reference 360, create the hierarchy asset and define the hierarchy model. For more information, see Creating hierarchy models.
  2. 2Use the List hierarchies REST API to retrieve all hierarchies.
  3. 3Use the List hierarchy model relationships REST API to retrieve the relationships in a hierarchy model.
  4. 4Use the Import hierarchy relationships REST API to import relationships in a hierarchy tree.

Step 1. Get hierarchies

You can retrieve all hierarchies in Reference 360.
Before you begin, you must get a session ID. The session ID authenticates your requests. For more information, see Session IDs.
    1To retrieve all hierarchies, use the List hierarchies REST API.
    For more information about the List hierarchies REST API, see Get hierarchies.
    For example, the following request retrieves all hierarchies:
    GET https://use4-mdm.dm-us.informaticacloud.com/rdm-service/external/v1/hierarchies HTTP/1.1
    Accept: application/json
    IDS-SESSION-ID: XXXXXXXXXXXXXXXXXXXXXX
    For example, the List hierarchies REST API returns the following hierarchies:
    HTTP/1.1 200 OK
    Content-Type: application/json;charset=UTF-8
    Content-Length: 452
    IDS-SESSION-ID: XXXXXXXXXXXXXXXXXXXXXX

    [
    {
    "id":"6e7dd28fc13b417c5c19d1fb",
    "name":"Cost centers",
    "description":"Cost center hierarchy",
    "version":"v1",
    "domain":"International standards",
    "confidentiality":"private",
    "priority":"Prio1",
    "status":"Draft",
    "effectiveDate":"2017-04-01",
    "approvedOn":"2017-03-01"
    },
    {
    "id":"e3e57e39ea8623f258013c43",
    "name":"Profit centers",
    "description":"Profit center hierarchy",
    "version":"v1"
    }
    ]
    Note: The id attribute is the ID of the hierarchy, which you require for other hierarchy REST APIs.
    2Optionally, to retrieve the details of a hierarchy, use the List hierarchy details REST API.
    For more information about the List hierarchy details REST API, see Get hierarchy details.
    For example, the following request retrieves the details of a hierarchy:
    GET https://use4-mdm.dm-us.informaticacloud.com/rdm-service/external/v1/hierarchies/6e7dd28fc13b417c5c19d1fb HTTP/1.1
    Accept: application/json
    IDS-SESSION-ID: XXXXXXXXXXXXXXXXXXXXXX
    For example, the List hierarchy details REST API returns the following hierarchy details:
    HTTP/1.1 200 OK
    Content-Type: application/json;charset=UTF-8
    Content-Length: 334

    {
    "id":"6e7dd28fc13b417c5c19d1fb",
    "name":"Cost centers",
    "description":"Cost center hierarchy",
    "version":"v1",
    "application":"App1",
    "domain":"Internal standards",
    "confidentiality":"private",
    "priority":"Prio1",
    "status":"Draft",
    "effectiveDate":"2017-04-01",
    "approvedOn":"2020-03-01"
    }

Step 2. Get hierarchy model relationships

You can retrieve the top-level code list and the relationships between code lists in a hierarchy model. Then, based on the hierarchy model, you can import hierarchy relationships between code values in the code lists.
    bulletTo retrieve the relationships in a hierarchy model, use the List hierarchy model relationships REST API.
    For more information about the List hierarchy model relationships REST API, see Get hierarchy model relationships.
    For example, the following request retrieves the relationships in a hierarchy model:
    GET https://use4-mdm.dm-us.informaticacloud.com/rdm-service/external/v1/hierarchies/6e7dd28fc13b417c5c19d1fb/relations HTTP/1.1
    Accept: application/json
    IDS-SESSION-ID: XXXXXXXXXXXXXXXXXXXXXX
    For example, the List hierarchy model relationship REST API returns the following relationships:
    HTTP/1.1 200 OK
    Content-Type: application/json;charset=UTF-8
    Content-Length: 452

    {
    "relations":[
    {
    "child":{
    "codeListId":"8bc955e614df2040968e9d85",
    "codeListName":"Parent Codelist",
    "termId":"28a1320fe7f63cd25b58bef4",
    "termName":"Reference Data Set"
    }
    },
    {
    "parent":{
    "codeListId":"8bc955e614df2040968e9d85",
    "codeListName":"Parent Codelist",
    "termId":"28a1320fe7f63cd25b58bef4",
    "termName":"Reference Data Set"
    },
    "child":{
    "codeListId":"81a714a66863f954a9b60045",
    "codeListName":"First Level Codelist",
    "termId":"28a1320fe7f63cd25b58bef4",
    "termName":"Reference Data Set"
    }
    }
    ]
    }
    The child.codeListId attribute contains the top-level node relationship. For example, the first relationship in the example is the top-level node relationship.

Step 3. Import hierarchy relationships

You can import top-level code values and parent-child relationships into a hierarchy. For example, in a locations hierarchy, you might define the North America code value as a top-level code value. Then you define a relationship from the North America code value to the United States code value. You might also define a relationship from the North America code value to the Canada code value.
    1To import top-level code values into a hierarchy, use the Import hierarchy relationships REST API to specify the CSV file that contains the code values.
    For more information about the Import hierarchy relationships REST API, see Step 3. Import hierarchy relationships.
    For example, the following request imports top-level code values:
    POST https://use4-mdm.dm-us.informaticacloud.com/rdm-service/external/v1/import/hierarchy HTTP/1.1
    Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    IDS-SESSION-ID: XXXXXXXXXXXXXXXXXXXXXX

    --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    Content-Disposition: form-data; name=file; filename=import.csv
    Content-Type: text/plain

    --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    Content-Disposition: form-data; name=importSettings
    Content-Type: application/json;charset=UTF-8

    {
    "delimiter":"COMMA",
    "textQualifier":"DOUBLE_QUOTE",
    "startingRow":0,
    "codepage":"UTF8",
    "hierarchyId":"c79ab91c19b13b11d8d43770",
    "childCodeListId":"96f06071e4aaea81ff203abe"
    }
    --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--
    The CSV file might contain the following header row and data rows:
    Code
    P1
    P2
    P3
    For example, the Import hierarchy relationships REST API returns the following response:
    {
    "jobId":"73580d323feb170be5ec0fd5",
    "state":"INPROGRESS",
    "startTime":1603092643055,
    "numOfRecordsProcessed":100,
    "numOfRecordsFailed":25,
    "numOfRecordsSucceeded":75
    }
    2To import relationships, use the Import hierarchy relationships REST API to specify the CSV file that contains the relationships.
    For more information about the Import hierarchy relationships REST API, see Step 3. Import hierarchy relationships.
    For example, the following request imports relationships:
    POST https://use4-mdm.dm-us.informaticacloud.com/rdm-service/external/v1/import/hierarchy HTTP/1.1
    Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    IDS-SESSION-ID: XXXXXXXXXXXXXXXXXXXXXX

    --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    Content-Disposition: form-data; name=file; filename=import.csv
    Content-Type: text/plain

    --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
    Content-Disposition: form-data; name=importSettings
    Content-Type: application/json;charset=UTF-8

    {
    "delimiter":"COMMA",
    "textQualifier":"DOUBLE_QUOTE",
    "startingRow":0,
    "codepage":"UTF8",
    "hierarchyId":"c79ab91c19b13b11d8d43770",
    "childCodeListId":"96f06071e4aaea81ff203abe",
    "parentCodeListId":"9b300f793470882ca23e6091"
    }
    --6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--
    The CSV file might contain the following header row and data rows:
    Code,ParentCode
    C1,P1
    C2,P2
    C3,P3
    For example, the Import hierarchy relationships REST API returns the following response:
    {
    "jobId":"73580d323feb170be5ec0fd5",
    "state":"INPROGRESS",
    "startTime":1603092643055,
    "numOfRecordsProcessed":100,
    "numOfRecordsFailed":25,
    "numOfRecordsSucceeded":75
    }