mirror of
https://github.com/FlipsideCrypto/livequery-models.git
synced 2026-02-06 10:56:46 +00:00
Enhance UDF compatibility checks and refactor UDF definitions
- Updated UDF definitions to utilize the new `is_udf_api_v2_compatible()` macro for compatibility checks, replacing the previous `check_udf_api_v2_exists()` method. - Refactored SQL logic across multiple UDFs to improve clarity and maintainability. - Added conditional checks for UDF API version compatibility in various macros, ensuring backward compatibility and improved functionality. - Enhanced comments and documentation for better understanding and maintainability of the codebase.
This commit is contained in:
parent
8138951db2
commit
5ae4187602
@ -31,6 +31,7 @@
|
||||
NOT NULL
|
||||
sql: udf_api
|
||||
|
||||
{% if is_udf_api_v2_compatible() %}
|
||||
- name: {{ schema }}.udf_api_sync
|
||||
signature:
|
||||
- [method, STRING]
|
||||
@ -66,5 +67,6 @@
|
||||
options: |
|
||||
NOT NULL
|
||||
sql: 'v2/udf_api'
|
||||
{% endif %}
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
@ -154,38 +154,7 @@
|
||||
COMMENT = $$Returns a list of allowed domains.$$
|
||||
sql: allowed
|
||||
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
- [url, STRING]
|
||||
- [headers, OBJECT]
|
||||
- [secret_name, STRING]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes an LiveQuery Sync or Async External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
utils.udf_redirect_s3_presigned_url(
|
||||
_live.udf_api_async('GET', url, headers, {}, _utils.UDF_WHOAMI(), secret_name)
|
||||
:s3_presigned_url::STRING
|
||||
):data[0][1] as result
|
||||
WHERE LOWER(COALESCE(
|
||||
headers:"fsc-quantum-execution-mode"::STRING,
|
||||
headers:"Fsc-Quantum-Execution-Mode"::STRING,
|
||||
headers:"FSC-QUANTUM-EXECUTION-MODE"::STRING
|
||||
)) = 'async'
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
_live.udf_api_sync('GET', url, headers, {}, _utils.UDF_WHOAMI(), secret_name) as result
|
||||
WHERE LOWER(COALESCE(
|
||||
headers:"fsc-quantum-execution-mode"::STRING,
|
||||
headers:"Fsc-Quantum-Execution-Mode"::STRING,
|
||||
headers:"FSC-QUANTUM-EXECUTION-MODE"::STRING,
|
||||
'sync'
|
||||
)) != 'async'
|
||||
|
||||
{% if is_udf_api_v2_compatible() %}
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
- [url, STRING]
|
||||
@ -198,60 +167,19 @@
|
||||
COMMENT = $$Executes an LiveQuery Sync or Async External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
utils.udf_redirect_s3_presigned_url(
|
||||
_live.udf_api_async('GET', url, headers, {}, _utils.UDF_WHOAMI(), secret_name)
|
||||
:s3_presigned_url::STRING
|
||||
):data[0][1] as result
|
||||
WHERE LOWER(COALESCE(
|
||||
headers:"fsc-quantum-execution-mode"::STRING,
|
||||
headers:"Fsc-Quantum-Execution-Mode"::STRING,
|
||||
headers:"FSC-QUANTUM-EXECUTION-MODE"::STRING
|
||||
)) = 'async'
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
_live.udf_api_sync('GET', url, headers, {}, _utils.UDF_WHOAMI(), secret_name) as result
|
||||
WHERE LOWER(COALESCE(
|
||||
headers:"fsc-quantum-execution-mode"::STRING,
|
||||
headers:"Fsc-Quantum-Execution-Mode"::STRING,
|
||||
headers:"FSC-QUANTUM-EXECUTION-MODE"::STRING,
|
||||
'sync'
|
||||
)) != 'async'
|
||||
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
- [method, STRING]
|
||||
- [url, STRING]
|
||||
- [headers, OBJECT]
|
||||
- [data, VARIANT]
|
||||
- [secret_name, STRING]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes an LiveQuery Sync or Async External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
utils.udf_redirect_s3_presigned_url(
|
||||
_live.udf_api_async(method, url, headers, data, _utils.UDF_WHOAMI(), secret_name)
|
||||
:s3_presigned_url::STRING
|
||||
):data[0][1] as result
|
||||
WHERE LOWER(COALESCE(
|
||||
headers:"fsc-quantum-execution-mode"::STRING,
|
||||
headers:"Fsc-Quantum-Execution-Mode"::STRING,
|
||||
headers:"FSC-QUANTUM-EXECUTION-MODE"::STRING
|
||||
)) = 'async'
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
_live.udf_api_sync(method, url, headers, data, _utils.UDF_WHOAMI(), secret_name) as result
|
||||
WHERE LOWER(COALESCE(
|
||||
headers:"fsc-quantum-execution-mode"::STRING,
|
||||
headers:"Fsc-Quantum-Execution-Mode"::STRING,
|
||||
headers:"FSC-QUANTUM-EXECUTION-MODE"::STRING,
|
||||
'sync'
|
||||
)) != 'async'
|
||||
CASE is_async
|
||||
WHEN TRUE
|
||||
THEN
|
||||
utils.udf_redirect_s3_presigned_url(
|
||||
_live.udf_api_async(
|
||||
'GET', URL, HEADERS, {}, _utils.UDF_WHOAMI(), SECRET_NAME
|
||||
):s3_presigned_url :: STRING
|
||||
):data[0][1]
|
||||
ELSE
|
||||
_live.udf_api_sync(
|
||||
'GET', URL, HEADERS, {}, _utils.UDF_WHOAMI(), SECRET_NAME
|
||||
)
|
||||
END
|
||||
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
@ -287,32 +215,26 @@
|
||||
- [url, STRING]
|
||||
- [headers, OBJECT]
|
||||
- [data, VARIANT]
|
||||
- [is_async, BOOLEAN]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes an LiveQuery Sync or Async External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
utils.udf_redirect_s3_presigned_url(
|
||||
_live.udf_api_async(method, url, headers, data, _utils.UDF_WHOAMI(), '')
|
||||
:s3_presigned_url::STRING
|
||||
):data[0][1] as result
|
||||
WHERE LOWER(COALESCE(
|
||||
headers:"fsc-quantum-execution-mode"::STRING,
|
||||
headers:"Fsc-Quantum-Execution-Mode"::STRING,
|
||||
headers:"FSC-QUANTUM-EXECUTION-MODE"::STRING
|
||||
)) = 'async'
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
_live.udf_api_sync(method, url, headers, data, _utils.UDF_WHOAMI(), '') as result
|
||||
WHERE LOWER(COALESCE(
|
||||
headers:"fsc-quantum-execution-mode"::STRING,
|
||||
headers:"Fsc-Quantum-Execution-Mode"::STRING,
|
||||
headers:"FSC-QUANTUM-EXECUTION-MODE"::STRING,
|
||||
'sync'
|
||||
)) != 'async'
|
||||
CASE is_async
|
||||
WHEN TRUE
|
||||
THEN
|
||||
utils.udf_redirect_s3_presigned_url(
|
||||
_live.udf_api_async(
|
||||
METHOD, URL, HEADERS, DATA, _utils.UDF_WHOAMI(), ''
|
||||
):s3_presigned_url :: STRING
|
||||
):data[0][1]
|
||||
ELSE
|
||||
_live.udf_api_sync(
|
||||
METHOD, URL, HEADERS, DATA, _utils.UDF_WHOAMI(), ''
|
||||
)
|
||||
END
|
||||
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
@ -321,7 +243,7 @@
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes an LiveQuery Sync or Async External Function.$$
|
||||
COMMENT = $$Executes a Quick Post LiveQuery Sync External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
_live.udf_api_sync(
|
||||
@ -337,11 +259,36 @@
|
||||
signature:
|
||||
- [url, STRING]
|
||||
- [data, VARIANT]
|
||||
- [secret_name, STRING]
|
||||
- [is_async, BOOLEAN]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes an LiveQuery Sync or Async External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
CASE is_async
|
||||
WHEN TRUE
|
||||
THEN
|
||||
utils.udf_redirect_s3_presigned_url(
|
||||
_live.udf_api_async(
|
||||
'GET', URL, {'Content-Type': 'application/json'}, data, _utils.UDF_WHOAMI(), ''
|
||||
):s3_presigned_url :: STRING
|
||||
):data[0][1]
|
||||
ELSE
|
||||
_live.udf_api_sync(
|
||||
'GET', URL, {'Content-Type': 'application/json'}, data, _utils.UDF_WHOAMI(), ''
|
||||
)
|
||||
END
|
||||
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
- [url, STRING]
|
||||
- [data, VARIANT]
|
||||
- [secret_name, STRING]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes a Quick Post LiveQuery Sync External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
_live.udf_api_sync(
|
||||
@ -356,10 +303,36 @@
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
- [url, STRING]
|
||||
- [data, VARIANT]
|
||||
- [secret_name, STRING]
|
||||
- [is_async, BOOLEAN]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes an LiveQuery Sync or Async External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
CASE is_async
|
||||
WHEN TRUE
|
||||
THEN
|
||||
utils.udf_redirect_s3_presigned_url(
|
||||
_live.udf_api_async(
|
||||
'GET', URL, {'Content-Type': 'application/json'}, data, _utils.UDF_WHOAMI(), secret_name
|
||||
):s3_presigned_url :: STRING
|
||||
):data[0][1]
|
||||
ELSE
|
||||
_live.udf_api_sync(
|
||||
'GET', URL, {'Content-Type': 'application/json'}, data, _utils.UDF_WHOAMI(), secret_name
|
||||
)
|
||||
END
|
||||
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
- [url, STRING]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes a Quick GET LiveQuery Sync External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
_live.udf_api_sync(
|
||||
@ -374,11 +347,35 @@
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
- [url, STRING]
|
||||
- [secret_name, STRING]
|
||||
- [is_async, BOOLEAN]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes an LiveQuery Sync or Async External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
CASE is_async
|
||||
WHEN TRUE
|
||||
THEN
|
||||
utils.udf_redirect_s3_presigned_url(
|
||||
_live.udf_api_async(
|
||||
'GET', URL, {'Content-Type': 'application/json'}, {}, _utils.UDF_WHOAMI(), ''
|
||||
):s3_presigned_url :: STRING
|
||||
):data[0][1]
|
||||
ELSE
|
||||
_live.udf_api_sync(
|
||||
'GET', URL, {'Content-Type': 'application/json'}, {}, _utils.UDF_WHOAMI(), ''
|
||||
)
|
||||
END
|
||||
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
- [url, STRING]
|
||||
- [secret_name, STRING]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes a Quick GET LiveQuery Sync External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
_live.udf_api_sync(
|
||||
@ -389,4 +386,30 @@
|
||||
_utils.UDF_WHOAMI(),
|
||||
secret_name
|
||||
)
|
||||
|
||||
- name: {{ schema }}.udf_api_v2
|
||||
signature:
|
||||
- [url, STRING]
|
||||
- [secret_name, STRING]
|
||||
- [is_async, BOOLEAN]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
VOLATILE
|
||||
COMMENT = $$Executes an LiveQuery Sync or Async External Function.$$
|
||||
sql: |
|
||||
SELECT
|
||||
CASE is_async
|
||||
WHEN TRUE
|
||||
THEN
|
||||
utils.udf_redirect_s3_presigned_url(
|
||||
_live.udf_api_async(
|
||||
'GET', URL, {'Content-Type': 'application/json'}, {}, _utils.UDF_WHOAMI(), secret_name
|
||||
):s3_presigned_url :: STRING
|
||||
):data[0][1]
|
||||
ELSE
|
||||
_live.udf_api_sync(
|
||||
'GET', URL, {'Content-Type': 'application/json'}, {}, _utils.UDF_WHOAMI(), secret_name
|
||||
)
|
||||
END
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
@ -1,26 +1,63 @@
|
||||
{% macro check_udf_api_v2_exists() -%}
|
||||
{#
|
||||
Check if live.udf_api_v2 function exists at compile time
|
||||
Returns true/false to control which UDF call to render
|
||||
|
||||
Usage:
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
{% if v2_exists %}
|
||||
live.udf_api_v2(...)
|
||||
{% else %}
|
||||
live.udf_api(...)
|
||||
{% endif %}
|
||||
#}
|
||||
{% set check_v2_query %}
|
||||
SELECT COUNT(*) FROM information_schema.functions
|
||||
WHERE function_name = 'UDF_API_V2' AND function_schema = 'LIVE'
|
||||
{% macro get_streamline_stack_version() -%}
|
||||
{# Determine the environment based on target.name #}
|
||||
{% if target.name == 'dev' %}
|
||||
{% set env = 'stg' %}
|
||||
{% elif target.name == 'prod' %}
|
||||
{% set env = 'prod' %}
|
||||
{% else %}
|
||||
{% set env = 'stg' %}
|
||||
{% endif %}
|
||||
|
||||
{# Extract database prefix if it follows pattern <database_name>_<target_name> #}
|
||||
{% set database_parts = target.database.split('_') %}
|
||||
{% if database_parts|length > 1 and database_parts[-1].lower() == target.name.lower() %}
|
||||
{% set database_prefix = database_parts[:-1]|join('_') %}
|
||||
{% else %}
|
||||
{% set database_prefix = target.database %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% set streamline_stack_version_query %}
|
||||
SELECT
|
||||
TAGS:streamline_runtime_version::STRING as runtime_version,
|
||||
TAGS:streamline_infrastructure_version::STRING as infrastructure_version
|
||||
FROM TABLE(STREAMLINE.AWS.CLOUDFORMATION_DESCRIBE_STACKS('{{ env }}', '{{ database_prefix.lower() }}-api-{{ env }}'));
|
||||
{% endset %}
|
||||
|
||||
{% if execute %}
|
||||
{% set v2_exists = run_query(check_v2_query).rows[0][0] > 0 %}
|
||||
{% set result = run_query(streamline_stack_version_query) %}
|
||||
{% if result.rows|length > 0 %}
|
||||
{% set runtime_version = result.rows[0][0] %}
|
||||
{% set infrastructure_version = result.rows[0][1] %}
|
||||
{% set streamline_stack_version = {'runtime_version': runtime_version, 'infrastructure_version': infrastructure_version} %}
|
||||
{% else %}
|
||||
{% set streamline_stack_version = {'runtime_version': false, 'infrastructure_version': false} %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% set v2_exists = false %}
|
||||
{% set streamline_stack_version = {'runtime_version': false, 'infrastructure_version': false} %}
|
||||
{% endif %}
|
||||
|
||||
{{ return(v2_exists) }}
|
||||
{%- endmacro -%}
|
||||
{{ return(streamline_stack_version) }}
|
||||
{%- endmacro -%}
|
||||
|
||||
{% macro is_udf_api_v2_compatible() -%}
|
||||
{% set versions = get_streamline_stack_version() %}
|
||||
|
||||
{% if execute and versions.runtime_version %}
|
||||
{# Extract version number from runtime_version string (e.g., "v3.1.2" -> "3.1.2") #}
|
||||
{% set version_str = versions.runtime_version.replace('v', '') %}
|
||||
{% set version_parts = version_str.split('.') %}
|
||||
|
||||
{# Convert to comparable format: major.minor.patch #}
|
||||
{% set major = version_parts[0] | int %}
|
||||
{% set minor = version_parts[1] | int if version_parts|length > 1 else 0 %}
|
||||
{% set patch = version_parts[2] | int if version_parts|length > 2 else 0 %}
|
||||
|
||||
{# Check if version is >= 3.0.0 #}
|
||||
{% set is_compatible = major >= 3 %}
|
||||
{% else %}
|
||||
{% set is_compatible = false %}
|
||||
{% endif %}
|
||||
|
||||
{{ return(is_compatible) }}
|
||||
{%- endmacro -%}
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
options: |
|
||||
COMMENT = $$Used to issue a 'GET' request to the Alchemy NFT API.$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'GET',
|
||||
@ -52,8 +52,8 @@
|
||||
options: |
|
||||
COMMENT = $$Used to issue a 'GET' request to the Alchemy NFT API.$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'GET',
|
||||
@ -90,8 +90,8 @@
|
||||
options: |
|
||||
COMMENT = $$Used to issue a 'POST' request to the Alchemy NFT API.$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'POST',
|
||||
@ -122,8 +122,8 @@
|
||||
options: |
|
||||
COMMENT = $$Used to issue an RPC call to Alchemy.$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'POST',
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
options: |
|
||||
COMMENT = $$Make calls to Claude API [API docs: Claude](https://docs.anthropic.com/claude/reference/getting-started-with-the-api)$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'POST',
|
||||
@ -55,8 +55,8 @@
|
||||
options: |
|
||||
COMMENT = $$Make GET requests to Claude API [API docs: Get](https://docs.anthropic.com/claude/reference/get)$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'GET',
|
||||
@ -99,8 +99,8 @@
|
||||
options: |
|
||||
COMMENT = $$Make DELETE requests to Claude API [API docs: Delete](https://docs.anthropic.com/claude/reference/delete)$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'DELETE',
|
||||
|
||||
@ -10,16 +10,15 @@
|
||||
options: |
|
||||
COMMENT = $$Verify token [Authenticating to the REST API](https://docs.github.com/en/rest/overview/authenticating-to-the-rest-api?apiVersion=2022-11-28).$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'GET',
|
||||
'https://api.github.com/octocat',
|
||||
{'Authorization': 'Bearer {TOKEN}', 'X-GitHub-Api-Version': '2022-11-28', 'fsc-quantum-execution-mode': 'async'},
|
||||
{},
|
||||
IFF(_utils.udf_whoami() <> CURRENT_USER(), '_FSC_SYS/GITHUB', 'Vault/github/api'),
|
||||
TRUE
|
||||
IFF(_utils.udf_whoami() <> CURRENT_USER(), '_FSC_SYS/GITHUB', 'Vault/github/api')
|
||||
)
|
||||
{%- else -%}
|
||||
live.udf_api(
|
||||
@ -43,7 +42,8 @@
|
||||
sql: |
|
||||
SELECT '{"Authorization": "Bearer {TOKEN}",
|
||||
"X-GitHub-Api-Version": "2022-11-28",
|
||||
"Accept": "application/vnd.github+json"
|
||||
"Accept": "application/vnd.github+json",
|
||||
"fsc-quantum-execution-mode": "async"
|
||||
}'
|
||||
|
||||
- name: {{ schema_name -}}.get_api
|
||||
@ -55,16 +55,15 @@
|
||||
options: |
|
||||
COMMENT = $$List all workflow runs for a workflow. You can replace workflow_id with the workflow file name. You can use parameters to narrow the list of results. [Docs](https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow).$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'GET',
|
||||
CONCAT_WS('/', 'https://api.github.com', route || '?') || utils.udf_urlencode(query),
|
||||
PARSE_JSON({{ schema_name -}}.headers()),
|
||||
{},
|
||||
IFF(_utils.udf_whoami() <> CURRENT_USER(), '_FSC_SYS/GITHUB', 'Vault/github/api'),
|
||||
TRUE
|
||||
IFF(_utils.udf_whoami() <> CURRENT_USER(), '_FSC_SYS/GITHUB', 'Vault/github/api')
|
||||
)
|
||||
{%- else -%}
|
||||
live.udf_api(
|
||||
@ -85,16 +84,15 @@
|
||||
options: |
|
||||
COMMENT = $$List all workflow runs for a workflow. You can replace workflow_id with the workflow file name. You can use parameters to narrow the list of results. [Docs](https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow).$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'POST',
|
||||
CONCAT_WS('/', 'https://api.github.com', route),
|
||||
PARSE_JSON({{ schema_name -}}.headers()),
|
||||
data,
|
||||
IFF(_utils.udf_whoami() <> CURRENT_USER(), '_FSC_SYS/GITHUB', 'Vault/github/api'),
|
||||
TRUE
|
||||
IFF(_utils.udf_whoami() <> CURRENT_USER(), '_FSC_SYS/GITHUB', 'Vault/github/api')
|
||||
)
|
||||
{%- else -%}
|
||||
live.udf_api(
|
||||
@ -115,16 +113,15 @@
|
||||
options: |
|
||||
COMMENT = $$List all workflow runs for a workflow. You can replace workflow_id with the workflow file name. You can use parameters to narrow the list of results. [Docs](https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow).$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'PUT',
|
||||
CONCAT_WS('/', 'https://api.github.com', route),
|
||||
PARSE_JSON({{ schema_name -}}.headers()),
|
||||
data,
|
||||
IFF(_utils.udf_whoami() <> CURRENT_USER(), '_FSC_SYS/GITHUB', 'Vault/github/api'),
|
||||
TRUE
|
||||
IFF(_utils.udf_whoami() <> CURRENT_USER(), '_FSC_SYS/GITHUB', 'Vault/github/api')
|
||||
)
|
||||
{%- else -%}
|
||||
live.udf_api(
|
||||
|
||||
@ -22,15 +22,15 @@
|
||||
options: |
|
||||
COMMENT = $$Returns the native Solana balance (in lamports) and all token balances for a given address. [Helius docs here](https://docs.helius.xyz/solana-apis/balances-api).$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'GET',
|
||||
CASE
|
||||
WHEN NETWORK = 'devnet' THEN
|
||||
CASE
|
||||
WHEN NETWORK = 'devnet' THEN
|
||||
concat('https://api-devnet.helius.xyz/v0/addresses/', ADDRESS, '/balances?api-key={API_KEY}')
|
||||
ELSE
|
||||
ELSE
|
||||
concat('https://api.helius.xyz/v0/addresses/', ADDRESS, '/balances?api-key={API_KEY}')
|
||||
END,
|
||||
{'fsc-quantum-execution-mode': 'async'},
|
||||
@ -41,10 +41,10 @@
|
||||
{%- else -%}
|
||||
live.udf_api(
|
||||
'GET',
|
||||
CASE
|
||||
WHEN NETWORK = 'devnet' THEN
|
||||
CASE
|
||||
WHEN NETWORK = 'devnet' THEN
|
||||
concat('https://api-devnet.helius.xyz/v0/addresses/', ADDRESS, '/balances?api-key={API_KEY}')
|
||||
ELSE
|
||||
ELSE
|
||||
concat('https://api.helius.xyz/v0/addresses/', ADDRESS, '/balances?api-key={API_KEY}')
|
||||
END,
|
||||
{},
|
||||
@ -65,4 +65,4 @@
|
||||
sql: |
|
||||
SELECT {{ utils_schema_name -}}.post_api(NETWORK, '/v0/transactions', {'transactions': TRANSACTIONS}) as response
|
||||
|
||||
{% endmacro %}
|
||||
{% endmacro %}
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
options: |
|
||||
COMMENT = $$Used to issue an HTTP GET request to Helius.$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'GET',
|
||||
@ -55,8 +55,8 @@
|
||||
options: |
|
||||
COMMENT = $$Used to issue an HTTP POST request to Helius.$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'POST',
|
||||
@ -97,8 +97,8 @@
|
||||
options: |
|
||||
COMMENT = $$Used to issue an RPC call to Helius.$$
|
||||
sql: |
|
||||
SELECT
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
SELECT
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'POST',
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
WHEN PAYLOAD IS NULL THEN
|
||||
OBJECT_CONSTRUCT('ok', false, 'error', 'payload is required')
|
||||
ELSE
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'POST',
|
||||
@ -58,7 +58,7 @@
|
||||
WHEN PAYLOAD IS NULL THEN
|
||||
OBJECT_CONSTRUCT('ok', false, 'error', 'payload is required')
|
||||
ELSE
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'POST',
|
||||
@ -123,7 +123,7 @@
|
||||
WHEN PAYLOAD IS NULL THEN
|
||||
OBJECT_CONSTRUCT('ok', false, 'error', 'payload is required')
|
||||
ELSE
|
||||
{% set v2_exists = check_udf_api_v2_exists() %}
|
||||
{% set v2_exists = is_udf_api_v2_compatible() %}
|
||||
{% if v2_exists -%}
|
||||
live.udf_api_v2(
|
||||
'POST',
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
{% if is_udf_api_v2_compatible() %}
|
||||
{{ create_s3_express_external_access_integration() }}
|
||||
{% endif %}
|
||||
|
||||
-- this is to pass the model render as dbt dependency in other models
|
||||
-- livequery will need s3 express access to read from the s3 bucket
|
||||
|
||||
Loading…
Reference in New Issue
Block a user