DS Service Registry Quickstart Guide

Notes

  • This tutorial is only for learning to use the Service Registry (LinkSmart Service Catalog) to register and retrieve service metadata.
  • Only the cloud-native, Production environment instance of the Data Spine Service Registry must be used by the EFPF ecosystem users.

Learning with a local instance of Service Registry

  • Install and run: docker run -d --name serviceregistry -p 8082:8082 linksmart/sc
  • Retrieve Service Registry’s index page that displays all the registered services in a Web browser (or use Postman or cURL): http://localhost:8082/
  • Register (PUT) a new service with a custom id test-service-1:
curl --location --request PUT 'localhost:8082/test-service-1' \
--header 'Content-Type: application/json' \
--data-raw '{
   "id": "test-service-1",
   "type": "efpf.testservice",
   "title": "Test Service from the EFPF platform",
   "description": "Test Service from the EFPF platform to be used as an example in the Data Spine Service Registry Quickstart Guide.",
   "meta": {},
   "apis": [{
      "id": "test-api-1",
      "title": "Test API 1",
      "description": "Some description",
      "url": "https://ds-test.smecluster.com/p1/exp/",
      "spec": {
         "mediaType": "application/vnd.oai.openapi+json;version=3.0",
         "url": "https://docs.efpf.linksmart.eu/projects/data-spine-nifi/apidoc/examples-swagger.json",
         "schema": {}
      },
      "meta": {}
   }],
   "doc": "https://docs.efpf.linksmart.eu/swagger-ui/?url=https://docs.efpf.linksmart.eu/projects/data-spine-nifi/apidoc/examples-swagger.json",
   "ttl": 600
}'

Note: As the ttl is set to 600 sec, the Service Registry will automatically delete this service with Id test-service-1 after 600 sec. Therefore, update the ttl as required while registering a service.

  • Retrieve Service Registry’s index page again to check if it displays the test-service-1 service: http://localhost:8082/
  • Alternatively, you can retrieve only the test-service-1 service: http://localhost:8082/test-service-1
  • Check the Service Registry User Guide for more information.

Learning with the cloud-native Test environment instance of Service Registry

  • Access to the shared, cloud-native instance of the Data Spine (DS) Service Registry is secured using the EFPF Security Portal (EFS).
  • As a prerequisite, you must have an EFPF user account, and obtain an access token for accessing the DS Service Registry.
  • You would need the efpf_basic role to view the services registered in the DS Service Registry and the efpf_sr_admin role to register/update your services. Refer to the User Guide 101 and Service Registry User Guide for more details.
  • The following tutorial contains the URLs for the Test environment instances of components. You would need to get these URLs replaced with the Production environment ones, listed on the Connection Details page.
  • Here, it is assumed that you already have an EFPF user account and the efpf_sr_admin role
  • Obtain the access token from the EFS as given below (For the latest documentation on getting a token, see the API Security Gateway and EFS documentation):
curl --location --request POST 'https://ds-test.smecluster.com/auth/realms/master/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id=apisix' \
--data-urlencode 'client_secret=replace_this_with_apisix_client_secret' \
--data-urlencode 'username=replace_this_with_your_email_id@example.org' \
--data-urlencode 'password=replace_this_with_your_password'
  • Retrieve DS Service Registry’s index page that displays all the registered services, using Postman or cURL:
curl --location --request GET 'https://ds-test.smecluster.com/apis/sr/' \
--header 'Authorization: Bearer replace_this_with_token'
  • Register (PUT) a new service with a custom id test-service-1:
curl --location --request PUT 'https://ds-test.smecluster.com/apis/sr/test-service-1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer replace_this_with_token' \
--data-raw '{
   "id": "test-service-1",
   "type": "efpf.testservice",
   "title": "Test Service from the EFPF platform",
   "description": "Test Service from the EFPF platform to be used as an example in the Data Spine Service Registry Quickstart Guide.",
   "meta": {},
   "apis": [{
      "id": "test-api-1",
      "title": "Test API 1",
      "description": "Some description",
      "url": "https://ds-test.smecluster.com/p1/exp/",
      "spec": {
         "mediaType": "application/vnd.oai.openapi+json;version=3.0",
         "url": "https://docs.efpf.linksmart.eu/projects/data-spine-nifi/apidoc/examples-swagger.json",
         "schema": {}
      },
      "meta": {}
   }],
   "doc": "https://docs.efpf.linksmart.eu/swagger-ui/?url=https://docs.efpf.linksmart.eu/projects/data-spine-nifi/apidoc/examples-swagger.json",
   "ttl": 100
}'

Note: As the ttl is set to 600 sec, the Service Registry will automatically delete this service with Id test-service-1 after 600 sec. Therefore, update the ttl as required while registering a service.

  • Retrieve Service Registry’s index page again to check if it displays the test-service-1 service:
curl --location --request GET 'https://ds-test.smecluster.com/apis/sr/' \
--header 'Authorization: Bearer replace_this_with_token'
  • Alternatively, you can retrieve only the test-service-1 service:
curl --location --request GET 'https://ds-test.smecluster.com/apis/sr/test-service-1' \
--header 'Authorization: Bearer replace_this_with_token'

Data Spine Service Registry Documentation

Next