Describing a REST SQL service

Create a description for a REST SQL service so that an application programmer who wants to use the service can learn about its inputs and outputs.

  • A service's inputs must be known in order to be able to call it.
  • A service's outputs must be known in order to be able to process its response.
Note: This topic illustrates how to describe a REST SQL service using Python. You can follow a similar procedure to describe services using other programming languages such as Curl, Perl, or JavaScript.
For example, the following code creates a description for the listEmployees service:
def describe_listemployees_service():
    url = "https://%s:50050/v1/services/listemployees/1.0" % (restHostname, name, version)
    headers = {
        "content-type": "application/json",
        "authorization": token
    }

    response = requests.get(url, verify = False, headers = headers, proxies = None, json = None)
    pprint(response.json())
The important component of the response is the resultSetFields section, which describes the fields in each row of the JSON output.
{'grantees': {'groups': None,
              'roles': None,
              'users': [{'grantee': 'BLUADMIN', 'withGrantOption': True}]},
 'inputParameters': [],
 'lastModified': '2019-12-04T18:42:54.259082Z',
 'procName': 'REST_LISTEMPLOYEES_1_0',
 'procSchema': 'BLUADMIN',
 'resultSetFields': [{'jsonType': 'string',
                      'length': 5,
                      'name': 'EMPID',
                      'scale': 0,
                      'type': 'CHARACTER'},
                     {'jsonType': 'string',
                      'length': 100,
                      'name': 'FIRSTNAME',
                      'scale': 0,
                      'type': 'VARCHAR'},
                     {'jsonType': 'string',
                      'length': 100,
                      'name': 'LASTNAME',
                      'scale': 0,
                      'type': 'VARCHAR'}],
 'serviceCreator': 'bluadmin',
 'serviceDescription': 'Description of listemployees',
 'serviceName': 'listemployees',
 'serviceUpdater': 'bluadmin',
 'version': '1.0'}