SAS Viya Orders is a command-line interface (CLI) that calls the appropriate SAS Viya Orders API endpoint to obtain the requested deployment assets for a specified SAS Viya software order.
You can use this CLI both as a tool and as an example of how to use Golang to call the SAS Viya Orders API. You can also import the assetreqs and authn packages and use them in your own Golang project.
Usage:
viya4-orders-cli [command]
Available Commands:
certificates Download certificates for the given order number
deploymentAssets Download deployment assets for the given order number at the given cadence name and version - if version not specified, get the latest version of the given cadence name
help Help about any command
license Download a license for the given order number at the given cadence name and version
Flags:
-c, --config string config file (default is $HOME/.viya4-orders-cli)
-n, --file-name string name of the file where you want the downloaded order asset to be stored
(defaults:
certs - SASViyaV4_<order number>_certs.zip
license and depassets - SASViyaV4_<order number>_<renewal sequence>_<cadence information>_<asset name>_<date time stamp>.<asset extension>
)
-p, --file-path string path to where you want the downloaded order asset stored (default is path to your current working directory)
-h, --help help for viya4-orders-cli
-o, --output string output format - valid values:
j, json
t, text
(default "text")
-v, --version version for viya4-orders-cli
Use "viya4-orders-cli [command] --help" for more information about a command.
- API credentials for the SAS Viya Orders API are required. You can obtain them from the SAS API Portal.
- Go 1.19.4 (or later) or Docker is required if you intend to build your own image.
- git version 2 or later is required if you intend to clone the repository.
Binaries for Windows, macOS, and Linux are available as downloads from
https://github.com/sassoftware/viya4-orders-cli/releases. Expand Assets
under
the release of interest.
To build the project, you have several options:
- Using Make:
Clone the project from the GitHub repo. Then, from the project root you can do the following:- Build a Windows executable (viya4-orders-cli_windows_amd64.exe) by running
the following command:
make win
- Build a Linux executable (viya4-orders-cli_linux_amd64.exe) by running the
following command:
make linux
- Build a macOS executable (viya4-orders-cli_darwin_amd64.exe) by running the
following command:
make darwin
- Build all of the above executables by running the following command:
Remove all of the above executables by running the following command:
make build
make clean
- Build a Windows executable (viya4-orders-cli_windows_amd64.exe) by running
the following command:
- Using Docker:
You can build the project without cloning first:
- http:
docker build github.com/sassoftware/viya4-orders-cli -t viya4-orders-cli
- ssh:
Or you can clone the project from the GitHub repository. Then, from the project root, run the following command:
docker build [email protected]:sassoftware/viya4-orders-cli.git -t viya4-orders-cli
docker build . -t viya4-orders-cli
- http:
- Using
go build
:
Clone the project from the GitHub repository. Then, from the project root, run the following command:go build -o {executable file name} main.go
Take the following steps to start using SAS Viya Orders CLI:
-
If you do not yet have credentials for the SAS Viya Orders API, obtain them from the SAS API Portal.
-
Record the
Key
and theSecret
values that serve as your API credentials. -
Base64 encode each value.
NOTE: When base64 encoding the credentials, take care not to encode end-of-line characters into the result.
Here is an example of the correct way to encode from a Linux command prompt:
echo -n {secret} | base64
Here is an example of the incorrect way to encode from a Linux command prompt (the encoded result will include\n
):
echo {secret} | base64
-
Add both credentials to your configuration file, or define them as environment variables:
- Assign the encoded value of
Key
toclientCredentialsId
(if using environment variables, useCLIENTCREDENTIALSID
). - Assign the encoded value of
Secret
toclientCredentialsSecret
(if using environment variables, useCLIENTCREDENTIALSSECRET
).
- Assign the encoded value of
-
Select CLI options. You can then specify them on the command line, pass them in as environment variables, or include them in a configuration file.
SAS Viya Orders CLI options are applied in order of precedence, as follows:
- command-line specification
- environment variable specification
- config file specification
- default
-
If you want to use a configuration file, create it.
The default location for the configuration file is
$HOME/.viya4-orders-cli
. You can save the file anywhere you want as long as you use the--config
/-c
option to inform the CLI of any non-default location.The config file must be in YAML format, or else its file name must include a file extension that denotes another format. Supported formats are JSON, TOML, YAML, HCL, INI, envfile, or Java properties formats.
Here is a sample YAML configuration file that contains client credentials:
clientCredentialsId: 1a2B3c4D5e6F7h8I9j10K=
clientCredentialsSecret: 4D5e6F7g8H9i==
You have the following options for launching SAS Viya Orders CLI:
-
Running the executable that you downloaded or built previously in the Installation section:
{executable file name} [command] [args] [flags]
-
Using Docker (this assumes that you have already executed the Docker build step described in the Installation section):
docker run -v /my/local/path:/containerdir viya4-orders-cli [command] [args] [flags]
-
Using
go run
:
If you have not done so already, clone the project from the GitHub repo. Then run the following command from the project root:go run main.go [command] [args] [flags]
The examples in this section correspond to typical tasks that you might perform using SAS Viya Orders CLI:
-
Using a configuration file,
/c/Users/auser/vocli/.viya4-orders-cli.yaml
, to convey your API credentials, get deployment assets for SAS Viya order923456
at the latest version of the Long Term Support (lts
) cadence. Send the contents to file/c/Users/auser/vocli/sasfiles/923456_lts_depassets.tgz
:docker run -v /c/Users/auser/vocli:/sasstuff viya4-orders-cli deploymentAssets 923456 lts \ --config /sasstuff/.viya4-orders-cli.yaml --file-path /sasstuff/sasfiles --file-name 923456_lts_depassets
Sample output:
2020/10/02 19:16:30 Using config file: /sasstuff/.viya4-orders-cli.yaml OrderNumber: 923456 AssetName: deploymentAssets AssetReqURL: https://api.sas.com/mysas/orders/923456/cadenceNames/lts/deploymentAssets AssetLocation: /sasstuff/sasfiles/923456_lts_depassets.tgz Cadence: Long Term Support 2020.0 CadenceRelease: 20200808.1596943588306
-
Get a renewal license for the deployment of SAS Viya order
923456
and send the contents to file/auser/vocli/sasfiles/923456_lts_2020.0_license_ren1.jwt
:go run main.go lic 923456 lts 2020.0 -p /auser/vocli/sasfiles -n 923456_lts_2020.0_license_ren1
Sample output:
OrderNumber: 923456 AssetName: license AssetReqURL: https://api.sas.com/mysas/orders/923456/cadenceNames/lts/cadenceVersions/2020.0/license AssetLocation: /auser/vocli/sasfiles/923456_lts_2020.0_license_ren1.jwt Cadence: Long Term Support 2020.0 CadenceRelease:
-
Get certificates for SAS Viya order
923457
and send the contents to fileC:\Users\auser\vocli\sasfiles\923457_certs.zip
. Receive the output in JSON format:viya4-orders-cli_windows_amd64.exe cer 923457 -p C:\Users\auser\vocli\sasfiles -n 923457_certs -o json
Sample output:
{ "orderNumber": "923457", "assetName": "certificates", "assetReqURL": "https://api.sas.com/mysas/orders/923457/certificates", "assetLocation": "C:\Users\auser\vocli\sasfiles\923457_certs.zip", "cadence": "", "cadenceRelease": "" }
We welcome your contributions! Please read CONTRIBUTING.md for details on how to submit contributions to this project.
This project is licensed under the Apache 2.0 License.