Importing the Business Scopes using Knowledge Accelerators API

A project administrator can import each Knowledge Accelerators Business Scope into Watson Knowledge Catalog using an API call.

The following method sets a number of environment variables and calls the import_items API to import the business scopes directly into Watson Knowledge Catalog.

Tip: The API calls for the Knowledge Accelerators can be found at https://cloud.ibm.com/apidocs/watson-data-api#getknowledgeaccelerators.

Requirements and permissions

Offering plan
You can add Knowledge Accelerators to your governance framework as part of the IBM Cloud Pak for Data platform.
Required permissions
You must have this user permission to import the Knowledge Accelerators:
  • Manage governance categories

Setting your environment variables

Use the following commands to set the variables used in the import command: CPD_URL; TOKEN; KA_IND and KA_IDS.
  1. Set your IBM Cloud Pak for Data URL, for example https://cpd-wkc.apps.host.company.com:
    export CPD_URL={CPD_URL}
    To check the value of the $CPD_URL variable, run this command:
    echo $CPD_URL
  2. Generate your token using your API_KEY. To get your API key, see Generating API keys for authentication.
    curl -k -X POST $CPD_URL/icp4d-api/v1/authorize -H 'cache-control: no-cache' -H 'content-type: application/json' -d '{"username":"admin","api_key":"{API_KEY}"}'
    You should get output similar to:
    {"_messageCode_":"200","message":"Success","token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik1PamZFMGNVR2FFe..."}
  3. To set the TOKEN variable, copy and paste the token value into the following command:
    export TOKEN={TOKEN}
    For example: export TOKEN=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik1PamZFMGNVR2FFe...
    To check the value of the TOKEN variable, run this command:
    echo $TOKEN
  4. Set the KA_IND variable for the Knowledge Accelerator industry, see Table 1 for {ka_id} values:
    export KA_IND={ka_id}
    Table 1. {ka_id} values for each industry
    Cross Industry Energy and Utilities Financial Services Healthcare Insurance
    kaci20
    kaeu20
    kafs20
    kahc20
    kain20
    To check the value of the KA_IND variable, run this command:
    echo $KA_IND
  5. Set the KA_IDS variable for the single scope you want to import. Ensure you select a scope from the industry you set in the previous step. See Table 2 for {scope_id} values:
    export KA_IDS={scope_id}
    Note: Select only one business scope at a time.
    Table 2. {scope_id} values for each industry
    Cross Industry Energy and Utilities Financial Services Healthcare Insurance
    contact-center power-network-assets banking-customers clinical-order---imaging claim-management
    personal-data gas-network-assets credit-cards health-plan-product---features-and-benefits vehicle-accident
    weather-insights network-asset-measurements loans-and-mortgages patient-administration---adt vehicle-information
      utility-customer aml-suspicious-transactions patient-practitioner contact-information
      metering-and-usage-point credit-risk-mitigation personal-health-record---continuity-of-care customer-360
        payments-data submitted-healthcare-claim party
            policy-management
            premium-management
    For a definition and more information on the content of each of the business scopes, see the following links: To check the value of the KA_IDS variable, run this command:
    echo $KA_IDS

Importing Business Scopes

You import each of the business scopes for a Knowledge Accelerator industry using the import_items API call.

  1. To check what is going to be imported in advance, run the following command:
    curl -X POST "$CPD_URL/v1/knowledge_accelerators/$KA_IND/import_items?ids=$KA_IDS&merge_option=all" -k -s -H "Authorization: Bearer $TOKEN"
    Result example:
    {
      "message": "KA004I: The import has been evaluated. If ready to import, please repeat call with the 
       parameter do_import\u003dtrue.",
      "import_evaluation": {
        "knowledge_accelerator": "CPD_URL/v1/knowledge_accelerators/kaci20",
        "items": [
          {
            "id": "personal-data",
            "evaluation": "import",
            "reason": "user_selected"
          }
        ]
      }
    }
  2. Import the selected Knowledge Accelerator Business Scope using the following command:
    curl -X POST "$CPD_URL/v1/knowledge_accelerators/$KA_IND/import_items?ids=$KA_IDS&merge_option=all&do_import=true" -k -s -H "Authorization: Bearer $TOKEN"
    Result example:
    {
      "message": "The import has been submitted, please check url below for update status",
      "process_id": "CPD_URL/v3/governance_artifact_types/import/status
       /9ad7169b-adea-4a13-9e92-411b073934ae",
      "import_evaluation": {
        "knowledge_accelerator": "CPD_URL/v1/knowledge_accelerators/kaci20",
        "items": [
          {
            "id": "personal-data",
            "evaluation": "import",
            "reason": "user_selected"
          }
        ]
      }
    }
    Tip: Take note of the "process_id" as you can use this to check the status of the import job.

    Note: The link that is listed in the response does not open in your browser as the bearer token is needed. Use the curl command from the Checking which Knowledge Accelerators are installed section to check the status of the import.

  3. To import another business scope, repeat steps 4 and 5 to set the KA_IND and KA_IDS variables.

Checking which Knowledge Accelerators are installed

You can check which Knowledge Accelerators are imported into an instance of Watson Knowledge Catalog by using the following command:
curl -X GET "$CPD_URL/v1/knowledge_accelerators/import_items" -k -s -H "Authorization: Bearer $TOKEN"

This command returns a listing of any Knowledge Accelerator categories that are already imported into the Watson Knowledge Catalog instance.

Output example:
{
  "message": "KA008I: The following knowledge accelerator items are imported",
  "import_evaluation": [
    {
      "knowledge_accelerator": "CPD_URL/v1/knowledge_accelerators/kaci20",
      "items": [
        {
          "id": "personal-data",
          "evaluation": "imported_at_undeterminable_version",
          "latest_version": "2.0.20220520"
        }
      ]
    }
  ]
}

Adding collaborators

You need to add collaborators to the Knowledge Accelerators categories, otherwise only the person who imports the accelerator can use the artifacts. See Managing access to a category for details on how to do this.

Optional import parameters

The following parameters can be changed in the POST import_items command:

Mandatory query parameters
merge_option [string]
No default value so a value must be specified.
Value Description
all Imported values replace existing values in catalog.
specified Imported values that are not empty replace existing values in catalog.
empty Imported values replace only empty values in catalog.
Optional query parameters
do_import [boolean]
The default value is false.
Value Description
false Does all the logic checking and indicate what going to be imported, useful for checking in advance of doing the import.
true At the end of logic checking, triggers the import and returns a process id to the user.