Table of contents

Administer Watson Studio Local from the command line

You can automate some Watson Studio Local administration tasks using the command line interface (CLI).

Some of the administrative tasks you can automate with the command line interface include:
  • Onboarding a new user in Watson Studio Local and associate them with the appropriate set of projects.
  • Removing users and all of their associated assets from Watson Studio Local.
  • Managing assets in a continuous integration/continuous delivery pipeline. For example, take assets built by a data scientist and move them through test and production environments.
  • Developing custom solutions for your organization's needs.
  • Monitoring the health of your clusters and notifications are provided when pods are down, such as dsx-core/usermgmt.

To use the command line interface for Watson Studio Local, download the package from https://www-01.ibm.com/marketing/iwm/iwm/web/dispatcher.do?source=mrs-ibmdselt.

Prerequisites

  • Java 8 runtime environment (64-bit)

Installing the CLI

To install the command line interface:

  1. Unzip WSCLI.zip to extract the contents of the directory.
  2. From a command prompt, change to the WSCLI directory. For example, on Windows:
    cd WSCLI
  3. To view a list of available commands, type:
     ./wscli --help 

    which returns help for each command. For example:

    $ ./wscli -h     
    NAME
    wscli <command>
    
    DESCRIPTION
    WS command-line interface
    
    AVAILABLE COMMANDS
    
    USER MANAGEMENT
    
      add user            Adds the user to Watson Studio
      get user            Returns the user information
      list users          Returns the list of users in Watson Studio
      edit user           Edits the Watson Studio user
      delete user         Deletes the user in Watson Studio
      add collaborator    Adds the user as a collaborator to the project, with the specific role
      list collaborators  Returns the list of collaborators in the project
      edit collaborator   Changes the user role as a collaborator in the project
      delete collaborator Removes the user's access to the project as a collaborator
      reset password      Reset the user's password. Can only be run by Admin User
      get token           Returns the authorization token for the user

Supplying credentials for CLI

Every command has three required parameters to connect to the CLI service:
  • --cluster-host (-ch)
  • --auth-user (-au)
  • --auth-password (-ap)
For example, these are valid values for the cluster-host parameter:
https://cluster-host-name.domain.com
   https://9.100.123.123
   cluster-host-name.domain.com
9.100.123.123

If you do not want to provide these credential parameters for every command, set them using environment variables.

Option Environment variable
--cluster-host -ch WS_CLUSTER_IP
--auth-user -au WS_AUTH_USER
--auth-password -ap WS_AUTH_PWD
To set the ENV variables:
  1. From a command prompt, run the setupEnv.sh shell command:
    - vi setupEnv.sh
  2. Edit the following fields to supply your credentials:
    export WS_CLUSTER_IP="<ws-cluster-host-or-ip>"
          export WS_AUTH_USER="<ws-admin-user-name>"
    export WS_AUTH_PWD="<ws-admin-user-password>"
  3. Save the changes:
    source ./setupEnv.sh

Alternatively, you can retrieve a bearer token for your user credentials and store that in the WS_AUTH_TOKEN environment variable. When this variable is populated, CLI ignores the values for WS_AUTH_USER and AUTH_PWD.

Follow these steps to retrieve and store the authentication token.
  1. Run this command to retrieve the token:
    WS_AUTH_TOKEN=`curl -k -X GET <CLUSTER_HOST>/v1/preauth/validateAuth -u <username>:<password> | jq -r '.accessToken'`
  2. Run the utility script getToken.sh to store the token:
     source ./getToken.sh
Note: Bearer tokens expire after a few hours. If the token stored in WS_AUTH_TOKEN has expired, the command will fail and you will need to either generate a new token or clear the WS_AUTH_TOKEN environment variable.

Using optional parameters with CLI

You can supply optional parameter that control attributes such as the format of the command output or how much information to display for each command. Required and optional parameters can be provided in any order. The complete list is supplied when you enter the CLI help command:
 ./wscli --help 

Optional parameters include:

OPTIONAL PARAMETERS:

    -json --json
       Provides the command output in JSON format
       Default: false

Common:

    -debug --debug
       Provides additional debug content for IBM Support
       Default: false
    -h --help
       Displays the command reference help
    -rs --result-status
       Shows the command execution status and time before the final command result output
       Default: false
    -v --verbose
       Provides detailed command execution output messages
       Default: false