API Procedures
Snoweaver offers a suite of stored procedures within the admin schema and individual projects, enabling users to execute a variety of DevOps and development tasks directly, bypassing the need for the Streamlit GUI.
Admin API Reference
save_project
This procedure appends the specified secrets and integrations to the target project. If the project does not already exist, it will be created automatically.
Arguments:
- name (varchar)
The name of the project to be created or updated.
- data (varchar)
Configuration data for the project in YAML format.
Template:
secrets: [] external_integrations: []
secrets: - <secret1> - <secret2> external_integrations: - <integration1> - <integration2>
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "execution results."
}
save_secret
This procedure creates or replaces a secret.
Arguments:
- name (varchar)
The name of the secret to be created or updated.
- data (varchar)
Configuration data of the secret in YAML format.
Templates:
OAuth2 Secret:
type: oauth2 api_name: <oauth_integration> refresh_token: <refresh_token> refresh_token_expiry: <refresh_token_expiry> oauth_scopes: - <scope1> - <scope2>
Generic String Secret:
type: string generic_string: <string_value>
Basic Secret:
type: basic username: <username> password: <password>
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "execution results."
}
save_network_rule
This procedure creates or updates a network rule.
Arguments:
- name (varchar)
The name of the network rule to be created or updated.
- domains (varchar)
Domains of the network rule, separated by commas.
Example:
domain1,domain2,domain3
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "execution results."
}
register_external_integration
This procedure registers an external access integration.
Arguments:
- name (varchar)
The name of the external access integration to be registered.
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "execution results."
}
register_oauth_integration
This procedure registers an OAuth security integration.
Arguments:
- name (varchar)
The name of the OAuth security integration to be registered.
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "execution results."
}
get_version
This procedure returns the version of API procedures installed.
Arguments:
None
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "V_X.X.X"
}
Project API Reference
sw_test_job_components
This procedure tests components of a job and returns the test results. If any component fails, the procedure status is set to “failed”.
Arguments:
- job (varchar)
The name of the job to be tested.
- components (varchar)
The components to be tested, separated by commas. Use ‘*’ to test all available components.
valid values: prehook, endpoint, params, headers, payload, payload_parts, output, file_path, sftp_file_path, posthook
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": {
"component1": {
"status": ["failed"|"ok"],
"data": "test results",
},
"component2": {
"status": ["failed"|"ok"],
"data": "test results",
}
...
}
}
sw_test_job_component
This procedure tests an input template for a specific job component in real-time and returns the test results generated by the Jinja engine.
Arguments:
- job (varchar)
The name of the job to be tested.
- components (varchar)
The components to be tested, separated by commas. Use ‘*’ to test all available components.
valid values: prehook, endpoint, params, headers, payload, payload_parts, output, file_path, sftp_file_path, posthook
- template (varchar)
The content of the Jinja template.
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "raw test results generated by the Jinja engine."
}
sw_test_macro_lib
This procedure tests a macro library and returns the test results. If the library and test templates are specified, the procedure will use the test template to validate the library template in real-time and return the test results.
Arguments:
- macro_lib (varchar)
The name of the macro library to be tested.
- lib_template (varchar) -optional
The content of the lib template.
- test_template (varchar) -optional
The content of the test template.
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "test results"
}
sw_test_function
This procedure tests a function and returns the test results. If the definition and the test template are specified, the procedure will use the test template to validate the Python definition in real-time and return the test results.
Arguments:
- function (varchar)
The name of the function to be tested.
- definition (varchar) -optional
The content of the Python definition for this function.
- test_template (varchar) -optional
Content of the test template.
Return Value:(variant)
{
"status": ["failed"|"ok"],
"data": "test results"
}
sw_preview_web_request
This procedure previews the HTTP content prepared by a web request job.
Arguments:
- job (varchar)
The name of job to be previwed.
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "the HTTP content prepared by a web request job"
}
sw_make_test_call
This procedure makes a test call from a temporary instance of a job.
Arguments:
- job (varchar)
The name of the job to make the test call.
- enable_posthook (boolean)
Specifies if the posthook should be executed after the call, if it has been defined.
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "response payload or posthook output"
}
sw_build_instance
This procedure builds or rebuilds the instance for a specified job. To build instances for all jobs within the project, use ‘*’.
Arguments:
- job (varchar)
The name of the job to build the instance for.
Return Value: (variant)
The return value is a variant, depending on whether a single job or all jobs are specified.
Single job
{
"status": ["failed"|"ok"],
"data": "run results."
}
All the jobs
{
"status": ["failed"|"ok"],
"data": {
"job1": {
"status": ["failed"|"ok"],
"data": "run results",
},
"job2": {
"status": ["failed"|"ok"],
"data": "run results",
}
...
}
}
sw_export_resources
This procedure exports project resources to the CODE stage as YAML files. The naming convention for the generated resource files is: [resource_type]_[resource_name].yaml.
When exporting multiple resources, the status of the procedure is set to failed if any resource fails.
Arguments:
- resource_type (varchar)
The type of resources to be exported. Use ‘*’ to export all resource types.
valid values: job, function, macro_lib, config, *
- resource (varchar)
The name of the resource to be exported. Use ‘*’ to export all resources of a specified type.
- delete_all (boolean)
Set this option to true if you want to remove everything from the CODE stage before exporting.
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": {
"resource_type1": {
"resource1": {
"status": ["failed"|"ok"],
"message": "export results",
"target": "export_file.yaml",
},
"resource2": {
"status": ["failed"|"ok"],
"message": "export results",
"target": "export_file.yaml",
}
...
}
}
sw_export_resource
This procedure returns the YAML document of a project resource as a string.
Arguments:
- resource_type (varchar)
The type of resources to be exported.
valid values: job, function, macro_lib, config
- resource (varchar)
The name of the resource to be exported.
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "The YAML document of the resource."
}
sw_import_resources
This procedure imports project resource YAML files from the CODE stage. Valid resource files must follow the naming convention: [resource_type]_[resource_name].yaml.
When importing multiple resources, if any resource fails, the procedure’s status is set to “failed”.
Arguments:
- resource_type (varchar)
The type of resources to be imported. Use ‘*’ to import all resource types.
valid values: job, function, macro_lib, config, *
- resource (varchar)
The name of the resource to be imported. Use ‘*’ to import all resource files of a specified type.
- delete_all (boolean)
Set this option to remove all project resources before importing, except for the DATA stage and the RESULTS table.
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": {
"resource_type1": {
"resource1": {
"status": ["failed"|"ok"],
"data": "import results"
},
"resource2": {
"status": ["failed"|"ok"],
"data": "import results",
}
...
}
}
sw_import_resource
This procedure updates a project resource with the provided YAML document data.
Arguments:
- resource_type (varchar)
The type of resource to be updated.
valid values: job, function, macro_lib, config
- resource (varchar)
The name of the resource to be updated.
- data (varchar)
The resource data in YAML format.
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "Results of the import operation."
}
sw_get_version
This procedure returns the version of API procedures installed in the project.
Arguments:
None
Return Value: (variant)
{
"status": ["failed"|"ok"],
"data": "V_X.X.X"
}