-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a9ea33
commit c38f951
Showing
12 changed files
with
1,553 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
package sdk | ||
|
||
import g "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/poc/generator" | ||
|
||
//go:generate go run ./poc/main.go | ||
|
||
// https://medium.com/snowflake/hello-world-snowflake-native-apps-76e1ce82e1be | ||
|
||
var applicationPackageModifyReleaseDirective = g.NewQueryStruct("ModifyReleaseDirective"). | ||
Text("ReleaseDirective", g.KeywordOptions().NoQuotes().Required()). | ||
TextAssignment("VERSION", g.ParameterOptions().NoQuotes().Required()). | ||
NumberAssignment("PATCH", g.ParameterOptions().NoQuotes().Required()) | ||
|
||
var applicationPackageSetReleaseDirective = g.NewQueryStruct("SetReleaseDirective"). | ||
Text("ReleaseDirective", g.KeywordOptions().NoQuotes().Required()). | ||
PredefinedQueryStructField("Accounts", "[]string", g.ParameterOptions().MustParentheses().NoQuotes().Required().SQL("ACCOUNTS")). | ||
TextAssignment("VERSION", g.ParameterOptions().NoQuotes().Required()). | ||
NumberAssignment("PATCH", g.ParameterOptions().NoQuotes().Required()) | ||
|
||
var applicationPackageUnsetReleaseDirective = g.NewQueryStruct("UnsetReleaseDirective"). | ||
Text("ReleaseDirective", g.KeywordOptions().NoQuotes().Required()) | ||
|
||
var applicationPackageSetDefaultReleaseDirective = g.NewQueryStruct("SetDefaultReleaseDirective"). | ||
TextAssignment("VERSION", g.ParameterOptions().NoQuotes().Required()). | ||
NumberAssignment("PATCH", g.ParameterOptions().NoQuotes().Required()) | ||
|
||
var applicationPackageAddVersion = g.NewQueryStruct("AddVersion"). | ||
OptionalText("VersionIdentifier", g.KeywordOptions().NoQuotes()). | ||
TextAssignment("USING", g.ParameterOptions().NoEquals().SingleQuotes().Required()). | ||
OptionalTextAssignment("Label", g.ParameterOptions().SingleQuotes()) | ||
|
||
var applicationPackageDropVersion = g.NewQueryStruct("DropVersion"). | ||
Text("VersionIdentifier", g.KeywordOptions().NoQuotes().Required()) | ||
|
||
var applicationPackageAddPatchForVersion = g.NewQueryStruct("AddPatchForVersion"). | ||
OptionalText("VersionIdentifier", g.KeywordOptions().NoQuotes().Required()). | ||
TextAssignment("USING", g.ParameterOptions().NoEquals().SingleQuotes().Required()). | ||
OptionalTextAssignment("Label", g.ParameterOptions().SingleQuotes()) | ||
|
||
var applicationPackageSet = g.NewQueryStruct("ApplicationPackageSet"). | ||
OptionalNumberAssignment("DATA_RETENTION_TIME_IN_DAYS", g.ParameterOptions().NoQuotes()). | ||
OptionalNumberAssignment("MAX_DATA_EXTENSION_TIME_IN_DAYS", g.ParameterOptions().NoQuotes()). | ||
OptionalTextAssignment("DEFAULT_DDL_COLLATION", g.ParameterOptions().SingleQuotes()). | ||
OptionalTextAssignment("COMMENT", g.ParameterOptions().SingleQuotes()). | ||
PredefinedQueryStructField("Distribution", "*Distribution", g.ParameterOptions().SQL("DISTRIBUTION")) | ||
|
||
var ApplicationPackagesDef = g.NewInterface( | ||
"ApplicationPackages", | ||
"ApplicationPackage", | ||
g.KindOfT[AccountObjectIdentifier](), | ||
).CreateOperation( | ||
"https://docs.snowflake.com/en/sql-reference/sql/create-application-package", | ||
g.NewQueryStruct("CreateApplicationPackage"). | ||
Create(). | ||
SQL("APPLICATION PACKAGE"). | ||
IfNotExists(). | ||
Name(). | ||
OptionalNumberAssignment("DATA_RETENTION_TIME_IN_DAYS", g.ParameterOptions().NoQuotes()). | ||
OptionalNumberAssignment("MAX_DATA_EXTENSION_TIME_IN_DAYS", g.ParameterOptions().NoQuotes()). | ||
OptionalTextAssignment("DEFAULT_DDL_COLLATION", g.ParameterOptions().SingleQuotes()). | ||
OptionalTextAssignment("COMMENT", g.ParameterOptions().SingleQuotes()). | ||
PredefinedQueryStructField("Distribution", "*Distribution", g.ParameterOptions().SQL("DISTRIBUTION")). | ||
OptionalTags(). | ||
WithValidation(g.ValidIdentifier, "name"), | ||
).AlterOperation( | ||
"https://docs.snowflake.com/en/sql-reference/sql/alter-application-package", | ||
g.NewQueryStruct("AlterApplicationPackage"). | ||
Alter(). | ||
SQL("APPLICATION PACKAGE"). | ||
IfExists(). | ||
Name(). | ||
OptionalQueryStructField( | ||
"Set", | ||
applicationPackageSet, | ||
g.KeywordOptions().SQL("SET"), | ||
). | ||
OptionalSQL("UNSET DATA_RETENTION_TIME_IN_DAYS"). | ||
OptionalSQL("UNSET MAX_DATA_EXTENSION_TIME_IN_DAYS"). | ||
OptionalSQL("UNSET DEFAULT_DDL_COLLATION"). | ||
OptionalSQL("UNSET COMMENT"). | ||
OptionalSQL("UNSET DISTRIBUTION"). | ||
OptionalQueryStructField( | ||
"ModifyReleaseDirective", | ||
applicationPackageModifyReleaseDirective, | ||
g.KeywordOptions().SQL("MODIFY RELEASE DIRECTIVE"), | ||
). | ||
OptionalQueryStructField( | ||
"SetDefaultReleaseDirective", | ||
applicationPackageSetDefaultReleaseDirective, | ||
g.KeywordOptions().SQL("SET DEFAULT RELEASE DIRECTIVE"), | ||
). | ||
OptionalQueryStructField( | ||
"SetReleaseDirective", | ||
applicationPackageSetReleaseDirective, | ||
g.KeywordOptions().SQL("SET RELEASE DIRECTIVE"), | ||
). | ||
OptionalQueryStructField( | ||
"UnsetReleaseDirective", | ||
applicationPackageUnsetReleaseDirective, | ||
g.KeywordOptions().SQL("UNSET RELEASE DIRECTIVE"), | ||
). | ||
OptionalQueryStructField( | ||
"AddVersion", | ||
applicationPackageAddVersion, | ||
g.KeywordOptions().SQL("ADD VERSION"), | ||
). | ||
OptionalQueryStructField( | ||
"DropVersion", | ||
applicationPackageDropVersion, | ||
g.KeywordOptions().SQL("DROP VERSION"), | ||
). | ||
OptionalQueryStructField( | ||
"AddPatchForVersion", | ||
applicationPackageAddPatchForVersion, | ||
g.KeywordOptions().SQL("ADD PATCH FOR VERSION"), | ||
). | ||
OptionalSetTags(). | ||
OptionalUnsetTags(). | ||
WithValidation(g.ValidIdentifier, "name"). | ||
WithValidation(g.ExactlyOneValueSet, "Set", "UnsetDataRetentionTimeInDays", "UnsetMaxDataExtensionTimeInDays", "UnsetDefaultDdlCollation", "UnsetComment", "UnsetDistribution", "ModifyReleaseDirective", "SetDefaultReleaseDirective", "SetReleaseDirective", "UnsetReleaseDirective", "AddVersion", "DropVersion", "AddPatchForVersion", "SetTags", "UnsetTags"), | ||
).DropOperation( | ||
"https://docs.snowflake.com/en/sql-reference/sql/drop-application-package", | ||
g.NewQueryStruct("DropApplicationPackage"). | ||
Drop(). | ||
SQL("APPLICATION PACKAGE"). | ||
Name(). | ||
WithValidation(g.ValidIdentifier, "name"), | ||
).ShowOperation( | ||
"https://docs.snowflake.com/en/sql-reference/sql/show-application-packages", | ||
g.DbStruct("applicationPackageRow"). | ||
Field("created_on", "string"). | ||
Field("name", "string"). | ||
Field("is_default", "string"). | ||
Field("is_current", "string"). | ||
Field("distribution", "string"). | ||
Field("owner", "string"). | ||
Field("comment", "string"). | ||
Field("retention_time", "int"). | ||
Field("options", "string"). | ||
Field("dropped_on", "sql.NullString"). | ||
Field("application_class", "sql.NullString"), | ||
g.PlainStruct("ApplicationPackage"). | ||
Field("CreatedOn", "string"). | ||
Field("Name", "string"). | ||
Field("IsDefault", "bool"). | ||
Field("IsCurrent", "bool"). | ||
Field("Distribution", "string"). | ||
Field("Owner", "string"). | ||
Field("Comment", "string"). | ||
Field("RetentionTime", "int"). | ||
Field("Options", "string"). | ||
Field("DroppedOn", "string"). | ||
Field("ApplicationClass", "string"), | ||
g.NewQueryStruct("ShowApplicationPackages"). | ||
Show(). | ||
SQL("APPLICATION PACKAGES"). | ||
OptionalLike(). | ||
OptionalStartsWith(). | ||
OptionalLimit(), | ||
).ShowByIdOperation() |
Oops, something went wrong.