Kok Sing Khong
2 min readMar 29, 2019

API Connect v2018.x provides a new command line interface (CLI) that has a rich set of functionalities to manage your topology. Today, we will try to make use of the CLI to export products and APIs from the ‘develop’ (draft) mode of an old organization to the ‘develop’ (draft) mode of the new organization.

Assume I have the following environment

  1. The hostname of the API manager is manager.think.org
  2. We are using the default Local User Registry, therefore, the realm is provider/default-idp-2.
  3. There are two organizations, aptly named oldthink for the source organization and newthink for the target organization.

Next are the steps to prepare the environment/script and run the script.

  1. Download the file (toolkit-linux_lts_v2018.4.1.3.tgz) from IBM Fix Central.
  2. Untar the file
tar -zvxf toolkit-linux_lts_v2018.4.1.3.tgz

3. Copy the extracted file into /usr/local/bin

sudo cp -p apic-slim /usr/local/bin/apic-slim

4. Create a script export-import-draft-products.sh with the following. Modify the variables if you need to. Remember to do chmod to make the script executable.

set +eREALM=provider/default-idp-2
SERVER=manager.think.org
USER=<your_user>
PASS=<your_pass>
OLD_ORGNAME=oldthink
NEW_ORGNAME=newthink
apic-slim login -r $REALM -s $SERVER -u $USER -p $PASS
apic-slim draft-products:clone -s $SERVER -o $OLD_ORGNAME
for YAML_FILE in $(ls -v ./*.yaml); do
if grep -q product: "$YAML_FILE"; then
# This is a product file
echo 'Import' $YAML_FILE 'from' $OLD_ORGNAME 'to' $NEW_ORGNAME
apic-slim draft-products:create -o $NEW_ORGNAME -s $SERVER $YAML_FILE
fi
done
set -e

5. Finally, run the script.

./export-import-draft-products.sh

You should see the exported yaml files for the Products and APIs in the cwd (current working directory).

Disclaimer:

All opinions expressed here are very much my own and not of IBM. All codes/scripts/artifacts are provided as-is with no support unless otherwise stated.

Kok Sing Khong
Kok Sing Khong

No responses yet