This document outlines the process of creating a REST API to manage instances of a class using CRUD SPARQL Templates in the ENAPSO together View Management Service.

Prerequisites

Before creating a REST API, you must first define the necessary CRUD SPARQL Templates for managing instances of a class. You can follow the instructions on the following Confluence page to create these templates:

Creating CRUD SPARQL Templates

Once the templates are created, you can proceed with setting up the REST API.

Creating REST API Endpoints for SPARQL Templates

To create REST API endpoints for the defined SPARQL templates, send a request to the following endpoint:

POST /v1/create-endpoint-4-template

Request Payload Format

{
    "records": [
        {
            "endpoint": "domain",
            "baseURL": "/v1",
            "endpointConfig": [
                {
                    "method": "get",
                    "template": "getListOfDomain"
                },
                {
                    "method": "post",
                    "template": "createDomain"
                },
                {
                    "method": "put",
                    "template": "updateDomain"
                },
                {
                    "method": "delete",
                    "template": "deleteDomain"
                }
            ]
        }
    ]
}

Request Parameters Explanation

Expected Response

{
    "status": 200,
    "message": "Route Created Successfully",
    "success": true,
    "records": [
        {"success": true, "status": 200, "message": "Route GET /v1/domain created successfully."},
        {"success": true, "status": 200, "message": "Route POST /v1/domain created successfully."},
        {"success": true, "status": 200, "message": "Route PUT /v1/domain created successfully."},
        {"success": true, "status": 200, "message": "Route DELETE /v1/domain created successfully."}
    ]
}

Using the Created Endpoints

Once the endpoints are successfully created, you can send requests to them with the required variables.

Create an Instance (POST /v1/domain)

{
    "variables": {
        "domainValues": [
            {"domain": "Check New", "language": "en"},
            {"domain": "Hallo New", "language": "de"}
        ]
    }
}

2. Read Data (GET /v1/domain)

Send a GET request with query parameters:

GET /v1/domain?limit=1&offset=5&language=fr&calculateTotal=true&countPropertyName=?iri

Query Parameters:

3. Update an Instance (PUT /v1/domain)

{
    "variables": {
        "domainIRI": "http://ont.enapso.com/companion/data#Domain_a06a7605-d374-47b1-b2bb-e4512df04cc7",
        "domainValues": [
            {"domain": "Hell", "language": "en"},
            {"domain": "Hollo", "language": "fr"}
        ]
    }
}

4. Delete an Instance (DELETE /v1/domain)

{
    "variables": {
        "domain": "Hell"
    }
}

Conclusion

Following the steps above, you can successfully create and manage REST API endpoints for CRUD operations on SPARQL templates using the ENAPSO together View Management Service.