diff --git a/docs/data-sources/databases.md b/docs/data-sources/databases.md index 991f8741fcc..d933362a52f 100644 --- a/docs/data-sources/databases.md +++ b/docs/data-sources/databases.md @@ -151,6 +151,208 @@ Read-Only: Read-Only: +- `catalog` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--catalog)) +- `data_retention_time_in_days` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--data_retention_time_in_days)) +- `default_ddl_collation` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--default_ddl_collation)) +- `enable_console_output` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--enable_console_output)) +- `external_volume` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--external_volume)) +- `log_level` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--log_level)) +- `max_data_extension_time_in_days` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--max_data_extension_time_in_days)) +- `quoted_identifiers_ignore_case` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--quoted_identifiers_ignore_case)) +- `replace_invalid_characters` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--replace_invalid_characters)) +- `storage_serialization_policy` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--storage_serialization_policy)) +- `suspend_task_after_num_failures` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--suspend_task_after_num_failures)) +- `task_auto_retry_attempts` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--task_auto_retry_attempts)) +- `trace_level` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--trace_level)) +- `user_task_managed_initial_warehouse_size` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--user_task_managed_initial_warehouse_size)) +- `user_task_minimum_trigger_interval_in_seconds` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--user_task_minimum_trigger_interval_in_seconds)) +- `user_task_timeout_ms` (List of Object) (see [below for nested schema](#nestedobjatt--databases--parameters--user_task_timeout_ms)) + + +### Nested Schema for `databases.parameters.catalog` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.data_retention_time_in_days` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.default_ddl_collation` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.enable_console_output` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.external_volume` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.log_level` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.max_data_extension_time_in_days` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.quoted_identifiers_ignore_case` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.replace_invalid_characters` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.storage_serialization_policy` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.suspend_task_after_num_failures` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.task_auto_retry_attempts` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.trace_level` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.user_task_managed_initial_warehouse_size` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.user_task_minimum_trigger_interval_in_seconds` + +Read-Only: + +- `default` (String) +- `description` (String) +- `key` (String) +- `level` (String) +- `value` (String) + + + +### Nested Schema for `databases.parameters.user_task_timeout_ms` + +Read-Only: + - `default` (String) - `description` (String) - `key` (String) diff --git a/pkg/schemas/database_parameters.go b/pkg/schemas/database_parameters.go index 5042a6b4493..79fa3e7fdcc 100644 --- a/pkg/schemas/database_parameters.go +++ b/pkg/schemas/database_parameters.go @@ -1,10 +1,11 @@ package schemas import ( - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "slices" "strings" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) var ( diff --git a/pkg/sdk/common_types_test.go b/pkg/sdk/common_types_test.go index 15c96b72c7e..3029d81e10e 100644 --- a/pkg/sdk/common_types_test.go +++ b/pkg/sdk/common_types_test.go @@ -1,6 +1,7 @@ package sdk import ( + "fmt" "testing" "github.com/stretchr/testify/assert" @@ -115,35 +116,19 @@ func TestToStorageSerializationPolicy(t *testing.T) { Expected StorageSerializationPolicy Error string }{ - { - Name: "optimized storage serialization policy", - Input: string(StorageSerializationPolicyOptimized), - Expected: StorageSerializationPolicyOptimized, - }, - { - Name: "compatible storage serialization policy", - Input: string(StorageSerializationPolicyCompatible), - Expected: StorageSerializationPolicyCompatible, - }, - { - Name: "validation: incorrect storage serialization policy", - Input: "incorrect", - Error: "unknown storage serialization policy: incorrect", - }, - { - Name: "validation: empty input", - Input: "", - Error: "unknown storage serialization policy: ", - }, - { - Name: "validation: lower case input", - Input: "optimized", - Expected: StorageSerializationPolicyOptimized, - }, + {Input: string(StorageSerializationPolicyOptimized), Expected: StorageSerializationPolicyOptimized}, + {Input: string(StorageSerializationPolicyCompatible), Expected: StorageSerializationPolicyCompatible}, + {Name: "validation: incorrect storage serialization policy", Input: "incorrect", Error: "unknown storage serialization policy: incorrect"}, + {Name: "validation: empty input", Input: "", Error: "unknown storage serialization policy: "}, + {Name: "validation: lower case input", Input: "optimized", Expected: StorageSerializationPolicyOptimized}, } for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { + name := testCase.Name + if name == "" { + name = fmt.Sprintf("%v storage serialization policy", testCase.Input) + } + t.Run(name, func(t *testing.T) { value, err := ToStorageSerializationPolicy(testCase.Input) if testCase.Error != "" { assert.Empty(t, value) @@ -163,60 +148,24 @@ func TestToLogLevel(t *testing.T) { Expected LogLevel Error string }{ - { - Name: "trace log level", - Input: string(LogLevelTrace), - Expected: LogLevelTrace, - }, - { - Name: "debug log level", - Input: string(LogLevelDebug), - Expected: LogLevelDebug, - }, - { - Name: "info log level", - Input: string(LogLevelInfo), - Expected: LogLevelInfo, - }, - { - Name: "warn log level", - Input: string(LogLevelWarn), - Expected: LogLevelWarn, - }, - { - Name: "error log level", - Input: string(LogLevelError), - Expected: LogLevelError, - }, - { - Name: "fatal log level", - Input: string(LogLevelFatal), - Expected: LogLevelFatal, - }, - { - Name: "off log level", - Input: string(LogLevelOff), - Expected: LogLevelOff, - }, - { - Name: "validation: incorrect log level", - Input: "incorrect", - Error: "unknown log level: incorrect", - }, - { - Name: "validation: empty input", - Input: "", - Error: "unknown log level: ", - }, - { - Name: "validation: lower case input", - Input: "info", - Expected: LogLevelInfo, - }, + {Input: string(LogLevelTrace), Expected: LogLevelTrace}, + {Input: string(LogLevelDebug), Expected: LogLevelDebug}, + {Input: string(LogLevelInfo), Expected: LogLevelInfo}, + {Input: string(LogLevelWarn), Expected: LogLevelWarn}, + {Input: string(LogLevelError), Expected: LogLevelError}, + {Input: string(LogLevelFatal), Expected: LogLevelFatal}, + {Input: string(LogLevelOff), Expected: LogLevelOff}, + {Name: "validation: incorrect log level", Input: "incorrect", Error: "unknown log level: incorrect"}, + {Name: "validation: empty input", Input: "", Error: "unknown log level: "}, + {Name: "validation: lower case input", Input: "info", Expected: LogLevelInfo}, } for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { + name := testCase.Name + if name == "" { + name = fmt.Sprintf("%v log level", testCase.Input) + } + t.Run(name, func(t *testing.T) { value, err := ToLogLevel(testCase.Input) if testCase.Error != "" { assert.Empty(t, value) @@ -236,40 +185,20 @@ func TestToTraceLevel(t *testing.T) { Expected TraceLevel Error string }{ - { - Name: "always trace level", - Input: string(TraceLevelAlways), - Expected: TraceLevelAlways, - }, - { - Name: "on event trace level", - Input: string(TraceLevelOnEvent), - Expected: TraceLevelOnEvent, - }, - { - Name: "off trace level", - Input: string(TraceLevelOff), - Expected: TraceLevelOff, - }, - { - Name: "validation: incorrect trace level", - Input: "incorrect", - Error: "unknown trace level: incorrect", - }, - { - Name: "validation: empty input", - Input: "", - Error: "unknown trace level: ", - }, - { - Name: "validation: lower case input", - Input: "always", - Expected: TraceLevelAlways, - }, + {Input: string(TraceLevelAlways), Expected: TraceLevelAlways}, + {Input: string(TraceLevelOnEvent), Expected: TraceLevelOnEvent}, + {Input: string(TraceLevelOff), Expected: TraceLevelOff}, + {Name: "validation: incorrect trace level", Input: "incorrect", Error: "unknown trace level: incorrect"}, + {Name: "validation: empty input", Input: "", Error: "unknown trace level: "}, + {Name: "validation: lower case input", Input: "always", Expected: TraceLevelAlways}, } for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { + name := testCase.Name + if name == "" { + name = fmt.Sprintf("%v trace level", testCase.Input) + } + t.Run(name, func(t *testing.T) { value, err := ToTraceLevel(testCase.Input) if testCase.Error != "" { assert.Empty(t, value)