Skip to end of metadata
Go to start of metadata

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

Compare with Current View Page History

« Previous Version 2 Next »

To set up the ENAPSO together Free platform on your end and learn how to manage SPARQL templates effectively, please follow the instructions on this Confluence page. Once you have completed the setup, you can proceed with the steps below to create REST APIs for managing CRUD operations for each class.

This documentation provides a step-by-step guide to creating REST APIs for managing CRUD operations for each class using SPARQL templates on the ENAPSO together Free platform. By following these instructions, you will be able to automate and enhance the interactivity of your system through RESTful services.

Access the Swagger Documentation

Navigate to the View Management Service documentation in your web browser. This interface provides access to all the necessary endpoints for managing and executing SPARQL templates.

Create Endpoints for CRUD Operations

  1. Find the create-endpoint-4-template endpoint, which is used for setting up new REST APIs for each SPARQL template.

  2. Click on the "Try it out" button to enable interactive usage of this endpoint.

  3. Configure the Endpoint Details

    • In the records array, you will configure each CRUD operation as a separate object. Hereโ€™s how you can set up each endpoint for the EditorialObject class:

      {
          "records": [
              {
                  "endpoint": "editorialObject",
                  "baseURL": "/v1",
                  "endpointConfig": [
                      {
                          "method": "get",
                          "template": "readEditorialObject"
                      },
                      {
                          "method": "post",
                          "template": "createEditorialObject"
                      },
                      {
                          "method": "put",
                          "template": "updateEditorialObject"
                      },
                      {
                          "method": "delete",
                          "template": "deleteEditorialObject"
                      }
                  ]
              }
          ]
      }
    • Variable Descriptions

      • records: This array holds one or more configuration objects. Each object defines a set of CRUD operations associated with a specific endpoint.

        • endpoint: This string specifies the name of the endpoint. It acts as a part of the URL path where the API will be accessible. For example, "editorialObject" results in a REST endpoint that could be accessed via ${baseURL}/editorialObject.

        • baseURL: This is the base path under which the endpoint will be grouped. For instance, "/v1" indicates that the endpoint will be accessed under the version 1 group, forming part of the complete URL path.

        • endpointConfig: An array of objects where each object specifies a CRUD operation and the associated settings:

          • method: The HTTP method (e.g., "get", "post", "put", "delete") that determines what kind of operation this endpoint will perform. This corresponds to the CRUD operation:

            • "get" for reading or retrieving data,

            • "post" for creating new data,

            • "put" for updating existing data,

            • "delete" for removing data.

          • template: The name of the SPARQL template that will be executed when this endpoint is called. It ties the REST API directly to a predefined SPARQL operation within the database management system.

  4. Execute the Configuration:

    • After entering all the necessary details, click on the "Execute" button. A successful request will create REST endpoints for each configured operation.

    • The response will indicate success, confirming that the endpoints are now set up and ready for use.

Using the REST API

  1. Execute API Calls:

    • With the REST API configured, you can now use tools like Postman or any programming language that supports HTTP requests to interact with these endpoints.

    • For example, to send a GET request to retrieve data, you could use a curl command like this:

      curl -X GET http://localhost/enapso-dev/view-management/v1/editorialObject
    • Similarly, to create, update, or delete entries, configure your POST, PUT, or DELETE requests with the variables object in the POST body. This object contains key-value pairs that are necessary for the request.

Summary

This setup enables you to fully utilize the RESTful interface of the ENAPSO together Free platform, integrating seamlessly with your existing workflows and enhancing data manipulation capabilities through programmatically accessible endpoints.

By following these steps, users can effectively create and manage REST APIs for CRUD operations, empowering them to perform sophisticated data interactions directly through HTTP requests.

  • No labels