Snoweaver CLI

The Snoweaver CLI is a Bash script designed to simplify the use of the API Procedures. It can be downloaded and installed on your system, and customized to fit your specific requirements.

To use the CLI tool after installation, use the following syntax:

sw <operation> [args] [-optins]

If you run the command without any arguments, it will display the usage reference.

$sw
usage:  sw  [get|put] <file>|all [-trunc] [-c value]
            [import|export] all [-d] [-c value]
                           type [-c value]
                           type resource [-l] [-c value]
            test job <job> [-c value]
               job <job> <components> [-c value]
               job <job> <component> <test.j2> [-c value]
               lib <lib> [-c value]
               lib <lib> <lib.j2> <test.j2> [-c value]
               func <func> [-c value]
               func <func> <def.py> <test.j2> [-c value]
            build <job>|all [-c value]
            preview <job> [-c value]
            testcall <job> [-c value] [-p]

            -c: Specifies the connection to be used by SnowSQL.
                If this option is not provided, SnowSQL will use the default connection.
                If the default connection fails, you will be prompted to enter your credentials.
            -d: get - Deletes all .yaml files in the local directory before proceeding.
                put,`export` - Purges the CODE stage prior to execution.
                import - Removes all project resources before importing, except for the DATA stage and the RESULTS table.
            -l: Directs Snoweaver to export to or import from a local file instead of the CODE stage.
            -p: Enables the post-hook functionality.

Commands Reference

get

Arguments: <file> | all

Downloads a specific file or all files from the CODE stage of the connected project to the local directory.

Options:

-c <value>: Specifies the connection to be used by SnowSQL.

-d: Deletes all .yaml files in the local directory before downloading.

Examples:

sw get config.yaml
sw get all -c my_connection -d

put

Arguments: <file> | all

Uploads a specific file or all files from the local directory to the CODE stage of the connected project.

Options:

-c <value>: Specifies the connection to be used by SnowSQL.

-d: Purges the CODE stage prior to uploading.

Examples:

sw put job.yaml
sw put all -c my_connection -d

import

Arguments: all | type [resource]

Imports resources into the connected project. You can import all resources, a specific type of resource, or a particular resource.

Options:

-c <value>: Specifies the connection to be used by SnowSQL.

-d: Removes all project resources before importing, except for the DATA stage and the RESULTS table.

-l: Directs Snoweaver to import from a local file instead of the CODE stage.

Examples:

sw import job my_job
sw import all -d
sw import job my_job -c my_connection -l

export

Arguments: all | type [resource]

Exports resources from the connected project. You can export all resources, a specific type of resource, or a particular resource.

Options:

-c <value>: Specifies the connection to be used by SnowSQL.

-d: Purges the CODE stage prior to execution.

-l: Directs Snoweaver to export to a local file instead of the CODE stage.

Examples:

sw export job my_job
sw export all -d
sw export job my_job -c my_connection -l

test job

Arguments: <job> [component1,component2 | component] [test.j2]

Tests components of a specified job. You can test all components, a subset of components, or a particular component.

Options:

-c <value>: Specifies the connection to be used by SnowSQL.

Optionally, include a local file containing the test template for live testing a component locally.

Examples:

sw test job my_job
sw test job my_job prehook,posthook -c my_connection
sw test job my_job endpoint test_template.j2 -c my_connection

test lib

Arguments: <lib> [lib.j2] [test.j2]

Tests a macro library.

Options:

-c <value>: Specifies the connection to be used by SnowSQL.

Optionally, include local files for the library template and the test template for live testing the library remotely.

Examples:

sw test lib my_lib
sw test lib my_lib lib_template.j2 test_template.j2 -c my_connection

test func

Arguments: <func> [def.py] [test.j2]

Tests a function.

Options:

-c <value>: Specifies the connection to be used by SnowSQL.

Optionally, include local files for the Python function definition and the test template for live testing the function remotely.

Examples:

sw test func my_func
sw test func my_func function_def.py test_template.j2 -c my_connection

build

Arguments: all | <job>

Builds or rebuilds job instances for either all jobs or a specific job in the connected project.

Options:

-c <value>: Specifies the connection to be used by SnowSQL.

Examples:

sw build all
sw build my_job -c my_connection

preview

Arguments: <job>

Previews the HTTP content prepared by the specified web request job.

Options:

-c <value>: Specifies the connection to be used by SnowSQL.

Examples:

sw preview my_web_job
sw preview my_web_job -c my_connection

testcall

Arguments: <job>

Initiates a test execution of the specified job.

Options:

-c <value>: Specifies the connection to be used by SnowSQL.

-p: Enables the post-hook functionality.

Examples:

sw testcall my_job
sw testcall my_job -p -c my_connection