diff --git a/docs/resources/function_java.md b/docs/resources/function_java.md index eb8062232b..23ab3b5dc2 100644 --- a/docs/resources/function_java.md +++ b/docs/resources/function_java.md @@ -17,7 +17,7 @@ Resource used to manage java function objects. For more information, check [func ### 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). +- `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). To mitigate permadiff on this field, the provider replaces blank characters with a space. This can lead to false positives in cases where a change in case or run of whitespace is semantically significant. - `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). @@ -30,14 +30,14 @@ Resource used to manage java function objects. For more information, check [func - `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. +- `is_secure` (String) Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure functions (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)) +- `secrets` (Block Set) Assigns the names of [secrets](https://docs.snowflake.com/en/sql-reference/sql/create-secret) 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). @@ -63,7 +63,7 @@ Required: 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_id` (String) Fully qualified name of the allowed [secret](https://docs.snowflake.com/en/sql-reference/sql/create-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. diff --git a/docs/resources/function_javascript.md b/docs/resources/function_javascript.md index 7925c74c59..2680ff6653 100644 --- a/docs/resources/function_javascript.md +++ b/docs/resources/function_javascript.md @@ -17,7 +17,7 @@ Resource used to manage javascript function objects. For more information, check ### 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). +- `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). To mitigate permadiff on this field, the provider replaces blank characters with a space. This can lead to false positives in cases where a change in case or run of whitespace is semantically significant. - `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: `|`, `.`, `"`. @@ -27,7 +27,7 @@ Resource used to manage javascript function objects. For more information, check - `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. +- `is_secure` (String) Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure functions (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`. diff --git a/docs/resources/function_python.md b/docs/resources/function_python.md index 814e7a38de..5f68cfb014 100644 --- a/docs/resources/function_python.md +++ b/docs/resources/function_python.md @@ -17,7 +17,7 @@ Resource used to manage python function objects. For more information, check [fu ### 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). +- `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). To mitigate permadiff on this field, the provider replaces blank characters with a space. This can lead to false positives in cases where a change in case or run of whitespace is semantically significant. - `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). @@ -32,13 +32,13 @@ Resource used to manage python function objects. For more information, check [fu - `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. +- `is_secure` (String) Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure functions (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)) +- `secrets` (Block Set) Assigns the names of [secrets](https://docs.snowflake.com/en/sql-reference/sql/create-secret) 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 @@ -63,7 +63,7 @@ Required: 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_id` (String) Fully qualified name of the allowed [secret](https://docs.snowflake.com/en/sql-reference/sql/create-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. diff --git a/docs/resources/function_scala.md b/docs/resources/function_scala.md index 5fffff6762..9ec48d3866 100644 --- a/docs/resources/function_scala.md +++ b/docs/resources/function_scala.md @@ -17,7 +17,7 @@ Resource used to manage scala function objects. For more information, check [fun ### 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). +- `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). To mitigate permadiff on this field, the provider replaces blank characters with a space. This can lead to false positives in cases where a change in case or run of whitespace is semantically significant. - `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). @@ -31,13 +31,13 @@ Resource used to manage scala function objects. For more information, check [fun - `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. +- `is_secure` (String) Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure functions (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)) +- `secrets` (Block Set) Assigns the names of [secrets](https://docs.snowflake.com/en/sql-reference/sql/create-secret) 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). @@ -63,7 +63,7 @@ Required: 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_id` (String) Fully qualified name of the allowed [secret](https://docs.snowflake.com/en/sql-reference/sql/create-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. diff --git a/docs/resources/function_sql.md b/docs/resources/function_sql.md index e37e57514d..80d83727fb 100644 --- a/docs/resources/function_sql.md +++ b/docs/resources/function_sql.md @@ -17,7 +17,7 @@ Resource used to manage sql function objects. For more information, check [funct ### 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). +- `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). To mitigate permadiff on this field, the provider replaces blank characters with a space. This can lead to false positives in cases where a change in case or run of whitespace is semantically significant. - `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: `|`, `.`, `"`. @@ -27,7 +27,7 @@ Resource used to manage sql function objects. For more information, check [funct - `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. +- `is_secure` (String) Specifies that the function is secure. By design, the Snowflake's `SHOW FUNCTIONS` command does not provide information about secure functions (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`. diff --git a/docs/resources/procedure_java.md b/docs/resources/procedure_java.md new file mode 100644 index 0000000000..94490ed21e --- /dev/null +++ b/docs/resources/procedure_java.md @@ -0,0 +1,102 @@ +--- +page_title: "snowflake_procedure_java Resource - terraform-provider-snowflake" +subcategory: "" +description: |- + Resource used to manage java procedure objects. For more information, check procedure documentation https://docs.snowflake.com/en/sql-reference/sql/create-procedure. +--- + +# snowflake_procedure_java (Resource) + +Resource used to manage java procedure objects. For more information, check [procedure documentation](https://docs.snowflake.com/en/sql-reference/sql/create-procedure). + + + + +## Schema + +### Required + +- `database` (String) The database in which to create the procedure. 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: `|`, `.`, `"`. +- `handler` (String) Use the fully qualified name of the method or function for the stored procedure. This is typically in the following form `com.my_company.my_package.MyClass.myMethod` where `com.my_company.my_package` corresponds to the package containing the object or class: `package com.my_company.my_package;`. +- `name` (String) The name of the procedure; the identifier does not need to be unique for the schema in which the procedure is created because stored procedures are [identified and resolved by the combination of the name and argument types](https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-naming-conventions.html#label-procedure-function-name-overloading). 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: `|`, `.`, `"`. +- `procedure_definition` (String) Defines the code executed by the stored procedure. The definition can consist of any valid code. Wrapping `$$` signs are added by the provider automatically; do not include them. The `procedure_definition` value must be Java source code. For more information, see [Java (using Snowpark)](https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-java). To mitigate permadiff on this field, the provider replaces blank characters with a space. This can lead to false positives in cases where a change in case or run of whitespace is semantically significant. +- `return_type` (String) Specifies the type of the result returned by the stored procedure. For ``, use the Snowflake data type that corresponds to the type of the language that you are using (see [SQL-Java Data Type Mappings](https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-data-type-mapping.html#label-sql-java-data-type-mappings)). For `RETURNS TABLE ( [ col_name col_data_type [ , ... ] ] )`, if you know the Snowflake data types of the columns in the returned table, specify the column names and types. Otherwise (e.g. if you are determining the column types during run time), you can omit the column names and types (i.e. `TABLE ()`). +- `runtime_version` (String) The language runtime version to use. Currently, the supported versions are: 11. +- `schema` (String) The schema in which to create the procedure. 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: `|`, `.`, `"`. +- `snowpark_package` (String) The Snowpark package is required for stored procedures, so it must always be present. For more information about Snowpark, see [Snowpark API](https://docs.snowflake.com/en/developer-guide/snowpark/index). + +### Optional + +- `arguments` (Block List) List of the arguments for the procedure. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-procedure#all-languages) for more details. (see [below for nested schema](#nestedblock--arguments)) +- `comment` (String) Specifies a comment for the procedure. +- `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). +- `execute_as` (String) Specifies whether the stored procedure executes with the privileges of the owner (an “owner’s rights” stored procedure) or with the privileges of the caller (a “caller’s rights” stored procedure). If you execute the statement CREATE PROCEDURE … EXECUTE AS CALLER, then in the future the procedure will execute as a caller’s rights procedure. If you execute CREATE PROCEDURE … EXECUTE AS OWNER, then the procedure will execute as an owner’s rights procedure. For more information, see [Understanding caller’s rights and owner’s rights stored procedures](https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-rights). Valid values are (case-insensitive): `EXECUTE AS CALLER` | `EXECUTE AS OWNER`. +- `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 procedure’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. You must set the IMPORTS clause to include any files that your stored procedure depends on. If you are writing an in-line stored procedure, you can omit this clause, unless your code depends on classes defined outside the stored procedure or resource files. If you are writing a stored procedure with a staged handler, you must also include a path to the JAR file containing the stored procedure’s handler code. The IMPORTS definition cannot reference variables from arguments that are passed into the stored procedure. Each file in the IMPORTS clause must have a unique name, even if the files are in different subdirectories or different stages. +- `is_secure` (String) Specifies that the procedure is secure. For more information about secure procedures, see [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure). 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 procedure when called with null inputs. Valid values are (case-insensitive): `CALLED ON NULL INPUT` | `RETURNS NULL ON NULL INPUT`. +- `packages` (Set of String) List of the names of packages deployed in Snowflake that should be included in the handler code’s execution environment. The Snowpark package is required for stored procedures, but is specified in the `snowpark_package` attribute. For more information about Snowpark, see [Snowpark API](https://docs.snowflake.com/en/developer-guide/snowpark/index). +- `secrets` (Block Set) Assigns the names of [secrets](https://docs.snowflake.com/en/sql-reference/sql/create-secret) 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) Use the fully qualified name of the method or function for the stored procedure. This is typically in the following form `com.my_company.my_package.MyClass.myMethod` where `com.my_company.my_package` corresponds to the package containing the object or class: `package com.my_company.my_package;`. +- `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). +- `id` (String) The ID of this resource. +- `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN PROCEDURE` for the given procedure. (see [below for nested schema](#nestedatt--parameters)) +- `procedure_language` (String) Specifies language for the procedure. Used to detect external changes. +- `show_output` (List of Object) Outputs the result of `SHOW PROCEDURE` for the given procedure. (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](https://docs.snowflake.com/en/sql-reference/sql/create-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_secure` (Boolean) +- `is_table_function` (Boolean) +- `max_num_arguments` (Number) +- `min_num_arguments` (Number) +- `name` (String) +- `schema_name` (String) +- `secrets` (String) +- `valid_for_clustering` (Boolean) diff --git a/docs/resources/procedure_javascript.md b/docs/resources/procedure_javascript.md new file mode 100644 index 0000000000..a562ad589d --- /dev/null +++ b/docs/resources/procedure_javascript.md @@ -0,0 +1,85 @@ +--- +page_title: "snowflake_procedure_javascript Resource - terraform-provider-snowflake" +subcategory: "" +description: |- + Resource used to manage javascript procedure objects. For more information, check procedure documentation https://docs.snowflake.com/en/sql-reference/sql/create-procedure. +--- + +# snowflake_procedure_javascript (Resource) + +Resource used to manage javascript procedure objects. For more information, check [procedure documentation](https://docs.snowflake.com/en/sql-reference/sql/create-procedure). + + + + +## Schema + +### Required + +- `database` (String) The database in which to create the procedure. 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: `|`, `.`, `"`. +- `name` (String) The name of the procedure; the identifier does not need to be unique for the schema in which the procedure is created because stored procedures are [identified and resolved by the combination of the name and argument types](https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-naming-conventions.html#label-procedure-function-name-overloading). 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: `|`, `.`, `"`. +- `procedure_definition` (String) Defines the code executed by the stored procedure. The definition can consist of any valid code. Wrapping `$$` signs are added by the provider automatically; do not include them. The `procedure_definition` value must be JavaScript source code. For more information, see [JavaScript](https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-javascript). To mitigate permadiff on this field, the provider replaces blank characters with a space. This can lead to false positives in cases where a change in case or run of whitespace is semantically significant. +- `return_type` (String) Specifies the type of the result returned by the stored procedure. For ``, use the Snowflake data type that corresponds to the type of the language that you are using (see [SQL and JavaScript data type mapping](https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-javascript.html#label-stored-procedure-data-type-mapping)). For `RETURNS TABLE ( [ col_name col_data_type [ , ... ] ] )`, if you know the Snowflake data types of the columns in the returned table, specify the column names and types. Otherwise (e.g. if you are determining the column types during run time), you can omit the column names and types (i.e. `TABLE ()`). +- `schema` (String) The schema in which to create the procedure. 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 procedure. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-procedure#all-languages) for more details. (see [below for nested schema](#nestedblock--arguments)) +- `comment` (String) Specifies a comment for the procedure. +- `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). +- `execute_as` (String) Specifies whether the stored procedure executes with the privileges of the owner (an “owner’s rights” stored procedure) or with the privileges of the caller (a “caller’s rights” stored procedure). If you execute the statement CREATE PROCEDURE … EXECUTE AS CALLER, then in the future the procedure will execute as a caller’s rights procedure. If you execute CREATE PROCEDURE … EXECUTE AS OWNER, then the procedure will execute as an owner’s rights procedure. For more information, see [Understanding caller’s rights and owner’s rights stored procedures](https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-rights). Valid values are (case-insensitive): `EXECUTE AS CALLER` | `EXECUTE AS OWNER`. +- `is_secure` (String) Specifies that the procedure is secure. For more information about secure procedures, see [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure). 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 procedure when called with null inputs. Valid values are (case-insensitive): `CALLED ON NULL INPUT` | `RETURNS NULL ON NULL INPUT`. +- `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). +- `id` (String) The ID of this resource. +- `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN PROCEDURE` for the given procedure. (see [below for nested schema](#nestedatt--parameters)) +- `procedure_language` (String) Specifies language for the procedure. Used to detect external changes. +- `show_output` (List of Object) Outputs the result of `SHOW PROCEDURE` for the given procedure. (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_secure` (Boolean) +- `is_table_function` (Boolean) +- `max_num_arguments` (Number) +- `min_num_arguments` (Number) +- `name` (String) +- `schema_name` (String) +- `secrets` (String) +- `valid_for_clustering` (Boolean) diff --git a/docs/resources/procedure_python.md b/docs/resources/procedure_python.md new file mode 100644 index 0000000000..7b6759ef75 --- /dev/null +++ b/docs/resources/procedure_python.md @@ -0,0 +1,101 @@ +--- +page_title: "snowflake_procedure_python Resource - terraform-provider-snowflake" +subcategory: "" +description: |- + Resource used to manage python procedure objects. For more information, check procedure documentation https://docs.snowflake.com/en/sql-reference/sql/create-procedure. +--- + +# snowflake_procedure_python (Resource) + +Resource used to manage python procedure objects. For more information, check [procedure documentation](https://docs.snowflake.com/en/sql-reference/sql/create-procedure). + + + + +## Schema + +### Required + +- `database` (String) The database in which to create the procedure. 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: `|`, `.`, `"`. +- `handler` (String) Use the name of the stored procedure’s function or method. This can differ depending on whether the code is in-line or referenced at a stage. When the code is in-line, you can specify just the function name. When the code is imported from a stage, specify the fully-qualified handler function name as `.`. +- `name` (String) The name of the procedure; the identifier does not need to be unique for the schema in which the procedure is created because stored procedures are [identified and resolved by the combination of the name and argument types](https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-naming-conventions.html#label-procedure-function-name-overloading). 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: `|`, `.`, `"`. +- `procedure_definition` (String) Defines the code executed by the stored procedure. The definition can consist of any valid code. Wrapping `$$` signs are added by the provider automatically; do not include them. The `procedure_definition` value must be Python source code. For more information, see [Python (using Snowpark)](https://docs.snowflake.com/en/developer-guide/stored-procedure/python/procedure-python-overview). To mitigate permadiff on this field, the provider replaces blank characters with a space. This can lead to false positives in cases where a change in case or run of whitespace is semantically significant. +- `return_type` (String) Specifies the type of the result returned by the stored procedure. For ``, use the Snowflake data type that corresponds to the type of the language that you are using (see [SQL-Python Data Type Mappings](https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-data-type-mapping.html#label-sql-python-data-type-mappings)). For `RETURNS TABLE ( [ col_name col_data_type [ , ... ] ] )`, if you know the Snowflake data types of the columns in the returned table, specify the column names and types. Otherwise (e.g. if you are determining the column types during run time), you can omit the column names and types (i.e. `TABLE ()`). +- `runtime_version` (String) The language runtime version to use. Currently, the supported versions are: 3.9, 3.10, and 3.11. +- `schema` (String) The schema in which to create the procedure. 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: `|`, `.`, `"`. +- `snowpark_package` (String) The Snowpark package is required for stored procedures, so it must always be present. For more information about Snowpark, see [Snowpark API](https://docs.snowflake.com/en/developer-guide/snowpark/index). + +### Optional + +- `arguments` (Block List) List of the arguments for the procedure. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-procedure#all-languages) for more details. (see [below for nested schema](#nestedblock--arguments)) +- `comment` (String) Specifies a comment for the procedure. +- `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). +- `execute_as` (String) Specifies whether the stored procedure executes with the privileges of the owner (an “owner’s rights” stored procedure) or with the privileges of the caller (a “caller’s rights” stored procedure). If you execute the statement CREATE PROCEDURE … EXECUTE AS CALLER, then in the future the procedure will execute as a caller’s rights procedure. If you execute CREATE PROCEDURE … EXECUTE AS OWNER, then the procedure will execute as an owner’s rights procedure. For more information, see [Understanding caller’s rights and owner’s rights stored procedures](https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-rights). Valid values are (case-insensitive): `EXECUTE AS CALLER` | `EXECUTE AS OWNER`. +- `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 procedure’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. You must set the IMPORTS clause to include any files that your stored procedure depends on. If you are writing an in-line stored procedure, you can omit this clause, unless your code depends on classes defined outside the stored procedure or resource files. If your stored procedure’s code will be on a stage, you must also include a path to the module file your code is in. The IMPORTS definition cannot reference variables from arguments that are passed into the stored procedure. Each file in the IMPORTS clause must have a unique name, even if the files are in different subdirectories or different stages. +- `is_secure` (String) Specifies that the procedure is secure. For more information about secure procedures, see [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure). 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 procedure when called with null inputs. Valid values are (case-insensitive): `CALLED ON NULL INPUT` | `RETURNS NULL ON NULL INPUT`. +- `packages` (Set of String) List of the names of packages deployed in Snowflake that should be included in the handler code’s execution environment. The Snowpark package is required for stored procedures, but is specified in the `snowpark_package` attribute. For more information about Snowpark, see [Snowpark API](https://docs.snowflake.com/en/developer-guide/snowpark/index). +- `secrets` (Block Set) Assigns the names of [secrets](https://docs.snowflake.com/en/sql-reference/sql/create-secret) 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). +- `id` (String) The ID of this resource. +- `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN PROCEDURE` for the given procedure. (see [below for nested schema](#nestedatt--parameters)) +- `procedure_language` (String) Specifies language for the procedure. Used to detect external changes. +- `show_output` (List of Object) Outputs the result of `SHOW PROCEDURE` for the given procedure. (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](https://docs.snowflake.com/en/sql-reference/sql/create-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_secure` (Boolean) +- `is_table_function` (Boolean) +- `max_num_arguments` (Number) +- `min_num_arguments` (Number) +- `name` (String) +- `schema_name` (String) +- `secrets` (String) +- `valid_for_clustering` (Boolean) diff --git a/docs/resources/procedure_scala.md b/docs/resources/procedure_scala.md new file mode 100644 index 0000000000..1347bfb5cf --- /dev/null +++ b/docs/resources/procedure_scala.md @@ -0,0 +1,102 @@ +--- +page_title: "snowflake_procedure_scala Resource - terraform-provider-snowflake" +subcategory: "" +description: |- + Resource used to manage scala procedure objects. For more information, check procedure documentation https://docs.snowflake.com/en/sql-reference/sql/create-procedure. +--- + +# snowflake_procedure_scala (Resource) + +Resource used to manage scala procedure objects. For more information, check [procedure documentation](https://docs.snowflake.com/en/sql-reference/sql/create-procedure). + + + + +## Schema + +### Required + +- `database` (String) The database in which to create the procedure. 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: `|`, `.`, `"`. +- `handler` (String) Use the fully qualified name of the method or function for the stored procedure. This is typically in the following form: `com.my_company.my_package.MyClass.myMethod` where `com.my_company.my_package` corresponds to the package containing the object or class: `package com.my_company.my_package;`. +- `name` (String) The name of the procedure; the identifier does not need to be unique for the schema in which the procedure is created because stored procedures are [identified and resolved by the combination of the name and argument types](https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-naming-conventions.html#label-procedure-function-name-overloading). 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: `|`, `.`, `"`. +- `procedure_definition` (String) Defines the code executed by the stored procedure. The definition can consist of any valid code. Wrapping `$$` signs are added by the provider automatically; do not include them. The `procedure_definition` value must be Scala source code. For more information, see [Scala (using Snowpark)](https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-scala). To mitigate permadiff on this field, the provider replaces blank characters with a space. This can lead to false positives in cases where a change in case or run of whitespace is semantically significant. +- `return_type` (String) Specifies the type of the result returned by the stored procedure. For ``, use the Snowflake data type that corresponds to the type of the language that you are using (see [SQL-Scala Data Type Mappings](https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-data-type-mapping.html#label-sql-types-to-scala-types)). For `RETURNS TABLE ( [ col_name col_data_type [ , ... ] ] )`, if you know the Snowflake data types of the columns in the returned table, specify the column names and types. Otherwise (e.g. if you are determining the column types during run time), you can omit the column names and types (i.e. `TABLE ()`). +- `runtime_version` (String) The language runtime version to use. Currently, the supported versions are: 2.12. +- `schema` (String) The schema in which to create the procedure. 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: `|`, `.`, `"`. +- `snowpark_package` (String) The Snowpark package is required for stored procedures, so it must always be present. For more information about Snowpark, see [Snowpark API](https://docs.snowflake.com/en/developer-guide/snowpark/index). + +### Optional + +- `arguments` (Block List) List of the arguments for the procedure. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-procedure#all-languages) for more details. (see [below for nested schema](#nestedblock--arguments)) +- `comment` (String) Specifies a comment for the procedure. +- `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). +- `execute_as` (String) Specifies whether the stored procedure executes with the privileges of the owner (an “owner’s rights” stored procedure) or with the privileges of the caller (a “caller’s rights” stored procedure). If you execute the statement CREATE PROCEDURE … EXECUTE AS CALLER, then in the future the procedure will execute as a caller’s rights procedure. If you execute CREATE PROCEDURE … EXECUTE AS OWNER, then the procedure will execute as an owner’s rights procedure. For more information, see [Understanding caller’s rights and owner’s rights stored procedures](https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-rights). Valid values are (case-insensitive): `EXECUTE AS CALLER` | `EXECUTE AS OWNER`. +- `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 procedure’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. You must set the IMPORTS clause to include any files that your stored procedure depends on. If you are writing an in-line stored procedure, you can omit this clause, unless your code depends on classes defined outside the stored procedure or resource files. If you are writing a stored procedure with a staged handler, you must also include a path to the JAR file containing the stored procedure’s handler code. The IMPORTS definition cannot reference variables from arguments that are passed into the stored procedure. Each file in the IMPORTS clause must have a unique name, even if the files are in different subdirectories or different stages. +- `is_secure` (String) Specifies that the procedure is secure. For more information about secure procedures, see [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure). 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 procedure when called with null inputs. Valid values are (case-insensitive): `CALLED ON NULL INPUT` | `RETURNS NULL ON NULL INPUT`. +- `packages` (Set of String) List of the names of packages deployed in Snowflake that should be included in the handler code’s execution environment. The Snowpark package is required for stored procedures, but is specified in the `snowpark_package` attribute. For more information about Snowpark, see [Snowpark API](https://docs.snowflake.com/en/developer-guide/snowpark/index). +- `secrets` (Block Set) Assigns the names of [secrets](https://docs.snowflake.com/en/sql-reference/sql/create-secret) 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) Use the fully qualified name of the method or function for the stored procedure. This is typically in the following form: `com.my_company.my_package.MyClass.myMethod` where `com.my_company.my_package` corresponds to the package containing the object or class: `package com.my_company.my_package;`. +- `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). +- `id` (String) The ID of this resource. +- `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN PROCEDURE` for the given procedure. (see [below for nested schema](#nestedatt--parameters)) +- `procedure_language` (String) Specifies language for the procedure. Used to detect external changes. +- `show_output` (List of Object) Outputs the result of `SHOW PROCEDURE` for the given procedure. (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](https://docs.snowflake.com/en/sql-reference/sql/create-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_secure` (Boolean) +- `is_table_function` (Boolean) +- `max_num_arguments` (Number) +- `min_num_arguments` (Number) +- `name` (String) +- `schema_name` (String) +- `secrets` (String) +- `valid_for_clustering` (Boolean) diff --git a/docs/resources/procedure_sql.md b/docs/resources/procedure_sql.md new file mode 100644 index 0000000000..3b078e3977 --- /dev/null +++ b/docs/resources/procedure_sql.md @@ -0,0 +1,85 @@ +--- +page_title: "snowflake_procedure_sql Resource - terraform-provider-snowflake" +subcategory: "" +description: |- + Resource used to manage sql procedure objects. For more information, check procedure documentation https://docs.snowflake.com/en/sql-reference/sql/create-procedure. +--- + +# snowflake_procedure_sql (Resource) + +Resource used to manage sql procedure objects. For more information, check [procedure documentation](https://docs.snowflake.com/en/sql-reference/sql/create-procedure). + + + + +## Schema + +### Required + +- `database` (String) The database in which to create the procedure. 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: `|`, `.`, `"`. +- `name` (String) The name of the procedure; the identifier does not need to be unique for the schema in which the procedure is created because stored procedures are [identified and resolved by the combination of the name and argument types](https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-naming-conventions.html#label-procedure-function-name-overloading). 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: `|`, `.`, `"`. +- `procedure_definition` (String) Defines the code executed by the stored procedure. The definition can consist of any valid code. Wrapping `$$` signs are added by the provider automatically; do not include them. The `procedure_definition` value must be SQL source code. For more information, see [Snowflake Scripting](https://docs.snowflake.com/en/developer-guide/snowflake-scripting/index). To mitigate permadiff on this field, the provider replaces blank characters with a space. This can lead to false positives in cases where a change in case or run of whitespace is semantically significant. +- `return_type` (String) Specifies the type of the result returned by the stored procedure. For ``, use the Snowflake data type that corresponds to the type of the language that you are using (see [SQL data type](https://docs.snowflake.com/en/sql-reference-data-types)). For `RETURNS TABLE ( [ col_name col_data_type [ , ... ] ] )`, if you know the Snowflake data types of the columns in the returned table, specify the column names and types. Otherwise (e.g. if you are determining the column types during run time), you can omit the column names and types (i.e. `TABLE ()`). +- `schema` (String) The schema in which to create the procedure. 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 procedure. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-procedure#all-languages) for more details. (see [below for nested schema](#nestedblock--arguments)) +- `comment` (String) Specifies a comment for the procedure. +- `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). +- `execute_as` (String) Specifies whether the stored procedure executes with the privileges of the owner (an “owner’s rights” stored procedure) or with the privileges of the caller (a “caller’s rights” stored procedure). If you execute the statement CREATE PROCEDURE … EXECUTE AS CALLER, then in the future the procedure will execute as a caller’s rights procedure. If you execute CREATE PROCEDURE … EXECUTE AS OWNER, then the procedure will execute as an owner’s rights procedure. For more information, see [Understanding caller’s rights and owner’s rights stored procedures](https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-rights). Valid values are (case-insensitive): `EXECUTE AS CALLER` | `EXECUTE AS OWNER`. +- `is_secure` (String) Specifies that the procedure is secure. For more information about secure procedures, see [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure). 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 procedure when called with null inputs. Valid values are (case-insensitive): `CALLED ON NULL INPUT` | `RETURNS NULL ON NULL INPUT`. +- `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). +- `id` (String) The ID of this resource. +- `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN PROCEDURE` for the given procedure. (see [below for nested schema](#nestedatt--parameters)) +- `procedure_language` (String) Specifies language for the procedure. Used to detect external changes. +- `show_output` (List of Object) Outputs the result of `SHOW PROCEDURE` for the given procedure. (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_secure` (Boolean) +- `is_table_function` (Boolean) +- `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/gen/resource_schema_def.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go index 44fa5d5490..23d5e9d5d9 100644 --- a/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go @@ -141,4 +141,24 @@ var allResourceSchemaDefs = []ResourceSchemaDef{ name: "FunctionSql", schema: resources.FunctionSql().Schema, }, + { + name: "ProcedureJava", + schema: resources.ProcedureJava().Schema, + }, + { + name: "ProcedureJavascript", + schema: resources.ProcedureJavascript().Schema, + }, + { + name: "ProcedurePython", + schema: resources.ProcedurePython().Schema, + }, + { + name: "ProcedureScala", + schema: resources.ProcedureScala().Schema, + }, + { + name: "ProcedureSql", + schema: resources.ProcedureSql().Schema, + }, } diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_java_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_java_resource_gen.go new file mode 100644 index 0000000000..4330077161 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_java_resource_gen.go @@ -0,0 +1,277 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" +) + +type ProcedureJavaResourceAssert struct { + *assert.ResourceAssert +} + +func ProcedureJavaResource(t *testing.T, name string) *ProcedureJavaResourceAssert { + t.Helper() + + return &ProcedureJavaResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedProcedureJavaResource(t *testing.T, id string) *ProcedureJavaResourceAssert { + t.Helper() + + return &ProcedureJavaResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (p *ProcedureJavaResourceAssert) HasArgumentsString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("arguments", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasCommentString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("comment", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasDatabaseString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("database", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasEnableConsoleOutputString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("enable_console_output", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasExecuteAsString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("execute_as", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasExternalAccessIntegrationsString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("external_access_integrations", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasFullyQualifiedNameString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasHandlerString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("handler", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasImportsString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("imports", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasIsSecureString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("is_secure", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasLogLevelString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("log_level", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasMetricLevelString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("metric_level", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNameString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("name", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNullInputBehaviorString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("null_input_behavior", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasPackagesString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("packages", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasProcedureDefinitionString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("procedure_definition", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasProcedureLanguageString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("procedure_language", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasReturnTypeString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("return_type", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasRuntimeVersionString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("runtime_version", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasSchemaString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("schema", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasSecretsString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("secrets", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasSnowparkPackageString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("snowpark_package", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasTargetPathString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("target_path", expected)) + return p +} + +func (p *ProcedureJavaResourceAssert) HasTraceLevelString(expected string) *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueSet("trace_level", expected)) + return p +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (p *ProcedureJavaResourceAssert) HasNoArguments() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("arguments")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoComment() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("comment")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoDatabase() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("database")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoEnableConsoleOutput() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("enable_console_output")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoExecuteAs() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("execute_as")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoExternalAccessIntegrations() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("external_access_integrations")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoFullyQualifiedName() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoHandler() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("handler")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoImports() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("imports")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoIsSecure() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("is_secure")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoLogLevel() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("log_level")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoMetricLevel() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("metric_level")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoName() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("name")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoNullInputBehavior() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("null_input_behavior")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoPackages() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("packages")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoProcedureDefinition() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("procedure_definition")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoProcedureLanguage() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("procedure_language")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoReturnType() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("return_type")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoRuntimeVersion() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("runtime_version")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoSchema() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("schema")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoSecrets() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("secrets")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoSnowparkPackage() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("snowpark_package")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoTargetPath() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("target_path")) + return p +} + +func (p *ProcedureJavaResourceAssert) HasNoTraceLevel() *ProcedureJavaResourceAssert { + p.AddAssertion(assert.ValueNotSet("trace_level")) + return p +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_javascript_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_javascript_resource_gen.go new file mode 100644 index 0000000000..2539011ad4 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_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 ProcedureJavascriptResourceAssert struct { + *assert.ResourceAssert +} + +func ProcedureJavascriptResource(t *testing.T, name string) *ProcedureJavascriptResourceAssert { + t.Helper() + + return &ProcedureJavascriptResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedProcedureJavascriptResource(t *testing.T, id string) *ProcedureJavascriptResourceAssert { + t.Helper() + + return &ProcedureJavascriptResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (p *ProcedureJavascriptResourceAssert) HasArgumentsString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("arguments", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasCommentString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("comment", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasDatabaseString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("database", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasEnableConsoleOutputString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("enable_console_output", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasExecuteAsString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("execute_as", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasFullyQualifiedNameString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasIsSecureString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("is_secure", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasLogLevelString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("log_level", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasMetricLevelString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("metric_level", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNameString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("name", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNullInputBehaviorString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("null_input_behavior", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasProcedureDefinitionString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("procedure_definition", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasProcedureLanguageString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("procedure_language", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasReturnTypeString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("return_type", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasSchemaString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("schema", expected)) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasTraceLevelString(expected string) *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueSet("trace_level", expected)) + return p +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (p *ProcedureJavascriptResourceAssert) HasNoArguments() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("arguments")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoComment() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("comment")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoDatabase() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("database")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoEnableConsoleOutput() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("enable_console_output")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoExecuteAs() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("execute_as")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoFullyQualifiedName() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoIsSecure() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("is_secure")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoLogLevel() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("log_level")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoMetricLevel() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("metric_level")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoName() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("name")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoNullInputBehavior() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("null_input_behavior")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoProcedureDefinition() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("procedure_definition")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoProcedureLanguage() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("procedure_language")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoReturnType() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("return_type")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoSchema() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("schema")) + return p +} + +func (p *ProcedureJavascriptResourceAssert) HasNoTraceLevel() *ProcedureJavascriptResourceAssert { + p.AddAssertion(assert.ValueNotSet("trace_level")) + return p +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_python_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_python_resource_gen.go new file mode 100644 index 0000000000..119c04708c --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_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 ProcedurePythonResourceAssert struct { + *assert.ResourceAssert +} + +func ProcedurePythonResource(t *testing.T, name string) *ProcedurePythonResourceAssert { + t.Helper() + + return &ProcedurePythonResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedProcedurePythonResource(t *testing.T, id string) *ProcedurePythonResourceAssert { + t.Helper() + + return &ProcedurePythonResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (p *ProcedurePythonResourceAssert) HasArgumentsString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("arguments", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasCommentString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("comment", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasDatabaseString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("database", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasEnableConsoleOutputString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("enable_console_output", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasExecuteAsString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("execute_as", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasExternalAccessIntegrationsString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("external_access_integrations", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasFullyQualifiedNameString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasHandlerString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("handler", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasImportsString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("imports", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasIsSecureString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("is_secure", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasLogLevelString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("log_level", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasMetricLevelString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("metric_level", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNameString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("name", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNullInputBehaviorString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("null_input_behavior", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasPackagesString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("packages", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasProcedureDefinitionString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("procedure_definition", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasProcedureLanguageString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("procedure_language", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasReturnTypeString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("return_type", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasRuntimeVersionString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("runtime_version", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasSchemaString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("schema", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasSecretsString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("secrets", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasSnowparkPackageString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("snowpark_package", expected)) + return p +} + +func (p *ProcedurePythonResourceAssert) HasTraceLevelString(expected string) *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueSet("trace_level", expected)) + return p +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (p *ProcedurePythonResourceAssert) HasNoArguments() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("arguments")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoComment() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("comment")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoDatabase() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("database")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoEnableConsoleOutput() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("enable_console_output")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoExecuteAs() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("execute_as")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoExternalAccessIntegrations() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("external_access_integrations")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoFullyQualifiedName() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoHandler() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("handler")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoImports() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("imports")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoIsSecure() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("is_secure")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoLogLevel() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("log_level")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoMetricLevel() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("metric_level")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoName() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("name")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoNullInputBehavior() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("null_input_behavior")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoPackages() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("packages")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoProcedureDefinition() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("procedure_definition")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoProcedureLanguage() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("procedure_language")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoReturnType() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("return_type")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoRuntimeVersion() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("runtime_version")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoSchema() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("schema")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoSecrets() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("secrets")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoSnowparkPackage() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("snowpark_package")) + return p +} + +func (p *ProcedurePythonResourceAssert) HasNoTraceLevel() *ProcedurePythonResourceAssert { + p.AddAssertion(assert.ValueNotSet("trace_level")) + return p +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_scala_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_scala_resource_gen.go new file mode 100644 index 0000000000..e668adf41e --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_scala_resource_gen.go @@ -0,0 +1,277 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" +) + +type ProcedureScalaResourceAssert struct { + *assert.ResourceAssert +} + +func ProcedureScalaResource(t *testing.T, name string) *ProcedureScalaResourceAssert { + t.Helper() + + return &ProcedureScalaResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedProcedureScalaResource(t *testing.T, id string) *ProcedureScalaResourceAssert { + t.Helper() + + return &ProcedureScalaResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (p *ProcedureScalaResourceAssert) HasArgumentsString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("arguments", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasCommentString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("comment", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasDatabaseString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("database", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasEnableConsoleOutputString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("enable_console_output", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasExecuteAsString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("execute_as", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasExternalAccessIntegrationsString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("external_access_integrations", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasFullyQualifiedNameString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasHandlerString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("handler", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasImportsString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("imports", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasIsSecureString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("is_secure", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasLogLevelString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("log_level", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasMetricLevelString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("metric_level", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNameString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("name", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNullInputBehaviorString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("null_input_behavior", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasPackagesString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("packages", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasProcedureDefinitionString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("procedure_definition", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasProcedureLanguageString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("procedure_language", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasReturnTypeString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("return_type", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasRuntimeVersionString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("runtime_version", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasSchemaString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("schema", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasSecretsString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("secrets", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasSnowparkPackageString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("snowpark_package", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasTargetPathString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("target_path", expected)) + return p +} + +func (p *ProcedureScalaResourceAssert) HasTraceLevelString(expected string) *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueSet("trace_level", expected)) + return p +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (p *ProcedureScalaResourceAssert) HasNoArguments() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("arguments")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoComment() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("comment")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoDatabase() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("database")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoEnableConsoleOutput() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("enable_console_output")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoExecuteAs() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("execute_as")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoExternalAccessIntegrations() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("external_access_integrations")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoFullyQualifiedName() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoHandler() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("handler")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoImports() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("imports")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoIsSecure() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("is_secure")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoLogLevel() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("log_level")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoMetricLevel() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("metric_level")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoName() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("name")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoNullInputBehavior() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("null_input_behavior")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoPackages() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("packages")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoProcedureDefinition() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("procedure_definition")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoProcedureLanguage() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("procedure_language")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoReturnType() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("return_type")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoRuntimeVersion() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("runtime_version")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoSchema() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("schema")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoSecrets() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("secrets")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoSnowparkPackage() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("snowpark_package")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoTargetPath() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("target_path")) + return p +} + +func (p *ProcedureScalaResourceAssert) HasNoTraceLevel() *ProcedureScalaResourceAssert { + p.AddAssertion(assert.ValueNotSet("trace_level")) + return p +} diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_sql_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_sql_resource_gen.go new file mode 100644 index 0000000000..6beb382c31 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/procedure_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 ProcedureSqlResourceAssert struct { + *assert.ResourceAssert +} + +func ProcedureSqlResource(t *testing.T, name string) *ProcedureSqlResourceAssert { + t.Helper() + + return &ProcedureSqlResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedProcedureSqlResource(t *testing.T, id string) *ProcedureSqlResourceAssert { + t.Helper() + + return &ProcedureSqlResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (p *ProcedureSqlResourceAssert) HasArgumentsString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("arguments", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasCommentString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("comment", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasDatabaseString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("database", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasEnableConsoleOutputString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("enable_console_output", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasExecuteAsString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("execute_as", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasFullyQualifiedNameString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("fully_qualified_name", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasIsSecureString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("is_secure", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasLogLevelString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("log_level", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasMetricLevelString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("metric_level", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNameString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("name", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNullInputBehaviorString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("null_input_behavior", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasProcedureDefinitionString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("procedure_definition", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasProcedureLanguageString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("procedure_language", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasReturnTypeString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("return_type", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasSchemaString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("schema", expected)) + return p +} + +func (p *ProcedureSqlResourceAssert) HasTraceLevelString(expected string) *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueSet("trace_level", expected)) + return p +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (p *ProcedureSqlResourceAssert) HasNoArguments() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("arguments")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoComment() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("comment")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoDatabase() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("database")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoEnableConsoleOutput() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("enable_console_output")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoExecuteAs() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("execute_as")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoFullyQualifiedName() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("fully_qualified_name")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoIsSecure() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("is_secure")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoLogLevel() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("log_level")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoMetricLevel() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("metric_level")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoName() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("name")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoNullInputBehavior() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("null_input_behavior")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoProcedureDefinition() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("procedure_definition")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoProcedureLanguage() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("procedure_language")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoReturnType() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("return_type")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoSchema() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("schema")) + return p +} + +func (p *ProcedureSqlResourceAssert) HasNoTraceLevel() *ProcedureSqlResourceAssert { + p.AddAssertion(assert.ValueNotSet("trace_level")) + return p +} diff --git a/pkg/acceptance/bettertestspoc/config/model/procedure_java_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/procedure_java_model_ext.go new file mode 100644 index 0000000000..1fa425aa28 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/procedure_java_model_ext.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" +) + +func (f *ProcedureJavaModel) MarshalJSON() ([]byte, error) { + type Alias ProcedureJavaModel + 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/procedure_java_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/procedure_java_model_gen.go new file mode 100644 index 0000000000..5be880ae22 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/procedure_java_model_gen.go @@ -0,0 +1,321 @@ +// 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 ProcedureJavaModel 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"` + ExecuteAs tfconfig.Variable `json:"execute_as,omitempty"` + ExternalAccessIntegrations tfconfig.Variable `json:"external_access_integrations,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,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"` + ProcedureDefinition tfconfig.Variable `json:"procedure_definition,omitempty"` + ProcedureLanguage tfconfig.Variable `json:"procedure_language,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"` + SnowparkPackage tfconfig.Variable `json:"snowpark_package,omitempty"` + TargetPath tfconfig.Variable `json:"target_path,omitempty"` + TraceLevel tfconfig.Variable `json:"trace_level,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func ProcedureJava( + resourceName string, + database string, + handler string, + name string, + procedureDefinition string, + returnType string, + runtimeVersion string, + schema string, + snowparkPackage string, +) *ProcedureJavaModel { + p := &ProcedureJavaModel{ResourceModelMeta: config.Meta(resourceName, resources.ProcedureJava)} + p.WithDatabase(database) + p.WithHandler(handler) + p.WithName(name) + p.WithProcedureDefinition(procedureDefinition) + p.WithReturnType(returnType) + p.WithRuntimeVersion(runtimeVersion) + p.WithSchema(schema) + p.WithSnowparkPackage(snowparkPackage) + return p +} + +func ProcedureJavaWithDefaultMeta( + database string, + handler string, + name string, + procedureDefinition string, + returnType string, + runtimeVersion string, + schema string, + snowparkPackage string, +) *ProcedureJavaModel { + p := &ProcedureJavaModel{ResourceModelMeta: config.DefaultMeta(resources.ProcedureJava)} + p.WithDatabase(database) + p.WithHandler(handler) + p.WithName(name) + p.WithProcedureDefinition(procedureDefinition) + p.WithReturnType(returnType) + p.WithRuntimeVersion(runtimeVersion) + p.WithSchema(schema) + p.WithSnowparkPackage(snowparkPackage) + return p +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// arguments attribute type is not yet supported, so WithArguments can't be generated + +func (p *ProcedureJavaModel) WithComment(comment string) *ProcedureJavaModel { + p.Comment = tfconfig.StringVariable(comment) + return p +} + +func (p *ProcedureJavaModel) WithDatabase(database string) *ProcedureJavaModel { + p.Database = tfconfig.StringVariable(database) + return p +} + +func (p *ProcedureJavaModel) WithEnableConsoleOutput(enableConsoleOutput bool) *ProcedureJavaModel { + p.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) + return p +} + +func (p *ProcedureJavaModel) WithExecuteAs(executeAs string) *ProcedureJavaModel { + p.ExecuteAs = tfconfig.StringVariable(executeAs) + return p +} + +// external_access_integrations attribute type is not yet supported, so WithExternalAccessIntegrations can't be generated + +func (p *ProcedureJavaModel) WithFullyQualifiedName(fullyQualifiedName string) *ProcedureJavaModel { + p.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return p +} + +func (p *ProcedureJavaModel) WithHandler(handler string) *ProcedureJavaModel { + p.Handler = tfconfig.StringVariable(handler) + return p +} + +// imports attribute type is not yet supported, so WithImports can't be generated + +func (p *ProcedureJavaModel) WithIsSecure(isSecure string) *ProcedureJavaModel { + p.IsSecure = tfconfig.StringVariable(isSecure) + return p +} + +func (p *ProcedureJavaModel) WithLogLevel(logLevel string) *ProcedureJavaModel { + p.LogLevel = tfconfig.StringVariable(logLevel) + return p +} + +func (p *ProcedureJavaModel) WithMetricLevel(metricLevel string) *ProcedureJavaModel { + p.MetricLevel = tfconfig.StringVariable(metricLevel) + return p +} + +func (p *ProcedureJavaModel) WithName(name string) *ProcedureJavaModel { + p.Name = tfconfig.StringVariable(name) + return p +} + +func (p *ProcedureJavaModel) WithNullInputBehavior(nullInputBehavior string) *ProcedureJavaModel { + p.NullInputBehavior = tfconfig.StringVariable(nullInputBehavior) + return p +} + +// packages attribute type is not yet supported, so WithPackages can't be generated + +func (p *ProcedureJavaModel) WithProcedureDefinition(procedureDefinition string) *ProcedureJavaModel { + p.ProcedureDefinition = tfconfig.StringVariable(procedureDefinition) + return p +} + +func (p *ProcedureJavaModel) WithProcedureLanguage(procedureLanguage string) *ProcedureJavaModel { + p.ProcedureLanguage = tfconfig.StringVariable(procedureLanguage) + return p +} + +func (p *ProcedureJavaModel) WithReturnType(returnType string) *ProcedureJavaModel { + p.ReturnType = tfconfig.StringVariable(returnType) + return p +} + +func (p *ProcedureJavaModel) WithRuntimeVersion(runtimeVersion string) *ProcedureJavaModel { + p.RuntimeVersion = tfconfig.StringVariable(runtimeVersion) + return p +} + +func (p *ProcedureJavaModel) WithSchema(schema string) *ProcedureJavaModel { + p.Schema = tfconfig.StringVariable(schema) + return p +} + +// secrets attribute type is not yet supported, so WithSecrets can't be generated + +func (p *ProcedureJavaModel) WithSnowparkPackage(snowparkPackage string) *ProcedureJavaModel { + p.SnowparkPackage = tfconfig.StringVariable(snowparkPackage) + return p +} + +func (p *ProcedureJavaModel) WithTargetPath(targetPath string) *ProcedureJavaModel { + p.TargetPath = tfconfig.StringVariable(targetPath) + return p +} + +func (p *ProcedureJavaModel) WithTraceLevel(traceLevel string) *ProcedureJavaModel { + p.TraceLevel = tfconfig.StringVariable(traceLevel) + return p +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (p *ProcedureJavaModel) WithArgumentsValue(value tfconfig.Variable) *ProcedureJavaModel { + p.Arguments = value + return p +} + +func (p *ProcedureJavaModel) WithCommentValue(value tfconfig.Variable) *ProcedureJavaModel { + p.Comment = value + return p +} + +func (p *ProcedureJavaModel) WithDatabaseValue(value tfconfig.Variable) *ProcedureJavaModel { + p.Database = value + return p +} + +func (p *ProcedureJavaModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *ProcedureJavaModel { + p.EnableConsoleOutput = value + return p +} + +func (p *ProcedureJavaModel) WithExecuteAsValue(value tfconfig.Variable) *ProcedureJavaModel { + p.ExecuteAs = value + return p +} + +func (p *ProcedureJavaModel) WithExternalAccessIntegrationsValue(value tfconfig.Variable) *ProcedureJavaModel { + p.ExternalAccessIntegrations = value + return p +} + +func (p *ProcedureJavaModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *ProcedureJavaModel { + p.FullyQualifiedName = value + return p +} + +func (p *ProcedureJavaModel) WithHandlerValue(value tfconfig.Variable) *ProcedureJavaModel { + p.Handler = value + return p +} + +func (p *ProcedureJavaModel) WithImportsValue(value tfconfig.Variable) *ProcedureJavaModel { + p.Imports = value + return p +} + +func (p *ProcedureJavaModel) WithIsSecureValue(value tfconfig.Variable) *ProcedureJavaModel { + p.IsSecure = value + return p +} + +func (p *ProcedureJavaModel) WithLogLevelValue(value tfconfig.Variable) *ProcedureJavaModel { + p.LogLevel = value + return p +} + +func (p *ProcedureJavaModel) WithMetricLevelValue(value tfconfig.Variable) *ProcedureJavaModel { + p.MetricLevel = value + return p +} + +func (p *ProcedureJavaModel) WithNameValue(value tfconfig.Variable) *ProcedureJavaModel { + p.Name = value + return p +} + +func (p *ProcedureJavaModel) WithNullInputBehaviorValue(value tfconfig.Variable) *ProcedureJavaModel { + p.NullInputBehavior = value + return p +} + +func (p *ProcedureJavaModel) WithPackagesValue(value tfconfig.Variable) *ProcedureJavaModel { + p.Packages = value + return p +} + +func (p *ProcedureJavaModel) WithProcedureDefinitionValue(value tfconfig.Variable) *ProcedureJavaModel { + p.ProcedureDefinition = value + return p +} + +func (p *ProcedureJavaModel) WithProcedureLanguageValue(value tfconfig.Variable) *ProcedureJavaModel { + p.ProcedureLanguage = value + return p +} + +func (p *ProcedureJavaModel) WithReturnTypeValue(value tfconfig.Variable) *ProcedureJavaModel { + p.ReturnType = value + return p +} + +func (p *ProcedureJavaModel) WithRuntimeVersionValue(value tfconfig.Variable) *ProcedureJavaModel { + p.RuntimeVersion = value + return p +} + +func (p *ProcedureJavaModel) WithSchemaValue(value tfconfig.Variable) *ProcedureJavaModel { + p.Schema = value + return p +} + +func (p *ProcedureJavaModel) WithSecretsValue(value tfconfig.Variable) *ProcedureJavaModel { + p.Secrets = value + return p +} + +func (p *ProcedureJavaModel) WithSnowparkPackageValue(value tfconfig.Variable) *ProcedureJavaModel { + p.SnowparkPackage = value + return p +} + +func (p *ProcedureJavaModel) WithTargetPathValue(value tfconfig.Variable) *ProcedureJavaModel { + p.TargetPath = value + return p +} + +func (p *ProcedureJavaModel) WithTraceLevelValue(value tfconfig.Variable) *ProcedureJavaModel { + p.TraceLevel = value + return p +} diff --git a/pkg/acceptance/bettertestspoc/config/model/procedure_javascript_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/procedure_javascript_model_ext.go new file mode 100644 index 0000000000..548259aa97 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/procedure_javascript_model_ext.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" +) + +func (f *ProcedureJavascriptModel) MarshalJSON() ([]byte, error) { + type Alias ProcedureJavascriptModel + 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/procedure_javascript_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/procedure_javascript_model_gen.go new file mode 100644 index 0000000000..c90c47d6fb --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/procedure_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 ProcedureJavascriptModel 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"` + ExecuteAs tfconfig.Variable `json:"execute_as,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,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"` + ProcedureDefinition tfconfig.Variable `json:"procedure_definition,omitempty"` + ProcedureLanguage tfconfig.Variable `json:"procedure_language,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 ProcedureJavascript( + resourceName string, + database string, + name string, + procedureDefinition string, + returnType string, + schema string, +) *ProcedureJavascriptModel { + p := &ProcedureJavascriptModel{ResourceModelMeta: config.Meta(resourceName, resources.ProcedureJavascript)} + p.WithDatabase(database) + p.WithName(name) + p.WithProcedureDefinition(procedureDefinition) + p.WithReturnType(returnType) + p.WithSchema(schema) + return p +} + +func ProcedureJavascriptWithDefaultMeta( + database string, + name string, + procedureDefinition string, + returnType string, + schema string, +) *ProcedureJavascriptModel { + p := &ProcedureJavascriptModel{ResourceModelMeta: config.DefaultMeta(resources.ProcedureJavascript)} + p.WithDatabase(database) + p.WithName(name) + p.WithProcedureDefinition(procedureDefinition) + p.WithReturnType(returnType) + p.WithSchema(schema) + return p +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// arguments attribute type is not yet supported, so WithArguments can't be generated + +func (p *ProcedureJavascriptModel) WithComment(comment string) *ProcedureJavascriptModel { + p.Comment = tfconfig.StringVariable(comment) + return p +} + +func (p *ProcedureJavascriptModel) WithDatabase(database string) *ProcedureJavascriptModel { + p.Database = tfconfig.StringVariable(database) + return p +} + +func (p *ProcedureJavascriptModel) WithEnableConsoleOutput(enableConsoleOutput bool) *ProcedureJavascriptModel { + p.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) + return p +} + +func (p *ProcedureJavascriptModel) WithExecuteAs(executeAs string) *ProcedureJavascriptModel { + p.ExecuteAs = tfconfig.StringVariable(executeAs) + return p +} + +func (p *ProcedureJavascriptModel) WithFullyQualifiedName(fullyQualifiedName string) *ProcedureJavascriptModel { + p.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return p +} + +func (p *ProcedureJavascriptModel) WithIsSecure(isSecure string) *ProcedureJavascriptModel { + p.IsSecure = tfconfig.StringVariable(isSecure) + return p +} + +func (p *ProcedureJavascriptModel) WithLogLevel(logLevel string) *ProcedureJavascriptModel { + p.LogLevel = tfconfig.StringVariable(logLevel) + return p +} + +func (p *ProcedureJavascriptModel) WithMetricLevel(metricLevel string) *ProcedureJavascriptModel { + p.MetricLevel = tfconfig.StringVariable(metricLevel) + return p +} + +func (p *ProcedureJavascriptModel) WithName(name string) *ProcedureJavascriptModel { + p.Name = tfconfig.StringVariable(name) + return p +} + +func (p *ProcedureJavascriptModel) WithNullInputBehavior(nullInputBehavior string) *ProcedureJavascriptModel { + p.NullInputBehavior = tfconfig.StringVariable(nullInputBehavior) + return p +} + +func (p *ProcedureJavascriptModel) WithProcedureDefinition(procedureDefinition string) *ProcedureJavascriptModel { + p.ProcedureDefinition = tfconfig.StringVariable(procedureDefinition) + return p +} + +func (p *ProcedureJavascriptModel) WithProcedureLanguage(procedureLanguage string) *ProcedureJavascriptModel { + p.ProcedureLanguage = tfconfig.StringVariable(procedureLanguage) + return p +} + +func (p *ProcedureJavascriptModel) WithReturnType(returnType string) *ProcedureJavascriptModel { + p.ReturnType = tfconfig.StringVariable(returnType) + return p +} + +func (p *ProcedureJavascriptModel) WithSchema(schema string) *ProcedureJavascriptModel { + p.Schema = tfconfig.StringVariable(schema) + return p +} + +func (p *ProcedureJavascriptModel) WithTraceLevel(traceLevel string) *ProcedureJavascriptModel { + p.TraceLevel = tfconfig.StringVariable(traceLevel) + return p +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (p *ProcedureJavascriptModel) WithArgumentsValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.Arguments = value + return p +} + +func (p *ProcedureJavascriptModel) WithCommentValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.Comment = value + return p +} + +func (p *ProcedureJavascriptModel) WithDatabaseValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.Database = value + return p +} + +func (p *ProcedureJavascriptModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.EnableConsoleOutput = value + return p +} + +func (p *ProcedureJavascriptModel) WithExecuteAsValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.ExecuteAs = value + return p +} + +func (p *ProcedureJavascriptModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.FullyQualifiedName = value + return p +} + +func (p *ProcedureJavascriptModel) WithIsSecureValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.IsSecure = value + return p +} + +func (p *ProcedureJavascriptModel) WithLogLevelValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.LogLevel = value + return p +} + +func (p *ProcedureJavascriptModel) WithMetricLevelValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.MetricLevel = value + return p +} + +func (p *ProcedureJavascriptModel) WithNameValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.Name = value + return p +} + +func (p *ProcedureJavascriptModel) WithNullInputBehaviorValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.NullInputBehavior = value + return p +} + +func (p *ProcedureJavascriptModel) WithProcedureDefinitionValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.ProcedureDefinition = value + return p +} + +func (p *ProcedureJavascriptModel) WithProcedureLanguageValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.ProcedureLanguage = value + return p +} + +func (p *ProcedureJavascriptModel) WithReturnTypeValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.ReturnType = value + return p +} + +func (p *ProcedureJavascriptModel) WithSchemaValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.Schema = value + return p +} + +func (p *ProcedureJavascriptModel) WithTraceLevelValue(value tfconfig.Variable) *ProcedureJavascriptModel { + p.TraceLevel = value + return p +} diff --git a/pkg/acceptance/bettertestspoc/config/model/procedure_python_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/procedure_python_model_ext.go new file mode 100644 index 0000000000..1bff75bcc2 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/procedure_python_model_ext.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" +) + +func (f *ProcedurePythonModel) MarshalJSON() ([]byte, error) { + type Alias ProcedurePythonModel + 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/procedure_python_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/procedure_python_model_gen.go new file mode 100644 index 0000000000..dfe2801f00 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/procedure_python_model_gen.go @@ -0,0 +1,310 @@ +// 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 ProcedurePythonModel 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"` + ExecuteAs tfconfig.Variable `json:"execute_as,omitempty"` + ExternalAccessIntegrations tfconfig.Variable `json:"external_access_integrations,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,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"` + ProcedureDefinition tfconfig.Variable `json:"procedure_definition,omitempty"` + ProcedureLanguage tfconfig.Variable `json:"procedure_language,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"` + SnowparkPackage tfconfig.Variable `json:"snowpark_package,omitempty"` + TraceLevel tfconfig.Variable `json:"trace_level,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func ProcedurePython( + resourceName string, + database string, + handler string, + name string, + procedureDefinition string, + returnType string, + runtimeVersion string, + schema string, + snowparkPackage string, +) *ProcedurePythonModel { + p := &ProcedurePythonModel{ResourceModelMeta: config.Meta(resourceName, resources.ProcedurePython)} + p.WithDatabase(database) + p.WithHandler(handler) + p.WithName(name) + p.WithProcedureDefinition(procedureDefinition) + p.WithReturnType(returnType) + p.WithRuntimeVersion(runtimeVersion) + p.WithSchema(schema) + p.WithSnowparkPackage(snowparkPackage) + return p +} + +func ProcedurePythonWithDefaultMeta( + database string, + handler string, + name string, + procedureDefinition string, + returnType string, + runtimeVersion string, + schema string, + snowparkPackage string, +) *ProcedurePythonModel { + p := &ProcedurePythonModel{ResourceModelMeta: config.DefaultMeta(resources.ProcedurePython)} + p.WithDatabase(database) + p.WithHandler(handler) + p.WithName(name) + p.WithProcedureDefinition(procedureDefinition) + p.WithReturnType(returnType) + p.WithRuntimeVersion(runtimeVersion) + p.WithSchema(schema) + p.WithSnowparkPackage(snowparkPackage) + return p +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// arguments attribute type is not yet supported, so WithArguments can't be generated + +func (p *ProcedurePythonModel) WithComment(comment string) *ProcedurePythonModel { + p.Comment = tfconfig.StringVariable(comment) + return p +} + +func (p *ProcedurePythonModel) WithDatabase(database string) *ProcedurePythonModel { + p.Database = tfconfig.StringVariable(database) + return p +} + +func (p *ProcedurePythonModel) WithEnableConsoleOutput(enableConsoleOutput bool) *ProcedurePythonModel { + p.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) + return p +} + +func (p *ProcedurePythonModel) WithExecuteAs(executeAs string) *ProcedurePythonModel { + p.ExecuteAs = tfconfig.StringVariable(executeAs) + return p +} + +// external_access_integrations attribute type is not yet supported, so WithExternalAccessIntegrations can't be generated + +func (p *ProcedurePythonModel) WithFullyQualifiedName(fullyQualifiedName string) *ProcedurePythonModel { + p.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return p +} + +func (p *ProcedurePythonModel) WithHandler(handler string) *ProcedurePythonModel { + p.Handler = tfconfig.StringVariable(handler) + return p +} + +// imports attribute type is not yet supported, so WithImports can't be generated + +func (p *ProcedurePythonModel) WithIsSecure(isSecure string) *ProcedurePythonModel { + p.IsSecure = tfconfig.StringVariable(isSecure) + return p +} + +func (p *ProcedurePythonModel) WithLogLevel(logLevel string) *ProcedurePythonModel { + p.LogLevel = tfconfig.StringVariable(logLevel) + return p +} + +func (p *ProcedurePythonModel) WithMetricLevel(metricLevel string) *ProcedurePythonModel { + p.MetricLevel = tfconfig.StringVariable(metricLevel) + return p +} + +func (p *ProcedurePythonModel) WithName(name string) *ProcedurePythonModel { + p.Name = tfconfig.StringVariable(name) + return p +} + +func (p *ProcedurePythonModel) WithNullInputBehavior(nullInputBehavior string) *ProcedurePythonModel { + p.NullInputBehavior = tfconfig.StringVariable(nullInputBehavior) + return p +} + +// packages attribute type is not yet supported, so WithPackages can't be generated + +func (p *ProcedurePythonModel) WithProcedureDefinition(procedureDefinition string) *ProcedurePythonModel { + p.ProcedureDefinition = tfconfig.StringVariable(procedureDefinition) + return p +} + +func (p *ProcedurePythonModel) WithProcedureLanguage(procedureLanguage string) *ProcedurePythonModel { + p.ProcedureLanguage = tfconfig.StringVariable(procedureLanguage) + return p +} + +func (p *ProcedurePythonModel) WithReturnType(returnType string) *ProcedurePythonModel { + p.ReturnType = tfconfig.StringVariable(returnType) + return p +} + +func (p *ProcedurePythonModel) WithRuntimeVersion(runtimeVersion string) *ProcedurePythonModel { + p.RuntimeVersion = tfconfig.StringVariable(runtimeVersion) + return p +} + +func (p *ProcedurePythonModel) WithSchema(schema string) *ProcedurePythonModel { + p.Schema = tfconfig.StringVariable(schema) + return p +} + +// secrets attribute type is not yet supported, so WithSecrets can't be generated + +func (p *ProcedurePythonModel) WithSnowparkPackage(snowparkPackage string) *ProcedurePythonModel { + p.SnowparkPackage = tfconfig.StringVariable(snowparkPackage) + return p +} + +func (p *ProcedurePythonModel) WithTraceLevel(traceLevel string) *ProcedurePythonModel { + p.TraceLevel = tfconfig.StringVariable(traceLevel) + return p +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (p *ProcedurePythonModel) WithArgumentsValue(value tfconfig.Variable) *ProcedurePythonModel { + p.Arguments = value + return p +} + +func (p *ProcedurePythonModel) WithCommentValue(value tfconfig.Variable) *ProcedurePythonModel { + p.Comment = value + return p +} + +func (p *ProcedurePythonModel) WithDatabaseValue(value tfconfig.Variable) *ProcedurePythonModel { + p.Database = value + return p +} + +func (p *ProcedurePythonModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *ProcedurePythonModel { + p.EnableConsoleOutput = value + return p +} + +func (p *ProcedurePythonModel) WithExecuteAsValue(value tfconfig.Variable) *ProcedurePythonModel { + p.ExecuteAs = value + return p +} + +func (p *ProcedurePythonModel) WithExternalAccessIntegrationsValue(value tfconfig.Variable) *ProcedurePythonModel { + p.ExternalAccessIntegrations = value + return p +} + +func (p *ProcedurePythonModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *ProcedurePythonModel { + p.FullyQualifiedName = value + return p +} + +func (p *ProcedurePythonModel) WithHandlerValue(value tfconfig.Variable) *ProcedurePythonModel { + p.Handler = value + return p +} + +func (p *ProcedurePythonModel) WithImportsValue(value tfconfig.Variable) *ProcedurePythonModel { + p.Imports = value + return p +} + +func (p *ProcedurePythonModel) WithIsSecureValue(value tfconfig.Variable) *ProcedurePythonModel { + p.IsSecure = value + return p +} + +func (p *ProcedurePythonModel) WithLogLevelValue(value tfconfig.Variable) *ProcedurePythonModel { + p.LogLevel = value + return p +} + +func (p *ProcedurePythonModel) WithMetricLevelValue(value tfconfig.Variable) *ProcedurePythonModel { + p.MetricLevel = value + return p +} + +func (p *ProcedurePythonModel) WithNameValue(value tfconfig.Variable) *ProcedurePythonModel { + p.Name = value + return p +} + +func (p *ProcedurePythonModel) WithNullInputBehaviorValue(value tfconfig.Variable) *ProcedurePythonModel { + p.NullInputBehavior = value + return p +} + +func (p *ProcedurePythonModel) WithPackagesValue(value tfconfig.Variable) *ProcedurePythonModel { + p.Packages = value + return p +} + +func (p *ProcedurePythonModel) WithProcedureDefinitionValue(value tfconfig.Variable) *ProcedurePythonModel { + p.ProcedureDefinition = value + return p +} + +func (p *ProcedurePythonModel) WithProcedureLanguageValue(value tfconfig.Variable) *ProcedurePythonModel { + p.ProcedureLanguage = value + return p +} + +func (p *ProcedurePythonModel) WithReturnTypeValue(value tfconfig.Variable) *ProcedurePythonModel { + p.ReturnType = value + return p +} + +func (p *ProcedurePythonModel) WithRuntimeVersionValue(value tfconfig.Variable) *ProcedurePythonModel { + p.RuntimeVersion = value + return p +} + +func (p *ProcedurePythonModel) WithSchemaValue(value tfconfig.Variable) *ProcedurePythonModel { + p.Schema = value + return p +} + +func (p *ProcedurePythonModel) WithSecretsValue(value tfconfig.Variable) *ProcedurePythonModel { + p.Secrets = value + return p +} + +func (p *ProcedurePythonModel) WithSnowparkPackageValue(value tfconfig.Variable) *ProcedurePythonModel { + p.SnowparkPackage = value + return p +} + +func (p *ProcedurePythonModel) WithTraceLevelValue(value tfconfig.Variable) *ProcedurePythonModel { + p.TraceLevel = value + return p +} diff --git a/pkg/acceptance/bettertestspoc/config/model/procedure_scala_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/procedure_scala_model_ext.go new file mode 100644 index 0000000000..b7434a4250 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/procedure_scala_model_ext.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" +) + +func (f *ProcedureScalaModel) MarshalJSON() ([]byte, error) { + type Alias ProcedureScalaModel + 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/procedure_scala_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/procedure_scala_model_gen.go new file mode 100644 index 0000000000..01ff2f1107 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/procedure_scala_model_gen.go @@ -0,0 +1,321 @@ +// 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 ProcedureScalaModel 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"` + ExecuteAs tfconfig.Variable `json:"execute_as,omitempty"` + ExternalAccessIntegrations tfconfig.Variable `json:"external_access_integrations,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,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"` + ProcedureDefinition tfconfig.Variable `json:"procedure_definition,omitempty"` + ProcedureLanguage tfconfig.Variable `json:"procedure_language,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"` + SnowparkPackage tfconfig.Variable `json:"snowpark_package,omitempty"` + TargetPath tfconfig.Variable `json:"target_path,omitempty"` + TraceLevel tfconfig.Variable `json:"trace_level,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func ProcedureScala( + resourceName string, + database string, + handler string, + name string, + procedureDefinition string, + returnType string, + runtimeVersion string, + schema string, + snowparkPackage string, +) *ProcedureScalaModel { + p := &ProcedureScalaModel{ResourceModelMeta: config.Meta(resourceName, resources.ProcedureScala)} + p.WithDatabase(database) + p.WithHandler(handler) + p.WithName(name) + p.WithProcedureDefinition(procedureDefinition) + p.WithReturnType(returnType) + p.WithRuntimeVersion(runtimeVersion) + p.WithSchema(schema) + p.WithSnowparkPackage(snowparkPackage) + return p +} + +func ProcedureScalaWithDefaultMeta( + database string, + handler string, + name string, + procedureDefinition string, + returnType string, + runtimeVersion string, + schema string, + snowparkPackage string, +) *ProcedureScalaModel { + p := &ProcedureScalaModel{ResourceModelMeta: config.DefaultMeta(resources.ProcedureScala)} + p.WithDatabase(database) + p.WithHandler(handler) + p.WithName(name) + p.WithProcedureDefinition(procedureDefinition) + p.WithReturnType(returnType) + p.WithRuntimeVersion(runtimeVersion) + p.WithSchema(schema) + p.WithSnowparkPackage(snowparkPackage) + return p +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// arguments attribute type is not yet supported, so WithArguments can't be generated + +func (p *ProcedureScalaModel) WithComment(comment string) *ProcedureScalaModel { + p.Comment = tfconfig.StringVariable(comment) + return p +} + +func (p *ProcedureScalaModel) WithDatabase(database string) *ProcedureScalaModel { + p.Database = tfconfig.StringVariable(database) + return p +} + +func (p *ProcedureScalaModel) WithEnableConsoleOutput(enableConsoleOutput bool) *ProcedureScalaModel { + p.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) + return p +} + +func (p *ProcedureScalaModel) WithExecuteAs(executeAs string) *ProcedureScalaModel { + p.ExecuteAs = tfconfig.StringVariable(executeAs) + return p +} + +// external_access_integrations attribute type is not yet supported, so WithExternalAccessIntegrations can't be generated + +func (p *ProcedureScalaModel) WithFullyQualifiedName(fullyQualifiedName string) *ProcedureScalaModel { + p.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return p +} + +func (p *ProcedureScalaModel) WithHandler(handler string) *ProcedureScalaModel { + p.Handler = tfconfig.StringVariable(handler) + return p +} + +// imports attribute type is not yet supported, so WithImports can't be generated + +func (p *ProcedureScalaModel) WithIsSecure(isSecure string) *ProcedureScalaModel { + p.IsSecure = tfconfig.StringVariable(isSecure) + return p +} + +func (p *ProcedureScalaModel) WithLogLevel(logLevel string) *ProcedureScalaModel { + p.LogLevel = tfconfig.StringVariable(logLevel) + return p +} + +func (p *ProcedureScalaModel) WithMetricLevel(metricLevel string) *ProcedureScalaModel { + p.MetricLevel = tfconfig.StringVariable(metricLevel) + return p +} + +func (p *ProcedureScalaModel) WithName(name string) *ProcedureScalaModel { + p.Name = tfconfig.StringVariable(name) + return p +} + +func (p *ProcedureScalaModel) WithNullInputBehavior(nullInputBehavior string) *ProcedureScalaModel { + p.NullInputBehavior = tfconfig.StringVariable(nullInputBehavior) + return p +} + +// packages attribute type is not yet supported, so WithPackages can't be generated + +func (p *ProcedureScalaModel) WithProcedureDefinition(procedureDefinition string) *ProcedureScalaModel { + p.ProcedureDefinition = tfconfig.StringVariable(procedureDefinition) + return p +} + +func (p *ProcedureScalaModel) WithProcedureLanguage(procedureLanguage string) *ProcedureScalaModel { + p.ProcedureLanguage = tfconfig.StringVariable(procedureLanguage) + return p +} + +func (p *ProcedureScalaModel) WithReturnType(returnType string) *ProcedureScalaModel { + p.ReturnType = tfconfig.StringVariable(returnType) + return p +} + +func (p *ProcedureScalaModel) WithRuntimeVersion(runtimeVersion string) *ProcedureScalaModel { + p.RuntimeVersion = tfconfig.StringVariable(runtimeVersion) + return p +} + +func (p *ProcedureScalaModel) WithSchema(schema string) *ProcedureScalaModel { + p.Schema = tfconfig.StringVariable(schema) + return p +} + +// secrets attribute type is not yet supported, so WithSecrets can't be generated + +func (p *ProcedureScalaModel) WithSnowparkPackage(snowparkPackage string) *ProcedureScalaModel { + p.SnowparkPackage = tfconfig.StringVariable(snowparkPackage) + return p +} + +func (p *ProcedureScalaModel) WithTargetPath(targetPath string) *ProcedureScalaModel { + p.TargetPath = tfconfig.StringVariable(targetPath) + return p +} + +func (p *ProcedureScalaModel) WithTraceLevel(traceLevel string) *ProcedureScalaModel { + p.TraceLevel = tfconfig.StringVariable(traceLevel) + return p +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (p *ProcedureScalaModel) WithArgumentsValue(value tfconfig.Variable) *ProcedureScalaModel { + p.Arguments = value + return p +} + +func (p *ProcedureScalaModel) WithCommentValue(value tfconfig.Variable) *ProcedureScalaModel { + p.Comment = value + return p +} + +func (p *ProcedureScalaModel) WithDatabaseValue(value tfconfig.Variable) *ProcedureScalaModel { + p.Database = value + return p +} + +func (p *ProcedureScalaModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *ProcedureScalaModel { + p.EnableConsoleOutput = value + return p +} + +func (p *ProcedureScalaModel) WithExecuteAsValue(value tfconfig.Variable) *ProcedureScalaModel { + p.ExecuteAs = value + return p +} + +func (p *ProcedureScalaModel) WithExternalAccessIntegrationsValue(value tfconfig.Variable) *ProcedureScalaModel { + p.ExternalAccessIntegrations = value + return p +} + +func (p *ProcedureScalaModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *ProcedureScalaModel { + p.FullyQualifiedName = value + return p +} + +func (p *ProcedureScalaModel) WithHandlerValue(value tfconfig.Variable) *ProcedureScalaModel { + p.Handler = value + return p +} + +func (p *ProcedureScalaModel) WithImportsValue(value tfconfig.Variable) *ProcedureScalaModel { + p.Imports = value + return p +} + +func (p *ProcedureScalaModel) WithIsSecureValue(value tfconfig.Variable) *ProcedureScalaModel { + p.IsSecure = value + return p +} + +func (p *ProcedureScalaModel) WithLogLevelValue(value tfconfig.Variable) *ProcedureScalaModel { + p.LogLevel = value + return p +} + +func (p *ProcedureScalaModel) WithMetricLevelValue(value tfconfig.Variable) *ProcedureScalaModel { + p.MetricLevel = value + return p +} + +func (p *ProcedureScalaModel) WithNameValue(value tfconfig.Variable) *ProcedureScalaModel { + p.Name = value + return p +} + +func (p *ProcedureScalaModel) WithNullInputBehaviorValue(value tfconfig.Variable) *ProcedureScalaModel { + p.NullInputBehavior = value + return p +} + +func (p *ProcedureScalaModel) WithPackagesValue(value tfconfig.Variable) *ProcedureScalaModel { + p.Packages = value + return p +} + +func (p *ProcedureScalaModel) WithProcedureDefinitionValue(value tfconfig.Variable) *ProcedureScalaModel { + p.ProcedureDefinition = value + return p +} + +func (p *ProcedureScalaModel) WithProcedureLanguageValue(value tfconfig.Variable) *ProcedureScalaModel { + p.ProcedureLanguage = value + return p +} + +func (p *ProcedureScalaModel) WithReturnTypeValue(value tfconfig.Variable) *ProcedureScalaModel { + p.ReturnType = value + return p +} + +func (p *ProcedureScalaModel) WithRuntimeVersionValue(value tfconfig.Variable) *ProcedureScalaModel { + p.RuntimeVersion = value + return p +} + +func (p *ProcedureScalaModel) WithSchemaValue(value tfconfig.Variable) *ProcedureScalaModel { + p.Schema = value + return p +} + +func (p *ProcedureScalaModel) WithSecretsValue(value tfconfig.Variable) *ProcedureScalaModel { + p.Secrets = value + return p +} + +func (p *ProcedureScalaModel) WithSnowparkPackageValue(value tfconfig.Variable) *ProcedureScalaModel { + p.SnowparkPackage = value + return p +} + +func (p *ProcedureScalaModel) WithTargetPathValue(value tfconfig.Variable) *ProcedureScalaModel { + p.TargetPath = value + return p +} + +func (p *ProcedureScalaModel) WithTraceLevelValue(value tfconfig.Variable) *ProcedureScalaModel { + p.TraceLevel = value + return p +} diff --git a/pkg/acceptance/bettertestspoc/config/model/procedure_sql_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/procedure_sql_model_ext.go new file mode 100644 index 0000000000..8b5dc3afbf --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/procedure_sql_model_ext.go @@ -0,0 +1,16 @@ +package model + +import ( + "encoding/json" +) + +func (f *ProcedureSqlModel) MarshalJSON() ([]byte, error) { + type Alias ProcedureSqlModel + 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/procedure_sql_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/procedure_sql_model_gen.go new file mode 100644 index 0000000000..274dfc5b50 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/procedure_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 ProcedureSqlModel 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"` + ExecuteAs tfconfig.Variable `json:"execute_as,omitempty"` + FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,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"` + ProcedureDefinition tfconfig.Variable `json:"procedure_definition,omitempty"` + ProcedureLanguage tfconfig.Variable `json:"procedure_language,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 ProcedureSql( + resourceName string, + database string, + name string, + procedureDefinition string, + returnType string, + schema string, +) *ProcedureSqlModel { + p := &ProcedureSqlModel{ResourceModelMeta: config.Meta(resourceName, resources.ProcedureSql)} + p.WithDatabase(database) + p.WithName(name) + p.WithProcedureDefinition(procedureDefinition) + p.WithReturnType(returnType) + p.WithSchema(schema) + return p +} + +func ProcedureSqlWithDefaultMeta( + database string, + name string, + procedureDefinition string, + returnType string, + schema string, +) *ProcedureSqlModel { + p := &ProcedureSqlModel{ResourceModelMeta: config.DefaultMeta(resources.ProcedureSql)} + p.WithDatabase(database) + p.WithName(name) + p.WithProcedureDefinition(procedureDefinition) + p.WithReturnType(returnType) + p.WithSchema(schema) + return p +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +// arguments attribute type is not yet supported, so WithArguments can't be generated + +func (p *ProcedureSqlModel) WithComment(comment string) *ProcedureSqlModel { + p.Comment = tfconfig.StringVariable(comment) + return p +} + +func (p *ProcedureSqlModel) WithDatabase(database string) *ProcedureSqlModel { + p.Database = tfconfig.StringVariable(database) + return p +} + +func (p *ProcedureSqlModel) WithEnableConsoleOutput(enableConsoleOutput bool) *ProcedureSqlModel { + p.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) + return p +} + +func (p *ProcedureSqlModel) WithExecuteAs(executeAs string) *ProcedureSqlModel { + p.ExecuteAs = tfconfig.StringVariable(executeAs) + return p +} + +func (p *ProcedureSqlModel) WithFullyQualifiedName(fullyQualifiedName string) *ProcedureSqlModel { + p.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) + return p +} + +func (p *ProcedureSqlModel) WithIsSecure(isSecure string) *ProcedureSqlModel { + p.IsSecure = tfconfig.StringVariable(isSecure) + return p +} + +func (p *ProcedureSqlModel) WithLogLevel(logLevel string) *ProcedureSqlModel { + p.LogLevel = tfconfig.StringVariable(logLevel) + return p +} + +func (p *ProcedureSqlModel) WithMetricLevel(metricLevel string) *ProcedureSqlModel { + p.MetricLevel = tfconfig.StringVariable(metricLevel) + return p +} + +func (p *ProcedureSqlModel) WithName(name string) *ProcedureSqlModel { + p.Name = tfconfig.StringVariable(name) + return p +} + +func (p *ProcedureSqlModel) WithNullInputBehavior(nullInputBehavior string) *ProcedureSqlModel { + p.NullInputBehavior = tfconfig.StringVariable(nullInputBehavior) + return p +} + +func (p *ProcedureSqlModel) WithProcedureDefinition(procedureDefinition string) *ProcedureSqlModel { + p.ProcedureDefinition = tfconfig.StringVariable(procedureDefinition) + return p +} + +func (p *ProcedureSqlModel) WithProcedureLanguage(procedureLanguage string) *ProcedureSqlModel { + p.ProcedureLanguage = tfconfig.StringVariable(procedureLanguage) + return p +} + +func (p *ProcedureSqlModel) WithReturnType(returnType string) *ProcedureSqlModel { + p.ReturnType = tfconfig.StringVariable(returnType) + return p +} + +func (p *ProcedureSqlModel) WithSchema(schema string) *ProcedureSqlModel { + p.Schema = tfconfig.StringVariable(schema) + return p +} + +func (p *ProcedureSqlModel) WithTraceLevel(traceLevel string) *ProcedureSqlModel { + p.TraceLevel = tfconfig.StringVariable(traceLevel) + return p +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (p *ProcedureSqlModel) WithArgumentsValue(value tfconfig.Variable) *ProcedureSqlModel { + p.Arguments = value + return p +} + +func (p *ProcedureSqlModel) WithCommentValue(value tfconfig.Variable) *ProcedureSqlModel { + p.Comment = value + return p +} + +func (p *ProcedureSqlModel) WithDatabaseValue(value tfconfig.Variable) *ProcedureSqlModel { + p.Database = value + return p +} + +func (p *ProcedureSqlModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *ProcedureSqlModel { + p.EnableConsoleOutput = value + return p +} + +func (p *ProcedureSqlModel) WithExecuteAsValue(value tfconfig.Variable) *ProcedureSqlModel { + p.ExecuteAs = value + return p +} + +func (p *ProcedureSqlModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *ProcedureSqlModel { + p.FullyQualifiedName = value + return p +} + +func (p *ProcedureSqlModel) WithIsSecureValue(value tfconfig.Variable) *ProcedureSqlModel { + p.IsSecure = value + return p +} + +func (p *ProcedureSqlModel) WithLogLevelValue(value tfconfig.Variable) *ProcedureSqlModel { + p.LogLevel = value + return p +} + +func (p *ProcedureSqlModel) WithMetricLevelValue(value tfconfig.Variable) *ProcedureSqlModel { + p.MetricLevel = value + return p +} + +func (p *ProcedureSqlModel) WithNameValue(value tfconfig.Variable) *ProcedureSqlModel { + p.Name = value + return p +} + +func (p *ProcedureSqlModel) WithNullInputBehaviorValue(value tfconfig.Variable) *ProcedureSqlModel { + p.NullInputBehavior = value + return p +} + +func (p *ProcedureSqlModel) WithProcedureDefinitionValue(value tfconfig.Variable) *ProcedureSqlModel { + p.ProcedureDefinition = value + return p +} + +func (p *ProcedureSqlModel) WithProcedureLanguageValue(value tfconfig.Variable) *ProcedureSqlModel { + p.ProcedureLanguage = value + return p +} + +func (p *ProcedureSqlModel) WithReturnTypeValue(value tfconfig.Variable) *ProcedureSqlModel { + p.ReturnType = value + return p +} + +func (p *ProcedureSqlModel) WithSchemaValue(value tfconfig.Variable) *ProcedureSqlModel { + p.Schema = value + return p +} + +func (p *ProcedureSqlModel) WithTraceLevelValue(value tfconfig.Variable) *ProcedureSqlModel { + p.TraceLevel = value + return p +} diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 5692d9a5eb..37e5316e39 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -522,6 +522,11 @@ func getResources() map[string]*schema.Resource { "snowflake_pipe": resources.Pipe(), "snowflake_primary_connection": resources.PrimaryConnection(), "snowflake_procedure": resources.Procedure(), + "snowflake_procedure_java": resources.ProcedureJava(), + "snowflake_procedure_javascript": resources.ProcedureJavascript(), + "snowflake_procedure_python": resources.ProcedurePython(), + "snowflake_procedure_scala": resources.ProcedureScala(), + "snowflake_procedure_sql": resources.ProcedureSql(), "snowflake_resource_monitor": resources.ResourceMonitor(), "snowflake_role": resources.Role(), "snowflake_row_access_policy": resources.RowAccessPolicy(), diff --git a/pkg/provider/resources/resources.go b/pkg/provider/resources/resources.go index a8173a6d96..8b43f012e7 100644 --- a/pkg/provider/resources/resources.go +++ b/pkg/provider/resources/resources.go @@ -55,6 +55,11 @@ const ( Pipe resource = "snowflake_pipe" PrimaryConnection resource = "snowflake_primary_connection" Procedure resource = "snowflake_procedure" + ProcedureJava resource = "snowflake_procedure_java" + ProcedureJavascript resource = "snowflake_procedure_javascript" + ProcedurePython resource = "snowflake_procedure_python" + ProcedureScala resource = "snowflake_procedure_scala" + ProcedureSql resource = "snowflake_procedure_sql" ResourceMonitor resource = "snowflake_resource_monitor" Role resource = "snowflake_role" RowAccessPolicy resource = "snowflake_row_access_policy" diff --git a/pkg/resources/function_commons.go b/pkg/resources/function_commons.go index d2e703a0e6..fd4d57913e 100644 --- a/pkg/resources/function_commons.go +++ b/pkg/resources/function_commons.go @@ -30,14 +30,14 @@ type functionSchemaDef struct { func setUpFunctionSchema(definition functionSchemaDef) map[string]*schema.Schema { currentSchema := make(map[string]*schema.Schema) - for k, v := range functionBaseSchema { + 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 + v.Description = diffSuppressStatementFieldDescription(definition.functionDefinitionDescription) } if v, ok := currentSchema["runtime_version"]; ok && v != nil { if definition.runtimeVersionRequired { @@ -158,187 +158,189 @@ var ( // 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.", +func functionBaseSchema() map[string]schema.Schema { + return 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 functions (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.", }, - 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{ + // 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, - ValidateDiagFunc: IsValidIdentifier[sdk.AccountObjectIdentifier](), + 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 }, - 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, + "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](https://docs.snowflake.com/en/sql-reference/sql/create-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](https://docs.snowflake.com/en/sql-reference/sql/create-secret) 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.", }, - 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, + // 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, }, - }, - ParametersAttributeName: { - Type: schema.TypeList, - Computed: true, - Description: "Outputs the result of `SHOW PARAMETERS IN FUNCTION` for the given function.", - Elem: &schema.Resource{ - Schema: functionParametersSchema, + "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, + }, }, - }, - FullyQualifiedNameAttributeName: *schemas.FullyQualifiedNameSchema, + 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/procedure_commons.go b/pkg/resources/procedure_commons.go new file mode 100644 index 0000000000..88e815978b --- /dev/null +++ b/pkg/resources/procedure_commons.go @@ -0,0 +1,343 @@ +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() { + javaProcedureSchema = setUpProcedureSchema(javaProcedureSchemaDefinition) + javascriptProcedureSchema = setUpProcedureSchema(javascriptProcedureSchemaDefinition) + pythonProcedureSchema = setUpProcedureSchema(pythonProcedureSchemaDefinition) + scalaProcedureSchema = setUpProcedureSchema(scalaProcedureSchemaDefinition) + sqlProcedureSchema = setUpProcedureSchema(sqlProcedureSchemaDefinition) +} + +type procedureSchemaDef struct { + additionalArguments []string + procedureDefinitionDescription string + returnTypeLinkName string + returnTypeLinkUrl string + runtimeVersionDescription string + importsDescription string + handlerDescription string + targetPathDescription string +} + +func setUpProcedureSchema(definition procedureSchemaDef) map[string]*schema.Schema { + currentSchema := make(map[string]*schema.Schema) + for k, v := range procedureBaseSchema() { + v := v + if slices.Contains(definition.additionalArguments, k) || slices.Contains(commonProcedureArguments, k) { + currentSchema[k] = &v + } + } + if v, ok := currentSchema["procedure_definition"]; ok && v != nil { + v.Description = diffSuppressStatementFieldDescription(definition.procedureDefinitionDescription) + } + if v, ok := currentSchema["return_type"]; ok && v != nil { + v.Description = procedureReturnsTemplate(definition.returnTypeLinkName, definition.returnTypeLinkUrl) + } + if v, ok := currentSchema["runtime_version"]; ok && v != nil { + v.Description = definition.runtimeVersionDescription + } + if v, ok := currentSchema["imports"]; ok && v != nil { + v.Description = definition.importsDescription + } + 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 procedureDefinitionTemplate(language string, linkName string, linkUrl string) string { + return fmt.Sprintf("Defines the code executed by the stored procedure. The definition can consist of any valid code. Wrapping `$$` signs are added by the provider automatically; do not include them. The `procedure_definition` value must be %[1]s source code. For more information, see [%[2]s](%[3]s).", language, linkName, linkUrl) +} + +func procedureReturnsTemplate(linkName string, linkUrl string) string { + return fmt.Sprintf("Specifies the type of the result returned by the stored procedure. For ``, use the Snowflake data type that corresponds to the type of the language that you are using (see [%s](%s)). For `RETURNS TABLE ( [ col_name col_data_type [ , ... ] ] )`, if you know the Snowflake data types of the columns in the returned table, specify the column names and types. Otherwise (e.g. if you are determining the column types during run time), you can omit the column names and types (i.e. `TABLE ()`).", linkName, linkUrl) +} + +var ( + commonProcedureArguments = []string{ + "database", + "schema", + "name", + "is_secure", + "arguments", + "return_type", + "null_input_behavior", + "comment", + "execute_as", + "procedure_definition", + "procedure_language", + ShowOutputAttributeName, + ParametersAttributeName, + FullyQualifiedNameAttributeName, + } + javaProcedureSchemaDefinition = procedureSchemaDef{ + additionalArguments: []string{ + "runtime_version", + "imports", + "snowpark_package", + "packages", + "handler", + "external_access_integrations", + "secrets", + "target_path", + }, + procedureDefinitionDescription: procedureDefinitionTemplate("Java", "Java (using Snowpark)", "https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-java"), + returnTypeLinkName: "SQL-Java Data Type Mappings", + returnTypeLinkUrl: "https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-data-type-mapping.html#label-sql-java-data-type-mappings", + runtimeVersionDescription: "The language runtime version to use. Currently, the supported versions are: 11.", + importsDescription: "The location (stage), path, and name of the file(s) to import. You must set the IMPORTS clause to include any files that your stored procedure depends on. If you are writing an in-line stored procedure, you can omit this clause, unless your code depends on classes defined outside the stored procedure or resource files. If you are writing a stored procedure with a staged handler, you must also include a path to the JAR file containing the stored procedure’s handler code. The IMPORTS definition cannot reference variables from arguments that are passed into the stored procedure. Each file in the IMPORTS clause must have a unique name, even if the files are in different subdirectories or different stages.", + handlerDescription: "Use the fully qualified name of the method or function for the stored procedure. This is typically in the following form `com.my_company.my_package.MyClass.myMethod` where `com.my_company.my_package` corresponds to the package containing the object or class: `package com.my_company.my_package;`.", + targetPathDescription: "For stored procedures with inline handler code, specifies the location to which Snowflake should write the compiled code (JAR file) after compiling the source code specified in the ``. If this clause is omitted, Snowflake re-compiles the source code each time the code is needed. If you specify this clause uou cannot set this to an existing file. Snowflake returns an error if the TARGET_PATH points to an existing file. If you specify both the IMPORTS and TARGET_PATH clauses, the file name in the TARGET_PATH clause must be different from each file name in the IMPORTS clause, even if the files are in different subdirectories or different stages. If you no longer need to use the stored procedure (e.g. if you drop the stored procedure), you must manually remove this JAR file.", + } + javascriptProcedureSchemaDefinition = procedureSchemaDef{ + additionalArguments: []string{}, + returnTypeLinkName: "SQL and JavaScript data type mapping", + returnTypeLinkUrl: "https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-javascript.html#label-stored-procedure-data-type-mapping", + procedureDefinitionDescription: procedureDefinitionTemplate("JavaScript", "JavaScript", "https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-javascript"), + } + pythonProcedureSchemaDefinition = procedureSchemaDef{ + additionalArguments: []string{ + "runtime_version", + "imports", + "snowpark_package", + "packages", + "handler", + "external_access_integrations", + "secrets", + }, + procedureDefinitionDescription: procedureDefinitionTemplate("Python", "Python (using Snowpark)", "https://docs.snowflake.com/en/developer-guide/stored-procedure/python/procedure-python-overview"), + returnTypeLinkName: "SQL-Python Data Type Mappings", + returnTypeLinkUrl: "https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-data-type-mapping.html#label-sql-python-data-type-mappings", + runtimeVersionDescription: "The language runtime version to use. Currently, the supported versions are: 3.9, 3.10, and 3.11.", + importsDescription: "The location (stage), path, and name of the file(s) to import. You must set the IMPORTS clause to include any files that your stored procedure depends on. If you are writing an in-line stored procedure, you can omit this clause, unless your code depends on classes defined outside the stored procedure or resource files. If your stored procedure’s code will be on a stage, you must also include a path to the module file your code is in. The IMPORTS definition cannot reference variables from arguments that are passed into the stored procedure. Each file in the IMPORTS clause must have a unique name, even if the files are in different subdirectories or different stages.", + handlerDescription: "Use the name of the stored procedure’s function or method. This can differ depending on whether the code is in-line or referenced at a stage. When the code is in-line, you can specify just the function name. When the code is imported from a stage, specify the fully-qualified handler function name as `.`.", + } + scalaProcedureSchemaDefinition = procedureSchemaDef{ + additionalArguments: []string{ + "runtime_version", + "imports", + "snowpark_package", + "packages", + "handler", + "external_access_integrations", + "secrets", + "target_path", + }, + procedureDefinitionDescription: procedureDefinitionTemplate("Scala", "Scala (using Snowpark)", "https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-scala"), + returnTypeLinkName: "SQL-Scala Data Type Mappings", + returnTypeLinkUrl: "https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-data-type-mapping.html#label-sql-types-to-scala-types", + runtimeVersionDescription: "The language runtime version to use. Currently, the supported versions are: 2.12.", + importsDescription: "The location (stage), path, and name of the file(s) to import. You must set the IMPORTS clause to include any files that your stored procedure depends on. If you are writing an in-line stored procedure, you can omit this clause, unless your code depends on classes defined outside the stored procedure or resource files. If you are writing a stored procedure with a staged handler, you must also include a path to the JAR file containing the stored procedure’s handler code. The IMPORTS definition cannot reference variables from arguments that are passed into the stored procedure. Each file in the IMPORTS clause must have a unique name, even if the files are in different subdirectories or different stages.", + handlerDescription: "Use the fully qualified name of the method or function for the stored procedure. This is typically in the following form: `com.my_company.my_package.MyClass.myMethod` where `com.my_company.my_package` corresponds to the package containing the object or class: `package com.my_company.my_package;`.", + targetPathDescription: "For stored procedures with inline handler code, specifies the location to which Snowflake should write the compiled code (JAR file) after compiling the source code specified in the procedure_definition. If this clause is omitted, Snowflake re-compiles the source code each time the code is needed. If you specify this clause you cannot set this to an existing file. Snowflake returns an error if the TARGET_PATH points to an existing file. If you specify both the IMPORTS and TARGET_PATH clauses, the file name in the TARGET_PATH clause must be different from each file name in the IMPORTS clause, even if the files are in different subdirectories or different stages. If you no longer need to use the stored procedure (e.g. if you drop the stored procedure), you must manually remove this JAR file.", + } + sqlProcedureSchemaDefinition = procedureSchemaDef{ + additionalArguments: []string{}, + procedureDefinitionDescription: procedureDefinitionTemplate("SQL", "Snowflake Scripting", "https://docs.snowflake.com/en/developer-guide/snowflake-scripting/index"), + returnTypeLinkName: "SQL data type", + returnTypeLinkUrl: "https://docs.snowflake.com/en/sql-reference-data-types", + } +) + +var ( + javaProcedureSchema map[string]*schema.Schema + javascriptProcedureSchema map[string]*schema.Schema + pythonProcedureSchema map[string]*schema.Schema + scalaProcedureSchema map[string]*schema.Schema + sqlProcedureSchema 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 +func procedureBaseSchema() map[string]schema.Schema { + return map[string]schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: suppressIdentifierQuoting, + Description: blocklistedCharactersFieldDescription("The database in which to create the procedure."), + }, + "schema": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: suppressIdentifierQuoting, + Description: blocklistedCharactersFieldDescription("The schema in which to create the procedure."), + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: blocklistedCharactersFieldDescription("The name of the procedure; the identifier does not need to be unique for the schema in which the procedure is created because stored procedures are [identified and resolved by the combination of the name and argument types](https://docs.snowflake.com/en/developer-guide/udf-stored-procedure-naming-conventions.html#label-procedure-function-name-overloading)."), + DiffSuppressFunc: suppressIdentifierQuoting, + }, + "is_secure": { + Type: schema.TypeString, + Optional: true, + Default: BooleanDefault, + ValidateDiagFunc: validateBooleanString, + DiffSuppressFunc: IgnoreChangeToCurrentSnowflakeValueInShow("is_secure"), + Description: booleanStringFieldDescription("Specifies that the procedure is secure. For more information about secure procedures, see [Protecting Sensitive Information with Secure UDFs and Stored Procedures](https://docs.snowflake.com/en/developer-guide/secure-udf-procedure)."), + }, + "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.", + }, + "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 procedure. Consult the [docs](https://docs.snowflake.com/en/sql-reference/sql/create-procedure#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, + }, + "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 procedure when called with null inputs. Valid values are (case-insensitive): %s.", possibleValuesListed(sdk.AllAllowedNullInputBehaviors)), + }, + // "return_behavior" removed because it is deprecated in the docs: https://docs.snowflake.com/en/sql-reference/sql/create-procedure#id1 + "runtime_version": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "comment": { + Type: schema.TypeString, + Optional: true, + // TODO [SNOW-1348103]: handle dynamic comment - this is a workaround for now + Default: "user-defined procedure", + Description: "Specifies a comment for the procedure.", + }, + "imports": { + Type: schema.TypeSet, + Elem: &schema.Schema{Type: schema.TypeString}, + Optional: true, + ForceNew: true, + }, + "snowpark_package": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The Snowpark package is required for stored procedures, so it must always be present. For more information about Snowpark, see [Snowpark API](https://docs.snowflake.com/en/developer-guide/snowpark/index).", + }, + // 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, + Description: "List of the names of packages deployed in Snowflake that should be included in the handler code’s execution environment. The Snowpark package is required for stored procedures, but is specified in the `snowpark_package` attribute. For more information about Snowpark, see [Snowpark API](https://docs.snowflake.com/en/developer-guide/snowpark/index).", + }, + "handler": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "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 procedure’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](https://docs.snowflake.com/en/sql-reference/sql/create-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](https://docs.snowflake.com/en/sql-reference/sql/create-secret) 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.", + }, + "target_path": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "execute_as": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: sdkValidation(sdk.ToExecuteAs), + DiffSuppressFunc: SuppressIfAny(NormalizeAndCompare(sdk.ToExecuteAs), IgnoreChangeToCurrentSnowflakeValueInShow("execute_as")), + Description: fmt.Sprintf("Specifies whether the stored procedure executes with the privileges of the owner (an “owner’s rights” stored procedure) or with the privileges of the caller (a “caller’s rights” stored procedure). If you execute the statement CREATE PROCEDURE … EXECUTE AS CALLER, then in the future the procedure will execute as a caller’s rights procedure. If you execute CREATE PROCEDURE … EXECUTE AS OWNER, then the procedure will execute as an owner’s rights procedure. For more information, see [Understanding caller’s rights and owner’s rights stored procedures](https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-rights). Valid values are (case-insensitive): %s.", possibleValuesListed(sdk.AllAllowedExecuteAs)), + }, + "procedure_definition": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: DiffSuppressStatement, + }, + "procedure_language": { + Type: schema.TypeString, + Computed: true, + Description: "Specifies language for the procedure. Used to detect external changes.", + }, + ShowOutputAttributeName: { + Type: schema.TypeList, + Computed: true, + Description: "Outputs the result of `SHOW PROCEDURE` for the given procedure.", + Elem: &schema.Resource{ + Schema: schemas.ShowProcedureSchema, + }, + }, + ParametersAttributeName: { + Type: schema.TypeList, + Computed: true, + Description: "Outputs the result of `SHOW PARAMETERS IN PROCEDURE` for the given procedure.", + Elem: &schema.Resource{ + Schema: procedureParametersSchema, + }, + }, + FullyQualifiedNameAttributeName: *schemas.FullyQualifiedNameSchema, + } +} diff --git a/pkg/resources/procedure_java.go b/pkg/resources/procedure_java.go new file mode 100644 index 0000000000..8019e72689 --- /dev/null +++ b/pkg/resources/procedure_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 ProcedureJava() *schema.Resource { + return &schema.Resource{ + CreateContext: TrackingCreateWrapper(resources.ProcedureJava, CreateContextProcedureJava), + ReadContext: TrackingReadWrapper(resources.ProcedureJava, ReadContextProcedureJava), + UpdateContext: TrackingUpdateWrapper(resources.ProcedureJava, UpdateContextProcedureJava), + DeleteContext: TrackingDeleteWrapper(resources.ProcedureJava, DeleteContextProcedureJava), + Description: "Resource used to manage java procedure objects. For more information, check [procedure documentation](https://docs.snowflake.com/en/sql-reference/sql/create-procedure).", + + CustomizeDiff: TrackingCustomDiffWrapper(resources.ProcedureJava, customdiff.All( + // TODO[SNOW-1348103]: ComputedIfAnyAttributeChanged(javaProcedureSchema, ShowOutputAttributeName, ...), + ComputedIfAnyAttributeChanged(javaProcedureSchema, FullyQualifiedNameAttributeName, "name"), + ComputedIfAnyAttributeChanged(procedureParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllProcedureParameters), strings.ToLower)...), + procedureParametersCustomDiff, + // TODO[SNOW-1348103]: recreate when type changed externally + )), + + Schema: collections.MergeMaps(javaProcedureSchema, procedureParametersSchema), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + } +} + +func CreateContextProcedureJava(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func ReadContextProcedureJava(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func UpdateContextProcedureJava(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func DeleteContextProcedureJava(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} diff --git a/pkg/resources/procedure_javascript.go b/pkg/resources/procedure_javascript.go new file mode 100644 index 0000000000..8c3958b99e --- /dev/null +++ b/pkg/resources/procedure_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 ProcedureJavascript() *schema.Resource { + return &schema.Resource{ + CreateContext: TrackingCreateWrapper(resources.ProcedureJavascript, CreateContextProcedureJavascript), + ReadContext: TrackingReadWrapper(resources.ProcedureJavascript, ReadContextProcedureJavascript), + UpdateContext: TrackingUpdateWrapper(resources.ProcedureJavascript, UpdateContextProcedureJavascript), + DeleteContext: TrackingDeleteWrapper(resources.ProcedureJavascript, DeleteContextProcedureJavascript), + Description: "Resource used to manage javascript procedure objects. For more information, check [procedure documentation](https://docs.snowflake.com/en/sql-reference/sql/create-procedure).", + + CustomizeDiff: TrackingCustomDiffWrapper(resources.ProcedureJavascript, customdiff.All( + // TODO[SNOW-1348103]: ComputedIfAnyAttributeChanged(javascriptProcedureSchema, ShowOutputAttributeName, ...), + ComputedIfAnyAttributeChanged(javascriptProcedureSchema, FullyQualifiedNameAttributeName, "name"), + ComputedIfAnyAttributeChanged(procedureParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllProcedureParameters), strings.ToLower)...), + procedureParametersCustomDiff, + // TODO[SNOW-1348103]: recreate when type changed externally + )), + + Schema: collections.MergeMaps(javascriptProcedureSchema, procedureParametersSchema), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + } +} + +func CreateContextProcedureJavascript(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func ReadContextProcedureJavascript(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func UpdateContextProcedureJavascript(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func DeleteContextProcedureJavascript(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} diff --git a/pkg/resources/procedure_python.go b/pkg/resources/procedure_python.go new file mode 100644 index 0000000000..48d70329e7 --- /dev/null +++ b/pkg/resources/procedure_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 ProcedurePython() *schema.Resource { + return &schema.Resource{ + CreateContext: TrackingCreateWrapper(resources.ProcedurePython, CreateContextProcedurePython), + ReadContext: TrackingReadWrapper(resources.ProcedurePython, ReadContextProcedurePython), + UpdateContext: TrackingUpdateWrapper(resources.ProcedurePython, UpdateContextProcedurePython), + DeleteContext: TrackingDeleteWrapper(resources.ProcedurePython, DeleteContextProcedurePython), + Description: "Resource used to manage python procedure objects. For more information, check [procedure documentation](https://docs.snowflake.com/en/sql-reference/sql/create-procedure).", + + CustomizeDiff: TrackingCustomDiffWrapper(resources.ProcedurePython, customdiff.All( + // TODO[SNOW-1348103]: ComputedIfAnyAttributeChanged(pythonProcedureSchema, ShowOutputAttributeName, ...), + ComputedIfAnyAttributeChanged(pythonProcedureSchema, FullyQualifiedNameAttributeName, "name"), + ComputedIfAnyAttributeChanged(procedureParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllProcedureParameters), strings.ToLower)...), + procedureParametersCustomDiff, + // TODO[SNOW-1348103]: recreate when type changed externally + )), + + Schema: collections.MergeMaps(pythonProcedureSchema, procedureParametersSchema), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + } +} + +func CreateContextProcedurePython(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func ReadContextProcedurePython(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func UpdateContextProcedurePython(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func DeleteContextProcedurePython(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} diff --git a/pkg/resources/procedure_scala.go b/pkg/resources/procedure_scala.go new file mode 100644 index 0000000000..3a7816b7d0 --- /dev/null +++ b/pkg/resources/procedure_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 ProcedureScala() *schema.Resource { + return &schema.Resource{ + CreateContext: TrackingCreateWrapper(resources.ProcedureScala, CreateContextProcedureScala), + ReadContext: TrackingReadWrapper(resources.ProcedureScala, ReadContextProcedureScala), + UpdateContext: TrackingUpdateWrapper(resources.ProcedureScala, UpdateContextProcedureScala), + DeleteContext: TrackingDeleteWrapper(resources.ProcedureScala, DeleteContextProcedureScala), + Description: "Resource used to manage scala procedure objects. For more information, check [procedure documentation](https://docs.snowflake.com/en/sql-reference/sql/create-procedure).", + + CustomizeDiff: TrackingCustomDiffWrapper(resources.ProcedureScala, customdiff.All( + // TODO[SNOW-1348103]: ComputedIfAnyAttributeChanged(scalaProcedureSchema, ShowOutputAttributeName, ...), + ComputedIfAnyAttributeChanged(scalaProcedureSchema, FullyQualifiedNameAttributeName, "name"), + ComputedIfAnyAttributeChanged(procedureParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllProcedureParameters), strings.ToLower)...), + procedureParametersCustomDiff, + // TODO[SNOW-1348103]: recreate when type changed externally + )), + + Schema: collections.MergeMaps(scalaProcedureSchema, procedureParametersSchema), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + } +} + +func CreateContextProcedureScala(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func ReadContextProcedureScala(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func UpdateContextProcedureScala(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func DeleteContextProcedureScala(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} diff --git a/pkg/resources/procedure_sql.go b/pkg/resources/procedure_sql.go new file mode 100644 index 0000000000..0488941f03 --- /dev/null +++ b/pkg/resources/procedure_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 ProcedureSql() *schema.Resource { + return &schema.Resource{ + CreateContext: TrackingCreateWrapper(resources.ProcedureSql, CreateContextProcedureSql), + ReadContext: TrackingReadWrapper(resources.ProcedureSql, ReadContextProcedureSql), + UpdateContext: TrackingUpdateWrapper(resources.ProcedureSql, UpdateContextProcedureSql), + DeleteContext: TrackingDeleteWrapper(resources.ProcedureSql, DeleteContextProcedureSql), + Description: "Resource used to manage sql procedure objects. For more information, check [procedure documentation](https://docs.snowflake.com/en/sql-reference/sql/create-procedure).", + + CustomizeDiff: TrackingCustomDiffWrapper(resources.ProcedureSql, customdiff.All( + // TODO[SNOW-1348103]: ComputedIfAnyAttributeChanged(sqlProcedureSchema, ShowOutputAttributeName, ...), + ComputedIfAnyAttributeChanged(sqlProcedureSchema, FullyQualifiedNameAttributeName, "name"), + ComputedIfAnyAttributeChanged(procedureParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllProcedureParameters), strings.ToLower)...), + procedureParametersCustomDiff, + // TODO[SNOW-1348103]: recreate when type changed externally + )), + + Schema: collections.MergeMaps(sqlProcedureSchema, procedureParametersSchema), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + } +} + +func CreateContextProcedureSql(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func ReadContextProcedureSql(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func UpdateContextProcedureSql(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} + +func DeleteContextProcedureSql(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + return nil +} diff --git a/pkg/sdk/common_types.go b/pkg/sdk/common_types.go index 4276fe58d9..0621d9d995 100644 --- a/pkg/sdk/common_types.go +++ b/pkg/sdk/common_types.go @@ -220,11 +220,28 @@ func ExecuteAsPointer(v ExecuteAs) *ExecuteAs { return &v } +// TODO [SNOW-1348103]: fix SDK - constants should have only CALLER and OWNER (not the EXECUTE AS part) const ( ExecuteAsCaller ExecuteAs = "EXECUTE AS CALLER" ExecuteAsOwner ExecuteAs = "EXECUTE AS OWNER" ) +func ToExecuteAs(value string) (ExecuteAs, error) { + switch strings.ToUpper(value) { + case string(ExecuteAsCaller): + return ExecuteAsCaller, nil + case string(ExecuteAsOwner): + return ExecuteAsOwner, nil + default: + return "", fmt.Errorf("unknown execute as: %s", value) + } +} + +var AllAllowedExecuteAs = []ExecuteAs{ + ExecuteAsCaller, + ExecuteAsOwner, +} + type NullInputBehavior string func NullInputBehaviorPointer(v NullInputBehavior) *NullInputBehavior { diff --git a/pkg/sdk/common_types_test.go b/pkg/sdk/common_types_test.go index 2cb2f55665..7df8be779e 100644 --- a/pkg/sdk/common_types_test.go +++ b/pkg/sdk/common_types_test.go @@ -262,6 +262,38 @@ func TestToLogLevel(t *testing.T) { } } +func Test_ToExecuteAs(t *testing.T) { + testCases := []struct { + Name string + Input string + Expected ExecuteAs + Error string + }{ + {Input: string(ExecuteAsCaller), Expected: ExecuteAsCaller}, + {Input: string(ExecuteAsOwner), Expected: ExecuteAsOwner}, + {Name: "validation: incorrect execute as", Input: "incorrect", Error: "unknown execute as: incorrect"}, + {Name: "validation: empty input", Input: "", Error: "unknown execute as: "}, + {Name: "validation: lower case input", Input: "execute as caller", Expected: ExecuteAsCaller}, + } + + for _, testCase := range testCases { + name := testCase.Name + if name == "" { + name = fmt.Sprintf("%v execute as", testCase.Input) + } + t.Run(name, func(t *testing.T) { + value, err := ToExecuteAs(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_ToNullInputBehavior(t *testing.T) { testCases := []struct { Name string