Over the last several months I have been involved in the development of applications using SAS Viya. I witnessed a common pattern when integrating the capabilities of CAS and Visual Analytics Reports in web applications using SAS REST APIs.
To deploy the application at a user site the following is the typical list of artifacts.
There are standard ways to deploy items 1 and 2. This article is focused on two interactive CLI’s (available as npm packages) making the deployment of 3 through 5 simple and repeatable.
To facilitate the CI/CD process the tools allow for "batch" mode processing in addition to the CLI.
The creation of the clientid is not magic and just requires a couple of API calls. There are several blogs and other documentation on developer.sas.com that discuss how to get these using curl, postman, etc. In particular, refer to Authentication to SAS Viya: a couple of approaches. I always felt that something so basic should be managed either with a UI or a CLI. This CLI attempts to achieve that goal.
The registerclient tool is part of the restaf GitHub repository and is accompanied by full documentation.
The sample code below launches the app, displays the help text, logs on to SAS, and registers a clientid myapp1.
$ npx @sassoftware/registerclient --env register.env
--------------------------------------
Welcome to @sassoftware/registerclient
Enter help to get a list of all the commands
Use logon command to start your SAS Viya session. User must be an admin.
>> help
Commands:
help [command...] Provides help for a given command.
exit Exits application.
logon Logon to Viya
list [all] List clients. Use all option to include system clientids
config <config> File containing the configuration for clientid registeration
new [options] <clientid> Add a new client with specified name
delete <clientid> Delete specified client
>> logon
Enter your userid> sasdemo
Enter your password> ********
Logon Successful
>> add myapp1 -t authorization_code -s mysecret -r http://localhost:8080/myapp
myapp1 has been added
>> list
>>>>>>>>>>>>>>User defined clientids
clientid : myapp1
grantTypes: authorization_code,refresh_token
redirect : http://localhost:8080/myapp
undefined clientids detected
>>exit
This module is useful for the import and export of selected contents in SAS Viya. It is designed to address the simple import/export use case discussed earlier in this article. To move large amounts of data and reports please refer to the SAS Viya documentation.
The viyacaddy tool is located in the restaf GitHub repository and is accompanied by full documentation.
The sample code below launches the app, displays the help text, lists current reports, and imports a report.
$ npx @sassoftware/viyacaddy --env register.env
Welcome to @sassoftware/viyacaddy
Enter help to get a list of all the commands
Use logon command to start your SAS Viya session
>> help
Commands:
help [command...] Provides help for a given command.
exit Exits application.
logon Logon to Viya
tables import [options] <dir> [files...] Import .sas, .ds2, .sashdat, .sasb7dat, .astore , .sasast, .csv into CAS Tables
reports list List all the VA reports
reports import [options] <dir> [files...] Import VA reports
reports export [options] [files...] Export VA reports
caslibs List all active caslibs
tables list <caslib> List tables in a specified caslib
>> logon
Enter your userid> sasdemo
Enter your password> ********
Logon Successful
>> reports list
[
'Application Activity',
'CAS Activity',
'Disk Space',
'Home Loan Default Demo',
'SAS Viya Inventory'
]
>> reports import C:\Users\sas\Documents\env testReport.json -f Public
Imports started
Import of C:\Users\sas\Documents\env/testReport.json as report testReport completed
>> reports list
[
'Application Activity',
'CAS Activity',
'Disk Space',
'Home Loan Default Demo',
'SAS Viya Inventory'
'testReport'
]
>>exit
I hope you find these to be good additions to your toolbox. Please feel free to clone the code and make improvements.
Cheers…
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.