diff --git a/pkg/datasources/materialized_views.go b/pkg/datasources/materialized_views.go index 9724e9a560..a462ed1551 100644 --- a/pkg/datasources/materialized_views.go +++ b/pkg/datasources/materialized_views.go @@ -68,7 +68,7 @@ func ReadMaterializedViews(ctx context.Context, d *schema.ResourceData, meta any schemaId := sdk.NewDatabaseObjectIdentifier(databaseName, schemaName) extractedMaterializedViews, err := client.MaterializedViews.Show(ctx, sdk.NewShowMaterializedViewRequest().WithIn( - &sdk.In{Schema: schemaId}, + sdk.In{Schema: schemaId}, )) if err != nil { log.Printf("[DEBUG] failed when searching materialized views in schema (%s), err = %s", schemaId.FullyQualifiedName(), err.Error()) diff --git a/pkg/datasources/row_access_policies.go b/pkg/datasources/row_access_policies.go index a5cd35ee87..18fc3c148b 100644 --- a/pkg/datasources/row_access_policies.go +++ b/pkg/datasources/row_access_policies.go @@ -128,12 +128,12 @@ func ReadRowAccessPolicies(ctx context.Context, d *schema.ResourceData, meta any if v, ok := d.GetOk("in"); ok { in := v.([]any)[0].(map[string]any) if v, ok := in["account"]; ok && v.(bool) { - req.WithIn(&sdk.ExtendedIn{In: sdk.In{Account: sdk.Bool(true)}}) + req.WithIn(sdk.ExtendedIn{In: sdk.In{Account: sdk.Bool(true)}}) } if v, ok := in["database"]; ok { database := v.(string) if database != "" { - req.WithIn(&sdk.ExtendedIn{In: sdk.In{Database: sdk.NewAccountObjectIdentifier(database)}}) + req.WithIn(sdk.ExtendedIn{In: sdk.In{Database: sdk.NewAccountObjectIdentifier(database)}}) } } if v, ok := in["schema"]; ok { @@ -143,7 +143,7 @@ func ReadRowAccessPolicies(ctx context.Context, d *schema.ResourceData, meta any if err != nil { return diag.FromErr(err) } - req.WithIn(&sdk.ExtendedIn{In: sdk.In{Schema: schemaId}}) + req.WithIn(sdk.ExtendedIn{In: sdk.In{Schema: schemaId}}) } } if v, ok := in["application"]; ok { @@ -159,7 +159,7 @@ func ReadRowAccessPolicies(ctx context.Context, d *schema.ResourceData, meta any } if likePattern, ok := d.GetOk("like"); ok { - req.WithLike(&sdk.Like{ + req.WithLike(sdk.Like{ Pattern: sdk.String(likePattern.(string)), }) } diff --git a/pkg/datasources/sequences.go b/pkg/datasources/sequences.go index e0d9b989e2..aa62caf826 100644 --- a/pkg/datasources/sequences.go +++ b/pkg/datasources/sequences.go @@ -65,7 +65,7 @@ func ReadSequences(ctx context.Context, d *schema.ResourceData, meta any) diag.D databaseName := d.Get("database").(string) schemaName := d.Get("schema").(string) - req := sdk.NewShowSequenceRequest().WithIn(&sdk.In{ + req := sdk.NewShowSequenceRequest().WithIn(sdk.In{ Schema: sdk.NewDatabaseObjectIdentifier(databaseName, schemaName), }) seqs, err := client.Sequences.Show(ctx, req) diff --git a/pkg/datasources/stages.go b/pkg/datasources/stages.go index bfbaa0997a..f79e0a7a00 100644 --- a/pkg/datasources/stages.go +++ b/pkg/datasources/stages.go @@ -73,7 +73,7 @@ func ReadStages(ctx context.Context, d *schema.ResourceData, meta any) diag.Diag schemaName := d.Get("schema").(string) stages, err := client.Stages.Show(ctx, sdk.NewShowStageRequest().WithIn( - &sdk.In{ + sdk.In{ Schema: sdk.NewDatabaseObjectIdentifier(databaseName, schemaName), }, )) diff --git a/pkg/sdk/api_integrations_def.go b/pkg/sdk/api_integrations_def.go index 9625b23e72..83b1c588e9 100644 --- a/pkg/sdk/api_integrations_def.go +++ b/pkg/sdk/api_integrations_def.go @@ -151,7 +151,9 @@ var ApiIntegrationsDef = g.NewInterface( SQL("API INTEGRATIONS"). OptionalLike(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, + ). DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-integration", diff --git a/pkg/sdk/api_integrations_dto_builders_gen.go b/pkg/sdk/api_integrations_dto_builders_gen.go index 82d05298d7..1af9f50bcf 100644 --- a/pkg/sdk/api_integrations_dto_builders_gen.go +++ b/pkg/sdk/api_integrations_dto_builders_gen.go @@ -243,8 +243,8 @@ func NewShowApiIntegrationRequest() *ShowApiIntegrationRequest { return &ShowApiIntegrationRequest{} } -func (s *ShowApiIntegrationRequest) WithLike(Like *Like) *ShowApiIntegrationRequest { - s.Like = Like +func (s *ShowApiIntegrationRequest) WithLike(Like Like) *ShowApiIntegrationRequest { + s.Like = &Like return s } diff --git a/pkg/sdk/api_integrations_impl_gen.go b/pkg/sdk/api_integrations_impl_gen.go index 6de2304572..7c7d8f60d8 100644 --- a/pkg/sdk/api_integrations_impl_gen.go +++ b/pkg/sdk/api_integrations_impl_gen.go @@ -38,9 +38,9 @@ func (v *apiIntegrations) Show(ctx context.Context, request *ShowApiIntegrationR } func (v *apiIntegrations) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*ApiIntegration, error) { - apiIntegrations, err := v.Show(ctx, NewShowApiIntegrationRequest().WithLike(&Like{ - Pattern: String(id.Name()), - })) + request := NewShowApiIntegrationRequest(). + WithLike(Like{Pattern: String(id.Name())}) + apiIntegrations, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/application_packages_def.go b/pkg/sdk/application_packages_def.go index 8f6bdbce65..6cf9cc3e51 100644 --- a/pkg/sdk/application_packages_def.go +++ b/pkg/sdk/application_packages_def.go @@ -163,4 +163,6 @@ var ApplicationPackagesDef = g.NewInterface( OptionalLike(). OptionalStartsWith(). OptionalLimit(), -).ShowByIdOperation() +).ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, +) diff --git a/pkg/sdk/application_packages_dto_builders_gen.go b/pkg/sdk/application_packages_dto_builders_gen.go index 36cbec358e..d9759675ed 100644 --- a/pkg/sdk/application_packages_dto_builders_gen.go +++ b/pkg/sdk/application_packages_dto_builders_gen.go @@ -275,8 +275,8 @@ func NewShowApplicationPackageRequest() *ShowApplicationPackageRequest { return &ShowApplicationPackageRequest{} } -func (s *ShowApplicationPackageRequest) WithLike(Like *Like) *ShowApplicationPackageRequest { - s.Like = Like +func (s *ShowApplicationPackageRequest) WithLike(Like Like) *ShowApplicationPackageRequest { + s.Like = &Like return s } diff --git a/pkg/sdk/application_packages_impl_gen.go b/pkg/sdk/application_packages_impl_gen.go index 36b23c8f47..12cd3ff0a6 100644 --- a/pkg/sdk/application_packages_impl_gen.go +++ b/pkg/sdk/application_packages_impl_gen.go @@ -38,7 +38,8 @@ func (v *applicationPackages) Show(ctx context.Context, request *ShowApplication } func (v *applicationPackages) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*ApplicationPackage, error) { - request := NewShowApplicationPackageRequest().WithLike(&Like{String(id.Name())}) + request := NewShowApplicationPackageRequest(). + WithLike(Like{Pattern: String(id.Name())}) applicationPackages, err := v.Show(ctx, request) if err != nil { return nil, err diff --git a/pkg/sdk/applications_def.go b/pkg/sdk/applications_def.go index d809e22d55..e03deba570 100644 --- a/pkg/sdk/applications_def.go +++ b/pkg/sdk/applications_def.go @@ -132,7 +132,9 @@ var ApplicationsDef = g.NewInterface( OptionalLike(). OptionalStartsWith(). OptionalLimit(), -).ShowByIdOperation().DescribeOperation( +).ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, +).DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-application", g.DbStruct("applicationPropertyRow"). diff --git a/pkg/sdk/applications_dto_builders_gen.go b/pkg/sdk/applications_dto_builders_gen.go index 8e20a566ab..398d48173f 100644 --- a/pkg/sdk/applications_dto_builders_gen.go +++ b/pkg/sdk/applications_dto_builders_gen.go @@ -184,8 +184,8 @@ func NewShowApplicationRequest() *ShowApplicationRequest { return &ShowApplicationRequest{} } -func (s *ShowApplicationRequest) WithLike(Like *Like) *ShowApplicationRequest { - s.Like = Like +func (s *ShowApplicationRequest) WithLike(Like Like) *ShowApplicationRequest { + s.Like = &Like return s } diff --git a/pkg/sdk/applications_impl_gen.go b/pkg/sdk/applications_impl_gen.go index dab57a9411..94000115d9 100644 --- a/pkg/sdk/applications_impl_gen.go +++ b/pkg/sdk/applications_impl_gen.go @@ -38,7 +38,8 @@ func (v *applications) Show(ctx context.Context, request *ShowApplicationRequest } func (v *applications) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*Application, error) { - request := NewShowApplicationRequest().WithLike(&Like{String(id.Name())}) + request := NewShowApplicationRequest(). + WithLike(Like{Pattern: String(id.Name())}) applications, err := v.Show(ctx, request) if err != nil { return nil, err diff --git a/pkg/sdk/authentication_policies_def.go b/pkg/sdk/authentication_policies_def.go index 9db18e06f4..7fb0a08d4f 100644 --- a/pkg/sdk/authentication_policies_def.go +++ b/pkg/sdk/authentication_policies_def.go @@ -170,7 +170,10 @@ var AuthenticationPoliciesDef = g.NewInterface( OptionalStartsWith(). OptionalLimit(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, + g.ShowByIDInFiltering, + ). DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-authentication-policy", diff --git a/pkg/sdk/authentication_policies_impl_gen.go b/pkg/sdk/authentication_policies_impl_gen.go index 5311be8ff0..163a80b27c 100644 --- a/pkg/sdk/authentication_policies_impl_gen.go +++ b/pkg/sdk/authentication_policies_impl_gen.go @@ -38,11 +38,10 @@ func (v *authenticationPolicies) Show(ctx context.Context, request *ShowAuthenti } func (v *authenticationPolicies) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*AuthenticationPolicy, error) { - authenticationPolicies, err := v.Show(ctx, NewShowAuthenticationPolicyRequest().WithIn(In{ - Schema: id.SchemaId(), - }).WithLike(Like{ - Pattern: String(id.Name()), - })) + request := NewShowAuthenticationPolicyRequest(). + WithLike(Like{Pattern: String(id.Name())}). + WithIn(In{Schema: id.SchemaId()}) + authenticationPolicies, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/cortex_search_services_def.go b/pkg/sdk/cortex_search_services_def.go index e59dbebee0..87f514d11f 100644 --- a/pkg/sdk/cortex_search_services_def.go +++ b/pkg/sdk/cortex_search_services_def.go @@ -77,7 +77,10 @@ var CortexSearchServiceDef = g.NewInterface( OptionalIn(). OptionalStartsWith(). OptionalLimitFrom(), -).ShowByIdOperation().DescribeOperation( +).ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, + g.ShowByIDInFiltering, +).DescribeOperation( g.DescriptionMappingKindSingleValue, "https://docs.snowflake.com/LIMITEDACCESS/cortex-search/sql/desc-cortex-search", g.DbStruct("cortexSearchServiceDetailsRow"). diff --git a/pkg/sdk/cortex_search_services_impl_gen.go b/pkg/sdk/cortex_search_services_impl_gen.go index 320a5eaf40..89fe180dce 100644 --- a/pkg/sdk/cortex_search_services_impl_gen.go +++ b/pkg/sdk/cortex_search_services_impl_gen.go @@ -35,8 +35,8 @@ func (v *cortexSearchServices) Show(ctx context.Context, request *ShowCortexSear func (v *cortexSearchServices) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*CortexSearchService, error) { request := NewShowCortexSearchServiceRequest(). - WithIn(In{Schema: id.SchemaId()}). - WithLike(Like{Pattern: String(id.Name())}) + WithLike(Like{Pattern: String(id.Name())}). + WithIn(In{Schema: id.SchemaId()}) cortexSearchServices, err := v.Show(ctx, request) if err != nil { return nil, err diff --git a/pkg/sdk/event_tables_def.go b/pkg/sdk/event_tables_def.go index 6345c411b5..595ada7cc2 100644 --- a/pkg/sdk/event_tables_def.go +++ b/pkg/sdk/event_tables_def.go @@ -102,7 +102,10 @@ var EventTablesDef = g.NewInterface( OptionalIn(). OptionalStartsWith(). OptionalLimit(), -).ShowByIdOperation().DescribeOperation( +).ShowByIdOperationWithFiltering( + g.ShowByIDInFiltering, + g.ShowByIDLikeFiltering, +).DescribeOperation( g.DescriptionMappingKindSingleValue, "https://docs.snowflake.com/en/sql-reference/sql/desc-event-table", g.DbStruct("eventTableDetailsRow"). diff --git a/pkg/sdk/event_tables_dto_builders_gen.go b/pkg/sdk/event_tables_dto_builders_gen.go index c7ab428c05..efb266fc22 100644 --- a/pkg/sdk/event_tables_dto_builders_gen.go +++ b/pkg/sdk/event_tables_dto_builders_gen.go @@ -74,13 +74,13 @@ func (s *ShowEventTableRequest) WithTerse(Terse *bool) *ShowEventTableRequest { return s } -func (s *ShowEventTableRequest) WithLike(Like *Like) *ShowEventTableRequest { - s.Like = Like +func (s *ShowEventTableRequest) WithLike(Like Like) *ShowEventTableRequest { + s.Like = &Like return s } -func (s *ShowEventTableRequest) WithIn(In *In) *ShowEventTableRequest { - s.In = In +func (s *ShowEventTableRequest) WithIn(In In) *ShowEventTableRequest { + s.In = &In return s } diff --git a/pkg/sdk/event_tables_impl_gen.go b/pkg/sdk/event_tables_impl_gen.go index 57b18fdbcb..676fc3d2b5 100644 --- a/pkg/sdk/event_tables_impl_gen.go +++ b/pkg/sdk/event_tables_impl_gen.go @@ -28,7 +28,9 @@ func (v *eventTables) Show(ctx context.Context, request *ShowEventTableRequest) } func (v *eventTables) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*EventTable, error) { - request := NewShowEventTableRequest().WithIn(&In{Schema: id.SchemaId()}).WithLike(&Like{String(id.Name())}) + request := NewShowEventTableRequest(). + WithIn(In{Schema: id.SchemaId()}). + WithLike(Like{Pattern: String(id.Name())}) eventTables, err := v.Show(ctx, request) if err != nil { return nil, err diff --git a/pkg/sdk/external_functions_def.go b/pkg/sdk/external_functions_def.go index af7aeee9de..1a4c87825b 100644 --- a/pkg/sdk/external_functions_def.go +++ b/pkg/sdk/external_functions_def.go @@ -149,7 +149,10 @@ var ExternalFunctionsDef = g.NewInterface( SQL("EXTERNAL FUNCTIONS"). OptionalLike(). OptionalIn(), -).ShowByIdOperation().DescribeOperation( +).ShowByIdOperationWithFiltering( + g.ShowByIDInFiltering, + g.ShowByIDLikeFiltering, +).DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-function", g.DbStruct("externalFunctionPropertyRow"). diff --git a/pkg/sdk/external_functions_impl_gen.go b/pkg/sdk/external_functions_impl_gen.go index 51831541f1..1200be62e6 100644 --- a/pkg/sdk/external_functions_impl_gen.go +++ b/pkg/sdk/external_functions_impl_gen.go @@ -35,7 +35,10 @@ func (v *externalFunctions) Show(ctx context.Context, request *ShowExternalFunct } func (v *externalFunctions) ShowByID(ctx context.Context, id SchemaObjectIdentifierWithArguments) (*ExternalFunction, error) { - externalFunctions, err := v.Show(ctx, NewShowExternalFunctionRequest().WithIn(In{Schema: id.SchemaId()}).WithLike(Like{String(id.Name())})) + request := NewShowExternalFunctionRequest(). + WithIn(In{Schema: id.SchemaId()}). + WithLike(Like{Pattern: String(id.Name())}) + externalFunctions, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/external_volumes_def.go b/pkg/sdk/external_volumes_def.go index ac6fb0124f..17c5e96f61 100644 --- a/pkg/sdk/external_volumes_def.go +++ b/pkg/sdk/external_volumes_def.go @@ -226,4 +226,6 @@ var ExternalVolumesDef = g.NewInterface( SQL("EXTERNAL VOLUMES"). OptionalLike(), ). - ShowByIdOperation() + ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, + ) diff --git a/pkg/sdk/functions_def.go b/pkg/sdk/functions_def.go index 1c92cd4078..44f3ed59de 100644 --- a/pkg/sdk/functions_def.go +++ b/pkg/sdk/functions_def.go @@ -355,7 +355,10 @@ var FunctionsDef = g.NewInterface( SQL("USER FUNCTIONS"). OptionalLike(). OptionalExtendedIn(), -).ShowByIdOperation().DescribeOperation( +).ShowByIdOperationWithFiltering( + g.ShowByIDExtendedInFiltering, + g.ShowByIDLikeFiltering, +).DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-function", g.DbStruct("functionDetailRow"). diff --git a/pkg/sdk/functions_impl_gen.go b/pkg/sdk/functions_impl_gen.go index 051a8fc994..831ebe07a9 100644 --- a/pkg/sdk/functions_impl_gen.go +++ b/pkg/sdk/functions_impl_gen.go @@ -60,7 +60,10 @@ func (v *functions) Show(ctx context.Context, request *ShowFunctionRequest) ([]F } func (v *functions) ShowByID(ctx context.Context, id SchemaObjectIdentifierWithArguments) (*Function, error) { - functions, err := v.Show(ctx, NewShowFunctionRequest().WithIn(ExtendedIn{In: In{Schema: id.SchemaId()}}).WithLike(Like{String(id.Name())})) + request := NewShowFunctionRequest(). + WithIn(ExtendedIn{In: In{Schema: id.SchemaId()}}). + WithLike(Like{Pattern: String(id.Name())}) + functions, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/managed_accounts_def.go b/pkg/sdk/managed_accounts_def.go index 2124b6e258..1f1958436b 100644 --- a/pkg/sdk/managed_accounts_def.go +++ b/pkg/sdk/managed_accounts_def.go @@ -67,4 +67,6 @@ var ManagedAccountsDef = g.NewInterface( SQL("MANAGED ACCOUNTS"). OptionalLike(), ). - ShowByIdOperation() + ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, + ) diff --git a/pkg/sdk/managed_accounts_dto_builders_gen.go b/pkg/sdk/managed_accounts_dto_builders_gen.go index 7523608a2d..51e8e7f87b 100644 --- a/pkg/sdk/managed_accounts_dto_builders_gen.go +++ b/pkg/sdk/managed_accounts_dto_builders_gen.go @@ -41,7 +41,7 @@ func NewShowManagedAccountRequest() *ShowManagedAccountRequest { return &ShowManagedAccountRequest{} } -func (s *ShowManagedAccountRequest) WithLike(Like *Like) *ShowManagedAccountRequest { - s.Like = Like +func (s *ShowManagedAccountRequest) WithLike(Like Like) *ShowManagedAccountRequest { + s.Like = &Like return s } diff --git a/pkg/sdk/managed_accounts_impl_gen.go b/pkg/sdk/managed_accounts_impl_gen.go index f7a93b05d6..6298acf743 100644 --- a/pkg/sdk/managed_accounts_impl_gen.go +++ b/pkg/sdk/managed_accounts_impl_gen.go @@ -33,7 +33,9 @@ func (v *managedAccounts) Show(ctx context.Context, request *ShowManagedAccountR } func (v *managedAccounts) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*ManagedAccount, error) { - managedAccounts, err := v.Show(ctx, NewShowManagedAccountRequest().WithLike(&Like{String(id.Name())})) + request := NewShowManagedAccountRequest(). + WithLike(Like{Pattern: String(id.Name())}) + managedAccounts, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/materialized_views_def.go b/pkg/sdk/materialized_views_def.go index fedef1d829..2d9018cafe 100644 --- a/pkg/sdk/materialized_views_def.go +++ b/pkg/sdk/materialized_views_def.go @@ -175,7 +175,10 @@ var MaterializedViewsDef = g.NewInterface( OptionalLike(). OptionalIn(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDInFiltering, + g.ShowByIDLikeFiltering, + ). DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-materialized-view", diff --git a/pkg/sdk/materialized_views_dto_builders_gen.go b/pkg/sdk/materialized_views_dto_builders_gen.go index 5f8852b106..580497dea6 100644 --- a/pkg/sdk/materialized_views_dto_builders_gen.go +++ b/pkg/sdk/materialized_views_dto_builders_gen.go @@ -222,13 +222,13 @@ func NewShowMaterializedViewRequest() *ShowMaterializedViewRequest { return &ShowMaterializedViewRequest{} } -func (s *ShowMaterializedViewRequest) WithLike(Like *Like) *ShowMaterializedViewRequest { - s.Like = Like +func (s *ShowMaterializedViewRequest) WithLike(Like Like) *ShowMaterializedViewRequest { + s.Like = &Like return s } -func (s *ShowMaterializedViewRequest) WithIn(In *In) *ShowMaterializedViewRequest { - s.In = In +func (s *ShowMaterializedViewRequest) WithIn(In In) *ShowMaterializedViewRequest { + s.In = &In return s } diff --git a/pkg/sdk/materialized_views_impl_gen.go b/pkg/sdk/materialized_views_impl_gen.go index 9f1393d30c..5700af27d0 100644 --- a/pkg/sdk/materialized_views_impl_gen.go +++ b/pkg/sdk/materialized_views_impl_gen.go @@ -39,7 +39,9 @@ func (v *materializedViews) Show(ctx context.Context, request *ShowMaterializedV } func (v *materializedViews) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*MaterializedView, error) { - request := NewShowMaterializedViewRequest().WithIn(&In{Schema: id.SchemaId()}).WithLike(&Like{String(id.Name())}) + request := NewShowMaterializedViewRequest(). + WithIn(In{Schema: id.SchemaId()}). + WithLike(Like{Pattern: String(id.Name())}) materializedViews, err := v.Show(ctx, request) if err != nil { return nil, err diff --git a/pkg/sdk/network_policies_def.go b/pkg/sdk/network_policies_def.go index 77692c4ef5..05bf8dbb42 100644 --- a/pkg/sdk/network_policies_def.go +++ b/pkg/sdk/network_policies_def.go @@ -143,7 +143,9 @@ var ( SQL("NETWORK POLICIES"). OptionalLike(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, + ). DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-network-policy", diff --git a/pkg/sdk/network_policies_impl_gen.go b/pkg/sdk/network_policies_impl_gen.go index 950b9491e3..8571dacd17 100644 --- a/pkg/sdk/network_policies_impl_gen.go +++ b/pkg/sdk/network_policies_impl_gen.go @@ -38,7 +38,9 @@ func (v *networkPolicies) Show(ctx context.Context, request *ShowNetworkPolicyRe } func (v *networkPolicies) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*NetworkPolicy, error) { - networkPolicies, err := v.Show(ctx, NewShowNetworkPolicyRequest().WithLike(Like{Pattern: String(id.Name())})) + request := NewShowNetworkPolicyRequest(). + WithLike(Like{Pattern: String(id.Name())}) + networkPolicies, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/network_rule_def.go b/pkg/sdk/network_rule_def.go index 6e5bf918e7..5968bbadd5 100644 --- a/pkg/sdk/network_rule_def.go +++ b/pkg/sdk/network_rule_def.go @@ -108,7 +108,10 @@ var NetworkRuleDef = g.NewInterface( OptionalStartsWith(). OptionalLimitFrom(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDInFiltering, + g.ShowByIDLikeFiltering, + ). DescribeOperation( g.DescriptionMappingKindSingleValue, "https://docs.snowflake.com/en/sql-reference/sql/desc-network-rule", diff --git a/pkg/sdk/network_rule_dto_builders_gen.go b/pkg/sdk/network_rule_dto_builders_gen.go index 553e648568..ab5c2e930c 100644 --- a/pkg/sdk/network_rule_dto_builders_gen.go +++ b/pkg/sdk/network_rule_dto_builders_gen.go @@ -95,13 +95,13 @@ func NewShowNetworkRuleRequest() *ShowNetworkRuleRequest { return &ShowNetworkRuleRequest{} } -func (s *ShowNetworkRuleRequest) WithLike(Like *Like) *ShowNetworkRuleRequest { - s.Like = Like +func (s *ShowNetworkRuleRequest) WithLike(Like Like) *ShowNetworkRuleRequest { + s.Like = &Like return s } -func (s *ShowNetworkRuleRequest) WithIn(In *In) *ShowNetworkRuleRequest { - s.In = In +func (s *ShowNetworkRuleRequest) WithIn(In In) *ShowNetworkRuleRequest { + s.In = &In return s } diff --git a/pkg/sdk/network_rule_impl_gen.go b/pkg/sdk/network_rule_impl_gen.go index a4f84e23ba..074376a37e 100644 --- a/pkg/sdk/network_rule_impl_gen.go +++ b/pkg/sdk/network_rule_impl_gen.go @@ -39,11 +39,10 @@ func (v *networkRules) Show(ctx context.Context, request *ShowNetworkRuleRequest } func (v *networkRules) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*NetworkRule, error) { - networkRules, err := v.Show(ctx, NewShowNetworkRuleRequest().WithIn(&In{ - Schema: id.SchemaId(), - }).WithLike(&Like{ - Pattern: String(id.Name()), - })) + request := NewShowNetworkRuleRequest(). + WithIn(In{Schema: id.SchemaId()}). + WithLike(Like{Pattern: String(id.Name())}) + networkRules, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/notification_integrations_def.go b/pkg/sdk/notification_integrations_def.go index 5af67bc681..23b6a80e1d 100644 --- a/pkg/sdk/notification_integrations_def.go +++ b/pkg/sdk/notification_integrations_def.go @@ -181,7 +181,9 @@ var NotificationIntegrationsDef = g.NewInterface( SQL("NOTIFICATION INTEGRATIONS"). OptionalLike(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, + ). DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-integration", diff --git a/pkg/sdk/notification_integrations_dto_builders_gen.go b/pkg/sdk/notification_integrations_dto_builders_gen.go index e7f8584b3e..a68b38b6fb 100644 --- a/pkg/sdk/notification_integrations_dto_builders_gen.go +++ b/pkg/sdk/notification_integrations_dto_builders_gen.go @@ -2,8 +2,6 @@ package sdk -import () - func NewCreateNotificationIntegrationRequest( name AccountObjectIdentifier, Enabled bool, @@ -275,8 +273,8 @@ func NewShowNotificationIntegrationRequest() *ShowNotificationIntegrationRequest return &ShowNotificationIntegrationRequest{} } -func (s *ShowNotificationIntegrationRequest) WithLike(Like *Like) *ShowNotificationIntegrationRequest { - s.Like = Like +func (s *ShowNotificationIntegrationRequest) WithLike(Like Like) *ShowNotificationIntegrationRequest { + s.Like = &Like return s } diff --git a/pkg/sdk/notification_integrations_impl_gen.go b/pkg/sdk/notification_integrations_impl_gen.go index aaf5f38433..5859ab27a1 100644 --- a/pkg/sdk/notification_integrations_impl_gen.go +++ b/pkg/sdk/notification_integrations_impl_gen.go @@ -38,9 +38,9 @@ func (v *notificationIntegrations) Show(ctx context.Context, request *ShowNotifi } func (v *notificationIntegrations) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*NotificationIntegration, error) { - notificationIntegrations, err := v.Show(ctx, NewShowNotificationIntegrationRequest().WithLike(&Like{ - Pattern: String(id.Name()), - })) + request := NewShowNotificationIntegrationRequest(). + WithLike(Like{Pattern: String(id.Name())}) + notificationIntegrations, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/poc/README.md b/pkg/sdk/poc/README.md index eabaf74e55..c7f24fd5f5 100644 --- a/pkg/sdk/poc/README.md +++ b/pkg/sdk/poc/README.md @@ -11,7 +11,9 @@ There is an example file ready for generation [database_role_def.go](example/dat - [database_role_validations_gen.go](example/database_role_validations_gen.go) - options structs validations - [database_role_impl_gen.go](example/database_role_impl_gen.go) - SDK interface implementation - [database_role_gen_test.go](example/database_role_gen_test.go) - unit tests placeholders with guidance comments (at least for now) -- [database_role_gen_integration_test.go](example/database_role_gen_integration_test.go) - integration test placeholder file + +Note: +- for now integration tests files are not generated and they have to be created manually in the `pkg/sdk/testint` directory ### How it works ##### Creating object generation definition @@ -49,10 +51,6 @@ also adding small changes is very challenging, e.g. for new validation rule you one new function, revert to old tests (the one with filled tests), copy new test case (of course we could add that one by hand but if we add one case, or modify more cases this becomes more challenging) - add support for Enums -- generate `ShowID` function with 3 implementation variations (the last one is the rarest one and can be postponed) - - use `Show` function with Like - - use Show without any options and filter with Go for + if - - in some cases we could need more filters -> see alerts.go (but we can implement it later) - handle arrays - handle more validation types - write new `valueSet` function (see validations.go) that will have better defaults or more parameters that will determine @@ -124,15 +122,6 @@ B := QueryStruct("B") ``` - cannot re-generate when client.go is using generated interface - spaces in templates (especially nested validations) -- request mapping fails (`.toOpts()`) when nested object is not optional (pointer) e.g. -```go -type NestedReq struct { -} - -type SomeReq struct { - NestedReq NestedReq // Not a pointer and in toOpts right now we're always do a check if req.NestedReq != nil which is not correct for non pointer type -} -``` ##### Known limitations - automatic array conversion is not recursive, so we're only supporting one level mapping diff --git a/pkg/sdk/poc/generator/operation.go b/pkg/sdk/poc/generator/operation.go index c8d0c7e422..dfc20ca034 100644 --- a/pkg/sdk/poc/generator/operation.go +++ b/pkg/sdk/poc/generator/operation.go @@ -161,12 +161,14 @@ func (i *Interface) ShowOperation(doc string, dbRepresentation *dbStruct, resour return i } -func (i *Interface) ShowByIdOperation() *Interface { +// ShowByIdOperationWithNoFiltering adds a ShowByID operation to the interface without any filtering. Should be used for objects that do not implement any filtering options. +func (i *Interface) ShowByIdOperationWithNoFiltering() *Interface { op := newNoSqlOperation(string(OperationKindShowByID)) i.Operations = append(i.Operations, op) return i } +// ShowByIdOperationWithFiltering adds a ShowByID operation to the interface with filtering. Should be used for objects that implement filtering options e.g. Like or In. func (i *Interface) ShowByIdOperationWithFiltering(filter ShowByIDFilteringKind, filtering ...ShowByIDFilteringKind) *Interface { op := newNoSqlOperation(string(OperationKindShowByID)) op.ObjectInterface = i diff --git a/pkg/sdk/poc/generator/show_by_id_filtering.go b/pkg/sdk/poc/generator/show_by_id_filtering.go index c80ec3aef3..646624b2ed 100644 --- a/pkg/sdk/poc/generator/show_by_id_filtering.go +++ b/pkg/sdk/poc/generator/show_by_id_filtering.go @@ -12,7 +12,6 @@ const ( ShowByIDInFiltering ShowByIDExtendedInFiltering ShowByIDApplicationNameFiltering - ShowByIDNoFiltering ) type idPrefix string @@ -58,10 +57,6 @@ func newShowByIDFiltering(name, kind, args string) ShowByIDFiltering { } } -func newShowByIDNoFiltering() ShowByIDFiltering { - return newShowByIDFiltering("NoFiltering", "", "") -} - func newShowByIDLikeFiltering() ShowByIDFiltering { return newShowByIDFiltering("Like", "Like", "Pattern: String(id.Name())") } @@ -103,8 +98,6 @@ func (s *Operation) withFiltering(filtering ...ShowByIDFilteringKind) *Operation s.ShowByIDFiltering = append(s.ShowByIDFiltering, newShowByIDLikeFiltering()) case ShowByIDApplicationNameFiltering: s.ShowByIDFiltering = append(s.ShowByIDFiltering, newShowByIDApplicationFiltering()) - case ShowByIDNoFiltering: - s.ShowByIDFiltering = []ShowByIDFiltering{newShowByIDNoFiltering()} default: log.Println("No showByID filtering found for kind:", filteringKind) } diff --git a/pkg/sdk/poc/generator/template_executors.go b/pkg/sdk/poc/generator/template_executors.go index 00b4678410..a2fba04cc7 100644 --- a/pkg/sdk/poc/generator/template_executors.go +++ b/pkg/sdk/poc/generator/template_executors.go @@ -92,11 +92,6 @@ func GenerateValidations(writer io.Writer, def *Interface) { printTo(writer, ValidationsTemplate, def) } -func GenerateIntegrationTests(writer io.Writer, def *Interface) { - generatePackageDirective(writer) - printTo(writer, IntegrationTestsTemplate, def) -} - func generatePackageDirective(writer io.Writer) { printTo(writer, PackageTemplate, os.Getenv("GOPACKAGE")) } diff --git a/pkg/sdk/poc/generator/templates.go b/pkg/sdk/poc/generator/templates.go index 8d7d6b52b4..8e0188bcb2 100644 --- a/pkg/sdk/poc/generator/templates.go +++ b/pkg/sdk/poc/generator/templates.go @@ -32,10 +32,6 @@ var ( dtoStructsTemplateContent string DtoDeclTemplate, _ = template.New("dtoTemplate").Parse(dtoStructsTemplateContent) - //go:embed templates/integration_tests.tmpl - integrationTestTemplateContent string - IntegrationTestsTemplate, _ = template.New("integrationTestsTemplate").Parse(integrationTestTemplateContent) - //go:embed templates/implementation.tmpl implementationTemplateContent string ImplementationTemplate *template.Template diff --git a/pkg/sdk/poc/generator/templates/integration_tests.tmpl b/pkg/sdk/poc/generator/templates/integration_tests.tmpl deleted file mode 100644 index f814ba6f31..0000000000 --- a/pkg/sdk/poc/generator/templates/integration_tests.tmpl +++ /dev/null @@ -1,13 +0,0 @@ -{{- /*gotype: github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/poc/generator.Interface*/ -}} - -import "testing" - -func TestInt_{{ .Name }}(t *testing.T) { -// TODO: prepare common resources - -{{ range .Operations }} - t.Run("{{ .Name }}", func(t *testing.T) { - // TODO: fill me - }) -{{ end -}} -} diff --git a/pkg/sdk/poc/generator/templates/sub_templates/implementation_functions.tmpl b/pkg/sdk/poc/generator/templates/sub_templates/implementation_functions.tmpl index 60b0cc7e0d..7c89cefa99 100644 --- a/pkg/sdk/poc/generator/templates/sub_templates/implementation_functions.tmpl +++ b/pkg/sdk/poc/generator/templates/sub_templates/implementation_functions.tmpl @@ -16,10 +16,8 @@ {{ else if eq .Name "ShowByID" }} func (v *{{ $impl }}) ShowByID(ctx context.Context, id {{ .ObjectInterface.IdentifierKind }}) (*{{ .ObjectInterface.NameSingular }}, error) { request := NewShow{{ .ObjectInterface.NameSingular }}Request() - {{- range .ShowByIDFiltering }} - {{- if not (eq .Name "NoFiltering") -}}. - {{ .WithFiltering }} - {{- end }} + {{- range .ShowByIDFiltering }}. + {{ .WithFiltering }} {{- end }} {{ $impl }}, err := v.Show(ctx, request) if err != nil { diff --git a/pkg/sdk/poc/main.go b/pkg/sdk/poc/main.go index d7fd8c094a..fb7596ec9b 100644 --- a/pkg/sdk/poc/main.go +++ b/pkg/sdk/poc/main.go @@ -57,6 +57,7 @@ func main() { // runAllTemplatesToStdOut(definition) runAllTemplatesAndSave(definition, file) + fmt.Println("Integration tests should be added manually to the pkg/sdk/testint/ directory") } func getDefinition(file string) *generator.Interface { @@ -94,7 +95,6 @@ func runAllTemplatesToStdOut(definition *generator.Interface) { generator.GenerateImplementation(writer, definition) generator.GenerateUnitTests(writer, definition) generator.GenerateValidations(writer, definition) - generator.GenerateIntegrationTests(writer, definition) } func runAllTemplatesAndSave(definition *generator.Interface, file string) { @@ -104,7 +104,6 @@ func runAllTemplatesAndSave(definition *generator.Interface, file string) { runTemplateAndSave(definition, generator.GenerateImplementation, filenameFor(fileWithoutSuffix, "_impl")) runTemplateAndSave(definition, generator.GenerateUnitTests, filename(fileWithoutSuffix, "_gen", "_test.go")) runTemplateAndSave(definition, generator.GenerateValidations, filenameFor(fileWithoutSuffix, "_validations")) - runTemplateAndSave(definition, generator.GenerateIntegrationTests, filename(fileWithoutSuffix, "_gen_integration", "_test.go")) } func runTemplateAndSave(def *generator.Interface, genFunc func(io.Writer, *generator.Interface), fileName string) { diff --git a/pkg/sdk/procedures_def.go b/pkg/sdk/procedures_def.go index 636da06187..1779da568b 100644 --- a/pkg/sdk/procedures_def.go +++ b/pkg/sdk/procedures_def.go @@ -355,7 +355,10 @@ var ProceduresDef = g.NewInterface( SQL("PROCEDURES"). OptionalLike(). OptionalExtendedIn(), -).ShowByIdOperation().DescribeOperation( +).ShowByIdOperationWithFiltering( + g.ShowByIDInFiltering, + g.ShowByIDLikeFiltering, +).DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-procedure", g.DbStruct("procedureDetailRow"). diff --git a/pkg/sdk/procedures_impl_gen.go b/pkg/sdk/procedures_impl_gen.go index 5a7e1ce84e..9772688a3d 100644 --- a/pkg/sdk/procedures_impl_gen.go +++ b/pkg/sdk/procedures_impl_gen.go @@ -60,7 +60,10 @@ func (v *procedures) Show(ctx context.Context, request *ShowProcedureRequest) ([ } func (v *procedures) ShowByID(ctx context.Context, id SchemaObjectIdentifierWithArguments) (*Procedure, error) { - procedures, err := v.Show(ctx, NewShowProcedureRequest().WithIn(ExtendedIn{In: In{Schema: id.SchemaId()}}).WithLike(Like{String(id.Name())})) + request := NewShowProcedureRequest(). + WithIn(ExtendedIn{In: In{Schema: id.SchemaId()}}). + WithLike(Like{Pattern: String(id.Name())}) + procedures, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/row_access_policies_def.go b/pkg/sdk/row_access_policies_def.go index 02d42c0dbb..a6f1fd5453 100644 --- a/pkg/sdk/row_access_policies_def.go +++ b/pkg/sdk/row_access_policies_def.go @@ -90,7 +90,10 @@ var RowAccessPoliciesDef = g.NewInterface( OptionalExtendedIn(). OptionalLimitFrom(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDExtendedInFiltering, + g.ShowByIDLikeFiltering, + ). DescribeOperation( g.DescriptionMappingKindSingleValue, "https://docs.snowflake.com/en/sql-reference/sql/desc-row-access-policy", diff --git a/pkg/sdk/row_access_policies_dto_builders_gen.go b/pkg/sdk/row_access_policies_dto_builders_gen.go index ffdc0454dd..ef23517847 100644 --- a/pkg/sdk/row_access_policies_dto_builders_gen.go +++ b/pkg/sdk/row_access_policies_dto_builders_gen.go @@ -100,13 +100,13 @@ func NewShowRowAccessPolicyRequest() *ShowRowAccessPolicyRequest { return &ShowRowAccessPolicyRequest{} } -func (s *ShowRowAccessPolicyRequest) WithLike(Like *Like) *ShowRowAccessPolicyRequest { - s.Like = Like +func (s *ShowRowAccessPolicyRequest) WithLike(Like Like) *ShowRowAccessPolicyRequest { + s.Like = &Like return s } -func (s *ShowRowAccessPolicyRequest) WithIn(In *ExtendedIn) *ShowRowAccessPolicyRequest { - s.In = In +func (s *ShowRowAccessPolicyRequest) WithIn(In ExtendedIn) *ShowRowAccessPolicyRequest { + s.In = &In return s } diff --git a/pkg/sdk/row_access_policies_impl_gen.go b/pkg/sdk/row_access_policies_impl_gen.go index f6f0f1e905..03dbab8e7d 100644 --- a/pkg/sdk/row_access_policies_impl_gen.go +++ b/pkg/sdk/row_access_policies_impl_gen.go @@ -39,7 +39,9 @@ func (v *rowAccessPolicies) Show(ctx context.Context, request *ShowRowAccessPoli } func (v *rowAccessPolicies) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*RowAccessPolicy, error) { - request := NewShowRowAccessPolicyRequest().WithIn(&ExtendedIn{In: In{Schema: id.SchemaId()}}).WithLike(&Like{String(id.Name())}) + request := NewShowRowAccessPolicyRequest(). + WithIn(ExtendedIn{In: In{Schema: id.SchemaId()}}). + WithLike(Like{Pattern: String(id.Name())}) rowAccessPolicies, err := v.Show(ctx, request) if err != nil { return nil, err diff --git a/pkg/sdk/security_integrations_def.go b/pkg/sdk/security_integrations_def.go index 1fb48d58cf..e027084493 100644 --- a/pkg/sdk/security_integrations_def.go +++ b/pkg/sdk/security_integrations_def.go @@ -976,4 +976,6 @@ var SecurityIntegrationsDef = g.NewInterface( SQL("SECURITY INTEGRATIONS"). OptionalLike(), ). - ShowByIdOperation() + ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, + ) diff --git a/pkg/sdk/security_integrations_impl_gen.go b/pkg/sdk/security_integrations_impl_gen.go index d430bbc2d9..3c1bf90a29 100644 --- a/pkg/sdk/security_integrations_impl_gen.go +++ b/pkg/sdk/security_integrations_impl_gen.go @@ -119,9 +119,9 @@ func (v *securityIntegrations) Show(ctx context.Context, request *ShowSecurityIn } func (v *securityIntegrations) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*SecurityIntegration, error) { - securityIntegrations, err := v.Show(ctx, NewShowSecurityIntegrationRequest().WithLike(Like{ - Pattern: String(id.Name()), - })) + request := NewShowSecurityIntegrationRequest(). + WithLike(Like{Pattern: String(id.Name())}) + securityIntegrations, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/sequences_def.go b/pkg/sdk/sequences_def.go index c73ea4d506..95bcbeb9e3 100644 --- a/pkg/sdk/sequences_def.go +++ b/pkg/sdk/sequences_def.go @@ -78,7 +78,10 @@ var SequencesDef = g.NewInterface( SQL("SEQUENCES"). OptionalLike(). OptionalIn(), -).ShowByIdOperation().DescribeOperation( +).ShowByIdOperationWithFiltering( + g.ShowByIDInFiltering, + g.ShowByIDLikeFiltering, +).DescribeOperation( g.DescriptionMappingKindSingleValue, "https://docs.snowflake.com/en/sql-reference/sql/desc-sequence", g.DbStruct("sequenceDetailRow"). diff --git a/pkg/sdk/sequences_dto_builders_gen.go b/pkg/sdk/sequences_dto_builders_gen.go index 95b0355f95..1967527f5c 100644 --- a/pkg/sdk/sequences_dto_builders_gen.go +++ b/pkg/sdk/sequences_dto_builders_gen.go @@ -2,8 +2,6 @@ package sdk -import () - func NewCreateSequenceRequest( name SchemaObjectIdentifier, ) *CreateSequenceRequest { @@ -93,13 +91,13 @@ func NewShowSequenceRequest() *ShowSequenceRequest { return &ShowSequenceRequest{} } -func (s *ShowSequenceRequest) WithLike(Like *Like) *ShowSequenceRequest { - s.Like = Like +func (s *ShowSequenceRequest) WithLike(Like Like) *ShowSequenceRequest { + s.Like = &Like return s } -func (s *ShowSequenceRequest) WithIn(In *In) *ShowSequenceRequest { - s.In = In +func (s *ShowSequenceRequest) WithIn(In In) *ShowSequenceRequest { + s.In = &In return s } diff --git a/pkg/sdk/sequences_impl_gen.go b/pkg/sdk/sequences_impl_gen.go index 202f61b605..e2a4a4a6dc 100644 --- a/pkg/sdk/sequences_impl_gen.go +++ b/pkg/sdk/sequences_impl_gen.go @@ -33,7 +33,9 @@ func (v *sequences) Show(ctx context.Context, request *ShowSequenceRequest) ([]S } func (v *sequences) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Sequence, error) { - request := NewShowSequenceRequest().WithIn(&In{Schema: id.SchemaId()}).WithLike(&Like{String(id.Name())}) + request := NewShowSequenceRequest(). + WithIn(In{Schema: id.SchemaId()}). + WithLike(Like{Pattern: String(id.Name())}) sequences, err := v.Show(ctx, request) if err != nil { return nil, err diff --git a/pkg/sdk/session_policies_def.go b/pkg/sdk/session_policies_def.go index 3b172f5562..f892ffd038 100644 --- a/pkg/sdk/session_policies_def.go +++ b/pkg/sdk/session_policies_def.go @@ -89,9 +89,7 @@ var SessionPoliciesDef = g.NewInterface( Show(). SQL("SESSION POLICIES"), ). - ShowByIdOperationWithFiltering( - g.ShowByIDNoFiltering, - ). + ShowByIdOperationWithNoFiltering(). DescribeOperation( g.DescriptionMappingKindSingleValue, "https://docs.snowflake.com/en/sql-reference/sql/desc-session-policy", diff --git a/pkg/sdk/stages_def.go b/pkg/sdk/stages_def.go index a71688d92e..abb686e161 100644 --- a/pkg/sdk/stages_def.go +++ b/pkg/sdk/stages_def.go @@ -398,4 +398,7 @@ var StagesDef = g.NewInterface( OptionalLike(). OptionalIn(), ). - ShowByIdOperation() + ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, + g.ShowByIDInFiltering, + ) diff --git a/pkg/sdk/stages_dto_builders_gen.go b/pkg/sdk/stages_dto_builders_gen.go index 9aec793e27..31fb4d67a3 100644 --- a/pkg/sdk/stages_dto_builders_gen.go +++ b/pkg/sdk/stages_dto_builders_gen.go @@ -826,12 +826,12 @@ func NewShowStageRequest() *ShowStageRequest { return &ShowStageRequest{} } -func (s *ShowStageRequest) WithLike(Like *Like) *ShowStageRequest { - s.Like = Like +func (s *ShowStageRequest) WithLike(Like Like) *ShowStageRequest { + s.Like = &Like return s } -func (s *ShowStageRequest) WithIn(In *In) *ShowStageRequest { - s.In = In +func (s *ShowStageRequest) WithIn(In In) *ShowStageRequest { + s.In = &In return s } diff --git a/pkg/sdk/stages_impl_gen.go b/pkg/sdk/stages_impl_gen.go index 9797678aa5..661173144f 100644 --- a/pkg/sdk/stages_impl_gen.go +++ b/pkg/sdk/stages_impl_gen.go @@ -94,13 +94,10 @@ func (v *stages) Show(ctx context.Context, request *ShowStageRequest) ([]Stage, } func (v *stages) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Stage, error) { - stages, err := v.Show(ctx, NewShowStageRequest(). - WithLike(&Like{ - Pattern: String(id.Name()), - }). - WithIn(&In{ - Schema: id.SchemaId(), - })) + request := NewShowStageRequest(). + WithLike(Like{Pattern: String(id.Name())}). + WithIn(In{Schema: id.SchemaId()}) + stages, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/storage_integration_def.go b/pkg/sdk/storage_integration_def.go index 04e24c37da..3e89c8b584 100644 --- a/pkg/sdk/storage_integration_def.go +++ b/pkg/sdk/storage_integration_def.go @@ -151,7 +151,9 @@ var StorageIntegrationDef = g.NewInterface( SQL("STORAGE INTEGRATIONS"). OptionalLike(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDLikeFiltering, + ). DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-integration", diff --git a/pkg/sdk/storage_integration_impl_gen.go b/pkg/sdk/storage_integration_impl_gen.go index 9ac54949d8..47aa686b01 100644 --- a/pkg/sdk/storage_integration_impl_gen.go +++ b/pkg/sdk/storage_integration_impl_gen.go @@ -38,9 +38,9 @@ func (v *storageIntegrations) Show(ctx context.Context, request *ShowStorageInte } func (v *storageIntegrations) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*StorageIntegration, error) { - storageIntegrations, err := v.Show(ctx, NewShowStorageIntegrationRequest().WithLike(Like{ - Pattern: String(id.Name()), - })) + request := NewShowStorageIntegrationRequest(). + WithLike(Like{Pattern: String(id.Name())}) + storageIntegrations, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/streams_def.go b/pkg/sdk/streams_def.go index a67098574f..21395f2b2b 100644 --- a/pkg/sdk/streams_def.go +++ b/pkg/sdk/streams_def.go @@ -233,7 +233,10 @@ var ( OptionalStartsWith(). OptionalLimit(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDExtendedInFiltering, + g.ShowByIDLikeFiltering, + ). DescribeOperation( g.DescriptionMappingKindSingleValue, "https://docs.snowflake.com/en/sql-reference/sql/desc-stream", diff --git a/pkg/sdk/streams_impl_gen.go b/pkg/sdk/streams_impl_gen.go index 6612925b60..969ea99b51 100644 --- a/pkg/sdk/streams_impl_gen.go +++ b/pkg/sdk/streams_impl_gen.go @@ -59,13 +59,10 @@ func (v *streams) Show(ctx context.Context, request *ShowStreamRequest) ([]Strea } func (v *streams) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Stream, error) { - streams, err := v.Show(ctx, NewShowStreamRequest(). - WithIn(ExtendedIn{ - In: In{ - Schema: id.SchemaId(), - }, - }). - WithLike(Like{Pattern: String(id.Name())})) + request := NewShowStreamRequest(). + WithIn(ExtendedIn{In: In{Schema: id.SchemaId()}}). + WithLike(Like{Pattern: String(id.Name())}) + streams, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/tasks_def.go b/pkg/sdk/tasks_def.go index 83ff671492..13fdaa89fc 100644 --- a/pkg/sdk/tasks_def.go +++ b/pkg/sdk/tasks_def.go @@ -292,7 +292,10 @@ var TasksDef = g.NewInterface( OptionalSQL("ROOT ONLY"). OptionalLimit(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDExtendedInFiltering, + g.ShowByIDLikeFiltering, + ). DescribeOperation( g.DescriptionMappingKindSingleValue, "https://docs.snowflake.com/en/sql-reference/sql/desc-task", diff --git a/pkg/sdk/tasks_impl_gen.go b/pkg/sdk/tasks_impl_gen.go index 5f7bd10a82..96ec539770 100644 --- a/pkg/sdk/tasks_impl_gen.go +++ b/pkg/sdk/tasks_impl_gen.go @@ -54,13 +54,10 @@ func (v *tasks) Show(ctx context.Context, request *ShowTaskRequest) ([]Task, err } func (v *tasks) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Task, error) { - tasks, err := v.Show(ctx, NewShowTaskRequest().WithIn(ExtendedIn{ - In: In{ - Schema: id.SchemaId(), - }, - }).WithLike(Like{ - Pattern: String(id.Name()), - })) + request := NewShowTaskRequest(). + WithIn(ExtendedIn{In: In{Schema: id.SchemaId()}}). + WithLike(Like{Pattern: String(id.Name())}) + tasks, err := v.Show(ctx, request) if err != nil { return nil, err } diff --git a/pkg/sdk/testint/api_integrations_gen_integration_test.go b/pkg/sdk/testint/api_integrations_gen_integration_test.go index b4c04c6e64..7f816d6b4d 100644 --- a/pkg/sdk/testint/api_integrations_gen_integration_test.go +++ b/pkg/sdk/testint/api_integrations_gen_integration_test.go @@ -387,7 +387,7 @@ func TestInt_ApiIntegrations(t *testing.T) { integrationAzure := createAzureApiIntegration(t) showRequest := sdk.NewShowApiIntegrationRequest(). - WithLike(&sdk.Like{Pattern: &integrationAws.Name}) + WithLike(sdk.Like{Pattern: &integrationAws.Name}) returnedIntegrations, err := client.ApiIntegrations.Show(ctx, showRequest) require.NoError(t, err) diff --git a/pkg/sdk/testint/application_packages_integration_test.go b/pkg/sdk/testint/application_packages_integration_test.go index a9e5e5b2fd..dd0d768acc 100644 --- a/pkg/sdk/testint/application_packages_integration_test.go +++ b/pkg/sdk/testint/application_packages_integration_test.go @@ -123,7 +123,7 @@ func TestInt_ApplicationPackages(t *testing.T) { t.Run("show application package for SQL: with like", func(t *testing.T) { e := createApplicationPackageHandle(t) - packages, err := client.ApplicationPackages.Show(ctx, sdk.NewShowApplicationPackageRequest().WithLike(&sdk.Like{Pattern: &e.Name})) + packages, err := client.ApplicationPackages.Show(ctx, sdk.NewShowApplicationPackageRequest().WithLike(sdk.Like{Pattern: &e.Name})) require.NoError(t, err) require.Equal(t, 1, len(packages)) require.Equal(t, *e, packages[0]) diff --git a/pkg/sdk/testint/applications_integration_test.go b/pkg/sdk/testint/applications_integration_test.go index 4332983a97..280a119c00 100644 --- a/pkg/sdk/testint/applications_integration_test.go +++ b/pkg/sdk/testint/applications_integration_test.go @@ -182,7 +182,7 @@ func TestInt_Applications(t *testing.T) { t.Run("show application: with like", func(t *testing.T) { version, patch := "V001", 0 _, e, _ := createApplicationHandle(t, version, patch, false, true, false) - packages, err := client.Applications.Show(ctx, sdk.NewShowApplicationRequest().WithLike(&sdk.Like{Pattern: &e.Name})) + packages, err := client.Applications.Show(ctx, sdk.NewShowApplicationRequest().WithLike(sdk.Like{Pattern: &e.Name})) require.NoError(t, err) require.Equal(t, 1, len(packages)) require.Equal(t, *e, packages[0]) diff --git a/pkg/sdk/testint/event_tables_integration_test.go b/pkg/sdk/testint/event_tables_integration_test.go index 434e0e60c0..b6a3cef727 100644 --- a/pkg/sdk/testint/event_tables_integration_test.go +++ b/pkg/sdk/testint/event_tables_integration_test.go @@ -84,7 +84,7 @@ func TestInt_EventTables(t *testing.T) { et1 := createEventTableHandle(t) et2 := createEventTableHandle(t) - tables, err := client.EventTables.Show(ctx, sdk.NewShowEventTableRequest().WithLike(&sdk.Like{Pattern: &et1.Name})) + tables, err := client.EventTables.Show(ctx, sdk.NewShowEventTableRequest().WithLike(sdk.Like{Pattern: &et1.Name})) require.NoError(t, err) assert.Equal(t, 1, len(tables)) assert.Contains(t, tables, *et1) @@ -98,7 +98,7 @@ func TestInt_EventTables(t *testing.T) { }) t.Run("show event table: no matches", func(t *testing.T) { - tables, err := client.EventTables.Show(ctx, sdk.NewShowEventTableRequest().WithLike(&sdk.Like{Pattern: sdk.String("non-existent")})) + tables, err := client.EventTables.Show(ctx, sdk.NewShowEventTableRequest().WithLike(sdk.Like{Pattern: sdk.String("non-existent")})) require.NoError(t, err) assert.Equal(t, 0, len(tables)) }) diff --git a/pkg/sdk/testint/managed_accounts_gen_integration_test.go b/pkg/sdk/testint/managed_accounts_gen_integration_test.go index 717db30db0..b76ce8956c 100644 --- a/pkg/sdk/testint/managed_accounts_gen_integration_test.go +++ b/pkg/sdk/testint/managed_accounts_gen_integration_test.go @@ -125,7 +125,7 @@ func TestInt_ManagedAccounts(t *testing.T) { managedAccount2 := createManagedAccount(t) showRequest := sdk.NewShowManagedAccountRequest(). - WithLike(&sdk.Like{Pattern: &managedAccount1.Name}) + WithLike(sdk.Like{Pattern: &managedAccount1.Name}) returnedManagedAccounts, err := client.ManagedAccounts.Show(ctx, showRequest) require.NoError(t, err) diff --git a/pkg/sdk/testint/materialized_views_gen_integration_test.go b/pkg/sdk/testint/materialized_views_gen_integration_test.go index 6cad7bcb93..f4e74bdb4a 100644 --- a/pkg/sdk/testint/materialized_views_gen_integration_test.go +++ b/pkg/sdk/testint/materialized_views_gen_integration_test.go @@ -335,7 +335,7 @@ func TestInt_MaterializedViews(t *testing.T) { t.Run("show materialized view: no existing view", func(t *testing.T) { showRequest := sdk.NewShowMaterializedViewRequest(). - WithIn(&sdk.In{Schema: testClientHelper().Ids.SchemaId()}) + WithIn(sdk.In{Schema: testClientHelper().Ids.SchemaId()}) returnedViews, err := client.MaterializedViews.Show(ctx, showRequest) require.NoError(t, err) @@ -344,7 +344,7 @@ func TestInt_MaterializedViews(t *testing.T) { t.Run("show materialized view: schema not existing", func(t *testing.T) { showRequest := sdk.NewShowMaterializedViewRequest(). - WithIn(&sdk.In{Schema: NonExistingDatabaseObjectIdentifier}) + WithIn(sdk.In{Schema: NonExistingDatabaseObjectIdentifier}) _, err := client.MaterializedViews.Show(ctx, showRequest) require.Error(t, err) }) @@ -354,8 +354,8 @@ func TestInt_MaterializedViews(t *testing.T) { view2 := createMaterializedView(t) showRequest := sdk.NewShowMaterializedViewRequest(). - WithLike(&sdk.Like{Pattern: &view1.Name}). - WithIn(&sdk.In{Schema: testClientHelper().Ids.SchemaId()}) + WithLike(sdk.Like{Pattern: &view1.Name}). + WithIn(sdk.In{Schema: testClientHelper().Ids.SchemaId()}) returnedViews, err := client.MaterializedViews.Show(ctx, showRequest) require.NoError(t, err) diff --git a/pkg/sdk/testint/network_rule_gen_integration_test.go b/pkg/sdk/testint/network_rule_gen_integration_test.go index 705b29824b..91122f3b05 100644 --- a/pkg/sdk/testint/network_rule_gen_integration_test.go +++ b/pkg/sdk/testint/network_rule_gen_integration_test.go @@ -92,9 +92,9 @@ func TestInt_NetworkRules(t *testing.T) { require.NoError(t, err) }) - networkRules, err := client.NetworkRules.Show(ctx, sdk.NewShowNetworkRuleRequest().WithIn(&sdk.In{ + networkRules, err := client.NetworkRules.Show(ctx, sdk.NewShowNetworkRuleRequest().WithIn(sdk.In{ Schema: id.SchemaId(), - }).WithLike(&sdk.Like{ + }).WithLike(sdk.Like{ Pattern: sdk.String(id.Name()), })) require.NoError(t, err) diff --git a/pkg/sdk/testint/notification_integrations_gen_integration_test.go b/pkg/sdk/testint/notification_integrations_gen_integration_test.go index e813680226..5f3c4ab354 100644 --- a/pkg/sdk/testint/notification_integrations_gen_integration_test.go +++ b/pkg/sdk/testint/notification_integrations_gen_integration_test.go @@ -401,7 +401,7 @@ func TestInt_NotificationIntegrations(t *testing.T) { notificationAutoAzure := createNotificationIntegrationAutoAzure(t) showRequest := sdk.NewShowNotificationIntegrationRequest(). - WithLike(&sdk.Like{Pattern: ¬ificationAutoGoogle.Name}) + WithLike(sdk.Like{Pattern: ¬ificationAutoGoogle.Name}) returnedIntegrations, err := client.NotificationIntegrations.Show(ctx, showRequest) require.NoError(t, err) diff --git a/pkg/sdk/testint/row_access_policies_gen_integration_test.go b/pkg/sdk/testint/row_access_policies_gen_integration_test.go index 2833210fe8..cbcea2f05e 100644 --- a/pkg/sdk/testint/row_access_policies_gen_integration_test.go +++ b/pkg/sdk/testint/row_access_policies_gen_integration_test.go @@ -190,8 +190,8 @@ func TestInt_RowAccessPolicies(t *testing.T) { t.Cleanup(cleanup2) showRequest := sdk.NewShowRowAccessPolicyRequest(). - WithLike(&sdk.Like{Pattern: &rowAccessPolicy1.Name}). - WithIn(&sdk.ExtendedIn{In: sdk.In{Schema: testClientHelper().Ids.SchemaId()}}). + WithLike(sdk.Like{Pattern: &rowAccessPolicy1.Name}). + WithIn(sdk.ExtendedIn{In: sdk.In{Schema: testClientHelper().Ids.SchemaId()}}). WithLimit(&sdk.LimitFrom{Rows: sdk.Int(5)}) returnedRowAccessPolicies, err := client.RowAccessPolicies.Show(ctx, showRequest) diff --git a/pkg/sdk/testint/sequences_integration_test.go b/pkg/sdk/testint/sequences_integration_test.go index 1a8cb538f2..c268cfa85e 100644 --- a/pkg/sdk/testint/sequences_integration_test.go +++ b/pkg/sdk/testint/sequences_integration_test.go @@ -92,7 +92,7 @@ func TestInt_Sequences(t *testing.T) { e1 := createSequenceHandle(t) e2 := createSequenceHandle(t) - sequences, err := client.Sequences.Show(ctx, sdk.NewShowSequenceRequest().WithLike(&sdk.Like{Pattern: &e1.Name})) + sequences, err := client.Sequences.Show(ctx, sdk.NewShowSequenceRequest().WithLike(sdk.Like{Pattern: &e1.Name})) require.NoError(t, err) require.Equal(t, 1, len(sequences)) require.Contains(t, sequences, *e1) @@ -100,7 +100,7 @@ func TestInt_Sequences(t *testing.T) { }) t.Run("show sequence: no matches", func(t *testing.T) { - sequences, err := client.Sequences.Show(ctx, sdk.NewShowSequenceRequest().WithLike(&sdk.Like{Pattern: sdk.String("non-existent")})) + sequences, err := client.Sequences.Show(ctx, sdk.NewShowSequenceRequest().WithLike(sdk.Like{Pattern: sdk.String("non-existent")})) require.NoError(t, err) require.Equal(t, 0, len(sequences)) }) diff --git a/pkg/sdk/views_def.go b/pkg/sdk/views_def.go index e981a19c70..0346ace03b 100644 --- a/pkg/sdk/views_def.go +++ b/pkg/sdk/views_def.go @@ -336,7 +336,10 @@ var ViewsDef = g.NewInterface( OptionalStartsWith(). OptionalLimit(), ). - ShowByIdOperation(). + ShowByIdOperationWithFiltering( + g.ShowByIDExtendedInFiltering, + g.ShowByIDLikeFiltering, + ). DescribeOperation( g.DescriptionMappingKindSlice, "https://docs.snowflake.com/en/sql-reference/sql/desc-view", diff --git a/pkg/sdk/views_impl_gen.go b/pkg/sdk/views_impl_gen.go index a9a2783fb4..1bf940b4a9 100644 --- a/pkg/sdk/views_impl_gen.go +++ b/pkg/sdk/views_impl_gen.go @@ -40,7 +40,9 @@ func (v *views) Show(ctx context.Context, request *ShowViewRequest) ([]View, err } func (v *views) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*View, error) { - request := NewShowViewRequest().WithIn(ExtendedIn{In: In{Schema: id.SchemaId()}}).WithLike(Like{String(id.Name())}) + request := NewShowViewRequest(). + WithIn(ExtendedIn{In: In{Schema: id.SchemaId()}}). + WithLike(Like{Pattern: String(id.Name())}) views, err := v.Show(ctx, request) if err != nil { return nil, err