mirror of
https://github.com/FlipsideCrypto/livequery-models.git
synced 2026-02-06 10:56:46 +00:00
Merge efbd76076d into da46dc4a8e
This commit is contained in:
commit
371a3956ef
@ -6,7 +6,7 @@ version: "1.0.0"
|
||||
config-version: 2
|
||||
|
||||
# This setting configures which "profile" dbt uses for this project.
|
||||
profile: "livequery"
|
||||
profile: livequery
|
||||
|
||||
# These configurations specify where dbt should look for different types of files.
|
||||
# The `source-paths` config, for example, states that models in this project can be
|
||||
|
||||
@ -14,4 +14,50 @@
|
||||
options: |
|
||||
NOT NULL
|
||||
sql: udf_api
|
||||
|
||||
- name: {{ schema }}.udf_rest_api_args_only
|
||||
signature:
|
||||
- [method, STRING]
|
||||
- [url, STRING]
|
||||
- [headers, OBJECT]
|
||||
- [DATA, VARIANT]
|
||||
- [SECRET_NAME, STRING]
|
||||
return_type: OBJECT
|
||||
func_type: SECURE
|
||||
options: |
|
||||
NOT NULL
|
||||
RETURNS NULL ON NULL INPUT
|
||||
sql: |
|
||||
{
|
||||
'method': method,
|
||||
'url': url,
|
||||
'headers': headers,
|
||||
'data': data,
|
||||
'secret_name': SECRET_NAME
|
||||
}
|
||||
|
||||
{# - name: {{ schema }}.udf_api
|
||||
description: |
|
||||
This function is used to select the appropriate function to call based on the user_id
|
||||
signature:
|
||||
- [method, STRING]
|
||||
- [url, STRING]
|
||||
- [headers, OBJECT]
|
||||
- [DATA, VARIANT]
|
||||
- [user_id, STRING]
|
||||
- [SECRET, STRING]
|
||||
return_type: VARIANT
|
||||
func_type: SECURE
|
||||
options: |
|
||||
NOT NULL
|
||||
RETURNS NULL ON NULL INPUT
|
||||
sql: |
|
||||
SELECT
|
||||
CASE
|
||||
WHEN user_id ilike 'AWS_%'
|
||||
THEN {{ schema }}.udf_rest_api_args_only(method, url, headers, DATA, SECRET)::VARIANT
|
||||
ELSE {{ schema }}._udf_api(method, url, headers, DATA, user_id, SECRET)
|
||||
END #}
|
||||
|
||||
|
||||
{% endmacro %}
|
||||
@ -108,6 +108,24 @@
|
||||
secret_name
|
||||
)
|
||||
|
||||
- name: {{ schema }}.udf_api
|
||||
signature:
|
||||
- [args, OBJECT]
|
||||
return_type: VARIANT
|
||||
options: |
|
||||
NOT NULL
|
||||
VOLATILE
|
||||
sql: |
|
||||
SELECT
|
||||
_live.UDF_API(
|
||||
COALESCE(args:method, 'GET'),
|
||||
args:url,
|
||||
COALESCE(args:headers, {}),
|
||||
COALESCE(args:data, {}),
|
||||
_utils.UDF_WHOAMI(),
|
||||
COALESCE(args:secret_name, '')
|
||||
)
|
||||
|
||||
- name: {{ schema }}.udf_rpc
|
||||
signature:
|
||||
- [blockchain, STRING]
|
||||
|
||||
47
models/deploy/core/_live._yml
Normal file
47
models/deploy/core/_live._yml
Normal file
@ -0,0 +1,47 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: _live
|
||||
columns:
|
||||
- name: udf_rest_api_args_only
|
||||
tests:
|
||||
- test_udf:
|
||||
name: test___live_udf_rest_api_args_only
|
||||
args: >
|
||||
'GET',
|
||||
'https://api.example.com',
|
||||
{'Content-Type': 'application/json'},
|
||||
{'hello': 'world'},
|
||||
'my_secret'
|
||||
assertions:
|
||||
- |
|
||||
result = {
|
||||
'method': 'GET',
|
||||
'url': 'https://api.example.com',
|
||||
'headers': {'Content-Type': 'application/json'},
|
||||
'data': {'hello': 'world'},
|
||||
'secret_name': 'my_secret'
|
||||
}
|
||||
- test_udf:
|
||||
name: test___live_udf_rest_api_args_only_null
|
||||
args: null, null, null, null, null
|
||||
assertions:
|
||||
- result = {}
|
||||
- test_udf:
|
||||
name: test___live_udf_api
|
||||
args: >
|
||||
'GET',
|
||||
'https://api.example.com',
|
||||
{'Content-Type': 'application/json'},
|
||||
{'hello': 'world'},
|
||||
'non_streamline_user'
|
||||
'my_secret'
|
||||
assertions:
|
||||
- |
|
||||
result = {
|
||||
'method': 'GET',
|
||||
'url': 'https://httpbin.org/get',
|
||||
'headers': {'Content-Type': 'application/json'},
|
||||
'data': {'hello': 'world'},
|
||||
'user': 'non_streamline_user',
|
||||
'secret_name': 'my_secret'
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user