diff --git a/docs/resources/function_java.md b/docs/resources/function_java.md new file mode 100644 index 0000000000..eb8062232b --- /dev/null +++ b/docs/resources/function_java.md @@ -0,0 +1,105 @@ +--- +page_title: "snowflake_function_java Resource - terraform-provider-snowflake" +subcategory: "" +description: |- + Resource used to manage java function objects. For more information, check function documentation https://docs.snowflake.com/en/sql-reference/sql/create-function. +--- + +# snowflake_function_java (Resource) + +Resource used to manage java function objects. For more information, check [function documentation](https://docs.snowflake.com/en/sql-reference/sql/create-function). + + + + +## Schema + +### Required + +- `database` (String) The database in which to create the function. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. +- `function_definition` (String) Defines the handler code executed when the UDF is called. Wrapping `$$` signs are added by the provider automatically; do not include them. The `function_definition` value must be Java source code. For more information, see [Introduction to Java UDFs](https://docs.snowflake.com/en/developer-guide/udf/java/udf-java-introduction). +- `handler` (String) The name of the handler method or class. If the handler is for a scalar UDF, returning a non-tabular value, the HANDLER value should be a method name, as in the following form: `MyClass.myMethod`. If the handler is for a tabular UDF, the HANDLER value should be the name of a handler class. +- `name` (String) The name of the function; the identifier does not need to be unique for the schema in which the function is created because UDFs are identified and resolved by the combination of the name and argument types. Check the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages). Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. +- `return_type` (String) Specifies the results returned by the UDF, which determines the UDF type. Use `` to create a scalar UDF that returns a single value with the specified data type. Use `TABLE (col_name col_data_type, ...)` to creates a table UDF that returns tabular results with the specified table column(s) and column type(s). For the details, consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages). +- `schema` (String) The schema in which to create the function. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. + +### Optional + +- `arguments` (Block List) List of the arguments for the function. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages) for more details. (see [below for nested schema](#nestedblock--arguments)) +- `comment` (String) Specifies a comment for the function. +- `enable_console_output` (Boolean) Enable stdout/stderr fast path logging for anonyous stored procs. This is a public parameter (similar to LOG_LEVEL). For more information, check [ENABLE_CONSOLE_OUTPUT docs](https://docs.snowflake.com/en/sql-reference/parameters#enable-console-output). +- `external_access_integrations` (Set of String) The names of [external access integrations](https://docs.snowflake.com/en/sql-reference/sql/create-external-access-integration) needed in order for this function’s handler code to access external networks. An external access integration specifies [network rules](https://docs.snowflake.com/en/sql-reference/sql/create-network-rule) and [secrets](https://docs.snowflake.com/en/sql-reference/sql/create-secret) that specify external locations and credentials (if any) allowed for use by handler code when making requests of an external network, such as an external REST API. +- `imports` (Set of String) The location (stage), path, and name of the file(s) to import. A file can be a JAR file or another type of file. If the file is a JAR file, it can contain one or more .class files and zero or more resource files. JNI (Java Native Interface) is not supported. Snowflake prohibits loading libraries that contain native code (as opposed to Java bytecode). Java UDFs can also read non-JAR files. For an example, see [Reading a file specified statically in IMPORTS](https://docs.snowflake.com/en/developer-guide/udf/java/udf-java-cookbook.html#label-reading-file-from-java-udf-imports). Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#java). +- `is_secure` (String) Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure views (consult [function docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#id1) and [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure)) which is essential to manage/import function with Terraform. Use the role owning the function while managing secure functions. Available options are: "true" or "false". When the value is not set in the configuration the provider will put "default" there which means to use the Snowflake default for this value. +- `log_level` (String) LOG_LEVEL to use when filtering events For more information, check [LOG_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#log-level). +- `metric_level` (String) METRIC_LEVEL value to control whether to emit metrics to Event Table For more information, check [METRIC_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#metric-level). +- `null_input_behavior` (String) Specifies the behavior of the function when called with null inputs. Valid values are (case-insensitive): `CALLED ON NULL INPUT` | `RETURNS NULL ON NULL INPUT`. +- `packages` (Set of String) The name and version number of Snowflake system packages required as dependencies. The value should be of the form `package_name:version_number`, where `package_name` is `snowflake_domain:package`. +- `return_behavior` (String) Specifies the behavior of the function when returning results. Valid values are (case-insensitive): `VOLATILE` | `IMMUTABLE`. +- `runtime_version` (String) Specifies the Java JDK runtime version to use. The supported versions of Java are 11.x and 17.x. If RUNTIME_VERSION is not set, Java JDK 11 is used. +- `secrets` (Block Set) Assigns the names of secrets to variables so that you can use the variables to reference the secrets when retrieving information from secrets in handler code. Secrets you specify here must be allowed by the [external access integration](https://docs.snowflake.com/en/sql-reference/sql/create-external-access-integration) specified as a value of this CREATE FUNCTION command’s EXTERNAL_ACCESS_INTEGRATIONS parameter. (see [below for nested schema](#nestedblock--secrets)) +- `target_path` (String) The name of the handler method or class. If the handler is for a scalar UDF, returning a non-tabular value, the HANDLER value should be a method name, as in the following form: `MyClass.myMethod`. If the handler is for a tabular UDF, the HANDLER value should be the name of a handler class. +- `trace_level` (String) Trace level value to use when generating/filtering trace events For more information, check [TRACE_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#trace-level). + +### Read-Only + +- `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution). +- `function_language` (String) Specifies language for the user. Used to detect external changes. +- `id` (String) The ID of this resource. +- `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN FUNCTION` for the given function. (see [below for nested schema](#nestedatt--parameters)) +- `show_output` (List of Object) Outputs the result of `SHOW FUNCTION` for the given function. (see [below for nested schema](#nestedatt--show_output)) + + +### Nested Schema for `arguments` + +Required: + +- `arg_data_type` (String) The argument type. +- `arg_name` (String) The argument name. + + + +### Nested Schema for `secrets` + +Required: + +- `secret_id` (String) Fully qualified name of the allowed secret. You will receive an error if you specify a SECRETS value whose secret isn’t also included in an integration specified by the EXTERNAL_ACCESS_INTEGRATIONS parameter. +- `secret_variable_name` (String) The variable that will be used in handler code when retrieving information from the secret. + + + +### Nested Schema for `parameters` + +Read-Only: + +- `enable_console_output` (Boolean) +- `log_level` (String) +- `metric_level` (String) +- `trace_level` (String) + + + +### Nested Schema for `show_output` + +Read-Only: + +- `arguments_raw` (String) +- `catalog_name` (String) +- `created_on` (String) +- `description` (String) +- `external_access_integrations` (String) +- `is_aggregate` (Boolean) +- `is_ansi` (Boolean) +- `is_builtin` (Boolean) +- `is_data_metric` (Boolean) +- `is_external_function` (Boolean) +- `is_memoizable` (Boolean) +- `is_secure` (Boolean) +- `is_table_function` (Boolean) +- `language` (String) +- `max_num_arguments` (Number) +- `min_num_arguments` (Number) +- `name` (String) +- `schema_name` (String) +- `secrets` (String) +- `valid_for_clustering` (Boolean) diff --git a/docs/resources/function_javascript.md b/docs/resources/function_javascript.md new file mode 100644 index 0000000000..7925c74c59 --- /dev/null +++ b/docs/resources/function_javascript.md @@ -0,0 +1,89 @@ +--- +page_title: "snowflake_function_javascript Resource - terraform-provider-snowflake" +subcategory: "" +description: |- + Resource used to manage javascript function objects. For more information, check function documentation https://docs.snowflake.com/en/sql-reference/sql/create-function. +--- + +# snowflake_function_javascript (Resource) + +Resource used to manage javascript function objects. For more information, check [function documentation](https://docs.snowflake.com/en/sql-reference/sql/create-function). + + + + +## Schema + +### Required + +- `database` (String) The database in which to create the function. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. +- `function_definition` (String) Defines the handler code executed when the UDF is called. Wrapping `$$` signs are added by the provider automatically; do not include them. The `function_definition` value must be JavaScript source code. For more information, see [Introduction to JavaScript UDFs](https://docs.snowflake.com/en/developer-guide/udf/javascript/udf-javascript-introduction). +- `name` (String) The name of the function; the identifier does not need to be unique for the schema in which the function is created because UDFs are identified and resolved by the combination of the name and argument types. Check the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages). Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. +- `return_type` (String) Specifies the results returned by the UDF, which determines the UDF type. Use `` to create a scalar UDF that returns a single value with the specified data type. Use `TABLE (col_name col_data_type, ...)` to creates a table UDF that returns tabular results with the specified table column(s) and column type(s). For the details, consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages). +- `schema` (String) The schema in which to create the function. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. + +### Optional + +- `arguments` (Block List) List of the arguments for the function. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages) for more details. (see [below for nested schema](#nestedblock--arguments)) +- `comment` (String) Specifies a comment for the function. +- `enable_console_output` (Boolean) Enable stdout/stderr fast path logging for anonyous stored procs. This is a public parameter (similar to LOG_LEVEL). For more information, check [ENABLE_CONSOLE_OUTPUT docs](https://docs.snowflake.com/en/sql-reference/parameters#enable-console-output). +- `is_secure` (String) Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure views (consult [function docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#id1) and [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure)) which is essential to manage/import function with Terraform. Use the role owning the function while managing secure functions. Available options are: "true" or "false". When the value is not set in the configuration the provider will put "default" there which means to use the Snowflake default for this value. +- `log_level` (String) LOG_LEVEL to use when filtering events For more information, check [LOG_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#log-level). +- `metric_level` (String) METRIC_LEVEL value to control whether to emit metrics to Event Table For more information, check [METRIC_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#metric-level). +- `null_input_behavior` (String) Specifies the behavior of the function when called with null inputs. Valid values are (case-insensitive): `CALLED ON NULL INPUT` | `RETURNS NULL ON NULL INPUT`. +- `return_behavior` (String) Specifies the behavior of the function when returning results. Valid values are (case-insensitive): `VOLATILE` | `IMMUTABLE`. +- `trace_level` (String) Trace level value to use when generating/filtering trace events For more information, check [TRACE_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#trace-level). + +### Read-Only + +- `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution). +- `function_language` (String) Specifies language for the user. Used to detect external changes. +- `id` (String) The ID of this resource. +- `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN FUNCTION` for the given function. (see [below for nested schema](#nestedatt--parameters)) +- `show_output` (List of Object) Outputs the result of `SHOW FUNCTION` for the given function. (see [below for nested schema](#nestedatt--show_output)) + + +### Nested Schema for `arguments` + +Required: + +- `arg_data_type` (String) The argument type. +- `arg_name` (String) The argument name. + + + +### Nested Schema for `parameters` + +Read-Only: + +- `enable_console_output` (Boolean) +- `log_level` (String) +- `metric_level` (String) +- `trace_level` (String) + + + +### Nested Schema for `show_output` + +Read-Only: + +- `arguments_raw` (String) +- `catalog_name` (String) +- `created_on` (String) +- `description` (String) +- `external_access_integrations` (String) +- `is_aggregate` (Boolean) +- `is_ansi` (Boolean) +- `is_builtin` (Boolean) +- `is_data_metric` (Boolean) +- `is_external_function` (Boolean) +- `is_memoizable` (Boolean) +- `is_secure` (Boolean) +- `is_table_function` (Boolean) +- `language` (String) +- `max_num_arguments` (Number) +- `min_num_arguments` (Number) +- `name` (String) +- `schema_name` (String) +- `secrets` (String) +- `valid_for_clustering` (Boolean) diff --git a/docs/resources/function_python.md b/docs/resources/function_python.md new file mode 100644 index 0000000000..814e7a38de --- /dev/null +++ b/docs/resources/function_python.md @@ -0,0 +1,105 @@ +--- +page_title: "snowflake_function_python Resource - terraform-provider-snowflake" +subcategory: "" +description: |- + Resource used to manage python function objects. For more information, check function documentation https://docs.snowflake.com/en/sql-reference/sql/create-function. +--- + +# snowflake_function_python (Resource) + +Resource used to manage python function objects. For more information, check [function documentation](https://docs.snowflake.com/en/sql-reference/sql/create-function). + + + + +## Schema + +### Required + +- `database` (String) The database in which to create the function. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. +- `function_definition` (String) Defines the handler code executed when the UDF is called. Wrapping `$$` signs are added by the provider automatically; do not include them. The `function_definition` value must be Python source code. For more information, see [Introduction to Python UDFs](https://docs.snowflake.com/en/developer-guide/udf/python/udf-python-introduction). +- `handler` (String) The name of the handler function or class. If the handler is for a scalar UDF, returning a non-tabular value, the HANDLER value should be a function name. If the handler code is in-line with the CREATE FUNCTION statement, you can use the function name alone. When the handler code is referenced at a stage, this value should be qualified with the module name, as in the following form: `my_module.my_function`. If the handler is for a tabular UDF, the HANDLER value should be the name of a handler class. +- `name` (String) The name of the function; the identifier does not need to be unique for the schema in which the function is created because UDFs are identified and resolved by the combination of the name and argument types. Check the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages). Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. +- `return_type` (String) Specifies the results returned by the UDF, which determines the UDF type. Use `` to create a scalar UDF that returns a single value with the specified data type. Use `TABLE (col_name col_data_type, ...)` to creates a table UDF that returns tabular results with the specified table column(s) and column type(s). For the details, consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages). +- `runtime_version` (String) Specifies the Python version to use. The supported versions of Python are: 3.9, 3.10, and 3.11. +- `schema` (String) The schema in which to create the function. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. + +### Optional + +- `arguments` (Block List) List of the arguments for the function. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages) for more details. (see [below for nested schema](#nestedblock--arguments)) +- `comment` (String) Specifies a comment for the function. +- `enable_console_output` (Boolean) Enable stdout/stderr fast path logging for anonyous stored procs. This is a public parameter (similar to LOG_LEVEL). For more information, check [ENABLE_CONSOLE_OUTPUT docs](https://docs.snowflake.com/en/sql-reference/parameters#enable-console-output). +- `external_access_integrations` (Set of String) The names of [external access integrations](https://docs.snowflake.com/en/sql-reference/sql/create-external-access-integration) needed in order for this function’s handler code to access external networks. An external access integration specifies [network rules](https://docs.snowflake.com/en/sql-reference/sql/create-network-rule) and [secrets](https://docs.snowflake.com/en/sql-reference/sql/create-secret) that specify external locations and credentials (if any) allowed for use by handler code when making requests of an external network, such as an external REST API. +- `imports` (Set of String) The location (stage), path, and name of the file(s) to import. A file can be a `.py` file or another type of file. Python UDFs can also read non-Python files, such as text files. For an example, see [Reading a file](https://docs.snowflake.com/en/developer-guide/udf/python/udf-python-examples.html#label-udf-python-read-files). Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#python). +- `is_aggregate` (String) Specifies that the function is an aggregate function. For more information about user-defined aggregate functions, see [Python user-defined aggregate functions](https://docs.snowflake.com/en/developer-guide/udf/python/udf-python-aggregate-functions). Available options are: "true" or "false". When the value is not set in the configuration the provider will put "default" there which means to use the Snowflake default for this value. +- `is_secure` (String) Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure views (consult [function docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#id1) and [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure)) which is essential to manage/import function with Terraform. Use the role owning the function while managing secure functions. Available options are: "true" or "false". When the value is not set in the configuration the provider will put "default" there which means to use the Snowflake default for this value. +- `log_level` (String) LOG_LEVEL to use when filtering events For more information, check [LOG_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#log-level). +- `metric_level` (String) METRIC_LEVEL value to control whether to emit metrics to Event Table For more information, check [METRIC_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#metric-level). +- `null_input_behavior` (String) Specifies the behavior of the function when called with null inputs. Valid values are (case-insensitive): `CALLED ON NULL INPUT` | `RETURNS NULL ON NULL INPUT`. +- `packages` (Set of String) The name and version number of packages required as dependencies. The value should be of the form `package_name==version_number`. +- `return_behavior` (String) Specifies the behavior of the function when returning results. Valid values are (case-insensitive): `VOLATILE` | `IMMUTABLE`. +- `secrets` (Block Set) Assigns the names of secrets to variables so that you can use the variables to reference the secrets when retrieving information from secrets in handler code. Secrets you specify here must be allowed by the [external access integration](https://docs.snowflake.com/en/sql-reference/sql/create-external-access-integration) specified as a value of this CREATE FUNCTION command’s EXTERNAL_ACCESS_INTEGRATIONS parameter. (see [below for nested schema](#nestedblock--secrets)) +- `trace_level` (String) Trace level value to use when generating/filtering trace events For more information, check [TRACE_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#trace-level). + +### Read-Only + +- `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution). +- `function_language` (String) Specifies language for the user. Used to detect external changes. +- `id` (String) The ID of this resource. +- `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN FUNCTION` for the given function. (see [below for nested schema](#nestedatt--parameters)) +- `show_output` (List of Object) Outputs the result of `SHOW FUNCTION` for the given function. (see [below for nested schema](#nestedatt--show_output)) + + +### Nested Schema for `arguments` + +Required: + +- `arg_data_type` (String) The argument type. +- `arg_name` (String) The argument name. + + + +### Nested Schema for `secrets` + +Required: + +- `secret_id` (String) Fully qualified name of the allowed secret. You will receive an error if you specify a SECRETS value whose secret isn’t also included in an integration specified by the EXTERNAL_ACCESS_INTEGRATIONS parameter. +- `secret_variable_name` (String) The variable that will be used in handler code when retrieving information from the secret. + + + +### Nested Schema for `parameters` + +Read-Only: + +- `enable_console_output` (Boolean) +- `log_level` (String) +- `metric_level` (String) +- `trace_level` (String) + + + +### Nested Schema for `show_output` + +Read-Only: + +- `arguments_raw` (String) +- `catalog_name` (String) +- `created_on` (String) +- `description` (String) +- `external_access_integrations` (String) +- `is_aggregate` (Boolean) +- `is_ansi` (Boolean) +- `is_builtin` (Boolean) +- `is_data_metric` (Boolean) +- `is_external_function` (Boolean) +- `is_memoizable` (Boolean) +- `is_secure` (Boolean) +- `is_table_function` (Boolean) +- `language` (String) +- `max_num_arguments` (Number) +- `min_num_arguments` (Number) +- `name` (String) +- `schema_name` (String) +- `secrets` (String) +- `valid_for_clustering` (Boolean) diff --git a/docs/resources/function_scala.md b/docs/resources/function_scala.md new file mode 100644 index 0000000000..5fffff6762 --- /dev/null +++ b/docs/resources/function_scala.md @@ -0,0 +1,105 @@ +--- +page_title: "snowflake_function_scala Resource - terraform-provider-snowflake" +subcategory: "" +description: |- + Resource used to manage scala function objects. For more information, check function documentation https://docs.snowflake.com/en/sql-reference/sql/create-function. +--- + +# snowflake_function_scala (Resource) + +Resource used to manage scala function objects. For more information, check [function documentation](https://docs.snowflake.com/en/sql-reference/sql/create-function). + + + + +## Schema + +### Required + +- `database` (String) The database in which to create the function. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. +- `function_definition` (String) Defines the handler code executed when the UDF is called. Wrapping `$$` signs are added by the provider automatically; do not include them. The `function_definition` value must be Scala source code. For more information, see [Introduction to Scala UDFs](https://docs.snowflake.com/en/developer-guide/udf/scala/udf-scala-introduction). +- `handler` (String) The name of the handler method or class. If the handler is for a scalar UDF, returning a non-tabular value, the HANDLER value should be a method name, as in the following form: `MyClass.myMethod`. +- `name` (String) The name of the function; the identifier does not need to be unique for the schema in which the function is created because UDFs are identified and resolved by the combination of the name and argument types. Check the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages). Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. +- `return_type` (String) Specifies the results returned by the UDF, which determines the UDF type. Use `` to create a scalar UDF that returns a single value with the specified data type. Use `TABLE (col_name col_data_type, ...)` to creates a table UDF that returns tabular results with the specified table column(s) and column type(s). For the details, consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages). +- `runtime_version` (String) Specifies the Scala runtime version to use. The supported versions of Scala are: 2.12. +- `schema` (String) The schema in which to create the function. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. + +### Optional + +- `arguments` (Block List) List of the arguments for the function. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages) for more details. (see [below for nested schema](#nestedblock--arguments)) +- `comment` (String) Specifies a comment for the function. +- `enable_console_output` (Boolean) Enable stdout/stderr fast path logging for anonyous stored procs. This is a public parameter (similar to LOG_LEVEL). For more information, check [ENABLE_CONSOLE_OUTPUT docs](https://docs.snowflake.com/en/sql-reference/parameters#enable-console-output). +- `external_access_integrations` (Set of String) The names of [external access integrations](https://docs.snowflake.com/en/sql-reference/sql/create-external-access-integration) needed in order for this function’s handler code to access external networks. An external access integration specifies [network rules](https://docs.snowflake.com/en/sql-reference/sql/create-network-rule) and [secrets](https://docs.snowflake.com/en/sql-reference/sql/create-secret) that specify external locations and credentials (if any) allowed for use by handler code when making requests of an external network, such as an external REST API. +- `imports` (Set of String) The location (stage), path, and name of the file(s) to import, such as a JAR or other kind of file. The JAR file might contain handler dependency libraries. It can contain one or more .class files and zero or more resource files. JNI (Java Native Interface) is not supported. Snowflake prohibits loading libraries that contain native code (as opposed to Java bytecode). A non-JAR file might a file read by handler code. For an example, see [Reading a file specified statically in IMPORTS](https://docs.snowflake.com/en/developer-guide/udf/java/udf-java-cookbook.html#label-reading-file-from-java-udf-imports). Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#scala). +- `is_secure` (String) Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure views (consult [function docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#id1) and [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure)) which is essential to manage/import function with Terraform. Use the role owning the function while managing secure functions. Available options are: "true" or "false". When the value is not set in the configuration the provider will put "default" there which means to use the Snowflake default for this value. +- `log_level` (String) LOG_LEVEL to use when filtering events For more information, check [LOG_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#log-level). +- `metric_level` (String) METRIC_LEVEL value to control whether to emit metrics to Event Table For more information, check [METRIC_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#metric-level). +- `null_input_behavior` (String) Specifies the behavior of the function when called with null inputs. Valid values are (case-insensitive): `CALLED ON NULL INPUT` | `RETURNS NULL ON NULL INPUT`. +- `packages` (Set of String) The name and version number of Snowflake system packages required as dependencies. The value should be of the form `package_name:version_number`, where `package_name` is `snowflake_domain:package`. +- `return_behavior` (String) Specifies the behavior of the function when returning results. Valid values are (case-insensitive): `VOLATILE` | `IMMUTABLE`. +- `secrets` (Block Set) Assigns the names of secrets to variables so that you can use the variables to reference the secrets when retrieving information from secrets in handler code. Secrets you specify here must be allowed by the [external access integration](https://docs.snowflake.com/en/sql-reference/sql/create-external-access-integration) specified as a value of this CREATE FUNCTION command’s EXTERNAL_ACCESS_INTEGRATIONS parameter. (see [below for nested schema](#nestedblock--secrets)) +- `target_path` (String) The name of the handler method or class. If the handler is for a scalar UDF, returning a non-tabular value, the HANDLER value should be a method name, as in the following form: `MyClass.myMethod`. +- `trace_level` (String) Trace level value to use when generating/filtering trace events For more information, check [TRACE_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#trace-level). + +### Read-Only + +- `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution). +- `function_language` (String) Specifies language for the user. Used to detect external changes. +- `id` (String) The ID of this resource. +- `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN FUNCTION` for the given function. (see [below for nested schema](#nestedatt--parameters)) +- `show_output` (List of Object) Outputs the result of `SHOW FUNCTION` for the given function. (see [below for nested schema](#nestedatt--show_output)) + + +### Nested Schema for `arguments` + +Required: + +- `arg_data_type` (String) The argument type. +- `arg_name` (String) The argument name. + + + +### Nested Schema for `secrets` + +Required: + +- `secret_id` (String) Fully qualified name of the allowed secret. You will receive an error if you specify a SECRETS value whose secret isn’t also included in an integration specified by the EXTERNAL_ACCESS_INTEGRATIONS parameter. +- `secret_variable_name` (String) The variable that will be used in handler code when retrieving information from the secret. + + + +### Nested Schema for `parameters` + +Read-Only: + +- `enable_console_output` (Boolean) +- `log_level` (String) +- `metric_level` (String) +- `trace_level` (String) + + + +### Nested Schema for `show_output` + +Read-Only: + +- `arguments_raw` (String) +- `catalog_name` (String) +- `created_on` (String) +- `description` (String) +- `external_access_integrations` (String) +- `is_aggregate` (Boolean) +- `is_ansi` (Boolean) +- `is_builtin` (Boolean) +- `is_data_metric` (Boolean) +- `is_external_function` (Boolean) +- `is_memoizable` (Boolean) +- `is_secure` (Boolean) +- `is_table_function` (Boolean) +- `language` (String) +- `max_num_arguments` (Number) +- `min_num_arguments` (Number) +- `name` (String) +- `schema_name` (String) +- `secrets` (String) +- `valid_for_clustering` (Boolean) diff --git a/docs/resources/function_sql.md b/docs/resources/function_sql.md new file mode 100644 index 0000000000..e37e57514d --- /dev/null +++ b/docs/resources/function_sql.md @@ -0,0 +1,89 @@ +--- +page_title: "snowflake_function_sql Resource - terraform-provider-snowflake" +subcategory: "" +description: |- + Resource used to manage sql function objects. For more information, check function documentation https://docs.snowflake.com/en/sql-reference/sql/create-function. +--- + +# snowflake_function_sql (Resource) + +Resource used to manage sql function objects. For more information, check [function documentation](https://docs.snowflake.com/en/sql-reference/sql/create-function). + + + + +## Schema + +### Required + +- `database` (String) The database in which to create the function. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. +- `function_definition` (String) Defines the handler code executed when the UDF is called. Wrapping `$$` signs are added by the provider automatically; do not include them. The `function_definition` value must be SQL source code. For more information, see [Introduction to SQL UDFs](https://docs.snowflake.com/en/developer-guide/udf/sql/udf-sql-introduction). +- `name` (String) The name of the function; the identifier does not need to be unique for the schema in which the function is created because UDFs are identified and resolved by the combination of the name and argument types. Check the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages). Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. +- `return_type` (String) Specifies the results returned by the UDF, which determines the UDF type. Use `` to create a scalar UDF that returns a single value with the specified data type. Use `TABLE (col_name col_data_type, ...)` to creates a table UDF that returns tabular results with the specified table column(s) and column type(s). For the details, consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages). +- `schema` (String) The schema in which to create the function. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `"`. + +### Optional + +- `arguments` (Block List) List of the arguments for the function. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages) for more details. (see [below for nested schema](#nestedblock--arguments)) +- `comment` (String) Specifies a comment for the function. +- `enable_console_output` (Boolean) Enable stdout/stderr fast path logging for anonyous stored procs. This is a public parameter (similar to LOG_LEVEL). For more information, check [ENABLE_CONSOLE_OUTPUT docs](https://docs.snowflake.com/en/sql-reference/parameters#enable-console-output). +- `is_secure` (String) Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure views (consult [function docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#id1) and [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure)) which is essential to manage/import function with Terraform. Use the role owning the function while managing secure functions. Available options are: "true" or "false". When the value is not set in the configuration the provider will put "default" there which means to use the Snowflake default for this value. +- `log_level` (String) LOG_LEVEL to use when filtering events For more information, check [LOG_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#log-level). +- `metric_level` (String) METRIC_LEVEL value to control whether to emit metrics to Event Table For more information, check [METRIC_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#metric-level). +- `null_input_behavior` (String) Specifies the behavior of the function when called with null inputs. Valid values are (case-insensitive): `CALLED ON NULL INPUT` | `RETURNS NULL ON NULL INPUT`. +- `return_behavior` (String) Specifies the behavior of the function when returning results. Valid values are (case-insensitive): `VOLATILE` | `IMMUTABLE`. +- `trace_level` (String) Trace level value to use when generating/filtering trace events For more information, check [TRACE_LEVEL docs](https://docs.snowflake.com/en/sql-reference/parameters#trace-level). + +### Read-Only + +- `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution). +- `function_language` (String) Specifies language for the user. Used to detect external changes. +- `id` (String) The ID of this resource. +- `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN FUNCTION` for the given function. (see [below for nested schema](#nestedatt--parameters)) +- `show_output` (List of Object) Outputs the result of `SHOW FUNCTION` for the given function. (see [below for nested schema](#nestedatt--show_output)) + + +### Nested Schema for `arguments` + +Required: + +- `arg_data_type` (String) The argument type. +- `arg_name` (String) The argument name. + + + +### Nested Schema for `parameters` + +Read-Only: + +- `enable_console_output` (Boolean) +- `log_level` (String) +- `metric_level` (String) +- `trace_level` (String) + + + +### Nested Schema for `show_output` + +Read-Only: + +- `arguments_raw` (String) +- `catalog_name` (String) +- `created_on` (String) +- `description` (String) +- `external_access_integrations` (String) +- `is_aggregate` (Boolean) +- `is_ansi` (Boolean) +- `is_builtin` (Boolean) +- `is_data_metric` (Boolean) +- `is_external_function` (Boolean) +- `is_memoizable` (Boolean) +- `is_secure` (Boolean) +- `is_table_function` (Boolean) +- `language` (String) +- `max_num_arguments` (Number) +- `min_num_arguments` (Number) +- `name` (String) +- `schema_name` (String) +- `secrets` (String) +- `valid_for_clustering` (Boolean) diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/function_java_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/function_java_resource_gen.go new file mode 100644 index 0000000000..089d621565 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/function_java_resource_gen.go @@ -0,0 +1,267 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" +) + +type FunctionJavaResourceAssert struct { + *assert.ResourceAssert +} + +func FunctionJavaResource(t *testing.T, name string) *FunctionJavaResourceAssert { + t.Helper() + + return &FunctionJavaResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedFunctionJavaResource(t *testing.T, id string) *FunctionJavaResourceAssert { + t.Helper() + + return &FunctionJavaResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (f *FunctionJavaResourceAssert) HasArgumentsString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("arguments", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasCommentString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("comment", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasDatabaseString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("database", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasEnableConsoleOutputString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("enable_console_output", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasExternalAccessIntegrationsString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("external_access_integrations", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasFullyQualifiedNameString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasFunctionDefinitionString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("function_definition", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasFunctionLanguageString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("function_language", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasHandlerString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("handler", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasImportsString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("imports", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasIsSecureString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("is_secure", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasLogLevelString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("log_level", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasMetricLevelString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("metric_level", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasNameString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("name", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasNullInputBehaviorString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("null_input_behavior", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasPackagesString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("packages", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasReturnBehaviorString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("return_behavior", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasReturnTypeString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("return_type", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasRuntimeVersionString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("runtime_version", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasSchemaString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("schema", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasSecretsString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("secrets", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasTargetPathString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("target_path", expected)) + return f +} + +func (f *FunctionJavaResourceAssert) HasTraceLevelString(expected string) *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueSet("trace_level", expected)) + return f +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (f *FunctionJavaResourceAssert) HasNoArguments() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("arguments")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoComment() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("comment")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoDatabase() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("database")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoEnableConsoleOutput() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("enable_console_output")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoExternalAccessIntegrations() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("external_access_integrations")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoFullyQualifiedName() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoFunctionDefinition() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("function_definition")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoFunctionLanguage() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("function_language")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoHandler() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("handler")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoImports() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("imports")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoIsSecure() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("is_secure")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoLogLevel() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("log_level")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoMetricLevel() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("metric_level")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoName() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("name")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoNullInputBehavior() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("null_input_behavior")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoPackages() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("packages")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoReturnBehavior() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("return_behavior")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoReturnType() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("return_type")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoRuntimeVersion() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("runtime_version")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoSchema() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("schema")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoSecrets() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("secrets")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoTargetPath() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("target_path")) + return f +} + +func (f *FunctionJavaResourceAssert) HasNoTraceLevel() *FunctionJavaResourceAssert { + f.AddAssertion(assert.ValueNotSet("trace_level")) + return f +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/function_javascript_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/function_javascript_resource_gen.go new file mode 100644 index 0000000000..e633c26e0c --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/function_javascript_resource_gen.go @@ -0,0 +1,197 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" +) + +type FunctionJavascriptResourceAssert struct { + *assert.ResourceAssert +} + +func FunctionJavascriptResource(t *testing.T, name string) *FunctionJavascriptResourceAssert { + t.Helper() + + return &FunctionJavascriptResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedFunctionJavascriptResource(t *testing.T, id string) *FunctionJavascriptResourceAssert { + t.Helper() + + return &FunctionJavascriptResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (f *FunctionJavascriptResourceAssert) HasArgumentsString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("arguments", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasCommentString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("comment", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasDatabaseString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("database", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasEnableConsoleOutputString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("enable_console_output", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasFullyQualifiedNameString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasFunctionDefinitionString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("function_definition", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasFunctionLanguageString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("function_language", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasIsSecureString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("is_secure", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasLogLevelString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("log_level", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasMetricLevelString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("metric_level", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNameString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("name", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNullInputBehaviorString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("null_input_behavior", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasReturnBehaviorString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("return_behavior", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasReturnTypeString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("return_type", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasSchemaString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("schema", expected)) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasTraceLevelString(expected string) *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueSet("trace_level", expected)) + return f +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (f *FunctionJavascriptResourceAssert) HasNoArguments() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("arguments")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoComment() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("comment")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoDatabase() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("database")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoEnableConsoleOutput() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("enable_console_output")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoFullyQualifiedName() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoFunctionDefinition() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("function_definition")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoFunctionLanguage() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("function_language")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoIsSecure() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("is_secure")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoLogLevel() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("log_level")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoMetricLevel() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("metric_level")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoName() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("name")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoNullInputBehavior() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("null_input_behavior")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoReturnBehavior() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("return_behavior")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoReturnType() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("return_type")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoSchema() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("schema")) + return f +} + +func (f *FunctionJavascriptResourceAssert) HasNoTraceLevel() *FunctionJavascriptResourceAssert { + f.AddAssertion(assert.ValueNotSet("trace_level")) + return f +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/function_python_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/function_python_resource_gen.go new file mode 100644 index 0000000000..17a9849c99 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/function_python_resource_gen.go @@ -0,0 +1,267 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" +) + +type FunctionPythonResourceAssert struct { + *assert.ResourceAssert +} + +func FunctionPythonResource(t *testing.T, name string) *FunctionPythonResourceAssert { + t.Helper() + + return &FunctionPythonResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedFunctionPythonResource(t *testing.T, id string) *FunctionPythonResourceAssert { + t.Helper() + + return &FunctionPythonResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (f *FunctionPythonResourceAssert) HasArgumentsString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("arguments", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasCommentString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("comment", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasDatabaseString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("database", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasEnableConsoleOutputString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("enable_console_output", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasExternalAccessIntegrationsString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("external_access_integrations", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasFullyQualifiedNameString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasFunctionDefinitionString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("function_definition", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasFunctionLanguageString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("function_language", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasHandlerString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("handler", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasImportsString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("imports", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasIsAggregateString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("is_aggregate", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasIsSecureString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("is_secure", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasLogLevelString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("log_level", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasMetricLevelString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("metric_level", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasNameString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("name", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasNullInputBehaviorString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("null_input_behavior", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasPackagesString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("packages", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasReturnBehaviorString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("return_behavior", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasReturnTypeString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("return_type", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasRuntimeVersionString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("runtime_version", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasSchemaString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("schema", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasSecretsString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("secrets", expected)) + return f +} + +func (f *FunctionPythonResourceAssert) HasTraceLevelString(expected string) *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueSet("trace_level", expected)) + return f +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (f *FunctionPythonResourceAssert) HasNoArguments() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("arguments")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoComment() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("comment")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoDatabase() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("database")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoEnableConsoleOutput() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("enable_console_output")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoExternalAccessIntegrations() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("external_access_integrations")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoFullyQualifiedName() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoFunctionDefinition() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("function_definition")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoFunctionLanguage() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("function_language")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoHandler() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("handler")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoImports() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("imports")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoIsAggregate() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("is_aggregate")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoIsSecure() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("is_secure")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoLogLevel() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("log_level")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoMetricLevel() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("metric_level")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoName() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("name")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoNullInputBehavior() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("null_input_behavior")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoPackages() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("packages")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoReturnBehavior() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("return_behavior")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoReturnType() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("return_type")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoRuntimeVersion() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("runtime_version")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoSchema() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("schema")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoSecrets() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("secrets")) + return f +} + +func (f *FunctionPythonResourceAssert) HasNoTraceLevel() *FunctionPythonResourceAssert { + f.AddAssertion(assert.ValueNotSet("trace_level")) + return f +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/function_scala_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/function_scala_resource_gen.go new file mode 100644 index 0000000000..be1ccc837a --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/function_scala_resource_gen.go @@ -0,0 +1,267 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" +) + +type FunctionScalaResourceAssert struct { + *assert.ResourceAssert +} + +func FunctionScalaResource(t *testing.T, name string) *FunctionScalaResourceAssert { + t.Helper() + + return &FunctionScalaResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedFunctionScalaResource(t *testing.T, id string) *FunctionScalaResourceAssert { + t.Helper() + + return &FunctionScalaResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (f *FunctionScalaResourceAssert) HasArgumentsString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("arguments", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasCommentString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("comment", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasDatabaseString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("database", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasEnableConsoleOutputString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("enable_console_output", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasExternalAccessIntegrationsString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("external_access_integrations", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasFullyQualifiedNameString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasFunctionDefinitionString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("function_definition", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasFunctionLanguageString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("function_language", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasHandlerString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("handler", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasImportsString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("imports", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasIsSecureString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("is_secure", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasLogLevelString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("log_level", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasMetricLevelString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("metric_level", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasNameString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("name", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasNullInputBehaviorString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("null_input_behavior", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasPackagesString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("packages", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasReturnBehaviorString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("return_behavior", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasReturnTypeString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("return_type", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasRuntimeVersionString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("runtime_version", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasSchemaString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("schema", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasSecretsString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("secrets", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasTargetPathString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("target_path", expected)) + return f +} + +func (f *FunctionScalaResourceAssert) HasTraceLevelString(expected string) *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueSet("trace_level", expected)) + return f +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (f *FunctionScalaResourceAssert) HasNoArguments() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("arguments")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoComment() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("comment")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoDatabase() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("database")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoEnableConsoleOutput() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("enable_console_output")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoExternalAccessIntegrations() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("external_access_integrations")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoFullyQualifiedName() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoFunctionDefinition() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("function_definition")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoFunctionLanguage() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("function_language")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoHandler() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("handler")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoImports() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("imports")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoIsSecure() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("is_secure")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoLogLevel() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("log_level")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoMetricLevel() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("metric_level")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoName() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("name")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoNullInputBehavior() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("null_input_behavior")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoPackages() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("packages")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoReturnBehavior() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("return_behavior")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoReturnType() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("return_type")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoRuntimeVersion() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("runtime_version")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoSchema() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("schema")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoSecrets() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("secrets")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoTargetPath() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("target_path")) + return f +} + +func (f *FunctionScalaResourceAssert) HasNoTraceLevel() *FunctionScalaResourceAssert { + f.AddAssertion(assert.ValueNotSet("trace_level")) + return f +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/function_sql_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/function_sql_resource_gen.go new file mode 100644 index 0000000000..142de640a5 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/function_sql_resource_gen.go @@ -0,0 +1,197 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" +) + +type FunctionSqlResourceAssert struct { + *assert.ResourceAssert +} + +func FunctionSqlResource(t *testing.T, name string) *FunctionSqlResourceAssert { + t.Helper() + + return &FunctionSqlResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedFunctionSqlResource(t *testing.T, id string) *FunctionSqlResourceAssert { + t.Helper() + + return &FunctionSqlResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (f *FunctionSqlResourceAssert) HasArgumentsString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("arguments", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasCommentString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("comment", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasDatabaseString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("database", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasEnableConsoleOutputString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("enable_console_output", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasFullyQualifiedNameString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasFunctionDefinitionString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("function_definition", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasFunctionLanguageString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("function_language", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasIsSecureString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("is_secure", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasLogLevelString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("log_level", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasMetricLevelString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("metric_level", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasNameString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("name", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasNullInputBehaviorString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("null_input_behavior", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasReturnBehaviorString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("return_behavior", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasReturnTypeString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("return_type", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasSchemaString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("schema", expected)) + return f +} + +func (f *FunctionSqlResourceAssert) HasTraceLevelString(expected string) *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueSet("trace_level", expected)) + return f +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (f *FunctionSqlResourceAssert) HasNoArguments() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("arguments")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoComment() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("comment")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoDatabase() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("database")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoEnableConsoleOutput() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("enable_console_output")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoFullyQualifiedName() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoFunctionDefinition() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("function_definition")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoFunctionLanguage() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("function_language")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoIsSecure() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("is_secure")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoLogLevel() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("log_level")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoMetricLevel() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("metric_level")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoName() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("name")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoNullInputBehavior() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("null_input_behavior")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoReturnBehavior() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("return_behavior")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoReturnType() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("return_type")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoSchema() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("schema")) + return f +} + +func (f *FunctionSqlResourceAssert) HasNoTraceLevel() *FunctionSqlResourceAssert { + f.AddAssertion(assert.ValueNotSet("trace_level")) + return f +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go index 2c48ff623c..44fa5d5490 100644 --- a/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go @@ -121,4 +121,24 @@ var allResourceSchemaDefs = []ResourceSchemaDef{ name: "Account", schema: resources.Account().Schema, }, + { + name: "FunctionJava", + schema: resources.FunctionJava().Schema, + }, + { + name: "FunctionJavascript", + schema: resources.FunctionJavascript().Schema, + }, + { + name: "FunctionPython", + schema: resources.FunctionPython().Schema, + }, + { + name: "FunctionScala", + schema: resources.FunctionScala().Schema, + }, + { + name: "FunctionSql", + schema: resources.FunctionSql().Schema, + }, } diff --git a/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/function_resource_parameters_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/function_resource_parameters_gen.go new file mode 100644 index 0000000000..a7414b06e0 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/function_resource_parameters_gen.go @@ -0,0 +1,82 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceparametersassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +type FunctionResourceParametersAssert struct { + *assert.ResourceAssert +} + +func FunctionResourceParameters(t *testing.T, name string) *FunctionResourceParametersAssert { + t.Helper() + + resourceParameterAssert := FunctionResourceParametersAssert{ + ResourceAssert: assert.NewResourceAssert(name, "parameters"), + } + resourceParameterAssert.AddAssertion(assert.ValueSet("parameters.#", "1")) + return &resourceParameterAssert +} + +func ImportedFunctionResourceParameters(t *testing.T, id string) *FunctionResourceParametersAssert { + t.Helper() + + resourceParameterAssert := FunctionResourceParametersAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported parameters"), + } + resourceParameterAssert.AddAssertion(assert.ValueSet("parameters.#", "1")) + return &resourceParameterAssert +} + +//////////////////////////// +// Parameter value checks // +//////////////////////////// + +func (f *FunctionResourceParametersAssert) HasEnableConsoleOutput(expected bool) *FunctionResourceParametersAssert { + f.AddAssertion(assert.ResourceParameterBoolValueSet(sdk.FunctionParameterEnableConsoleOutput, expected)) + return f +} + +func (f *FunctionResourceParametersAssert) HasLogLevel(expected sdk.LogLevel) *FunctionResourceParametersAssert { + f.AddAssertion(assert.ResourceParameterStringUnderlyingValueSet(sdk.FunctionParameterLogLevel, expected)) + return f +} + +func (f *FunctionResourceParametersAssert) HasMetricLevel(expected sdk.MetricLevel) *FunctionResourceParametersAssert { + f.AddAssertion(assert.ResourceParameterStringUnderlyingValueSet(sdk.FunctionParameterMetricLevel, expected)) + return f +} + +func (f *FunctionResourceParametersAssert) HasTraceLevel(expected sdk.TraceLevel) *FunctionResourceParametersAssert { + f.AddAssertion(assert.ResourceParameterStringUnderlyingValueSet(sdk.FunctionParameterTraceLevel, expected)) + return f +} + +//////////////////////////// +// Parameter level checks // +//////////////////////////// + +func (f *FunctionResourceParametersAssert) HasEnableConsoleOutputLevel(expected sdk.ParameterType) *FunctionResourceParametersAssert { + f.AddAssertion(assert.ResourceParameterLevelSet(sdk.FunctionParameterEnableConsoleOutput, expected)) + return f +} + +func (f *FunctionResourceParametersAssert) HasLogLevelLevel(expected sdk.ParameterType) *FunctionResourceParametersAssert { + f.AddAssertion(assert.ResourceParameterLevelSet(sdk.FunctionParameterLogLevel, expected)) + return f +} + +func (f *FunctionResourceParametersAssert) HasMetricLevelLevel(expected sdk.ParameterType) *FunctionResourceParametersAssert { + f.AddAssertion(assert.ResourceParameterLevelSet(sdk.FunctionParameterMetricLevel, expected)) + return f +} + +func (f *FunctionResourceParametersAssert) HasTraceLevelLevel(expected sdk.ParameterType) *FunctionResourceParametersAssert { + f.AddAssertion(assert.ResourceParameterLevelSet(sdk.FunctionParameterTraceLevel, expected)) + return f +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/procedure_resource_parameters_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/procedure_resource_parameters_gen.go new file mode 100644 index 0000000000..3c89493541 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/procedure_resource_parameters_gen.go @@ -0,0 +1,92 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceparametersassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +type ProcedureResourceParametersAssert struct { + *assert.ResourceAssert +} + +func ProcedureResourceParameters(t *testing.T, name string) *ProcedureResourceParametersAssert { + t.Helper() + + resourceParameterAssert := ProcedureResourceParametersAssert{ + ResourceAssert: assert.NewResourceAssert(name, "parameters"), + } + resourceParameterAssert.AddAssertion(assert.ValueSet("parameters.#", "1")) + return &resourceParameterAssert +} + +func ImportedProcedureResourceParameters(t *testing.T, id string) *ProcedureResourceParametersAssert { + t.Helper() + + resourceParameterAssert := ProcedureResourceParametersAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported parameters"), + } + resourceParameterAssert.AddAssertion(assert.ValueSet("parameters.#", "1")) + return &resourceParameterAssert +} + +//////////////////////////// +// Parameter value checks // +//////////////////////////// + +func (p *ProcedureResourceParametersAssert) HasAutoEventLogging(expected sdk.AutoEventLogging) *ProcedureResourceParametersAssert { + p.AddAssertion(assert.ResourceParameterStringUnderlyingValueSet(sdk.ProcedureParameterAutoEventLogging, expected)) + return p +} + +func (p *ProcedureResourceParametersAssert) HasEnableConsoleOutput(expected bool) *ProcedureResourceParametersAssert { + p.AddAssertion(assert.ResourceParameterBoolValueSet(sdk.ProcedureParameterEnableConsoleOutput, expected)) + return p +} + +func (p *ProcedureResourceParametersAssert) HasLogLevel(expected sdk.LogLevel) *ProcedureResourceParametersAssert { + p.AddAssertion(assert.ResourceParameterStringUnderlyingValueSet(sdk.ProcedureParameterLogLevel, expected)) + return p +} + +func (p *ProcedureResourceParametersAssert) HasMetricLevel(expected sdk.MetricLevel) *ProcedureResourceParametersAssert { + p.AddAssertion(assert.ResourceParameterStringUnderlyingValueSet(sdk.ProcedureParameterMetricLevel, expected)) + return p +} + +func (p *ProcedureResourceParametersAssert) HasTraceLevel(expected sdk.TraceLevel) *ProcedureResourceParametersAssert { + p.AddAssertion(assert.ResourceParameterStringUnderlyingValueSet(sdk.ProcedureParameterTraceLevel, expected)) + return p +} + +//////////////////////////// +// Parameter level checks // +//////////////////////////// + +func (p *ProcedureResourceParametersAssert) HasAutoEventLoggingLevel(expected sdk.ParameterType) *ProcedureResourceParametersAssert { + p.AddAssertion(assert.ResourceParameterLevelSet(sdk.ProcedureParameterAutoEventLogging, expected)) + return p +} + +func (p *ProcedureResourceParametersAssert) HasEnableConsoleOutputLevel(expected sdk.ParameterType) *ProcedureResourceParametersAssert { + p.AddAssertion(assert.ResourceParameterLevelSet(sdk.ProcedureParameterEnableConsoleOutput, expected)) + return p +} + +func (p *ProcedureResourceParametersAssert) HasLogLevelLevel(expected sdk.ParameterType) *ProcedureResourceParametersAssert { + p.AddAssertion(assert.ResourceParameterLevelSet(sdk.ProcedureParameterLogLevel, expected)) + return p +} + +func (p *ProcedureResourceParametersAssert) HasMetricLevelLevel(expected sdk.ParameterType) *ProcedureResourceParametersAssert { + p.AddAssertion(assert.ResourceParameterLevelSet(sdk.ProcedureParameterMetricLevel, expected)) + return p +} + +func (p *ProcedureResourceParametersAssert) HasTraceLevelLevel(expected sdk.ParameterType) *ProcedureResourceParametersAssert { + p.AddAssertion(assert.ResourceParameterLevelSet(sdk.ProcedureParameterTraceLevel, expected)) + return p +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/function_show_output_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/function_show_output_gen.go new file mode 100644 index 0000000000..dc8fd54d38 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/function_show_output_gen.go @@ -0,0 +1,144 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceshowoutputassert + +// imports edited manually +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +// to ensure sdk package is used +var _ = sdk.Object{} + +type FunctionShowOutputAssert struct { + *assert.ResourceAssert +} + +func FunctionShowOutput(t *testing.T, name string) *FunctionShowOutputAssert { + t.Helper() + + f := FunctionShowOutputAssert{ + ResourceAssert: assert.NewResourceAssert(name, "show_output"), + } + f.AddAssertion(assert.ValueSet("show_output.#", "1")) + return &f +} + +func ImportedFunctionShowOutput(t *testing.T, id string) *FunctionShowOutputAssert { + t.Helper() + + f := FunctionShowOutputAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "show_output"), + } + f.AddAssertion(assert.ValueSet("show_output.#", "1")) + return &f +} + +//////////////////////////// +// Attribute value checks // +//////////////////////////// + +func (f *FunctionShowOutputAssert) HasCreatedOn(expected string) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputValueSet("created_on", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasName(expected string) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputValueSet("name", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasSchemaName(expected string) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputValueSet("schema_name", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasIsBuiltin(expected bool) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_builtin", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasIsAggregate(expected bool) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_aggregate", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasIsAnsi(expected bool) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_ansi", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasMinNumArguments(expected int) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputIntValueSet("min_num_arguments", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasMaxNumArguments(expected int) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputIntValueSet("max_num_arguments", expected)) + return f +} + +// HasArgumentsOld removed manually + +func (f *FunctionShowOutputAssert) HasArgumentsRaw(expected string) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputValueSet("arguments_raw", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasDescription(expected string) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputValueSet("description", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasCatalogName(expected string) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputValueSet("catalog_name", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasIsTableFunction(expected bool) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_table_function", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasValidForClustering(expected bool) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputBoolValueSet("valid_for_clustering", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasIsSecure(expected bool) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_secure", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasSecrets(expected string) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputValueSet("secrets", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasExternalAccessIntegrations(expected string) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputValueSet("external_access_integrations", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasIsExternalFunction(expected bool) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_external_function", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasLanguage(expected string) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputValueSet("language", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasIsMemoizable(expected bool) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_memoizable", expected)) + return f +} + +func (f *FunctionShowOutputAssert) HasIsDataMetric(expected bool) *FunctionShowOutputAssert { + f.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_data_metric", expected)) + return f +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/procedure_show_output_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/procedure_show_output_gen.go new file mode 100644 index 0000000000..f9f6ed5831 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/procedure_show_output_gen.go @@ -0,0 +1,124 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceshowoutputassert + +// imports edited manually +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +// to ensure sdk package is used +var _ = sdk.Object{} + +type ProcedureShowOutputAssert struct { + *assert.ResourceAssert +} + +func ProcedureShowOutput(t *testing.T, name string) *ProcedureShowOutputAssert { + t.Helper() + + p := ProcedureShowOutputAssert{ + ResourceAssert: assert.NewResourceAssert(name, "show_output"), + } + p.AddAssertion(assert.ValueSet("show_output.#", "1")) + return &p +} + +func ImportedProcedureShowOutput(t *testing.T, id string) *ProcedureShowOutputAssert { + t.Helper() + + p := ProcedureShowOutputAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "show_output"), + } + p.AddAssertion(assert.ValueSet("show_output.#", "1")) + return &p +} + +//////////////////////////// +// Attribute value checks // +//////////////////////////// + +func (p *ProcedureShowOutputAssert) HasCreatedOn(expected string) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputValueSet("created_on", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasName(expected string) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputValueSet("name", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasSchemaName(expected string) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputValueSet("schema_name", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasIsBuiltin(expected bool) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_builtin", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasIsAggregate(expected bool) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_aggregate", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasIsAnsi(expected bool) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_ansi", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasMinNumArguments(expected int) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputIntValueSet("min_num_arguments", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasMaxNumArguments(expected int) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputIntValueSet("max_num_arguments", expected)) + return p +} + +// HasArgumentsOld removed manually + +func (p *ProcedureShowOutputAssert) HasArgumentsRaw(expected string) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputValueSet("arguments_raw", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasDescription(expected string) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputValueSet("description", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasCatalogName(expected string) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputValueSet("catalog_name", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasIsTableFunction(expected bool) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_table_function", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasValidForClustering(expected bool) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputBoolValueSet("valid_for_clustering", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasIsSecure(expected bool) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputBoolValueSet("is_secure", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasSecrets(expected string) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputValueSet("secrets", expected)) + return p +} + +func (p *ProcedureShowOutputAssert) HasExternalAccessIntegrations(expected string) *ProcedureShowOutputAssert { + p.AddAssertion(assert.ResourceShowOutputValueSet("external_access_integrations", expected)) + return p +} diff --git a/pkg/acceptance/bettertestspoc/config/model/function_java_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/function_java_model_ext.go new file mode 100644 index 0000000000..4bac27ada5 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/function_java_model_ext.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" +) + +func (f *FunctionJavaModel) MarshalJSON() ([]byte, error) { + type Alias FunctionJavaModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(f), + DependsOn: f.DependsOn(), + }) +} diff --git a/pkg/acceptance/bettertestspoc/config/model/function_java_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/function_java_model_gen.go new file mode 100644 index 0000000000..704f6b2bcf --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/function_java_model_gen.go @@ -0,0 +1,302 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type FunctionJavaModel struct { + Arguments tfconfig.Variable `json:"arguments,omitempty"` + Comment tfconfig.Variable `json:"comment,omitempty"` + Database tfconfig.Variable `json:"database,omitempty"` + EnableConsoleOutput tfconfig.Variable `json:"enable_console_output,omitempty"` + ExternalAccessIntegrations tfconfig.Variable `json:"external_access_integrations,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + FunctionDefinition tfconfig.Variable `json:"function_definition,omitempty"` + FunctionLanguage tfconfig.Variable `json:"function_language,omitempty"` + Handler tfconfig.Variable `json:"handler,omitempty"` + Imports tfconfig.Variable `json:"imports,omitempty"` + IsSecure tfconfig.Variable `json:"is_secure,omitempty"` + LogLevel tfconfig.Variable `json:"log_level,omitempty"` + MetricLevel tfconfig.Variable `json:"metric_level,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + NullInputBehavior tfconfig.Variable `json:"null_input_behavior,omitempty"` + Packages tfconfig.Variable `json:"packages,omitempty"` + ReturnBehavior tfconfig.Variable `json:"return_behavior,omitempty"` + ReturnType tfconfig.Variable `json:"return_type,omitempty"` + RuntimeVersion tfconfig.Variable `json:"runtime_version,omitempty"` + Schema tfconfig.Variable `json:"schema,omitempty"` + Secrets tfconfig.Variable `json:"secrets,omitempty"` + TargetPath tfconfig.Variable `json:"target_path,omitempty"` + TraceLevel tfconfig.Variable `json:"trace_level,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func FunctionJava( + resourceName string, + database string, + functionDefinition string, + handler string, + name string, + returnType string, + schema string, +) *FunctionJavaModel { + f := &FunctionJavaModel{ResourceModelMeta: config.Meta(resourceName, resources.FunctionJava)} + f.WithDatabase(database) + f.WithFunctionDefinition(functionDefinition) + f.WithHandler(handler) + f.WithName(name) + f.WithReturnType(returnType) + f.WithSchema(schema) + return f +} + +func FunctionJavaWithDefaultMeta( + database string, + functionDefinition string, + handler string, + name string, + returnType string, + schema string, +) *FunctionJavaModel { + f := &FunctionJavaModel{ResourceModelMeta: config.DefaultMeta(resources.FunctionJava)} + f.WithDatabase(database) + f.WithFunctionDefinition(functionDefinition) + f.WithHandler(handler) + f.WithName(name) + f.WithReturnType(returnType) + f.WithSchema(schema) + return f +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// arguments attribute type is not yet supported, so WithArguments can't be generated + +func (f *FunctionJavaModel) WithComment(comment string) *FunctionJavaModel { + f.Comment = tfconfig.StringVariable(comment) + return f +} + +func (f *FunctionJavaModel) WithDatabase(database string) *FunctionJavaModel { + f.Database = tfconfig.StringVariable(database) + return f +} + +func (f *FunctionJavaModel) WithEnableConsoleOutput(enableConsoleOutput bool) *FunctionJavaModel { + f.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) + return f +} + +// external_access_integrations attribute type is not yet supported, so WithExternalAccessIntegrations can't be generated + +func (f *FunctionJavaModel) WithFullyQualifiedName(fullyQualifiedName string) *FunctionJavaModel { + f.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return f +} + +func (f *FunctionJavaModel) WithFunctionDefinition(functionDefinition string) *FunctionJavaModel { + f.FunctionDefinition = tfconfig.StringVariable(functionDefinition) + return f +} + +func (f *FunctionJavaModel) WithFunctionLanguage(functionLanguage string) *FunctionJavaModel { + f.FunctionLanguage = tfconfig.StringVariable(functionLanguage) + return f +} + +func (f *FunctionJavaModel) WithHandler(handler string) *FunctionJavaModel { + f.Handler = tfconfig.StringVariable(handler) + return f +} + +// imports attribute type is not yet supported, so WithImports can't be generated + +func (f *FunctionJavaModel) WithIsSecure(isSecure string) *FunctionJavaModel { + f.IsSecure = tfconfig.StringVariable(isSecure) + return f +} + +func (f *FunctionJavaModel) WithLogLevel(logLevel string) *FunctionJavaModel { + f.LogLevel = tfconfig.StringVariable(logLevel) + return f +} + +func (f *FunctionJavaModel) WithMetricLevel(metricLevel string) *FunctionJavaModel { + f.MetricLevel = tfconfig.StringVariable(metricLevel) + return f +} + +func (f *FunctionJavaModel) WithName(name string) *FunctionJavaModel { + f.Name = tfconfig.StringVariable(name) + return f +} + +func (f *FunctionJavaModel) WithNullInputBehavior(nullInputBehavior string) *FunctionJavaModel { + f.NullInputBehavior = tfconfig.StringVariable(nullInputBehavior) + return f +} + +// packages attribute type is not yet supported, so WithPackages can't be generated + +func (f *FunctionJavaModel) WithReturnBehavior(returnBehavior string) *FunctionJavaModel { + f.ReturnBehavior = tfconfig.StringVariable(returnBehavior) + return f +} + +func (f *FunctionJavaModel) WithReturnType(returnType string) *FunctionJavaModel { + f.ReturnType = tfconfig.StringVariable(returnType) + return f +} + +func (f *FunctionJavaModel) WithRuntimeVersion(runtimeVersion string) *FunctionJavaModel { + f.RuntimeVersion = tfconfig.StringVariable(runtimeVersion) + return f +} + +func (f *FunctionJavaModel) WithSchema(schema string) *FunctionJavaModel { + f.Schema = tfconfig.StringVariable(schema) + return f +} + +// secrets attribute type is not yet supported, so WithSecrets can't be generated + +func (f *FunctionJavaModel) WithTargetPath(targetPath string) *FunctionJavaModel { + f.TargetPath = tfconfig.StringVariable(targetPath) + return f +} + +func (f *FunctionJavaModel) WithTraceLevel(traceLevel string) *FunctionJavaModel { + f.TraceLevel = tfconfig.StringVariable(traceLevel) + return f +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (f *FunctionJavaModel) WithArgumentsValue(value tfconfig.Variable) *FunctionJavaModel { + f.Arguments = value + return f +} + +func (f *FunctionJavaModel) WithCommentValue(value tfconfig.Variable) *FunctionJavaModel { + f.Comment = value + return f +} + +func (f *FunctionJavaModel) WithDatabaseValue(value tfconfig.Variable) *FunctionJavaModel { + f.Database = value + return f +} + +func (f *FunctionJavaModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *FunctionJavaModel { + f.EnableConsoleOutput = value + return f +} + +func (f *FunctionJavaModel) WithExternalAccessIntegrationsValue(value tfconfig.Variable) *FunctionJavaModel { + f.ExternalAccessIntegrations = value + return f +} + +func (f *FunctionJavaModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *FunctionJavaModel { + f.FullyQualifiedName = value + return f +} + +func (f *FunctionJavaModel) WithFunctionDefinitionValue(value tfconfig.Variable) *FunctionJavaModel { + f.FunctionDefinition = value + return f +} + +func (f *FunctionJavaModel) WithFunctionLanguageValue(value tfconfig.Variable) *FunctionJavaModel { + f.FunctionLanguage = value + return f +} + +func (f *FunctionJavaModel) WithHandlerValue(value tfconfig.Variable) *FunctionJavaModel { + f.Handler = value + return f +} + +func (f *FunctionJavaModel) WithImportsValue(value tfconfig.Variable) *FunctionJavaModel { + f.Imports = value + return f +} + +func (f *FunctionJavaModel) WithIsSecureValue(value tfconfig.Variable) *FunctionJavaModel { + f.IsSecure = value + return f +} + +func (f *FunctionJavaModel) WithLogLevelValue(value tfconfig.Variable) *FunctionJavaModel { + f.LogLevel = value + return f +} + +func (f *FunctionJavaModel) WithMetricLevelValue(value tfconfig.Variable) *FunctionJavaModel { + f.MetricLevel = value + return f +} + +func (f *FunctionJavaModel) WithNameValue(value tfconfig.Variable) *FunctionJavaModel { + f.Name = value + return f +} + +func (f *FunctionJavaModel) WithNullInputBehaviorValue(value tfconfig.Variable) *FunctionJavaModel { + f.NullInputBehavior = value + return f +} + +func (f *FunctionJavaModel) WithPackagesValue(value tfconfig.Variable) *FunctionJavaModel { + f.Packages = value + return f +} + +func (f *FunctionJavaModel) WithReturnBehaviorValue(value tfconfig.Variable) *FunctionJavaModel { + f.ReturnBehavior = value + return f +} + +func (f *FunctionJavaModel) WithReturnTypeValue(value tfconfig.Variable) *FunctionJavaModel { + f.ReturnType = value + return f +} + +func (f *FunctionJavaModel) WithRuntimeVersionValue(value tfconfig.Variable) *FunctionJavaModel { + f.RuntimeVersion = value + return f +} + +func (f *FunctionJavaModel) WithSchemaValue(value tfconfig.Variable) *FunctionJavaModel { + f.Schema = value + return f +} + +func (f *FunctionJavaModel) WithSecretsValue(value tfconfig.Variable) *FunctionJavaModel { + f.Secrets = value + return f +} + +func (f *FunctionJavaModel) WithTargetPathValue(value tfconfig.Variable) *FunctionJavaModel { + f.TargetPath = value + return f +} + +func (f *FunctionJavaModel) WithTraceLevelValue(value tfconfig.Variable) *FunctionJavaModel { + f.TraceLevel = value + return f +} diff --git a/pkg/acceptance/bettertestspoc/config/model/function_javascript_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/function_javascript_model_ext.go new file mode 100644 index 0000000000..3fa63b5701 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/function_javascript_model_ext.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" +) + +func (f *FunctionJavascriptModel) MarshalJSON() ([]byte, error) { + type Alias FunctionJavascriptModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(f), + DependsOn: f.DependsOn(), + }) +} diff --git a/pkg/acceptance/bettertestspoc/config/model/function_javascript_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/function_javascript_model_gen.go new file mode 100644 index 0000000000..5d8ad68aec --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/function_javascript_model_gen.go @@ -0,0 +1,233 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type FunctionJavascriptModel struct { + Arguments tfconfig.Variable `json:"arguments,omitempty"` + Comment tfconfig.Variable `json:"comment,omitempty"` + Database tfconfig.Variable `json:"database,omitempty"` + EnableConsoleOutput tfconfig.Variable `json:"enable_console_output,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + FunctionDefinition tfconfig.Variable `json:"function_definition,omitempty"` + FunctionLanguage tfconfig.Variable `json:"function_language,omitempty"` + IsSecure tfconfig.Variable `json:"is_secure,omitempty"` + LogLevel tfconfig.Variable `json:"log_level,omitempty"` + MetricLevel tfconfig.Variable `json:"metric_level,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + NullInputBehavior tfconfig.Variable `json:"null_input_behavior,omitempty"` + ReturnBehavior tfconfig.Variable `json:"return_behavior,omitempty"` + ReturnType tfconfig.Variable `json:"return_type,omitempty"` + Schema tfconfig.Variable `json:"schema,omitempty"` + TraceLevel tfconfig.Variable `json:"trace_level,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func FunctionJavascript( + resourceName string, + database string, + functionDefinition string, + name string, + returnType string, + schema string, +) *FunctionJavascriptModel { + f := &FunctionJavascriptModel{ResourceModelMeta: config.Meta(resourceName, resources.FunctionJavascript)} + f.WithDatabase(database) + f.WithFunctionDefinition(functionDefinition) + f.WithName(name) + f.WithReturnType(returnType) + f.WithSchema(schema) + return f +} + +func FunctionJavascriptWithDefaultMeta( + database string, + functionDefinition string, + name string, + returnType string, + schema string, +) *FunctionJavascriptModel { + f := &FunctionJavascriptModel{ResourceModelMeta: config.DefaultMeta(resources.FunctionJavascript)} + f.WithDatabase(database) + f.WithFunctionDefinition(functionDefinition) + f.WithName(name) + f.WithReturnType(returnType) + f.WithSchema(schema) + return f +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// arguments attribute type is not yet supported, so WithArguments can't be generated + +func (f *FunctionJavascriptModel) WithComment(comment string) *FunctionJavascriptModel { + f.Comment = tfconfig.StringVariable(comment) + return f +} + +func (f *FunctionJavascriptModel) WithDatabase(database string) *FunctionJavascriptModel { + f.Database = tfconfig.StringVariable(database) + return f +} + +func (f *FunctionJavascriptModel) WithEnableConsoleOutput(enableConsoleOutput bool) *FunctionJavascriptModel { + f.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) + return f +} + +func (f *FunctionJavascriptModel) WithFullyQualifiedName(fullyQualifiedName string) *FunctionJavascriptModel { + f.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return f +} + +func (f *FunctionJavascriptModel) WithFunctionDefinition(functionDefinition string) *FunctionJavascriptModel { + f.FunctionDefinition = tfconfig.StringVariable(functionDefinition) + return f +} + +func (f *FunctionJavascriptModel) WithFunctionLanguage(functionLanguage string) *FunctionJavascriptModel { + f.FunctionLanguage = tfconfig.StringVariable(functionLanguage) + return f +} + +func (f *FunctionJavascriptModel) WithIsSecure(isSecure string) *FunctionJavascriptModel { + f.IsSecure = tfconfig.StringVariable(isSecure) + return f +} + +func (f *FunctionJavascriptModel) WithLogLevel(logLevel string) *FunctionJavascriptModel { + f.LogLevel = tfconfig.StringVariable(logLevel) + return f +} + +func (f *FunctionJavascriptModel) WithMetricLevel(metricLevel string) *FunctionJavascriptModel { + f.MetricLevel = tfconfig.StringVariable(metricLevel) + return f +} + +func (f *FunctionJavascriptModel) WithName(name string) *FunctionJavascriptModel { + f.Name = tfconfig.StringVariable(name) + return f +} + +func (f *FunctionJavascriptModel) WithNullInputBehavior(nullInputBehavior string) *FunctionJavascriptModel { + f.NullInputBehavior = tfconfig.StringVariable(nullInputBehavior) + return f +} + +func (f *FunctionJavascriptModel) WithReturnBehavior(returnBehavior string) *FunctionJavascriptModel { + f.ReturnBehavior = tfconfig.StringVariable(returnBehavior) + return f +} + +func (f *FunctionJavascriptModel) WithReturnType(returnType string) *FunctionJavascriptModel { + f.ReturnType = tfconfig.StringVariable(returnType) + return f +} + +func (f *FunctionJavascriptModel) WithSchema(schema string) *FunctionJavascriptModel { + f.Schema = tfconfig.StringVariable(schema) + return f +} + +func (f *FunctionJavascriptModel) WithTraceLevel(traceLevel string) *FunctionJavascriptModel { + f.TraceLevel = tfconfig.StringVariable(traceLevel) + return f +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (f *FunctionJavascriptModel) WithArgumentsValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.Arguments = value + return f +} + +func (f *FunctionJavascriptModel) WithCommentValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.Comment = value + return f +} + +func (f *FunctionJavascriptModel) WithDatabaseValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.Database = value + return f +} + +func (f *FunctionJavascriptModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.EnableConsoleOutput = value + return f +} + +func (f *FunctionJavascriptModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.FullyQualifiedName = value + return f +} + +func (f *FunctionJavascriptModel) WithFunctionDefinitionValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.FunctionDefinition = value + return f +} + +func (f *FunctionJavascriptModel) WithFunctionLanguageValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.FunctionLanguage = value + return f +} + +func (f *FunctionJavascriptModel) WithIsSecureValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.IsSecure = value + return f +} + +func (f *FunctionJavascriptModel) WithLogLevelValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.LogLevel = value + return f +} + +func (f *FunctionJavascriptModel) WithMetricLevelValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.MetricLevel = value + return f +} + +func (f *FunctionJavascriptModel) WithNameValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.Name = value + return f +} + +func (f *FunctionJavascriptModel) WithNullInputBehaviorValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.NullInputBehavior = value + return f +} + +func (f *FunctionJavascriptModel) WithReturnBehaviorValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.ReturnBehavior = value + return f +} + +func (f *FunctionJavascriptModel) WithReturnTypeValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.ReturnType = value + return f +} + +func (f *FunctionJavascriptModel) WithSchemaValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.Schema = value + return f +} + +func (f *FunctionJavascriptModel) WithTraceLevelValue(value tfconfig.Variable) *FunctionJavascriptModel { + f.TraceLevel = value + return f +} diff --git a/pkg/acceptance/bettertestspoc/config/model/function_python_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/function_python_model_ext.go new file mode 100644 index 0000000000..8d7475e389 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/function_python_model_ext.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" +) + +func (f *FunctionPythonModel) MarshalJSON() ([]byte, error) { + type Alias FunctionPythonModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(f), + DependsOn: f.DependsOn(), + }) +} diff --git a/pkg/acceptance/bettertestspoc/config/model/function_python_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/function_python_model_gen.go new file mode 100644 index 0000000000..9d0ffbd348 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/function_python_model_gen.go @@ -0,0 +1,306 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type FunctionPythonModel struct { + Arguments tfconfig.Variable `json:"arguments,omitempty"` + Comment tfconfig.Variable `json:"comment,omitempty"` + Database tfconfig.Variable `json:"database,omitempty"` + EnableConsoleOutput tfconfig.Variable `json:"enable_console_output,omitempty"` + ExternalAccessIntegrations tfconfig.Variable `json:"external_access_integrations,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + FunctionDefinition tfconfig.Variable `json:"function_definition,omitempty"` + FunctionLanguage tfconfig.Variable `json:"function_language,omitempty"` + Handler tfconfig.Variable `json:"handler,omitempty"` + Imports tfconfig.Variable `json:"imports,omitempty"` + IsAggregate tfconfig.Variable `json:"is_aggregate,omitempty"` + IsSecure tfconfig.Variable `json:"is_secure,omitempty"` + LogLevel tfconfig.Variable `json:"log_level,omitempty"` + MetricLevel tfconfig.Variable `json:"metric_level,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + NullInputBehavior tfconfig.Variable `json:"null_input_behavior,omitempty"` + Packages tfconfig.Variable `json:"packages,omitempty"` + ReturnBehavior tfconfig.Variable `json:"return_behavior,omitempty"` + ReturnType tfconfig.Variable `json:"return_type,omitempty"` + RuntimeVersion tfconfig.Variable `json:"runtime_version,omitempty"` + Schema tfconfig.Variable `json:"schema,omitempty"` + Secrets tfconfig.Variable `json:"secrets,omitempty"` + TraceLevel tfconfig.Variable `json:"trace_level,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func FunctionPython( + resourceName string, + database string, + functionDefinition string, + handler string, + name string, + returnType string, + runtimeVersion string, + schema string, +) *FunctionPythonModel { + f := &FunctionPythonModel{ResourceModelMeta: config.Meta(resourceName, resources.FunctionPython)} + f.WithDatabase(database) + f.WithFunctionDefinition(functionDefinition) + f.WithHandler(handler) + f.WithName(name) + f.WithReturnType(returnType) + f.WithRuntimeVersion(runtimeVersion) + f.WithSchema(schema) + return f +} + +func FunctionPythonWithDefaultMeta( + database string, + functionDefinition string, + handler string, + name string, + returnType string, + runtimeVersion string, + schema string, +) *FunctionPythonModel { + f := &FunctionPythonModel{ResourceModelMeta: config.DefaultMeta(resources.FunctionPython)} + f.WithDatabase(database) + f.WithFunctionDefinition(functionDefinition) + f.WithHandler(handler) + f.WithName(name) + f.WithReturnType(returnType) + f.WithRuntimeVersion(runtimeVersion) + f.WithSchema(schema) + return f +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// arguments attribute type is not yet supported, so WithArguments can't be generated + +func (f *FunctionPythonModel) WithComment(comment string) *FunctionPythonModel { + f.Comment = tfconfig.StringVariable(comment) + return f +} + +func (f *FunctionPythonModel) WithDatabase(database string) *FunctionPythonModel { + f.Database = tfconfig.StringVariable(database) + return f +} + +func (f *FunctionPythonModel) WithEnableConsoleOutput(enableConsoleOutput bool) *FunctionPythonModel { + f.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) + return f +} + +// external_access_integrations attribute type is not yet supported, so WithExternalAccessIntegrations can't be generated + +func (f *FunctionPythonModel) WithFullyQualifiedName(fullyQualifiedName string) *FunctionPythonModel { + f.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return f +} + +func (f *FunctionPythonModel) WithFunctionDefinition(functionDefinition string) *FunctionPythonModel { + f.FunctionDefinition = tfconfig.StringVariable(functionDefinition) + return f +} + +func (f *FunctionPythonModel) WithFunctionLanguage(functionLanguage string) *FunctionPythonModel { + f.FunctionLanguage = tfconfig.StringVariable(functionLanguage) + return f +} + +func (f *FunctionPythonModel) WithHandler(handler string) *FunctionPythonModel { + f.Handler = tfconfig.StringVariable(handler) + return f +} + +// imports attribute type is not yet supported, so WithImports can't be generated + +func (f *FunctionPythonModel) WithIsAggregate(isAggregate string) *FunctionPythonModel { + f.IsAggregate = tfconfig.StringVariable(isAggregate) + return f +} + +func (f *FunctionPythonModel) WithIsSecure(isSecure string) *FunctionPythonModel { + f.IsSecure = tfconfig.StringVariable(isSecure) + return f +} + +func (f *FunctionPythonModel) WithLogLevel(logLevel string) *FunctionPythonModel { + f.LogLevel = tfconfig.StringVariable(logLevel) + return f +} + +func (f *FunctionPythonModel) WithMetricLevel(metricLevel string) *FunctionPythonModel { + f.MetricLevel = tfconfig.StringVariable(metricLevel) + return f +} + +func (f *FunctionPythonModel) WithName(name string) *FunctionPythonModel { + f.Name = tfconfig.StringVariable(name) + return f +} + +func (f *FunctionPythonModel) WithNullInputBehavior(nullInputBehavior string) *FunctionPythonModel { + f.NullInputBehavior = tfconfig.StringVariable(nullInputBehavior) + return f +} + +// packages attribute type is not yet supported, so WithPackages can't be generated + +func (f *FunctionPythonModel) WithReturnBehavior(returnBehavior string) *FunctionPythonModel { + f.ReturnBehavior = tfconfig.StringVariable(returnBehavior) + return f +} + +func (f *FunctionPythonModel) WithReturnType(returnType string) *FunctionPythonModel { + f.ReturnType = tfconfig.StringVariable(returnType) + return f +} + +func (f *FunctionPythonModel) WithRuntimeVersion(runtimeVersion string) *FunctionPythonModel { + f.RuntimeVersion = tfconfig.StringVariable(runtimeVersion) + return f +} + +func (f *FunctionPythonModel) WithSchema(schema string) *FunctionPythonModel { + f.Schema = tfconfig.StringVariable(schema) + return f +} + +// secrets attribute type is not yet supported, so WithSecrets can't be generated + +func (f *FunctionPythonModel) WithTraceLevel(traceLevel string) *FunctionPythonModel { + f.TraceLevel = tfconfig.StringVariable(traceLevel) + return f +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (f *FunctionPythonModel) WithArgumentsValue(value tfconfig.Variable) *FunctionPythonModel { + f.Arguments = value + return f +} + +func (f *FunctionPythonModel) WithCommentValue(value tfconfig.Variable) *FunctionPythonModel { + f.Comment = value + return f +} + +func (f *FunctionPythonModel) WithDatabaseValue(value tfconfig.Variable) *FunctionPythonModel { + f.Database = value + return f +} + +func (f *FunctionPythonModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *FunctionPythonModel { + f.EnableConsoleOutput = value + return f +} + +func (f *FunctionPythonModel) WithExternalAccessIntegrationsValue(value tfconfig.Variable) *FunctionPythonModel { + f.ExternalAccessIntegrations = value + return f +} + +func (f *FunctionPythonModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *FunctionPythonModel { + f.FullyQualifiedName = value + return f +} + +func (f *FunctionPythonModel) WithFunctionDefinitionValue(value tfconfig.Variable) *FunctionPythonModel { + f.FunctionDefinition = value + return f +} + +func (f *FunctionPythonModel) WithFunctionLanguageValue(value tfconfig.Variable) *FunctionPythonModel { + f.FunctionLanguage = value + return f +} + +func (f *FunctionPythonModel) WithHandlerValue(value tfconfig.Variable) *FunctionPythonModel { + f.Handler = value + return f +} + +func (f *FunctionPythonModel) WithImportsValue(value tfconfig.Variable) *FunctionPythonModel { + f.Imports = value + return f +} + +func (f *FunctionPythonModel) WithIsAggregateValue(value tfconfig.Variable) *FunctionPythonModel { + f.IsAggregate = value + return f +} + +func (f *FunctionPythonModel) WithIsSecureValue(value tfconfig.Variable) *FunctionPythonModel { + f.IsSecure = value + return f +} + +func (f *FunctionPythonModel) WithLogLevelValue(value tfconfig.Variable) *FunctionPythonModel { + f.LogLevel = value + return f +} + +func (f *FunctionPythonModel) WithMetricLevelValue(value tfconfig.Variable) *FunctionPythonModel { + f.MetricLevel = value + return f +} + +func (f *FunctionPythonModel) WithNameValue(value tfconfig.Variable) *FunctionPythonModel { + f.Name = value + return f +} + +func (f *FunctionPythonModel) WithNullInputBehaviorValue(value tfconfig.Variable) *FunctionPythonModel { + f.NullInputBehavior = value + return f +} + +func (f *FunctionPythonModel) WithPackagesValue(value tfconfig.Variable) *FunctionPythonModel { + f.Packages = value + return f +} + +func (f *FunctionPythonModel) WithReturnBehaviorValue(value tfconfig.Variable) *FunctionPythonModel { + f.ReturnBehavior = value + return f +} + +func (f *FunctionPythonModel) WithReturnTypeValue(value tfconfig.Variable) *FunctionPythonModel { + f.ReturnType = value + return f +} + +func (f *FunctionPythonModel) WithRuntimeVersionValue(value tfconfig.Variable) *FunctionPythonModel { + f.RuntimeVersion = value + return f +} + +func (f *FunctionPythonModel) WithSchemaValue(value tfconfig.Variable) *FunctionPythonModel { + f.Schema = value + return f +} + +func (f *FunctionPythonModel) WithSecretsValue(value tfconfig.Variable) *FunctionPythonModel { + f.Secrets = value + return f +} + +func (f *FunctionPythonModel) WithTraceLevelValue(value tfconfig.Variable) *FunctionPythonModel { + f.TraceLevel = value + return f +} diff --git a/pkg/acceptance/bettertestspoc/config/model/function_scala_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/function_scala_model_ext.go new file mode 100644 index 0000000000..a5e43e53ca --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/function_scala_model_ext.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" +) + +func (f *FunctionScalaModel) MarshalJSON() ([]byte, error) { + type Alias FunctionScalaModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(f), + DependsOn: f.DependsOn(), + }) +} diff --git a/pkg/acceptance/bettertestspoc/config/model/function_scala_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/function_scala_model_gen.go new file mode 100644 index 0000000000..017c397af3 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/function_scala_model_gen.go @@ -0,0 +1,306 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type FunctionScalaModel struct { + Arguments tfconfig.Variable `json:"arguments,omitempty"` + Comment tfconfig.Variable `json:"comment,omitempty"` + Database tfconfig.Variable `json:"database,omitempty"` + EnableConsoleOutput tfconfig.Variable `json:"enable_console_output,omitempty"` + ExternalAccessIntegrations tfconfig.Variable `json:"external_access_integrations,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + FunctionDefinition tfconfig.Variable `json:"function_definition,omitempty"` + FunctionLanguage tfconfig.Variable `json:"function_language,omitempty"` + Handler tfconfig.Variable `json:"handler,omitempty"` + Imports tfconfig.Variable `json:"imports,omitempty"` + IsSecure tfconfig.Variable `json:"is_secure,omitempty"` + LogLevel tfconfig.Variable `json:"log_level,omitempty"` + MetricLevel tfconfig.Variable `json:"metric_level,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + NullInputBehavior tfconfig.Variable `json:"null_input_behavior,omitempty"` + Packages tfconfig.Variable `json:"packages,omitempty"` + ReturnBehavior tfconfig.Variable `json:"return_behavior,omitempty"` + ReturnType tfconfig.Variable `json:"return_type,omitempty"` + RuntimeVersion tfconfig.Variable `json:"runtime_version,omitempty"` + Schema tfconfig.Variable `json:"schema,omitempty"` + Secrets tfconfig.Variable `json:"secrets,omitempty"` + TargetPath tfconfig.Variable `json:"target_path,omitempty"` + TraceLevel tfconfig.Variable `json:"trace_level,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func FunctionScala( + resourceName string, + database string, + functionDefinition string, + handler string, + name string, + returnType string, + runtimeVersion string, + schema string, +) *FunctionScalaModel { + f := &FunctionScalaModel{ResourceModelMeta: config.Meta(resourceName, resources.FunctionScala)} + f.WithDatabase(database) + f.WithFunctionDefinition(functionDefinition) + f.WithHandler(handler) + f.WithName(name) + f.WithReturnType(returnType) + f.WithRuntimeVersion(runtimeVersion) + f.WithSchema(schema) + return f +} + +func FunctionScalaWithDefaultMeta( + database string, + functionDefinition string, + handler string, + name string, + returnType string, + runtimeVersion string, + schema string, +) *FunctionScalaModel { + f := &FunctionScalaModel{ResourceModelMeta: config.DefaultMeta(resources.FunctionScala)} + f.WithDatabase(database) + f.WithFunctionDefinition(functionDefinition) + f.WithHandler(handler) + f.WithName(name) + f.WithReturnType(returnType) + f.WithRuntimeVersion(runtimeVersion) + f.WithSchema(schema) + return f +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// arguments attribute type is not yet supported, so WithArguments can't be generated + +func (f *FunctionScalaModel) WithComment(comment string) *FunctionScalaModel { + f.Comment = tfconfig.StringVariable(comment) + return f +} + +func (f *FunctionScalaModel) WithDatabase(database string) *FunctionScalaModel { + f.Database = tfconfig.StringVariable(database) + return f +} + +func (f *FunctionScalaModel) WithEnableConsoleOutput(enableConsoleOutput bool) *FunctionScalaModel { + f.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) + return f +} + +// external_access_integrations attribute type is not yet supported, so WithExternalAccessIntegrations can't be generated + +func (f *FunctionScalaModel) WithFullyQualifiedName(fullyQualifiedName string) *FunctionScalaModel { + f.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return f +} + +func (f *FunctionScalaModel) WithFunctionDefinition(functionDefinition string) *FunctionScalaModel { + f.FunctionDefinition = tfconfig.StringVariable(functionDefinition) + return f +} + +func (f *FunctionScalaModel) WithFunctionLanguage(functionLanguage string) *FunctionScalaModel { + f.FunctionLanguage = tfconfig.StringVariable(functionLanguage) + return f +} + +func (f *FunctionScalaModel) WithHandler(handler string) *FunctionScalaModel { + f.Handler = tfconfig.StringVariable(handler) + return f +} + +// imports attribute type is not yet supported, so WithImports can't be generated + +func (f *FunctionScalaModel) WithIsSecure(isSecure string) *FunctionScalaModel { + f.IsSecure = tfconfig.StringVariable(isSecure) + return f +} + +func (f *FunctionScalaModel) WithLogLevel(logLevel string) *FunctionScalaModel { + f.LogLevel = tfconfig.StringVariable(logLevel) + return f +} + +func (f *FunctionScalaModel) WithMetricLevel(metricLevel string) *FunctionScalaModel { + f.MetricLevel = tfconfig.StringVariable(metricLevel) + return f +} + +func (f *FunctionScalaModel) WithName(name string) *FunctionScalaModel { + f.Name = tfconfig.StringVariable(name) + return f +} + +func (f *FunctionScalaModel) WithNullInputBehavior(nullInputBehavior string) *FunctionScalaModel { + f.NullInputBehavior = tfconfig.StringVariable(nullInputBehavior) + return f +} + +// packages attribute type is not yet supported, so WithPackages can't be generated + +func (f *FunctionScalaModel) WithReturnBehavior(returnBehavior string) *FunctionScalaModel { + f.ReturnBehavior = tfconfig.StringVariable(returnBehavior) + return f +} + +func (f *FunctionScalaModel) WithReturnType(returnType string) *FunctionScalaModel { + f.ReturnType = tfconfig.StringVariable(returnType) + return f +} + +func (f *FunctionScalaModel) WithRuntimeVersion(runtimeVersion string) *FunctionScalaModel { + f.RuntimeVersion = tfconfig.StringVariable(runtimeVersion) + return f +} + +func (f *FunctionScalaModel) WithSchema(schema string) *FunctionScalaModel { + f.Schema = tfconfig.StringVariable(schema) + return f +} + +// secrets attribute type is not yet supported, so WithSecrets can't be generated + +func (f *FunctionScalaModel) WithTargetPath(targetPath string) *FunctionScalaModel { + f.TargetPath = tfconfig.StringVariable(targetPath) + return f +} + +func (f *FunctionScalaModel) WithTraceLevel(traceLevel string) *FunctionScalaModel { + f.TraceLevel = tfconfig.StringVariable(traceLevel) + return f +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (f *FunctionScalaModel) WithArgumentsValue(value tfconfig.Variable) *FunctionScalaModel { + f.Arguments = value + return f +} + +func (f *FunctionScalaModel) WithCommentValue(value tfconfig.Variable) *FunctionScalaModel { + f.Comment = value + return f +} + +func (f *FunctionScalaModel) WithDatabaseValue(value tfconfig.Variable) *FunctionScalaModel { + f.Database = value + return f +} + +func (f *FunctionScalaModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *FunctionScalaModel { + f.EnableConsoleOutput = value + return f +} + +func (f *FunctionScalaModel) WithExternalAccessIntegrationsValue(value tfconfig.Variable) *FunctionScalaModel { + f.ExternalAccessIntegrations = value + return f +} + +func (f *FunctionScalaModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *FunctionScalaModel { + f.FullyQualifiedName = value + return f +} + +func (f *FunctionScalaModel) WithFunctionDefinitionValue(value tfconfig.Variable) *FunctionScalaModel { + f.FunctionDefinition = value + return f +} + +func (f *FunctionScalaModel) WithFunctionLanguageValue(value tfconfig.Variable) *FunctionScalaModel { + f.FunctionLanguage = value + return f +} + +func (f *FunctionScalaModel) WithHandlerValue(value tfconfig.Variable) *FunctionScalaModel { + f.Handler = value + return f +} + +func (f *FunctionScalaModel) WithImportsValue(value tfconfig.Variable) *FunctionScalaModel { + f.Imports = value + return f +} + +func (f *FunctionScalaModel) WithIsSecureValue(value tfconfig.Variable) *FunctionScalaModel { + f.IsSecure = value + return f +} + +func (f *FunctionScalaModel) WithLogLevelValue(value tfconfig.Variable) *FunctionScalaModel { + f.LogLevel = value + return f +} + +func (f *FunctionScalaModel) WithMetricLevelValue(value tfconfig.Variable) *FunctionScalaModel { + f.MetricLevel = value + return f +} + +func (f *FunctionScalaModel) WithNameValue(value tfconfig.Variable) *FunctionScalaModel { + f.Name = value + return f +} + +func (f *FunctionScalaModel) WithNullInputBehaviorValue(value tfconfig.Variable) *FunctionScalaModel { + f.NullInputBehavior = value + return f +} + +func (f *FunctionScalaModel) WithPackagesValue(value tfconfig.Variable) *FunctionScalaModel { + f.Packages = value + return f +} + +func (f *FunctionScalaModel) WithReturnBehaviorValue(value tfconfig.Variable) *FunctionScalaModel { + f.ReturnBehavior = value + return f +} + +func (f *FunctionScalaModel) WithReturnTypeValue(value tfconfig.Variable) *FunctionScalaModel { + f.ReturnType = value + return f +} + +func (f *FunctionScalaModel) WithRuntimeVersionValue(value tfconfig.Variable) *FunctionScalaModel { + f.RuntimeVersion = value + return f +} + +func (f *FunctionScalaModel) WithSchemaValue(value tfconfig.Variable) *FunctionScalaModel { + f.Schema = value + return f +} + +func (f *FunctionScalaModel) WithSecretsValue(value tfconfig.Variable) *FunctionScalaModel { + f.Secrets = value + return f +} + +func (f *FunctionScalaModel) WithTargetPathValue(value tfconfig.Variable) *FunctionScalaModel { + f.TargetPath = value + return f +} + +func (f *FunctionScalaModel) WithTraceLevelValue(value tfconfig.Variable) *FunctionScalaModel { + f.TraceLevel = value + return f +} diff --git a/pkg/acceptance/bettertestspoc/config/model/function_sql_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/function_sql_model_ext.go new file mode 100644 index 0000000000..d4f775628d --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/function_sql_model_ext.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" +) + +func (f *FunctionSqlModel) MarshalJSON() ([]byte, error) { + type Alias FunctionSqlModel + return json.Marshal(&struct { + *Alias + DependsOn []string `json:"depends_on,omitempty"` + }{ + Alias: (*Alias)(f), + DependsOn: f.DependsOn(), + }) +} diff --git a/pkg/acceptance/bettertestspoc/config/model/function_sql_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/function_sql_model_gen.go new file mode 100644 index 0000000000..14cbbe9136 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/function_sql_model_gen.go @@ -0,0 +1,233 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type FunctionSqlModel struct { + Arguments tfconfig.Variable `json:"arguments,omitempty"` + Comment tfconfig.Variable `json:"comment,omitempty"` + Database tfconfig.Variable `json:"database,omitempty"` + EnableConsoleOutput tfconfig.Variable `json:"enable_console_output,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` + FunctionDefinition tfconfig.Variable `json:"function_definition,omitempty"` + FunctionLanguage tfconfig.Variable `json:"function_language,omitempty"` + IsSecure tfconfig.Variable `json:"is_secure,omitempty"` + LogLevel tfconfig.Variable `json:"log_level,omitempty"` + MetricLevel tfconfig.Variable `json:"metric_level,omitempty"` + Name tfconfig.Variable `json:"name,omitempty"` + NullInputBehavior tfconfig.Variable `json:"null_input_behavior,omitempty"` + ReturnBehavior tfconfig.Variable `json:"return_behavior,omitempty"` + ReturnType tfconfig.Variable `json:"return_type,omitempty"` + Schema tfconfig.Variable `json:"schema,omitempty"` + TraceLevel tfconfig.Variable `json:"trace_level,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func FunctionSql( + resourceName string, + database string, + functionDefinition string, + name string, + returnType string, + schema string, +) *FunctionSqlModel { + f := &FunctionSqlModel{ResourceModelMeta: config.Meta(resourceName, resources.FunctionSql)} + f.WithDatabase(database) + f.WithFunctionDefinition(functionDefinition) + f.WithName(name) + f.WithReturnType(returnType) + f.WithSchema(schema) + return f +} + +func FunctionSqlWithDefaultMeta( + database string, + functionDefinition string, + name string, + returnType string, + schema string, +) *FunctionSqlModel { + f := &FunctionSqlModel{ResourceModelMeta: config.DefaultMeta(resources.FunctionSql)} + f.WithDatabase(database) + f.WithFunctionDefinition(functionDefinition) + f.WithName(name) + f.WithReturnType(returnType) + f.WithSchema(schema) + return f +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// arguments attribute type is not yet supported, so WithArguments can't be generated + +func (f *FunctionSqlModel) WithComment(comment string) *FunctionSqlModel { + f.Comment = tfconfig.StringVariable(comment) + return f +} + +func (f *FunctionSqlModel) WithDatabase(database string) *FunctionSqlModel { + f.Database = tfconfig.StringVariable(database) + return f +} + +func (f *FunctionSqlModel) WithEnableConsoleOutput(enableConsoleOutput bool) *FunctionSqlModel { + f.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) + return f +} + +func (f *FunctionSqlModel) WithFullyQualifiedName(fullyQualifiedName string) *FunctionSqlModel { + f.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return f +} + +func (f *FunctionSqlModel) WithFunctionDefinition(functionDefinition string) *FunctionSqlModel { + f.FunctionDefinition = tfconfig.StringVariable(functionDefinition) + return f +} + +func (f *FunctionSqlModel) WithFunctionLanguage(functionLanguage string) *FunctionSqlModel { + f.FunctionLanguage = tfconfig.StringVariable(functionLanguage) + return f +} + +func (f *FunctionSqlModel) WithIsSecure(isSecure string) *FunctionSqlModel { + f.IsSecure = tfconfig.StringVariable(isSecure) + return f +} + +func (f *FunctionSqlModel) WithLogLevel(logLevel string) *FunctionSqlModel { + f.LogLevel = tfconfig.StringVariable(logLevel) + return f +} + +func (f *FunctionSqlModel) WithMetricLevel(metricLevel string) *FunctionSqlModel { + f.MetricLevel = tfconfig.StringVariable(metricLevel) + return f +} + +func (f *FunctionSqlModel) WithName(name string) *FunctionSqlModel { + f.Name = tfconfig.StringVariable(name) + return f +} + +func (f *FunctionSqlModel) WithNullInputBehavior(nullInputBehavior string) *FunctionSqlModel { + f.NullInputBehavior = tfconfig.StringVariable(nullInputBehavior) + return f +} + +func (f *FunctionSqlModel) WithReturnBehavior(returnBehavior string) *FunctionSqlModel { + f.ReturnBehavior = tfconfig.StringVariable(returnBehavior) + return f +} + +func (f *FunctionSqlModel) WithReturnType(returnType string) *FunctionSqlModel { + f.ReturnType = tfconfig.StringVariable(returnType) + return f +} + +func (f *FunctionSqlModel) WithSchema(schema string) *FunctionSqlModel { + f.Schema = tfconfig.StringVariable(schema) + return f +} + +func (f *FunctionSqlModel) WithTraceLevel(traceLevel string) *FunctionSqlModel { + f.TraceLevel = tfconfig.StringVariable(traceLevel) + return f +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (f *FunctionSqlModel) WithArgumentsValue(value tfconfig.Variable) *FunctionSqlModel { + f.Arguments = value + return f +} + +func (f *FunctionSqlModel) WithCommentValue(value tfconfig.Variable) *FunctionSqlModel { + f.Comment = value + return f +} + +func (f *FunctionSqlModel) WithDatabaseValue(value tfconfig.Variable) *FunctionSqlModel { + f.Database = value + return f +} + +func (f *FunctionSqlModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *FunctionSqlModel { + f.EnableConsoleOutput = value + return f +} + +func (f *FunctionSqlModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *FunctionSqlModel { + f.FullyQualifiedName = value + return f +} + +func (f *FunctionSqlModel) WithFunctionDefinitionValue(value tfconfig.Variable) *FunctionSqlModel { + f.FunctionDefinition = value + return f +} + +func (f *FunctionSqlModel) WithFunctionLanguageValue(value tfconfig.Variable) *FunctionSqlModel { + f.FunctionLanguage = value + return f +} + +func (f *FunctionSqlModel) WithIsSecureValue(value tfconfig.Variable) *FunctionSqlModel { + f.IsSecure = value + return f +} + +func (f *FunctionSqlModel) WithLogLevelValue(value tfconfig.Variable) *FunctionSqlModel { + f.LogLevel = value + return f +} + +func (f *FunctionSqlModel) WithMetricLevelValue(value tfconfig.Variable) *FunctionSqlModel { + f.MetricLevel = value + return f +} + +func (f *FunctionSqlModel) WithNameValue(value tfconfig.Variable) *FunctionSqlModel { + f.Name = value + return f +} + +func (f *FunctionSqlModel) WithNullInputBehaviorValue(value tfconfig.Variable) *FunctionSqlModel { + f.NullInputBehavior = value + return f +} + +func (f *FunctionSqlModel) WithReturnBehaviorValue(value tfconfig.Variable) *FunctionSqlModel { + f.ReturnBehavior = value + return f +} + +func (f *FunctionSqlModel) WithReturnTypeValue(value tfconfig.Variable) *FunctionSqlModel { + f.ReturnType = value + return f +} + +func (f *FunctionSqlModel) WithSchemaValue(value tfconfig.Variable) *FunctionSqlModel { + f.Schema = value + return f +} + +func (f *FunctionSqlModel) WithTraceLevelValue(value tfconfig.Variable) *FunctionSqlModel { + f.TraceLevel = value + return f +} diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 7e5f4c9370..5692d9a5eb 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -494,6 +494,11 @@ func getResources() map[string]*schema.Resource { "snowflake_failover_group": resources.FailoverGroup(), "snowflake_file_format": resources.FileFormat(), "snowflake_function": resources.Function(), + "snowflake_function_java": resources.FunctionJava(), + "snowflake_function_javascript": resources.FunctionJavascript(), + "snowflake_function_python": resources.FunctionPython(), + "snowflake_function_scala": resources.FunctionScala(), + "snowflake_function_sql": resources.FunctionSql(), "snowflake_grant_account_role": resources.GrantAccountRole(), "snowflake_grant_application_role": resources.GrantApplicationRole(), "snowflake_grant_database_role": resources.GrantDatabaseRole(), diff --git a/pkg/provider/resources/resources.go b/pkg/provider/resources/resources.go index 6991cbabe2..a8173a6d96 100644 --- a/pkg/provider/resources/resources.go +++ b/pkg/provider/resources/resources.go @@ -34,6 +34,11 @@ const ( GrantPrivilegesToDatabaseRole resource = "snowflake_grant_privileges_to_database_role" GrantPrivilegesToShare resource = "snowflake_grant_privileges_to_share" Function resource = "snowflake_function" + FunctionJava resource = "snowflake_function_java" + FunctionJavascript resource = "snowflake_function_javascript" + FunctionPython resource = "snowflake_function_python" + FunctionScala resource = "snowflake_function_scala" + FunctionSql resource = "snowflake_function_sql" LegacyServiceUser resource = "snowflake_legacy_service_user" ManagedAccount resource = "snowflake_managed_account" MaskingPolicy resource = "snowflake_masking_policy" diff --git a/pkg/resources/function_commons.go b/pkg/resources/function_commons.go new file mode 100644 index 0000000000..d2e703a0e6 --- /dev/null +++ b/pkg/resources/function_commons.go @@ -0,0 +1,344 @@ +package resources + +import ( + "fmt" + "slices" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/schemas" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func init() { + javaFunctionSchema = setUpFunctionSchema(javaFunctionSchemaDefinition) + javascriptFunctionSchema = setUpFunctionSchema(javascriptFunctionSchemaDefinition) + pythonFunctionSchema = setUpFunctionSchema(pythonFunctionSchemaDefinition) + scalaFunctionSchema = setUpFunctionSchema(scalaFunctionSchemaDefinition) + sqlFunctionSchema = setUpFunctionSchema(sqlFunctionSchemaDefinition) +} + +type functionSchemaDef struct { + additionalArguments []string + functionDefinitionDescription string + runtimeVersionRequired bool + runtimeVersionDescription string + importsDescription string + packagesDescription string + handlerDescription string + targetPathDescription string +} + +func setUpFunctionSchema(definition functionSchemaDef) map[string]*schema.Schema { + currentSchema := make(map[string]*schema.Schema) + for k, v := range functionBaseSchema { + v := v + if slices.Contains(definition.additionalArguments, k) || slices.Contains(commonFunctionArguments, k) { + currentSchema[k] = &v + } + } + if v, ok := currentSchema["function_definition"]; ok && v != nil { + v.Description = definition.functionDefinitionDescription + } + if v, ok := currentSchema["runtime_version"]; ok && v != nil { + if definition.runtimeVersionRequired { + v.Required = true + } else { + v.Optional = true + } + v.Description = definition.runtimeVersionDescription + } + if v, ok := currentSchema["imports"]; ok && v != nil { + v.Description = definition.importsDescription + } + if v, ok := currentSchema["packages"]; ok && v != nil { + v.Description = definition.packagesDescription + } + if v, ok := currentSchema["handler"]; ok && v != nil { + v.Description = definition.handlerDescription + } + if v, ok := currentSchema["target_path"]; ok && v != nil { + v.Description = definition.handlerDescription + } + return currentSchema +} + +func functionDefinitionTemplate(language string, linkUrl string) string { + return fmt.Sprintf("Defines the handler code executed when the UDF is called. Wrapping `$$` signs are added by the provider automatically; do not include them. The `function_definition` value must be %[1]s source code. For more information, see [Introduction to %[1]s UDFs](%[2]s).", language, linkUrl) +} + +var ( + commonFunctionArguments = []string{ + "database", + "schema", + "name", + "is_secure", + "arguments", + "return_type", + "null_input_behavior", + "return_behavior", + "comment", + "function_definition", + "function_language", + ShowOutputAttributeName, + ParametersAttributeName, + FullyQualifiedNameAttributeName, + } + javaFunctionSchemaDefinition = functionSchemaDef{ + additionalArguments: []string{ + "runtime_version", + "imports", + "packages", + "handler", + "external_access_integrations", + "secrets", + "target_path", + }, + functionDefinitionDescription: functionDefinitionTemplate("Java", "https://docs.snowflake.com/en/developer-guide/udf/java/udf-java-introduction"), + runtimeVersionRequired: false, + runtimeVersionDescription: "Specifies the Java JDK runtime version to use. The supported versions of Java are 11.x and 17.x. If RUNTIME_VERSION is not set, Java JDK 11 is used.", + importsDescription: "The location (stage), path, and name of the file(s) to import. A file can be a JAR file or another type of file. If the file is a JAR file, it can contain one or more .class files and zero or more resource files. JNI (Java Native Interface) is not supported. Snowflake prohibits loading libraries that contain native code (as opposed to Java bytecode). Java UDFs can also read non-JAR files. For an example, see [Reading a file specified statically in IMPORTS](https://docs.snowflake.com/en/developer-guide/udf/java/udf-java-cookbook.html#label-reading-file-from-java-udf-imports). Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#java).", + packagesDescription: "The name and version number of Snowflake system packages required as dependencies. The value should be of the form `package_name:version_number`, where `package_name` is `snowflake_domain:package`.", + handlerDescription: "The name of the handler method or class. If the handler is for a scalar UDF, returning a non-tabular value, the HANDLER value should be a method name, as in the following form: `MyClass.myMethod`. If the handler is for a tabular UDF, the HANDLER value should be the name of a handler class.", + targetPathDescription: "The TARGET_PATH clause specifies the location to which Snowflake should write the compiled code (JAR file) after compiling the source code specified in the `function_definition`. If this clause is included, the user should manually remove the JAR file when it is no longer needed (typically when the Java UDF is dropped). If this clause is omitted, Snowflake re-compiles the source code each time the code is needed. The JAR file is not stored permanently, and the user does not need to clean up the JAR file. Snowflake returns an error if the TARGET_PATH matches an existing file; you cannot use TARGET_PATH to overwrite an existing file.", + } + javascriptFunctionSchemaDefinition = functionSchemaDef{ + additionalArguments: []string{}, + functionDefinitionDescription: functionDefinitionTemplate("JavaScript", "https://docs.snowflake.com/en/developer-guide/udf/javascript/udf-javascript-introduction"), + } + pythonFunctionSchemaDefinition = functionSchemaDef{ + additionalArguments: []string{ + "is_aggregate", + "runtime_version", + "imports", + "packages", + "handler", + "external_access_integrations", + "secrets", + }, + functionDefinitionDescription: functionDefinitionTemplate("Python", "https://docs.snowflake.com/en/developer-guide/udf/python/udf-python-introduction"), + runtimeVersionRequired: true, + runtimeVersionDescription: "Specifies the Python version to use. The supported versions of Python are: 3.9, 3.10, and 3.11.", + importsDescription: "The location (stage), path, and name of the file(s) to import. A file can be a `.py` file or another type of file. Python UDFs can also read non-Python files, such as text files. For an example, see [Reading a file](https://docs.snowflake.com/en/developer-guide/udf/python/udf-python-examples.html#label-udf-python-read-files). Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#python).", + packagesDescription: "The name and version number of packages required as dependencies. The value should be of the form `package_name==version_number`.", + handlerDescription: "The name of the handler function or class. If the handler is for a scalar UDF, returning a non-tabular value, the HANDLER value should be a function name. If the handler code is in-line with the CREATE FUNCTION statement, you can use the function name alone. When the handler code is referenced at a stage, this value should be qualified with the module name, as in the following form: `my_module.my_function`. If the handler is for a tabular UDF, the HANDLER value should be the name of a handler class.", + } + scalaFunctionSchemaDefinition = functionSchemaDef{ + additionalArguments: []string{ + "runtime_version", + "imports", + "packages", + "handler", + "external_access_integrations", + "secrets", + "target_path", + }, + functionDefinitionDescription: functionDefinitionTemplate("Scala", "https://docs.snowflake.com/en/developer-guide/udf/scala/udf-scala-introduction"), + runtimeVersionRequired: true, + runtimeVersionDescription: "Specifies the Scala runtime version to use. The supported versions of Scala are: 2.12.", + importsDescription: "The location (stage), path, and name of the file(s) to import, such as a JAR or other kind of file. The JAR file might contain handler dependency libraries. It can contain one or more .class files and zero or more resource files. JNI (Java Native Interface) is not supported. Snowflake prohibits loading libraries that contain native code (as opposed to Java bytecode). A non-JAR file might a file read by handler code. For an example, see [Reading a file specified statically in IMPORTS](https://docs.snowflake.com/en/developer-guide/udf/java/udf-java-cookbook.html#label-reading-file-from-java-udf-imports). Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#scala).", + packagesDescription: "The name and version number of Snowflake system packages required as dependencies. The value should be of the form `package_name:version_number`, where `package_name` is `snowflake_domain:package`.", + handlerDescription: "The name of the handler method or class. If the handler is for a scalar UDF, returning a non-tabular value, the HANDLER value should be a method name, as in the following form: `MyClass.myMethod`.", + targetPathDescription: "The TARGET_PATH clause specifies the location to which Snowflake should write the compiled code (JAR file) after compiling the source code specified in the `function_definition`. If this clause is included, you should manually remove the JAR file when it is no longer needed (typically when the UDF is dropped). If this clause is omitted, Snowflake re-compiles the source code each time the code is needed. The JAR file is not stored permanently, and you do not need to clean up the JAR file. Snowflake returns an error if the TARGET_PATH matches an existing file; you cannot use TARGET_PATH to overwrite an existing file.", + } + sqlFunctionSchemaDefinition = functionSchemaDef{ + additionalArguments: []string{}, + functionDefinitionDescription: functionDefinitionTemplate("SQL", "https://docs.snowflake.com/en/developer-guide/udf/sql/udf-sql-introduction"), + } +) + +var ( + javaFunctionSchema map[string]*schema.Schema + javascriptFunctionSchema map[string]*schema.Schema + pythonFunctionSchema map[string]*schema.Schema + scalaFunctionSchema map[string]*schema.Schema + sqlFunctionSchema map[string]*schema.Schema +) + +// TODO [SNOW-1348103]: add null/not null +// TODO [SNOW-1348103]: currently database and schema are ForceNew but based on the docs it is possible to rename with moving to different db/schema +// TODO [SNOW-1348103]: copyGrants and orReplace logic omitted for now, will be added to the limitations docs +// TODO [SNOW-1348103]: temporary is not supported because it creates a per-session object; add to limitations/design decisions +var functionBaseSchema = map[string]schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: suppressIdentifierQuoting, + Description: blocklistedCharactersFieldDescription("The database in which to create the function."), + }, + "schema": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: suppressIdentifierQuoting, + Description: blocklistedCharactersFieldDescription("The schema in which to create the function."), + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: blocklistedCharactersFieldDescription("The name of the function; the identifier does not need to be unique for the schema in which the function is created because UDFs are identified and resolved by the combination of the name and argument types. Check the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages)."), + DiffSuppressFunc: suppressIdentifierQuoting, + }, + "is_secure": { + Type: schema.TypeString, + Optional: true, + Default: BooleanDefault, + ValidateDiagFunc: validateBooleanString, + DiffSuppressFunc: IgnoreChangeToCurrentSnowflakeValueInShow("is_secure"), + Description: booleanStringFieldDescription("Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure views (consult [function docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#id1) and [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure)) which is essential to manage/import function with Terraform. Use the role owning the function while managing secure functions."), + }, + "is_aggregate": { + Type: schema.TypeString, + Optional: true, + Default: BooleanDefault, + ValidateDiagFunc: validateBooleanString, + DiffSuppressFunc: IgnoreChangeToCurrentSnowflakeValueInShow("is_aggregate"), + Description: booleanStringFieldDescription("Specifies that the function is an aggregate function. For more information about user-defined aggregate functions, see [Python user-defined aggregate functions](https://docs.snowflake.com/en/developer-guide/udf/python/udf-python-aggregate-functions)."), + }, + "arguments": { + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "arg_name": { + Type: schema.TypeString, + Required: true, + // TODO [SNOW-1348103]: adjust diff suppression accordingly. + Description: "The argument name.", + }, + // TODO [SNOW-1348103]: after testing weird names add limitations to the docs and add validation here + "arg_data_type": { + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: IsDataTypeValid, + DiffSuppressFunc: DiffSuppressDataTypes, + Description: "The argument type.", + }, + }, + }, + Optional: true, + ForceNew: true, + Description: "List of the arguments for the function. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages) for more details.", + }, + // TODO [SNOW-1348103]: for now, the proposal is to leave return type as string, add TABLE to data types, and here always parse (easier handling and diff suppression) + "return_type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateDiagFunc: IsDataTypeValid, + DiffSuppressFunc: DiffSuppressDataTypes, + Description: "Specifies the results returned by the UDF, which determines the UDF type. Use `` to create a scalar UDF that returns a single value with the specified data type. Use `TABLE (col_name col_data_type, ...)` to creates a table UDF that returns tabular results with the specified table column(s) and column type(s). For the details, consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-function#all-languages).", + // TODO [SNOW-1348103]: adjust DiffSuppressFunc + }, + "null_input_behavior": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateDiagFunc: sdkValidation(sdk.ToNullInputBehavior), + DiffSuppressFunc: SuppressIfAny(NormalizeAndCompare(sdk.ToNullInputBehavior), IgnoreChangeToCurrentSnowflakeValueInShow("null_input_behavior")), + Description: fmt.Sprintf("Specifies the behavior of the function when called with null inputs. Valid values are (case-insensitive): %s.", possibleValuesListed(sdk.AllAllowedNullInputBehaviors)), + }, + "return_behavior": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateDiagFunc: sdkValidation(sdk.ToReturnResultsBehavior), + DiffSuppressFunc: SuppressIfAny(NormalizeAndCompare(sdk.ToReturnResultsBehavior), IgnoreChangeToCurrentSnowflakeValueInShow("return_behavior")), + Description: fmt.Sprintf("Specifies the behavior of the function when returning results. Valid values are (case-insensitive): %s.", possibleValuesListed(sdk.AllAllowedReturnResultsBehaviors)), + }, + "runtime_version": { + Type: schema.TypeString, + ForceNew: true, + // TODO [SNOW-1348103]: may be optional for java without consequence because if it is not set, the describe is not returning any version. + }, + "comment": { + Type: schema.TypeString, + Optional: true, + // TODO [SNOW-1348103]: handle dynamic comment - this is a workaround for now + Default: "user-defined function", + Description: "Specifies a comment for the function.", + }, + // TODO [SNOW-1348103]: because of https://docs.snowflake.com/en/sql-reference/sql/create-function#id6, maybe it will be better to split into stage_name + target_path + "imports": { + Type: schema.TypeSet, + Elem: &schema.Schema{Type: schema.TypeString}, + Optional: true, + ForceNew: true, + }, + // TODO [SNOW-1348103]: what do we do with the version "latest". + "packages": { + Type: schema.TypeSet, + Elem: &schema.Schema{Type: schema.TypeString}, + Optional: true, + ForceNew: true, + }, + "handler": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + // TODO [SNOW-1348103]: use suppress from network policies when adding logic + "external_access_integrations": { + Type: schema.TypeSet, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateDiagFunc: IsValidIdentifier[sdk.AccountObjectIdentifier](), + }, + Optional: true, + ForceNew: true, + Description: "The names of [external access integrations](https://docs.snowflake.com/en/sql-reference/sql/create-external-access-integration) needed in order for this function’s handler code to access external networks. An external access integration specifies [network rules](https://docs.snowflake.com/en/sql-reference/sql/create-network-rule) and [secrets](https://docs.snowflake.com/en/sql-reference/sql/create-secret) that specify external locations and credentials (if any) allowed for use by handler code when making requests of an external network, such as an external REST API.", + }, + "secrets": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "secret_variable_name": { + Type: schema.TypeString, + Required: true, + Description: "The variable that will be used in handler code when retrieving information from the secret.", + }, + "secret_id": { + Type: schema.TypeString, + Required: true, + Description: "Fully qualified name of the allowed secret. You will receive an error if you specify a SECRETS value whose secret isn’t also included in an integration specified by the EXTERNAL_ACCESS_INTEGRATIONS parameter.", + DiffSuppressFunc: suppressIdentifierQuoting, + }, + }, + }, + Description: "Assigns the names of secrets to variables so that you can use the variables to reference the secrets when retrieving information from secrets in handler code. Secrets you specify here must be allowed by the [external access integration](https://docs.snowflake.com/en/sql-reference/sql/create-external-access-integration) specified as a value of this CREATE FUNCTION command’s EXTERNAL_ACCESS_INTEGRATIONS parameter.", + }, + // TODO [SNOW-1348103]: because of https://docs.snowflake.com/en/sql-reference/sql/create-function#id6, maybe it will be better to split into stage + path + "target_path": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "function_definition": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: DiffSuppressStatement, + }, + "function_language": { + Type: schema.TypeString, + Computed: true, + Description: "Specifies language for the user. Used to detect external changes.", + }, + ShowOutputAttributeName: { + Type: schema.TypeList, + Computed: true, + Description: "Outputs the result of `SHOW FUNCTION` for the given function.", + Elem: &schema.Resource{ + Schema: schemas.ShowFunctionSchema, + }, + }, + ParametersAttributeName: { + Type: schema.TypeList, + Computed: true, + Description: "Outputs the result of `SHOW PARAMETERS IN FUNCTION` for the given function.", + Elem: &schema.Resource{ + Schema: functionParametersSchema, + }, + }, + FullyQualifiedNameAttributeName: *schemas.FullyQualifiedNameSchema, +} diff --git a/pkg/resources/function_java.go b/pkg/resources/function_java.go new file mode 100644 index 0000000000..5e05d3007f --- /dev/null +++ b/pkg/resources/function_java.go @@ -0,0 +1,52 @@ +package resources + +import ( + "context" + "strings" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func FunctionJava() *schema.Resource { + return &schema.Resource{ + CreateContext: TrackingCreateWrapper(resources.FunctionJava, CreateContextFunctionJava), + ReadContext: TrackingReadWrapper(resources.FunctionJava, ReadContextFunctionJava), + UpdateContext: TrackingUpdateWrapper(resources.FunctionJava, UpdateContextFunctionJava), + DeleteContext: TrackingDeleteWrapper(resources.FunctionJava, DeleteContextFunctionJava), + Description: "Resource used to manage java function objects. For more information, check [function documentation](https://docs.snowflake.com/en/sql-reference/sql/create-function).", + + CustomizeDiff: TrackingCustomDiffWrapper(resources.FunctionJava, customdiff.All( + // TODO[SNOW-1348103]: ComputedIfAnyAttributeChanged(javaFunctionSchema, ShowOutputAttributeName, ...), + ComputedIfAnyAttributeChanged(javaFunctionSchema, FullyQualifiedNameAttributeName, "name"), + ComputedIfAnyAttributeChanged(functionParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllFunctionParameters), strings.ToLower)...), + functionParametersCustomDiff, + // TODO[SNOW-1348103]: recreate when type changed externally + )), + + Schema: collections.MergeMaps(javaFunctionSchema, functionParametersSchema), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + } +} + +func CreateContextFunctionJava(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func ReadContextFunctionJava(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func UpdateContextFunctionJava(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func DeleteContextFunctionJava(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} diff --git a/pkg/resources/function_javascript.go b/pkg/resources/function_javascript.go new file mode 100644 index 0000000000..f1b3e17e2a --- /dev/null +++ b/pkg/resources/function_javascript.go @@ -0,0 +1,52 @@ +package resources + +import ( + "context" + "strings" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func FunctionJavascript() *schema.Resource { + return &schema.Resource{ + CreateContext: TrackingCreateWrapper(resources.FunctionJavascript, CreateContextFunctionJavascript), + ReadContext: TrackingReadWrapper(resources.FunctionJavascript, ReadContextFunctionJavascript), + UpdateContext: TrackingUpdateWrapper(resources.FunctionJavascript, UpdateContextFunctionJavascript), + DeleteContext: TrackingDeleteWrapper(resources.FunctionJavascript, DeleteContextFunctionJavascript), + Description: "Resource used to manage javascript function objects. For more information, check [function documentation](https://docs.snowflake.com/en/sql-reference/sql/create-function).", + + CustomizeDiff: TrackingCustomDiffWrapper(resources.FunctionJavascript, customdiff.All( + // TODO[SNOW-1348103]: ComputedIfAnyAttributeChanged(javascriptFunctionSchema, ShowOutputAttributeName, ...), + ComputedIfAnyAttributeChanged(javascriptFunctionSchema, FullyQualifiedNameAttributeName, "name"), + ComputedIfAnyAttributeChanged(functionParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllFunctionParameters), strings.ToLower)...), + functionParametersCustomDiff, + // TODO[SNOW-1348103]: recreate when type changed externally + )), + + Schema: collections.MergeMaps(javascriptFunctionSchema, functionParametersSchema), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + } +} + +func CreateContextFunctionJavascript(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func ReadContextFunctionJavascript(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func UpdateContextFunctionJavascript(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func DeleteContextFunctionJavascript(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} diff --git a/pkg/resources/function_parameters.go b/pkg/resources/function_parameters.go new file mode 100644 index 0000000000..bccbe0666a --- /dev/null +++ b/pkg/resources/function_parameters.go @@ -0,0 +1,99 @@ +package resources + +import ( + "context" + "strconv" + "strings" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +var ( + functionParametersSchema = make(map[string]*schema.Schema) + functionParametersCustomDiff = ParametersCustomDiff( + functionParametersProvider, + parameter[sdk.FunctionParameter]{sdk.FunctionParameterEnableConsoleOutput, valueTypeBool, sdk.ParameterTypeFunction}, + parameter[sdk.FunctionParameter]{sdk.FunctionParameterLogLevel, valueTypeString, sdk.ParameterTypeFunction}, + parameter[sdk.FunctionParameter]{sdk.FunctionParameterMetricLevel, valueTypeString, sdk.ParameterTypeFunction}, + parameter[sdk.FunctionParameter]{sdk.FunctionParameterTraceLevel, valueTypeString, sdk.ParameterTypeFunction}, + ) +) + +func init() { + functionParameterFields := []parameterDef[sdk.FunctionParameter]{ + // session params + {Name: sdk.FunctionParameterEnableConsoleOutput, Type: schema.TypeBool, Description: "Enable stdout/stderr fast path logging for anonyous stored procs. This is a public parameter (similar to LOG_LEVEL)."}, + {Name: sdk.FunctionParameterLogLevel, Type: schema.TypeString, Description: "LOG_LEVEL to use when filtering events"}, + {Name: sdk.FunctionParameterMetricLevel, Type: schema.TypeString, ValidateDiag: sdkValidation(sdk.ToMetricLevel), DiffSuppress: NormalizeAndCompare(sdk.ToMetricLevel), Description: "METRIC_LEVEL value to control whether to emit metrics to Event Table"}, + {Name: sdk.FunctionParameterTraceLevel, Type: schema.TypeString, ValidateDiag: sdkValidation(sdk.ToTraceLevel), DiffSuppress: NormalizeAndCompare(sdk.ToTraceLevel), Description: "Trace level value to use when generating/filtering trace events"}, + } + + for _, field := range functionParameterFields { + fieldName := strings.ToLower(string(field.Name)) + + functionParametersSchema[fieldName] = &schema.Schema{ + Type: field.Type, + Description: enrichWithReferenceToParameterDocs(field.Name, field.Description), + Computed: true, + Optional: true, + ValidateDiagFunc: field.ValidateDiag, + DiffSuppressFunc: field.DiffSuppress, + ConflictsWith: field.ConflictsWith, + } + } +} + +func functionParametersProvider(ctx context.Context, d ResourceIdProvider, meta any) ([]*sdk.Parameter, error) { + return parametersProvider(ctx, d, meta.(*provider.Context), functionParametersProviderFunc, sdk.ParseSchemaObjectIdentifierWithArguments) +} + +func functionParametersProviderFunc(c *sdk.Client) showParametersFunc[sdk.SchemaObjectIdentifierWithArguments] { + return c.Functions.ShowParameters +} + +func handleFunctionParameterRead(d *schema.ResourceData, functionParameters []*sdk.Parameter) error { + for _, p := range functionParameters { + switch p.Key { + case + string(sdk.FunctionParameterLogLevel), + string(sdk.FunctionParameterMetricLevel), + string(sdk.FunctionParameterTraceLevel): + if err := d.Set(strings.ToLower(p.Key), p.Value); err != nil { + return err + } + case + string(sdk.FunctionParameterEnableConsoleOutput): + value, err := strconv.ParseBool(p.Value) + if err != nil { + return err + } + if err := d.Set(strings.ToLower(p.Key), value); err != nil { + return err + } + } + } + + return nil +} + +// They do not work in create, that's why are set in alter +func handleFunctionParametersCreate(d *schema.ResourceData, alterOpts *sdk.FunctionSet) diag.Diagnostics { + return JoinDiags( + handleParameterCreate(d, sdk.FunctionParameterEnableConsoleOutput, &alterOpts.EnableConsoleOutput), + handleParameterCreateWithMapping(d, sdk.FunctionParameterLogLevel, &alterOpts.LogLevel, stringToStringEnumProvider(sdk.ToLogLevel)), + handleParameterCreateWithMapping(d, sdk.FunctionParameterMetricLevel, &alterOpts.MetricLevel, stringToStringEnumProvider(sdk.ToMetricLevel)), + handleParameterCreateWithMapping(d, sdk.FunctionParameterTraceLevel, &alterOpts.TraceLevel, stringToStringEnumProvider(sdk.ToTraceLevel)), + ) +} + +func handleFunctionParametersUpdate(d *schema.ResourceData, set *sdk.FunctionSet, unset *sdk.FunctionUnset) diag.Diagnostics { + return JoinDiags( + handleParameterUpdate(d, sdk.FunctionParameterEnableConsoleOutput, &set.EnableConsoleOutput, &unset.EnableConsoleOutput), + handleParameterUpdateWithMapping(d, sdk.FunctionParameterLogLevel, &set.LogLevel, &unset.LogLevel, stringToStringEnumProvider(sdk.ToLogLevel)), + handleParameterUpdateWithMapping(d, sdk.FunctionParameterMetricLevel, &set.MetricLevel, &unset.MetricLevel, stringToStringEnumProvider(sdk.ToMetricLevel)), + handleParameterUpdateWithMapping(d, sdk.FunctionParameterTraceLevel, &set.TraceLevel, &unset.TraceLevel, stringToStringEnumProvider(sdk.ToTraceLevel)), + ) +} diff --git a/pkg/resources/function_python.go b/pkg/resources/function_python.go new file mode 100644 index 0000000000..e270f80ef6 --- /dev/null +++ b/pkg/resources/function_python.go @@ -0,0 +1,52 @@ +package resources + +import ( + "context" + "strings" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func FunctionPython() *schema.Resource { + return &schema.Resource{ + CreateContext: TrackingCreateWrapper(resources.FunctionPython, CreateContextFunctionPython), + ReadContext: TrackingReadWrapper(resources.FunctionPython, ReadContextFunctionPython), + UpdateContext: TrackingUpdateWrapper(resources.FunctionPython, UpdateContextFunctionPython), + DeleteContext: TrackingDeleteWrapper(resources.FunctionPython, DeleteContextFunctionPython), + Description: "Resource used to manage python function objects. For more information, check [function documentation](https://docs.snowflake.com/en/sql-reference/sql/create-function).", + + CustomizeDiff: TrackingCustomDiffWrapper(resources.FunctionPython, customdiff.All( + // TODO[SNOW-1348103]: ComputedIfAnyAttributeChanged(pythonFunctionSchema, ShowOutputAttributeName, ...), + ComputedIfAnyAttributeChanged(pythonFunctionSchema, FullyQualifiedNameAttributeName, "name"), + ComputedIfAnyAttributeChanged(functionParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllFunctionParameters), strings.ToLower)...), + functionParametersCustomDiff, + // TODO[SNOW-1348103]: recreate when type changed externally + )), + + Schema: collections.MergeMaps(pythonFunctionSchema, functionParametersSchema), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + } +} + +func CreateContextFunctionPython(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func ReadContextFunctionPython(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func UpdateContextFunctionPython(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func DeleteContextFunctionPython(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} diff --git a/pkg/resources/function_scala.go b/pkg/resources/function_scala.go new file mode 100644 index 0000000000..2c3adf0bc3 --- /dev/null +++ b/pkg/resources/function_scala.go @@ -0,0 +1,52 @@ +package resources + +import ( + "context" + "strings" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func FunctionScala() *schema.Resource { + return &schema.Resource{ + CreateContext: TrackingCreateWrapper(resources.FunctionScala, CreateContextFunctionScala), + ReadContext: TrackingReadWrapper(resources.FunctionScala, ReadContextFunctionScala), + UpdateContext: TrackingUpdateWrapper(resources.FunctionScala, UpdateContextFunctionScala), + DeleteContext: TrackingDeleteWrapper(resources.FunctionScala, DeleteContextFunctionScala), + Description: "Resource used to manage scala function objects. For more information, check [function documentation](https://docs.snowflake.com/en/sql-reference/sql/create-function).", + + CustomizeDiff: TrackingCustomDiffWrapper(resources.FunctionScala, customdiff.All( + // TODO[SNOW-1348103]: ComputedIfAnyAttributeChanged(scalaFunctionSchema, ShowOutputAttributeName, ...), + ComputedIfAnyAttributeChanged(scalaFunctionSchema, FullyQualifiedNameAttributeName, "name"), + ComputedIfAnyAttributeChanged(functionParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllFunctionParameters), strings.ToLower)...), + functionParametersCustomDiff, + // TODO[SNOW-1348103]: recreate when type changed externally + )), + + Schema: collections.MergeMaps(scalaFunctionSchema, functionParametersSchema), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + } +} + +func CreateContextFunctionScala(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func ReadContextFunctionScala(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func UpdateContextFunctionScala(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func DeleteContextFunctionScala(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} diff --git a/pkg/resources/function_sql.go b/pkg/resources/function_sql.go new file mode 100644 index 0000000000..48ea385f71 --- /dev/null +++ b/pkg/resources/function_sql.go @@ -0,0 +1,52 @@ +package resources + +import ( + "context" + "strings" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func FunctionSql() *schema.Resource { + return &schema.Resource{ + CreateContext: TrackingCreateWrapper(resources.FunctionSql, CreateContextFunctionSql), + ReadContext: TrackingReadWrapper(resources.FunctionSql, ReadContextFunctionSql), + UpdateContext: TrackingUpdateWrapper(resources.FunctionSql, UpdateContextFunctionSql), + DeleteContext: TrackingDeleteWrapper(resources.FunctionSql, DeleteContextFunctionSql), + Description: "Resource used to manage sql function objects. For more information, check [function documentation](https://docs.snowflake.com/en/sql-reference/sql/create-function).", + + CustomizeDiff: TrackingCustomDiffWrapper(resources.FunctionSql, customdiff.All( + // TODO[SNOW-1348103]: ComputedIfAnyAttributeChanged(sqlFunctionSchema, ShowOutputAttributeName, ...), + ComputedIfAnyAttributeChanged(sqlFunctionSchema, FullyQualifiedNameAttributeName, "name"), + ComputedIfAnyAttributeChanged(functionParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllFunctionParameters), strings.ToLower)...), + functionParametersCustomDiff, + // TODO[SNOW-1348103]: recreate when type changed externally + )), + + Schema: collections.MergeMaps(sqlFunctionSchema, functionParametersSchema), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + } +} + +func CreateContextFunctionSql(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func ReadContextFunctionSql(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func UpdateContextFunctionSql(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func DeleteContextFunctionSql(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} diff --git a/pkg/resources/procedure_parameters.go b/pkg/resources/procedure_parameters.go new file mode 100644 index 0000000000..eba2a378b2 --- /dev/null +++ b/pkg/resources/procedure_parameters.go @@ -0,0 +1,99 @@ +package resources + +import ( + "context" + "strconv" + "strings" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +var ( + procedureParametersSchema = make(map[string]*schema.Schema) + procedureParametersCustomDiff = ParametersCustomDiff( + procedureParametersProvider, + parameter[sdk.ProcedureParameter]{sdk.ProcedureParameterEnableConsoleOutput, valueTypeBool, sdk.ParameterTypeProcedure}, + parameter[sdk.ProcedureParameter]{sdk.ProcedureParameterLogLevel, valueTypeString, sdk.ParameterTypeProcedure}, + parameter[sdk.ProcedureParameter]{sdk.ProcedureParameterMetricLevel, valueTypeString, sdk.ParameterTypeProcedure}, + parameter[sdk.ProcedureParameter]{sdk.ProcedureParameterTraceLevel, valueTypeString, sdk.ParameterTypeProcedure}, + ) +) + +func init() { + procedureParameterFields := []parameterDef[sdk.ProcedureParameter]{ + // session params + {Name: sdk.ProcedureParameterEnableConsoleOutput, Type: schema.TypeBool, Description: "Enable stdout/stderr fast path logging for anonyous stored procs. This is a public parameter (similar to LOG_LEVEL)."}, + {Name: sdk.ProcedureParameterLogLevel, Type: schema.TypeString, Description: "LOG_LEVEL to use when filtering events"}, + {Name: sdk.ProcedureParameterMetricLevel, Type: schema.TypeString, ValidateDiag: sdkValidation(sdk.ToMetricLevel), DiffSuppress: NormalizeAndCompare(sdk.ToMetricLevel), Description: "METRIC_LEVEL value to control whether to emit metrics to Event Table"}, + {Name: sdk.ProcedureParameterTraceLevel, Type: schema.TypeString, ValidateDiag: sdkValidation(sdk.ToTraceLevel), DiffSuppress: NormalizeAndCompare(sdk.ToTraceLevel), Description: "Trace level value to use when generating/filtering trace events"}, + } + + for _, field := range procedureParameterFields { + fieldName := strings.ToLower(string(field.Name)) + + procedureParametersSchema[fieldName] = &schema.Schema{ + Type: field.Type, + Description: enrichWithReferenceToParameterDocs(field.Name, field.Description), + Computed: true, + Optional: true, + ValidateDiagFunc: field.ValidateDiag, + DiffSuppressFunc: field.DiffSuppress, + ConflictsWith: field.ConflictsWith, + } + } +} + +func procedureParametersProvider(ctx context.Context, d ResourceIdProvider, meta any) ([]*sdk.Parameter, error) { + return parametersProvider(ctx, d, meta.(*provider.Context), procedureParametersProviderFunc, sdk.ParseSchemaObjectIdentifierWithArguments) +} + +func procedureParametersProviderFunc(c *sdk.Client) showParametersFunc[sdk.SchemaObjectIdentifierWithArguments] { + return c.Procedures.ShowParameters +} + +func handleProcedureParameterRead(d *schema.ResourceData, procedureParameters []*sdk.Parameter) error { + for _, p := range procedureParameters { + switch p.Key { + case + string(sdk.ProcedureParameterLogLevel), + string(sdk.ProcedureParameterMetricLevel), + string(sdk.ProcedureParameterTraceLevel): + if err := d.Set(strings.ToLower(p.Key), p.Value); err != nil { + return err + } + case + string(sdk.ProcedureParameterEnableConsoleOutput): + value, err := strconv.ParseBool(p.Value) + if err != nil { + return err + } + if err := d.Set(strings.ToLower(p.Key), value); err != nil { + return err + } + } + } + + return nil +} + +// They do not work in create, that's why are set in alter +func handleProcedureParametersCreate(d *schema.ResourceData, alterOpts *sdk.ProcedureSet) diag.Diagnostics { + return JoinDiags( + handleParameterCreate(d, sdk.ProcedureParameterEnableConsoleOutput, &alterOpts.EnableConsoleOutput), + handleParameterCreateWithMapping(d, sdk.ProcedureParameterLogLevel, &alterOpts.LogLevel, stringToStringEnumProvider(sdk.ToLogLevel)), + handleParameterCreateWithMapping(d, sdk.ProcedureParameterMetricLevel, &alterOpts.MetricLevel, stringToStringEnumProvider(sdk.ToMetricLevel)), + handleParameterCreateWithMapping(d, sdk.ProcedureParameterTraceLevel, &alterOpts.TraceLevel, stringToStringEnumProvider(sdk.ToTraceLevel)), + ) +} + +func handleProcedureParametersUpdate(d *schema.ResourceData, set *sdk.ProcedureSet, unset *sdk.ProcedureUnset) diag.Diagnostics { + return JoinDiags( + handleParameterUpdate(d, sdk.ProcedureParameterEnableConsoleOutput, &set.EnableConsoleOutput, &unset.EnableConsoleOutput), + handleParameterUpdateWithMapping(d, sdk.ProcedureParameterLogLevel, &set.LogLevel, &unset.LogLevel, stringToStringEnumProvider(sdk.ToLogLevel)), + handleParameterUpdateWithMapping(d, sdk.ProcedureParameterMetricLevel, &set.MetricLevel, &unset.MetricLevel, stringToStringEnumProvider(sdk.ToMetricLevel)), + handleParameterUpdateWithMapping(d, sdk.ProcedureParameterTraceLevel, &set.TraceLevel, &unset.TraceLevel, stringToStringEnumProvider(sdk.ToTraceLevel)), + ) +} diff --git a/pkg/resources/user_parameters.go b/pkg/resources/user_parameters.go index 05ecc15e0c..2c4f34f2ea 100644 --- a/pkg/resources/user_parameters.go +++ b/pkg/resources/user_parameters.go @@ -174,8 +174,8 @@ func userParametersProviderFunc(c *sdk.Client) showParametersFunc[sdk.AccountObj } // TODO [SNOW-1645342]: make generic based on type definition -func handleUserParameterRead(d *schema.ResourceData, warehouseParameters []*sdk.Parameter) error { - for _, p := range warehouseParameters { +func handleUserParameterRead(d *schema.ResourceData, userParameters []*sdk.Parameter) error { + for _, p := range userParameters { switch p.Key { case string(sdk.UserParameterClientMemoryLimit), diff --git a/pkg/schemas/function_gen.go b/pkg/schemas/function_gen.go index a211866ea5..f8daa18ecf 100644 --- a/pkg/schemas/function_gen.go +++ b/pkg/schemas/function_gen.go @@ -41,10 +41,10 @@ var ShowFunctionSchema = map[string]*schema.Schema{ Type: schema.TypeInt, Computed: true, }, - "arguments": { - Type: schema.TypeInvalid, - Computed: true, - }, + //"arguments_old": { + // Type: schema.TypeInvalid, + // Computed: true, + //}, "arguments_raw": { Type: schema.TypeString, Computed: true, @@ -69,6 +69,14 @@ var ShowFunctionSchema = map[string]*schema.Schema{ Type: schema.TypeBool, Computed: true, }, + "secrets": { + Type: schema.TypeString, + Computed: true, + }, + "external_access_integrations": { + Type: schema.TypeString, + Computed: true, + }, "is_external_function": { Type: schema.TypeBool, Computed: true, @@ -81,6 +89,10 @@ var ShowFunctionSchema = map[string]*schema.Schema{ Type: schema.TypeBool, Computed: true, }, + "is_data_metric": { + Type: schema.TypeBool, + Computed: true, + }, } var _ = ShowFunctionSchema @@ -95,16 +107,23 @@ func FunctionToSchema(function *sdk.Function) map[string]any { functionSchema["is_ansi"] = function.IsAnsi functionSchema["min_num_arguments"] = function.MinNumArguments functionSchema["max_num_arguments"] = function.MaxNumArguments - functionSchema["arguments"] = function.ArgumentsOld + // functionSchema["arguments_old"] = function.ArgumentsOld functionSchema["arguments_raw"] = function.ArgumentsRaw functionSchema["description"] = function.Description functionSchema["catalog_name"] = function.CatalogName functionSchema["is_table_function"] = function.IsTableFunction functionSchema["valid_for_clustering"] = function.ValidForClustering functionSchema["is_secure"] = function.IsSecure + if function.Secrets != nil { + functionSchema["secrets"] = function.Secrets + } + if function.ExternalAccessIntegrations != nil { + functionSchema["external_access_integrations"] = function.ExternalAccessIntegrations + } functionSchema["is_external_function"] = function.IsExternalFunction functionSchema["language"] = function.Language functionSchema["is_memoizable"] = function.IsMemoizable + functionSchema["is_data_metric"] = function.IsDataMetric return functionSchema } diff --git a/pkg/schemas/procedure_gen.go b/pkg/schemas/procedure_gen.go index 38d5937273..cd90b95298 100644 --- a/pkg/schemas/procedure_gen.go +++ b/pkg/schemas/procedure_gen.go @@ -41,10 +41,10 @@ var ShowProcedureSchema = map[string]*schema.Schema{ Type: schema.TypeInt, Computed: true, }, - "arguments": { - Type: schema.TypeInvalid, - Computed: true, - }, + //"arguments_old": { + // Type: schema.TypeInvalid, + // Computed: true, + //}, "arguments_raw": { Type: schema.TypeString, Computed: true, @@ -69,6 +69,14 @@ var ShowProcedureSchema = map[string]*schema.Schema{ Type: schema.TypeBool, Computed: true, }, + "secrets": { + Type: schema.TypeString, + Computed: true, + }, + "external_access_integrations": { + Type: schema.TypeString, + Computed: true, + }, } var _ = ShowProcedureSchema @@ -83,13 +91,19 @@ func ProcedureToSchema(procedure *sdk.Procedure) map[string]any { procedureSchema["is_ansi"] = procedure.IsAnsi procedureSchema["min_num_arguments"] = procedure.MinNumArguments procedureSchema["max_num_arguments"] = procedure.MaxNumArguments - procedureSchema["arguments"] = procedure.ArgumentsOld + // procedureSchema["arguments_old"] = procedure.ArgumentsOld procedureSchema["arguments_raw"] = procedure.ArgumentsRaw procedureSchema["description"] = procedure.Description procedureSchema["catalog_name"] = procedure.CatalogName procedureSchema["is_table_function"] = procedure.IsTableFunction procedureSchema["valid_for_clustering"] = procedure.ValidForClustering procedureSchema["is_secure"] = procedure.IsSecure + if procedure.Secrets != nil { + procedureSchema["secrets"] = procedure.Secrets + } + if procedure.ExternalAccessIntegrations != nil { + procedureSchema["external_access_integrations"] = procedure.ExternalAccessIntegrations + } return procedureSchema } diff --git a/pkg/sdk/common_types.go b/pkg/sdk/common_types.go index 3678fe4e05..4276fe58d9 100644 --- a/pkg/sdk/common_types.go +++ b/pkg/sdk/common_types.go @@ -237,13 +237,46 @@ const ( NullInputBehaviorStrict NullInputBehavior = "STRICT" ) +// ToNullInputBehavior maps STRICT to RETURNS NULL ON NULL INPUT, because Snowflake returns RETURNS NULL ON NULL INPUT for any of these two options +func ToNullInputBehavior(value string) (NullInputBehavior, error) { + switch strings.ToUpper(value) { + case string(NullInputBehaviorCalledOnNullInput): + return NullInputBehaviorCalledOnNullInput, nil + case string(NullInputBehaviorReturnsNullInput), string(NullInputBehaviorStrict): + return NullInputBehaviorReturnsNullInput, nil + default: + return "", fmt.Errorf("unknown null input behavior: %s", value) + } +} + +var AllAllowedNullInputBehaviors = []NullInputBehavior{ + NullInputBehaviorCalledOnNullInput, + NullInputBehaviorReturnsNullInput, +} + type ReturnResultsBehavior string -var ( +const ( ReturnResultsBehaviorVolatile ReturnResultsBehavior = "VOLATILE" ReturnResultsBehaviorImmutable ReturnResultsBehavior = "IMMUTABLE" ) +func ToReturnResultsBehavior(value string) (ReturnResultsBehavior, error) { + switch strings.ToUpper(value) { + case string(ReturnResultsBehaviorVolatile): + return ReturnResultsBehaviorVolatile, nil + case string(ReturnResultsBehaviorImmutable): + return ReturnResultsBehaviorImmutable, nil + default: + return "", fmt.Errorf("unknown return results behavior: %s", value) + } +} + +var AllAllowedReturnResultsBehaviors = []ReturnResultsBehavior{ + ReturnResultsBehaviorVolatile, + ReturnResultsBehaviorImmutable, +} + func ReturnResultsBehaviorPointer(v ReturnResultsBehavior) *ReturnResultsBehavior { return &v } diff --git a/pkg/sdk/common_types_test.go b/pkg/sdk/common_types_test.go index 263d02ad2c..2cb2f55665 100644 --- a/pkg/sdk/common_types_test.go +++ b/pkg/sdk/common_types_test.go @@ -262,6 +262,71 @@ func TestToLogLevel(t *testing.T) { } } +func Test_ToNullInputBehavior(t *testing.T) { + testCases := []struct { + Name string + Input string + Expected NullInputBehavior + Error string + }{ + {Input: string(NullInputBehaviorCalledOnNullInput), Expected: NullInputBehaviorCalledOnNullInput}, + {Input: string(NullInputBehaviorReturnsNullInput), Expected: NullInputBehaviorReturnsNullInput}, + {Input: string(NullInputBehaviorStrict), Expected: NullInputBehaviorReturnsNullInput}, + {Name: "validation: incorrect null input behavior", Input: "incorrect", Error: "unknown null input behavior: incorrect"}, + {Name: "validation: empty input", Input: "", Error: "unknown null input behavior: "}, + {Name: "validation: lower case input", Input: "called on null input", Expected: NullInputBehaviorCalledOnNullInput}, + } + + for _, testCase := range testCases { + name := testCase.Name + if name == "" { + name = fmt.Sprintf("%v null input behavior", testCase.Input) + } + t.Run(name, func(t *testing.T) { + value, err := ToNullInputBehavior(testCase.Input) + if testCase.Error != "" { + assert.Empty(t, value) + assert.ErrorContains(t, err, testCase.Error) + } else { + assert.NoError(t, err) + assert.Equal(t, testCase.Expected, value) + } + }) + } +} + +func Test_ToReturnResultsBehavior(t *testing.T) { + testCases := []struct { + Name string + Input string + Expected ReturnResultsBehavior + Error string + }{ + {Input: string(ReturnResultsBehaviorVolatile), Expected: ReturnResultsBehaviorVolatile}, + {Input: string(ReturnResultsBehaviorImmutable), Expected: ReturnResultsBehaviorImmutable}, + {Name: "validation: incorrect return results behavior", Input: "incorrect", Error: "unknown return results behavior: incorrect"}, + {Name: "validation: empty input", Input: "", Error: "unknown return results behavior: "}, + {Name: "validation: lower case input", Input: "volatile", Expected: ReturnResultsBehaviorVolatile}, + } + + for _, testCase := range testCases { + name := testCase.Name + if name == "" { + name = fmt.Sprintf("%v null input behavior", testCase.Input) + } + t.Run(name, func(t *testing.T) { + value, err := ToReturnResultsBehavior(testCase.Input) + if testCase.Error != "" { + assert.Empty(t, value) + assert.ErrorContains(t, err, testCase.Error) + } else { + assert.NoError(t, err) + assert.Equal(t, testCase.Expected, value) + } + }) + } +} + func TestToTraceLevel(t *testing.T) { testCases := []struct { Name string diff --git a/pkg/sdk/parameters.go b/pkg/sdk/parameters.go index 4940f4ed0b..44f73e9e55 100644 --- a/pkg/sdk/parameters.go +++ b/pkg/sdk/parameters.go @@ -842,6 +842,13 @@ const ( FunctionParameterTraceLevel FunctionParameter = "TRACE_LEVEL" ) +var AllFunctionParameters = []FunctionParameter{ + FunctionParameterEnableConsoleOutput, + FunctionParameterLogLevel, + FunctionParameterMetricLevel, + FunctionParameterTraceLevel, +} + type ProcedureParameter string const ( @@ -852,6 +859,13 @@ const ( ProcedureParameterTraceLevel ProcedureParameter = "TRACE_LEVEL" ) +var AllProcedureParameters = []ProcedureParameter{ + ProcedureParameterEnableConsoleOutput, + ProcedureParameterLogLevel, + ProcedureParameterMetricLevel, + ProcedureParameterTraceLevel, +} + // AccountParameters is based on https://docs.snowflake.com/en/sql-reference/parameters#account-parameters. type AccountParameters struct { // Account Parameters diff --git a/pkg/sdk/testint/functions_integration_test.go b/pkg/sdk/testint/functions_integration_test.go index 4f7220062c..bb292cd627 100644 --- a/pkg/sdk/testint/functions_integration_test.go +++ b/pkg/sdk/testint/functions_integration_test.go @@ -33,6 +33,7 @@ import ( // TODO [SNOW-1348103]: python aggregate func (100357 (P0000): Could not find accumulate method in function CVVEMHIT_06547800_08D6_DBCA_1AC7_5E422AFF8B39 with handler dump) // TODO [SNOW-1348103]: add a test documenting that we can't set parameters in create (and revert adding these parameters directly in object...) // TODO [SNOW-1850370]: active warehouse vs validations +// TODO [SNOW-1348103]: add a test documenting STRICT behavior func TestInt_Functions(t *testing.T) { client := testClient(t) ctx := context.Background()