Package: lrn-cli
Learnosity CLI tool (lrn-cli)Thelrn-clitool allows the exchange of JSON payloads with the Learnosity APIs
without having to worry about signature generation.In a nutshell, it can be used as follows:lrn-cli [--profile <PROFILE>|--consumer-key <KEY> --consumer-secret <SECRET>] [--region <REGION>]
	  --request-json '<REQUEST>' [--update|--set|--delete] \
	  <API> <ENDPOINT>By default, the demonstration consumer credentials will be used if none are
specified.If--request-jsonis not specified, the request will be read from
standard input, or an alternative JSON file can be provided through--file.Documentation about all the options is available with the--helpflag to both
the base tool, and each API.lrn-cli --helpGetting startedSetupThe simplest way to install, if you don't intend to develop, is viapip3(orpip).pip3 install lrn-cliIf you intend to make changes to the codebase, you can get run from a clone of
the git repository.git clone git@github.com:Learnosity/lrn-cli
cd lrn-cli
make
. .venv/lrn-cli/bin/activateSee at the end of this file for other development-related information.ConfigurationWhile most parameters (credentials, environment, version, region, ...) can be specified on
the command line, they can also be set as environment variables (LRN_...as
documented in the--helpoutput of the main and sub-commands, if relevant).lrn-cli also supports credentials and configuration files. By default, these are~/.learnosity/credentialsand~/.learnosity/configrespectively. You may need to
create a~/.learnositydirectory before creating these files.Both are formatted as simple INI file, with sections in square brackets, and parameters
set within the section.  Those entries can be selected for use with either the--profilecommand line option, or theLRN_PROFILEenvironment variable.If the profile provided is not found, and keys not otherwise specified,lrn-cliwill
default to the learnosity-demos consumer key.Credentials fileThe credentials file allows you to specify named consumer key and secret pairs.
By default, it is in~/.learnosity/credentials.[default]consumer_key=yis0TYCu7U9V4o7Mconsumer_secret=74c5fd430cf1242a527f6223aebd42d30464be22[some-other-consumer]consumer_key=Xconsumer_secret=Y[staging]consumer_key=Xconsumer_secret=YConfiguration fileThe config file allows additional parameters to be specified, such as environment, region and
version. By default, it is in~/.learnosity/config.[default]region=auversion=v2020.2.LTS[old-lts]version=v2020.1.LTSsource_profile=default[staging]environment=stagingversion=v2020.2.LTSThesource_profileallows to fetch a differently-named set of consumers
credentials.ActionThe default action is GET. Different actions can be selected by using the
switches--set,--update, or--delete. These are mutually exclusive:
if more than one occurs, the last will be the effective action. (There is
a--getswitch as well, though this is less useful, since GET is the default.)ExamplesGetting the status of a session, passing the request from the command line arguments.$ API=data
$ ENDPOINT=/sessions/statuses
$ lrn-cli -l debug -R  '{ "limit": 1, "session_ids": ["4562ae00-0f59-6d3c-860b-74b7b5579b32"] }' ${API} ${ENDPOINT}
2019-10-22 14:22:25,490 DEBUG:Using request JSON from command line argument
2019-10-22 14:22:25,491 DEBUG:Sending GET request to https://data.learnosity.com/v1/sessions/statuses ...
[
 {
  "user_id": "open_web_demo1",
  "activity_id": "Demo Activity Id",
  "num_attempted": 0,
  "num_questions": 5,
  "session_id": "4562ae00-0f59-6d3c-860b-74b7b5579b32",
  "session_duration": 0,
  "status": "Incomplete",
  "dt_saved": "2019-10-21T23:48:31Z",
  "dt_started": "2019-10-21T23:48:29Z",
  "dt_completed": null
 }
]Getting the last authored Item, passing the request from standard input.$ echo '{ "limit": 1 }' | lrn-cli -l debug data /itembank/items
2019-10-22 14:24:07,108 DEBUG:Reading request json from <_io.TextIOWrapper name='<stdin>' mode='r' encoding='UTF-8'>...
2019-10-22 14:24:07,108 DEBUG:Sending GET request to https://data.learnosity.com/v1/itembank/items ...
[
 {
  "reference": "1de592c9-0af5-4a58-8d47-75c304ec654e",
  "title": null,
  "workflow": null,
  "metadata": null,
  "note": "",
  "source": "",
  "definition": {
   "widgets": [
    {
     "reference": "10f24a41-64ad-4d08-ab44-cc7469e324ba",
     "widget_type": "response"
    },
    {
     "reference": "27093a4b-19cb-4517-9d47-557241577ec2",
     "widget_type": "response"
    }
   ],
   "template": "dynamic"
  },
  "description": "",
  "status": "published",
  "questions": [
   {
    "reference": "10f24a41-64ad-4d08-ab44-cc7469e324ba",
    "type": "mcq"
   },
   {
    "reference": "27093a4b-19cb-4517-9d47-557241577ec2",
    "type": "mcq"
   }
  ],
  "features": [],
  "tags": {}
 }
]DevelopmentA few handy dependencies to support development can be installed in the
virtualenv withmake pip-requirements-devRunning TestsRunmake test.Creating a new releaseRunmake release.This requires GNU-flavoured UNIX tools (particularlygsed). If these are not
the default on your system, you'll need to install them, e.g. for OS X,brew install gsed coreutilsDeploying to PyPiRunmake dist-upload.You will need to be set up as a maintainer in order to do this.