sassoftware / viya4-orders-cli

A CLI that calls the appropriate SAS Viya Orders API endpoint to obtain the requested Viya software order assets for the given order.
Apache License 2.0
14 stars 6 forks source link
sas-quest viya4

SAS Viya Orders CLI

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.

Overview

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.

Prerequisites

Installation

Option 1 - Download a pre-built binary file.

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.

Option 2 - Build the project yourself.

To build the project, you have several options:

Getting Started

Take the following steps to start using SAS Viya Orders CLI:

  1. If you do not yet have credentials for the SAS Viya Orders API, obtain them from the SAS API Portal.

  2. Record the Key and the Secret values that serve as your API credentials.

  3. 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

  4. Add both credentials to your configuration file, or define them as environment variables:

    • Assign the encoded value of Key to clientCredentialsId (if using environment variables, use CLIENTCREDENTIALSID).
    • Assign the encoded value of Secret to clientCredentialsSecret (if using environment variables, use CLIENTCREDENTIALSSECRET).
  5. 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:

    1. command-line specification
    2. environment variable specification
    3. config file specification
    4. default
  6. 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==

Running

You have the following options for launching SAS Viya Orders CLI:

Examples

The examples in this section correspond to typical tasks that you might perform using SAS Viya Orders CLI:

Contributing

We welcome your contributions! Please read CONTRIBUTING.md for details on how to submit contributions to this project.

License

This project is licensed under the Apache 2.0 License.

Additional Resources