-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathstorage_integration_def.go
146 lines (142 loc) · 5.25 KB
/
storage_integration_def.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package sdk
import g "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/poc/generator"
//go:generate go run ./poc/main.go
var StorageLocationDef = g.NewQueryStruct("StorageLocation").Text("Path", g.KeywordOptions().SingleQuotes().Required())
var StorageIntegrationDef = g.NewInterface(
"StorageIntegrations",
"StorageIntegration",
g.KindOfT[AccountObjectIdentifier](),
).
CreateOperation(
"https://docs.snowflake.com/en/sql-reference/sql/create-storage-integration",
g.NewQueryStruct("CreateStorageIntegration").
Create().
OrReplace().
SQL("STORAGE INTEGRATION").
IfNotExists().
Name().
PredefinedQueryStructField("externalStageType", "string", g.StaticOptions().SQL("TYPE = EXTERNAL_STAGE")).
OptionalQueryStructField(
"S3StorageProviderParams",
g.NewQueryStruct("S3StorageParams").
PredefinedQueryStructField("storageProvider", "string", g.StaticOptions().SQL("STORAGE_PROVIDER = 'S3'")).
TextAssignment("STORAGE_AWS_ROLE_ARN", g.ParameterOptions().SingleQuotes().Required()).
OptionalTextAssignment("STORAGE_AWS_OBJECT_ACL", g.ParameterOptions().SingleQuotes()),
g.KeywordOptions(),
).
OptionalQueryStructField(
"GCSStorageProviderParams",
g.NewQueryStruct("GCSStorageParams").
PredefinedQueryStructField("storageProvider", "string", g.StaticOptions().SQL("STORAGE_PROVIDER = 'GCS'")),
g.KeywordOptions(),
).
OptionalQueryStructField(
"AzureStorageProviderParams",
g.NewQueryStruct("AzureStorageParams").
PredefinedQueryStructField("storageProvider", "string", g.StaticOptions().SQL("STORAGE_PROVIDER = 'AZURE'")).
OptionalTextAssignment("AZURE_TENANT_ID", g.ParameterOptions().SingleQuotes().Required()),
g.KeywordOptions(),
).
BooleanAssignment("ENABLED", g.ParameterOptions().Required()).
ListAssignment("STORAGE_ALLOWED_LOCATIONS", "StorageLocation", g.ParameterOptions().Parentheses().Required()).
ListAssignment("STORAGE_BLOCKED_LOCATIONS", "StorageLocation", g.ParameterOptions().Parentheses()).
OptionalComment().
WithValidation(g.ValidIdentifier, "name").
WithValidation(g.ConflictingFields, "IfNotExists", "OrReplace").
WithValidation(g.ExactlyOneValueSet, "S3StorageProviderParams", "GCSStorageProviderParams", "AzureStorageProviderParams"),
StorageLocationDef,
).
AlterOperation(
"https://docs.snowflake.com/en/sql-reference/sql/alter-storage-integration",
g.NewQueryStruct("AlterStorageIntegration").
Alter().
SQL("STORAGE INTEGRATION").
IfExists().
Name().
OptionalQueryStructField(
"Set",
g.NewQueryStruct("StorageIntegrationSet").
OptionalQueryStructField(
"S3Params",
g.NewQueryStruct("SetS3StorageParams").
TextAssignment("STORAGE_AWS_ROLE_ARN", g.ParameterOptions().SingleQuotes().Required()).
OptionalTextAssignment("STORAGE_AWS_OBJECT_ACL", g.ParameterOptions().SingleQuotes()),
g.KeywordOptions(),
).
OptionalQueryStructField(
"AzureParams",
g.NewQueryStruct("SetAzureStorageParams").
TextAssignment("AZURE_TENANT_ID", g.ParameterOptions().SingleQuotes().Required()),
g.KeywordOptions(),
).
BooleanAssignment("ENABLED", g.ParameterOptions()).
ListAssignment("STORAGE_ALLOWED_LOCATIONS", "StorageLocation", g.ParameterOptions().Parentheses()).
ListAssignment("STORAGE_BLOCKED_LOCATIONS", "StorageLocation", g.ParameterOptions().Parentheses()).
OptionalComment(),
g.KeywordOptions().SQL("SET"),
).
OptionalQueryStructField(
"Unset",
g.NewQueryStruct("StorageIntegrationUnset").
OptionalSQL("STORAGE_AWS_OBJECT_ACL").
OptionalSQL("ENABLED").
OptionalSQL("STORAGE_BLOCKED_LOCATIONS").
OptionalSQL("COMMENT"),
g.ListOptions().SQL("UNSET"),
).
OptionalSetTags().
OptionalUnsetTags().
WithValidation(g.ValidIdentifier, "name").
WithValidation(g.ConflictingFields, "IfExists", "UnsetTags").
WithValidation(g.ExactlyOneValueSet, "Set", "Unset", "SetTags", "UnsetTags"),
).
DropOperation(
"https://docs.snowflake.com/en/sql-reference/sql/drop-integration",
g.NewQueryStruct("DropStorageIntegration").
Drop().
SQL("STORAGE INTEGRATION").
IfExists().
Name().
WithValidation(g.ValidIdentifier, "name"),
).
ShowOperation(
"https://docs.snowflake.com/en/sql-reference/sql/show-integrations",
g.DbStruct("showStorageIntegrationsDbRow").
Text("name").
Text("type").
Text("category").
Bool("enabled").
OptionalText("comment").
Time("created_on"),
g.PlainStruct("StorageIntegration").
Text("Name").
Text("StorageType").
Text("Category").
Bool("Enabled").
Text("Comment").
Time("CreatedOn"),
g.NewQueryStruct("ShowStorageIntegrations").
Show().
SQL("STORAGE INTEGRATIONS").
OptionalLike(),
).
ShowByIdOperation().
DescribeOperation(
g.DescriptionMappingKindSlice,
"https://docs.snowflake.com/en/sql-reference/sql/desc-integration",
g.DbStruct("descStorageIntegrationsDbRow").
Text("property").
Text("property_type").
Text("property_value").
Text("property_default"),
g.PlainStruct("StorageIntegrationProperty").
Text("Name").
Text("Type").
Text("Value").
Text("Default"),
g.NewQueryStruct("DescribeStorageIntegration").
Describe().
SQL("STORAGE INTEGRATION").
Name().
WithValidation(g.ValidIdentifier, "name"),
)