diff --git a/docs/resources/grant_privileges_to_role.md b/docs/resources/grant_privileges_to_role.md index 930c7a5265..c3c0d320b6 100644 --- a/docs/resources/grant_privileges_to_role.md +++ b/docs/resources/grant_privileges_to_role.md @@ -219,14 +219,14 @@ Optional: - `all` (Block List, Max: 1) Configures the privilege to be granted on all objects in eihter a database or schema. (see [below for nested schema](#nestedblock--on_schema_object--all)) - `future` (Block List, Max: 1) Configures the privilege to be granted on future objects in eihter a database or schema. (see [below for nested schema](#nestedblock--on_schema_object--future)) - `object_name` (String) The fully qualified name of the object on which privileges will be granted. -- `object_type` (String) The object type of the schema object on which privileges will be granted. Valid values are: USER | RESOURCE MONITOR | WAREHOUSE | DATABASE | INTEGRATION | FAILOVER GROUP | REPLICATION GROUP +- `object_type` (String) The object type of the schema object on which privileges will be granted. Valid values are: ALERT | EVENT TABLE | FILE FORMAT | FUNCTION | PROCEDURE | SECRET | SEQUENCE | PIPE | MASKING POLICY | PASSWORD POLICY | ROW ACCESS POLICY | SESSION POLICY | TAG | STAGE | STREAM | TABLE | EXTERNAL TABLE | TASK | VIEW | MATERIALIZED VIEW ### Nested Schema for `on_schema_object.all` Required: -- `object_type_plural` (String) The plural object type of the schema object on which privileges will be granted. Valid values are: USER | RESOURCE MONITOR | WAREHOUSE | DATABASE | INTEGRATION | FAILOVER GROUP | REPLICATION GROUP +- `object_type_plural` (String) The plural object type of the schema object on which privileges will be granted. Valid values are: ALERTS | EVENT TABLES | FILE FORMATS | FUNCTIONS | PROCEDURES | SECRETS | SEQUENCES | PIPES | MASKING POLICIES | PASSWORD POLICIES | ROW ACCESS POLICIES | SESSION POLICIES | TAGS | STAGES | STREAMS | TABLES | EXTERNAL TABLES | TASKS | VIEWS | MATERIALIZED VIEWS Optional: @@ -239,7 +239,7 @@ Optional: Required: -- `object_type_plural` (String) The plural object type of the schema object on which privileges will be granted. Valid values are: USER | RESOURCE MONITOR | WAREHOUSE | DATABASE | INTEGRATION | FAILOVER GROUP | REPLICATION GROUP +- `object_type_plural` (String) The plural object type of the schema object on which privileges will be granted. Valid values are: ALERTS | EVENT TABLES | FILE FORMATS | FUNCTIONS | PROCEDURES | SECRETS | SEQUENCES | PIPES | MASKING POLICIES | PASSWORD POLICIES | ROW ACCESS POLICIES | SESSION POLICIES | TAGS | STAGES | STREAMS | TABLES | EXTERNAL TABLES | TASKS | VIEWS | MATERIALIZED VIEWS Optional: diff --git a/pkg/resources/grant_privileges_to_role.go b/pkg/resources/grant_privileges_to_role.go index 410d747b47..b19e4c59b6 100644 --- a/pkg/resources/grant_privileges_to_role.go +++ b/pkg/resources/grant_privileges_to_role.go @@ -119,7 +119,7 @@ var grantPrivilegesToRoleSchema = map[string]*schema.Schema{ "object_type": { Type: schema.TypeString, Optional: true, - Description: "The object type of the schema object on which privileges will be granted. Valid values are: USER | RESOURCE MONITOR | WAREHOUSE | DATABASE | INTEGRATION | FAILOVER GROUP | REPLICATION GROUP", + Description: "The object type of the schema object on which privileges will be granted. Valid values are: ALERT | EVENT TABLE | FILE FORMAT | FUNCTION | PROCEDURE | SECRET | SEQUENCE | PIPE | MASKING POLICY | PASSWORD POLICY | ROW ACCESS POLICY | SESSION POLICY | TAG | STAGE | STREAM | TABLE | EXTERNAL TABLE | TASK | VIEW | MATERIALIZED VIEW", RequiredWith: []string{"on_schema_object.0.object_name"}, ConflictsWith: []string{"on_schema_object.0.all", "on_schema_object.0.future"}, ForceNew: true, @@ -140,6 +140,7 @@ var grantPrivilegesToRoleSchema = map[string]*schema.Schema{ "STAGE", "STREAM", "TABLE", + "EXTERNAL TABLE", "TASK", "VIEW", "MATERIALIZED VIEW", @@ -164,7 +165,7 @@ var grantPrivilegesToRoleSchema = map[string]*schema.Schema{ "object_type_plural": { Type: schema.TypeString, Required: true, - Description: "The plural object type of the schema object on which privileges will be granted. Valid values are: USER | RESOURCE MONITOR | WAREHOUSE | DATABASE | INTEGRATION | FAILOVER GROUP | REPLICATION GROUP", + Description: "The plural object type of the schema object on which privileges will be granted. Valid values are: ALERTS | EVENT TABLES | FILE FORMATS | FUNCTIONS | PROCEDURES | SECRETS | SEQUENCES | PIPES | MASKING POLICIES | PASSWORD POLICIES | ROW ACCESS POLICIES | SESSION POLICIES | TAGS | STAGES | STREAMS | TABLES | EXTERNAL TABLES | TASKS | VIEWS | MATERIALIZED VIEWS", ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ "ALERTS", @@ -183,6 +184,7 @@ var grantPrivilegesToRoleSchema = map[string]*schema.Schema{ "STAGES", "STREAMS", "TABLES", + "EXTERNAL TABLES", "TASKS", "VIEWS", "MATERIALIZED VIEWS", @@ -216,7 +218,7 @@ var grantPrivilegesToRoleSchema = map[string]*schema.Schema{ "object_type_plural": { Type: schema.TypeString, Required: true, - Description: "The plural object type of the schema object on which privileges will be granted. Valid values are: USER | RESOURCE MONITOR | WAREHOUSE | DATABASE | INTEGRATION | FAILOVER GROUP | REPLICATION GROUP", + Description: "The plural object type of the schema object on which privileges will be granted. Valid values are: ALERTS | EVENT TABLES | FILE FORMATS | FUNCTIONS | PROCEDURES | SECRETS | SEQUENCES | PIPES | MASKING POLICIES | PASSWORD POLICIES | ROW ACCESS POLICIES | SESSION POLICIES | TAGS | STAGES | STREAMS | TABLES | EXTERNAL TABLES | TASKS | VIEWS | MATERIALIZED VIEWS", ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ "ALERTS", @@ -235,6 +237,7 @@ var grantPrivilegesToRoleSchema = map[string]*schema.Schema{ "STAGES", "STREAMS", "TABLES", + "EXTERNAL TABLES", "TASKS", "VIEWS", "MATERIALIZED VIEWS", @@ -842,7 +845,8 @@ func readAccountRoleGrantPrivileges(ctx context.Context, client *sdk.Client, gra if !id.Future && grant.GrantedBy.Name() == "" { continue } - if grantedOn == grant.GrantedOn { + // grant_on is for future grants, granted_on is for current grants. They function the same way though in a test for matching the object type + if grantedOn == grant.GrantedOn || grantedOn == grant.GrantOn { privileges = append(privileges, grant.Privilege) } } diff --git a/pkg/resources/grant_privileges_to_role_acceptance_test.go b/pkg/resources/grant_privileges_to_role_acceptance_test.go index 749880c633..c6f1f35232 100644 --- a/pkg/resources/grant_privileges_to_role_acceptance_test.go +++ b/pkg/resources/grant_privileges_to_role_acceptance_test.go @@ -763,13 +763,13 @@ func grantPrivilegesToRole_onSchemaObject_futureInSchema(name string, privileges func TestAccGrantPrivilegesToRole_onSchemaObject_futureInDatabase(t *testing.T) { name := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) - + objectType := "TABLES" resource.ParallelTest(t, resource.TestCase{ Providers: providers(), CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: grantPrivilegesToRole_onSchemaObject_futureInDatabase(name, []string{"SELECT", "REFERENCES"}), + Config: grantPrivilegesToRole_onSchemaObject_futureInDatabase(name, objectType, []string{"SELECT", "REFERENCES"}), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "role_name", name), resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "on_schema_object.#", "1"), @@ -783,7 +783,7 @@ func TestAccGrantPrivilegesToRole_onSchemaObject_futureInDatabase(t *testing.T) }, // REMOVE PRIVILEGE { - Config: grantPrivilegesToRole_onSchemaObject_futureInDatabase(name, []string{"SELECT"}), + Config: grantPrivilegesToRole_onSchemaObject_futureInDatabase(name, objectType, []string{"SELECT"}), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "role_name", name), resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "privileges.#", "1"), @@ -800,7 +800,7 @@ func TestAccGrantPrivilegesToRole_onSchemaObject_futureInDatabase(t *testing.T) }) } -func grantPrivilegesToRole_onSchemaObject_futureInDatabase(name string, privileges []string) string { +func grantPrivilegesToRole_onSchemaObject_futureInDatabase(name string, objectType string, privileges []string) string { doubleQuotePrivileges := make([]string, len(privileges)) for i, p := range privileges { doubleQuotePrivileges[i] = fmt.Sprintf(`"%v"`, p) @@ -826,12 +826,12 @@ func grantPrivilegesToRole_onSchemaObject_futureInDatabase(name string, privileg privileges = [%s] on_schema_object { future { - object_type_plural = "TABLES" + object_type_plural = "%s" in_database = snowflake_database.d.name } } } - `, name, name, name, privilegesString) + `, name, name, name, privilegesString, objectType) } func TestAccGrantPrivilegesToRole_multipleResources(t *testing.T) { @@ -901,3 +901,42 @@ func grantPrivilegesToRole_multipleResources(name string, privileges1, privilege } `, name, privilegesString1, privilegesString2) } + +func TestAccGrantPrivilegesToRole_onSchemaObject_futureInDatabase_externalTable(t *testing.T) { + name := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)) + objectType := "EXTERNAL TABLES" + resource.ParallelTest(t, resource.TestCase{ + Providers: providers(), + CheckDestroy: nil, + Steps: []resource.TestStep{ + { + Config: grantPrivilegesToRole_onSchemaObject_futureInDatabase(name, objectType, []string{"SELECT", "REFERENCES"}), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "role_name", name), + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "on_schema_object.#", "1"), + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "on_schema_object.0.future.#", "1"), + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "on_schema_object.0.future.0.object_type_plural", "EXTERNAL TABLES"), + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "on_schema_object.0.future.0.in_database", name), + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "privileges.#", "2"), + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "privileges.0", "REFERENCES"), + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "privileges.1", "SELECT"), + ), + }, + // REMOVE PRIVILEGE + { + Config: grantPrivilegesToRole_onSchemaObject_futureInDatabase(name, objectType, []string{"SELECT"}), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "role_name", name), + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "privileges.#", "1"), + resource.TestCheckResourceAttr("snowflake_grant_privileges_to_role.g", "privileges.0", "SELECT"), + ), + }, + // IMPORT + { + ResourceName: "snowflake_grant_privileges_to_role.g", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/pkg/sdk/grants.go b/pkg/sdk/grants.go index c6977940b6..5bc3f9e9b9 100644 --- a/pkg/sdk/grants.go +++ b/pkg/sdk/grants.go @@ -26,6 +26,7 @@ type Grant struct { CreatedOn time.Time Privilege string GrantedOn ObjectType + GrantOn ObjectType Name ObjectIdentifier GrantedTo ObjectType GranteeName AccountObjectIdentifier @@ -50,7 +51,7 @@ type grantRow struct { } func (row *grantRow) toGrant() (*Grant, error) { - grantedTo := ObjectType(row.GrantedTo) + grantedTo := ObjectType(strings.ReplaceAll(row.GrantedTo, "_", " ")) granteeName := NewAccountObjectIdentifier(row.GranteeName) if grantedTo == ObjectTypeShare { parts := strings.Split(row.GranteeName, ".") @@ -60,16 +61,20 @@ func (row *grantRow) toGrant() (*Grant, error) { grant := &Grant{ CreatedOn: row.CreatedOn, Privilege: row.Privilege, - GrantedOn: ObjectType(row.GrantedOn), GrantedTo: grantedTo, Name: NewAccountObjectIdentifier(strings.Trim(row.Name, "\"")), GranteeName: granteeName, GrantOption: row.GrantOption, GrantedBy: NewAccountObjectIdentifier(row.GrantedBy), } + + // true for current grants + if row.GrantedOn != "" { + grant.GrantedOn = ObjectType(strings.ReplaceAll(row.GrantedOn, "_", " ")) + } // true for future grants if row.GrantOn != "" { - grant.GrantedOn = ObjectType(row.GrantOn) + grant.GrantOn = ObjectType(strings.ReplaceAll(row.GrantOn, "_", " ")) } return grant, nil } diff --git a/pkg/sdk/grants_integration_test.go b/pkg/sdk/grants_integration_test.go index 15ab065d40..e011ebc042 100644 --- a/pkg/sdk/grants_integration_test.go +++ b/pkg/sdk/grants_integration_test.go @@ -174,6 +174,46 @@ func TestInt_GrantAndRevokePrivilegesToAccountRole(t *testing.T) { require.NoError(t, err) assert.Equal(t, 0, len(grants)) }) + + t.Run("on future schema object", func(t *testing.T) { + roleTest, roleCleanup := createRole(t, client) + t.Cleanup(roleCleanup) + databaseTest, databaseCleanup := createDatabase(t, client) + t.Cleanup(databaseCleanup) + privileges := &AccountRoleGrantPrivileges{ + SchemaObjectPrivileges: []SchemaObjectPrivilege{SchemaObjectPrivilegeSelect}, + } + on := &AccountRoleGrantOn{ + SchemaObject: &GrantOnSchemaObject{ + Future: &GrantOnSchemaObjectIn{ + PluralObjectType: PluralObjectTypeExternalTables, + InDatabase: Pointer(databaseTest.ID()), + }, + }, + } + err := client.Grants.GrantPrivilegesToAccountRole(ctx, privileges, on, roleTest.ID(), nil) + require.NoError(t, err) + grants, err := client.Grants.Show(ctx, &ShowGrantOptions{ + Future: Bool(true), + To: &ShowGrantsTo{ + Role: roleTest.ID(), + }, + }) + require.NoError(t, err) + assert.Equal(t, 1, len(grants)) + assert.Equal(t, SchemaObjectPrivilegeSelect.String(), grants[0].Privilege) + + // now revoke and verify that the grant(s) are gone + err = client.Grants.RevokePrivilegesFromAccountRole(ctx, privileges, on, roleTest.ID(), nil) + require.NoError(t, err) + grants, err = client.Grants.Show(ctx, &ShowGrantOptions{ + To: &ShowGrantsTo{ + Role: roleTest.ID(), + }, + }) + require.NoError(t, err) + assert.Equal(t, 0, len(grants)) + }) } func TestInt_GrantPrivilegeToShare(t *testing.T) { diff --git a/pkg/sdk/object_types.go b/pkg/sdk/object_types.go index 72798cbdb1..102c4f00c9 100644 --- a/pkg/sdk/object_types.go +++ b/pkg/sdk/object_types.go @@ -16,27 +16,48 @@ type Object struct { type ObjectType string const ( - ObjectTypeAccount ObjectType = "ACCOUNT" - ObjectTypeAlert ObjectType = "ALERT" - ObjectTypeAccountParameter ObjectType = "ACCOUNT PARAMETER" - ObjectTypeDatabase ObjectType = "DATABASE" - ObjectTypeFailoverGroup ObjectType = "FAILOVER GROUP" - ObjectTypeFileFormat ObjectType = "FILE FORMAT" - ObjectTypeIntegration ObjectType = "INTEGRATION" - ObjectTypeMaskingPolicy ObjectType = "MASKING POLICY" - ObjectTypeNetworkPolicy ObjectType = "NETWORK POLICY" - ObjectTypePasswordPolicy ObjectType = "PASSWORD POLICY" - ObjectTypeReplicationGroup ObjectType = "REPLICATION GROUP" - ObjectTypeResourceMonitor ObjectType = "RESOURCE MONITOR" - ObjectTypeRole ObjectType = "ROLE" - ObjectTypeSchema ObjectType = "SCHEMA" - ObjectTypeSessionPolicy ObjectType = "SESSION POLICY" - ObjectTypeShare ObjectType = "SHARE" - ObjectTypeTable ObjectType = "TABLE" - ObjectTypeTag ObjectType = "TAG" - ObjectTypeTask ObjectType = "TASK" - ObjectTypeUser ObjectType = "USER" - ObjectTypeWarehouse ObjectType = "WAREHOUSE" + ObjectTypeAccount ObjectType = "ACCOUNT" + ObjectTypeManagedAccount ObjectType = "MANAGED ACCOUNT" + ObjectTypeUser ObjectType = "USER" + ObjectTypeDatabaseRole ObjectType = "DATABASE ROLE" + ObjectTypeRole ObjectType = "ROLE" + ObjectTypeIntegration ObjectType = "INTEGRATION" + ObjectTypeNetworkPolicy ObjectType = "NETWORK POLICY" + ObjectTypePasswordPolicy ObjectType = "PASSWORD POLICY" + ObjectTypeSessionPolicy ObjectType = "SESSION POLICY" + ObjectTypeReplicationGroup ObjectType = "REPLICATION GROUP" + ObjectTypeFailoverGroup ObjectType = "FAILOVER GROUP" + ObjectTypeConnection ObjectType = "CONNECTION" + ObjectTypeParameter ObjectType = "PARAMETER" + ObjectTypeWarehouse ObjectType = "WAREHOUSE" + ObjectTypeResourceMonitor ObjectType = "RESOURCE MONITOR" + ObjectTypeDatabase ObjectType = "DATABASE" + ObjectTypeSchema ObjectType = "SCHEMA" + ObjectTypeShare ObjectType = "SHARE" + ObjectTypeTable ObjectType = "TABLE" + ObjectTypeDynamicTable ObjectType = "DYNAMIC TABLE" + ObjectTypeExternalTable ObjectType = "EXTERNAL TABLE" + ObjectTypeEventTable ObjectType = "EVENT TABLE" + ObjectTypeView ObjectType = "VIEW" + ObjectTypeMaterializedView ObjectType = "MATERIALIZED VIEW" + ObjectTypeSequence ObjectType = "SEQUENCE" + ObjectTypeFunction ObjectType = "FUNCTION" + ObjectTypeExternalFunction ObjectType = "EXTERNAL FUNCTION" + ObjectTypeProcedure ObjectType = "PROCEDURE" + ObjectTypeStream ObjectType = "STREAM" + ObjectTypeTask ObjectType = "TASK" + ObjectTypeMaskingPolicy ObjectType = "MASKING POLICY" + ObjectTypeRowAccessPolicy ObjectType = "ROW ACCESS POLICY" + ObjectTypeTag ObjectType = "TAG" + ObjectTypeSecret ObjectType = "SECRET" + ObjectTypeStage ObjectType = "STAGE" + ObjectTypeFileFormat ObjectType = "FILE FORMAT" + ObjectTypePipe ObjectType = "PIPE" + ObjectTypeAlert ObjectType = "ALERT" + ObjectTypeApplication ObjectType = "APPLICATION" + ObjectTypeApplicationPackage ObjectType = "APPLICATION PACKAGE" + ObjectTypeApplicationRole ObjectType = "APPLICATION ROLE" + ObjectTypeStreamlit ObjectType = "STREAMLIT" ) func (o ObjectType) String() string { @@ -45,24 +66,48 @@ func (o ObjectType) String() string { func objectTypeSingularToPluralMap() map[ObjectType]PluralObjectType { return map[ObjectType]PluralObjectType{ - ObjectTypeAccountParameter: PluralObjectTypeAccountParameters, - ObjectTypeDatabase: PluralObjectTypeDatabases, - ObjectTypeFailoverGroup: PluralObjectTypeTypeFailoverGroups, - ObjectTypeIntegration: PluralObjectTypeIntegrations, - ObjectTypeMaskingPolicy: PluralObjectTypeMaskingPolicies, - ObjectTypeNetworkPolicy: PluralObjectTypeNetworkPolicies, - ObjectTypePasswordPolicy: PluralObjectTypePasswordPolicies, - ObjectTypeReplicationGroup: PluralObjectTypeReplicationGroups, - ObjectTypeResourceMonitor: PluralObjectTypeResourceMonitors, - ObjectTypeRole: PluralObjectTypeRoles, - ObjectTypeSchema: PluralObjectTypeSchemas, - ObjectTypeSessionPolicy: PluralObjectTypeSessionPolicies, - ObjectTypeShare: PluralObjectTypeShares, - ObjectTypeTable: PluralObjectTypeTables, - ObjectTypeTag: PluralObjectTypeTags, - ObjectTypeTask: PluralObjectTypeTasks, - ObjectTypeUser: PluralObjectTypeUsers, - ObjectTypeWarehouse: PluralObjectTypeWarehouses, + ObjectTypeAccount: PluralObjectTypeAccounts, + ObjectTypeManagedAccount: PluralObjectTypeManagedAccounts, + ObjectTypeUser: PluralObjectTypeUsers, + ObjectTypeDatabaseRole: PluralObjectTypeDatabaseRoles, + ObjectTypeRole: PluralObjectTypeRoles, + ObjectTypeIntegration: PluralObjectTypeIntegrations, + ObjectTypeNetworkPolicy: PluralObjectTypeNetworkPolicies, + ObjectTypePasswordPolicy: PluralObjectTypePasswordPolicies, + ObjectTypeSessionPolicy: PluralObjectTypeSessionPolicies, + ObjectTypeReplicationGroup: PluralObjectTypeReplicationGroups, + ObjectTypeFailoverGroup: PluralObjectTypeFailoverGroups, + ObjectTypeConnection: PluralObjectTypeConnections, + ObjectTypeParameter: PluralObjectTypeParameters, + ObjectTypeWarehouse: PluralObjectTypeWarehouses, + ObjectTypeResourceMonitor: PluralObjectTypeResourceMonitors, + ObjectTypeDatabase: PluralObjectTypeDatabases, + ObjectTypeSchema: PluralObjectTypeSchemas, + ObjectTypeShare: PluralObjectTypeShares, + ObjectTypeTable: PluralObjectTypeTables, + ObjectTypeDynamicTable: PluralObjectTypeDynamicTables, + ObjectTypeExternalTable: PluralObjectTypeExternalTables, + ObjectTypeEventTable: PluralObjectTypeEventTables, + ObjectTypeView: PluralObjectTypeViews, + ObjectTypeMaterializedView: PluralObjectTypeMaterializedViews, + ObjectTypeSequence: PluralObjectTypeSequences, + ObjectTypeFunction: PluralObjectTypeFunctions, + ObjectTypeExternalFunction: PluralObjectTypeExternalFunctions, + ObjectTypeProcedure: PluralObjectTypeProcedures, + ObjectTypeStream: PluralObjectTypeStreams, + ObjectTypeTask: PluralObjectTypeTasks, + ObjectTypeMaskingPolicy: PluralObjectTypeMaskingPolicies, + ObjectTypeRowAccessPolicy: PluralObjectTypeRowAccessPolicies, + ObjectTypeTag: PluralObjectTypeTags, + ObjectTypeSecret: PluralObjectTypeSecrets, + ObjectTypeStage: PluralObjectTypeStages, + ObjectTypeFileFormat: PluralObjectTypeFileFormats, + ObjectTypePipe: PluralObjectTypePipes, + ObjectTypeAlert: PluralObjectTypeAlerts, + ObjectTypeApplication: PluralObjectTypeApplications, + ObjectTypeApplicationPackage: PluralObjectTypeApplicationPackages, + ObjectTypeApplicationRole: PluralObjectTypeApplicationRoles, + ObjectTypeStreamlit: PluralObjectTypeStreamlits, } } @@ -83,8 +128,8 @@ func (o ObjectType) Plural() PluralObjectType { // GetObjectIdentifier returns the ObjectIdentifier for the ObjectType and fully qualified name. func (o ObjectType) GetObjectIdentifier(fullyQualifiedName string) ObjectIdentifier { - accountIdentifiers := []ObjectType{ - ObjectTypeAccountParameter, + accountObjectIdentifiers := []ObjectType{ + ObjectTypeParameter, ObjectTypeDatabase, ObjectTypeFailoverGroup, ObjectTypeIntegration, @@ -94,7 +139,7 @@ func (o ObjectType) GetObjectIdentifier(fullyQualifiedName string) ObjectIdentif ObjectTypeUser, ObjectTypeWarehouse, } - if slices.Contains(accountIdentifiers, o) { + if slices.Contains(accountObjectIdentifiers, o) { return NewAccountObjectIdentifier(fullyQualifiedName) } parts := strings.Split(fullyQualifiedName, ".") @@ -111,24 +156,48 @@ func (o ObjectType) GetObjectIdentifier(fullyQualifiedName string) ObjectIdentif type PluralObjectType string const ( - PluralObjectTypeAccountParameters PluralObjectType = "ACCOUNT PARAMETERS" - PluralObjectTypeDatabases PluralObjectType = "DATABASES" - PluralObjectTypeTypeFailoverGroups PluralObjectType = "FAILOVER GROUPS" - PluralObjectTypeIntegrations PluralObjectType = "INTEGRATIONS" - PluralObjectTypeMaskingPolicies PluralObjectType = "MASKING POLICIES" - PluralObjectTypeNetworkPolicies PluralObjectType = "NETWORK POLICIES" - PluralObjectTypePasswordPolicies PluralObjectType = "PASSWORD POLICIES" - PluralObjectTypeReplicationGroups PluralObjectType = "REPLICATION GROUPS" - PluralObjectTypeResourceMonitors PluralObjectType = "RESOURCE MONITORS" - PluralObjectTypeRoles PluralObjectType = "ROLES" - PluralObjectTypeSchemas PluralObjectType = "SCHEMAS" - PluralObjectTypeSessionPolicies PluralObjectType = "SESSION POLICIES" - PluralObjectTypeShares PluralObjectType = "SHARES" - PluralObjectTypeTables PluralObjectType = "TABLES" - PluralObjectTypeTags PluralObjectType = "TAGS" - PluralObjectTypeTasks PluralObjectType = "TASKS" - PluralObjectTypeUsers PluralObjectType = "USERS" - PluralObjectTypeWarehouses PluralObjectType = "WAREHOUSES" + PluralObjectTypeAccounts PluralObjectType = "ACCOUNTS" + PluralObjectTypeManagedAccounts PluralObjectType = "MANAGED ACCOUNTS" + PluralObjectTypeUsers PluralObjectType = "USERS" + PluralObjectTypeDatabaseRoles PluralObjectType = "DATABASE ROLES" + PluralObjectTypeRoles PluralObjectType = "ROLES" + PluralObjectTypeIntegrations PluralObjectType = "INTEGRATIONS" + PluralObjectTypeNetworkPolicies PluralObjectType = "NETWORK POLICIES" + PluralObjectTypePasswordPolicies PluralObjectType = "PASSWORD POLICIES" + PluralObjectTypeSessionPolicies PluralObjectType = "SESSION POLICIES" + PluralObjectTypeReplicationGroups PluralObjectType = "REPLICATION GROUPS" + PluralObjectTypeFailoverGroups PluralObjectType = "FAILOVER GROUPS" + PluralObjectTypeConnections PluralObjectType = "CONNECTIONS" + PluralObjectTypeParameters PluralObjectType = "PARAMETERS" + PluralObjectTypeWarehouses PluralObjectType = "WAREHOUSES" + PluralObjectTypeResourceMonitors PluralObjectType = "RESOURCE MONITORS" + PluralObjectTypeDatabases PluralObjectType = "DATABASES" + PluralObjectTypeSchemas PluralObjectType = "SCHEMAS" + PluralObjectTypeShares PluralObjectType = "SHARES" + PluralObjectTypeTables PluralObjectType = "TABLES" + PluralObjectTypeDynamicTables PluralObjectType = "DYNAMIC TABLES" + PluralObjectTypeExternalTables PluralObjectType = "EXTERNAL TABLES" + PluralObjectTypeEventTables PluralObjectType = "EVENT TABLES" + PluralObjectTypeViews PluralObjectType = "VIEWS" + PluralObjectTypeMaterializedViews PluralObjectType = "MATERIALIZED VIEWS" + PluralObjectTypeSequences PluralObjectType = "SEQUENCES" + PluralObjectTypeFunctions PluralObjectType = "FUNCTIONS" + PluralObjectTypeExternalFunctions PluralObjectType = "EXTERNAL FUNCTIONS" + PluralObjectTypeProcedures PluralObjectType = "PROCEDURES" + PluralObjectTypeStreams PluralObjectType = "STREAMS" + PluralObjectTypeTasks PluralObjectType = "TASKS" + PluralObjectTypeMaskingPolicies PluralObjectType = "MASKING POLICIES" + PluralObjectTypeRowAccessPolicies PluralObjectType = "ROW ACCESS POLICIES" + PluralObjectTypeTags PluralObjectType = "TAGS" + PluralObjectTypeSecrets PluralObjectType = "SECRETS" + PluralObjectTypeStages PluralObjectType = "STAGES" + PluralObjectTypeFileFormats PluralObjectType = "FILE FORMATS" + PluralObjectTypePipes PluralObjectType = "PIPES" + PluralObjectTypeAlerts PluralObjectType = "ALERTS" + PluralObjectTypeApplications PluralObjectType = "APPLICATIONS" + PluralObjectTypeApplicationPackages PluralObjectType = "APPLICATION PACKAGES" + PluralObjectTypeApplicationRoles PluralObjectType = "APPLICATION ROLES" + PluralObjectTypeStreamlits PluralObjectType = "STREAMLITS" ) func (p PluralObjectType) String() string {