As an Admin, you can enable the Db2 REST interface for an existing Watson
Query
deployment on Cloud Pak for Data.
Before you begin
Required role: To enable the Db2 REST interface, you must have the Watson
Query Admin role.
Note:
Db2 REST API endpoints are defined as
stored procedures in Db2. By default, if your
API endpoint queries data from tables, the query impersonates the API endpoint definer. As a
result, the Watson
Query authorizations and Watson Knowledge
Catalog data protection rules that apply to the definer
of the API endpoint, rather than to the caller of the API, are enforced when the API is called. To
use the permissions of the caller of the API, set the isDefiner parameter to
false when you define the Db2 REST service.
Procedure
To enable the Db2 REST interface in Watson
Query, follow these steps.
- When you provision the Watson
Query service instance, you can edit the
db2ucluster
custom resource. Find your db2ucluster
custom resource
by running the following command.
[root@deploysquad2-inf ~]# oc get db2ucluster
The command results match your deployment ID. In the following example,
db2u-dv
.
NAME STATE MAINTENANCESTATE AGE
db2u-dv Ready None 34m
- Run the following command to edit the add-ons file.
oc edit db2ucluster deployment_ID
Set the rest value to enabled: true. The edited file
looks similar to the following example.
addOns:
rest:
enabled: true
- Run the following command to view the REST service and deployment information.
oc get formations.db2u.databases.ibm.com db2u-dv -o go-template='{{range .status.components}}{{printf "%s,%s,%s\n" .kind .name .status.state}}{{end}}' | column -s, -t
The results look similar to the following example:
service c-db2u-dv-db2u-rest-svc Creating
Deployment c-db2u-dv-rest Creating
- Run the following command to view the REST pod as part of your deployment.
oc get pods |grep db2
The following example highlights the REST pod.
c-db2u-dv-db2u-0 1/1 Running 0 39m
c-db2u-dv-etcd-0 1/1 Running 0 39m
c-db2u-dv-instdb-df7hh 0/1 Completed 0 40m
c-db2u-dv-ldap-64bc6d58dc-ms29x 1/1 Running 0 40m
c-db2u-dv-rest-66f7fcb7d4-98fbh 1/1 Running 0 86s
c-db2u-dv-restore-morph-bkfpr 0/1 Completed 0 39m
c-db2u-dv-tools-57bc7d4ddf-wz8fr 1/1 Running 0 40m
db2u-operator-5999cd944b-dwgrr 1/1 Running 0 17m
Note the REST pod name, which is used to run documented REST commands.