55 "fmt"
66 "strings"
77
8- "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/iaasalpha/routingtable/shared"
8+ "github.com/stackitcloud/stackit-sdk-go/services/iaas"
9+ "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/iaas/routingtable/shared"
10+ iaasUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/iaas/utils"
911
1012 "github.com/hashicorp/terraform-plugin-framework/path"
1113 "github.com/hashicorp/terraform-plugin-framework/resource"
@@ -17,11 +19,9 @@ import (
1719 "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
1820 "github.com/hashicorp/terraform-plugin-log/tflog"
1921 sdkUtils "github.com/stackitcloud/stackit-sdk-go/core/utils"
20- "github.com/stackitcloud/stackit-sdk-go/services/iaasalpha"
2122 "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
2223 "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
2324 "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features"
24- iaasalphaUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/iaasalpha/utils"
2525 "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
2626 "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
2727)
@@ -41,7 +41,7 @@ func NewRoutingTableRouteResource() resource.Resource {
4141
4242// routeResource is the resource implementation.
4343type routeResource struct {
44- client * iaasalpha .APIClient
44+ client * iaas .APIClient
4545 providerData core.ProviderData
4646}
4747
@@ -63,7 +63,7 @@ func (r *routeResource) Configure(ctx context.Context, req resource.ConfigureReq
6363 return
6464 }
6565
66- apiClient := iaasalphaUtils .ConfigureClient (ctx , & r .providerData , & resp .Diagnostics )
66+ apiClient := iaasUtils .ConfigureClient (ctx , & r .providerData , & resp .Diagnostics )
6767 if resp .Diagnostics .HasError () {
6868 return
6969 }
@@ -461,7 +461,7 @@ func (r *routeResource) ImportState(ctx context.Context, req resource.ImportStat
461461 tflog .Info (ctx , "Routing table route state imported" )
462462}
463463
464- func mapFieldsFromList (ctx context.Context , routeResp * iaasalpha .RouteListResponse , model * shared.RouteModel , region string ) error {
464+ func mapFieldsFromList (ctx context.Context , routeResp * iaas .RouteListResponse , model * shared.RouteModel , region string ) error {
465465 if routeResp == nil || routeResp .Items == nil {
466466 return fmt .Errorf ("response input is nil" )
467467 } else if len (* routeResp .Items ) < 1 {
@@ -474,7 +474,7 @@ func mapFieldsFromList(ctx context.Context, routeResp *iaasalpha.RouteListRespon
474474 return shared .MapRouteModel (ctx , & route , model , region )
475475}
476476
477- func toCreatePayload (ctx context.Context , model * shared.RouteReadModel ) (* iaasalpha .AddRoutesToRoutingTablePayload , error ) {
477+ func toCreatePayload (ctx context.Context , model * shared.RouteReadModel ) (* iaas .AddRoutesToRoutingTablePayload , error ) {
478478 if model == nil {
479479 return nil , fmt .Errorf ("nil model" )
480480 }
@@ -493,8 +493,8 @@ func toCreatePayload(ctx context.Context, model *shared.RouteReadModel) (*iaasal
493493 return nil , err
494494 }
495495
496- return & iaasalpha .AddRoutesToRoutingTablePayload {
497- Items : & []iaasalpha .Route {
496+ return & iaas .AddRoutesToRoutingTablePayload {
497+ Items : & []iaas .Route {
498498 {
499499 Labels : & labels ,
500500 Nexthop : nextHopPayload ,
@@ -504,7 +504,7 @@ func toCreatePayload(ctx context.Context, model *shared.RouteReadModel) (*iaasal
504504 }, nil
505505}
506506
507- func toUpdatePayload (ctx context.Context , model * shared.RouteModel , currentLabels types.Map ) (* iaasalpha .UpdateRouteOfRoutingTablePayload , error ) {
507+ func toUpdatePayload (ctx context.Context , model * shared.RouteModel , currentLabels types.Map ) (* iaas .UpdateRouteOfRoutingTablePayload , error ) {
508508 if model == nil {
509509 return nil , fmt .Errorf ("nil model" )
510510 }
@@ -514,12 +514,12 @@ func toUpdatePayload(ctx context.Context, model *shared.RouteModel, currentLabel
514514 return nil , fmt .Errorf ("converting to Go map: %w" , err )
515515 }
516516
517- return & iaasalpha .UpdateRouteOfRoutingTablePayload {
517+ return & iaas .UpdateRouteOfRoutingTablePayload {
518518 Labels : & labels ,
519519 }, nil
520520}
521521
522- func toNextHopPayload (ctx context.Context , model * shared.RouteReadModel ) (* iaasalpha .RouteNexthop , error ) {
522+ func toNextHopPayload (ctx context.Context , model * shared.RouteReadModel ) (* iaas .RouteNexthop , error ) {
523523 if model == nil {
524524 return nil , fmt .Errorf ("nil model" )
525525 }
@@ -535,18 +535,18 @@ func toNextHopPayload(ctx context.Context, model *shared.RouteReadModel) (*iaasa
535535
536536 switch nexthopModel .Type .ValueString () {
537537 case "blackhole" :
538- return sdkUtils .Ptr (iaasalpha .NexthopBlackholeAsRouteNexthop (iaasalpha .NewNexthopBlackhole ("blackhole" ))), nil
538+ return sdkUtils .Ptr (iaas .NexthopBlackholeAsRouteNexthop (iaas .NewNexthopBlackhole ("blackhole" ))), nil
539539 case "internet" :
540- return sdkUtils .Ptr (iaasalpha .NexthopInternetAsRouteNexthop (iaasalpha .NewNexthopInternet ("internet" ))), nil
540+ return sdkUtils .Ptr (iaas .NexthopInternetAsRouteNexthop (iaas .NewNexthopInternet ("internet" ))), nil
541541 case "ipv4" :
542- return sdkUtils .Ptr (iaasalpha .NexthopIPv4AsRouteNexthop (iaasalpha .NewNexthopIPv4 ("ipv4" , nexthopModel .Value .ValueString ()))), nil
542+ return sdkUtils .Ptr (iaas .NexthopIPv4AsRouteNexthop (iaas .NewNexthopIPv4 ("ipv4" , nexthopModel .Value .ValueString ()))), nil
543543 case "ipv6" :
544- return sdkUtils .Ptr (iaasalpha .NexthopIPv6AsRouteNexthop (iaasalpha .NewNexthopIPv6 ("ipv6" , nexthopModel .Value .ValueString ()))), nil
544+ return sdkUtils .Ptr (iaas .NexthopIPv6AsRouteNexthop (iaas .NewNexthopIPv6 ("ipv6" , nexthopModel .Value .ValueString ()))), nil
545545 }
546546 return nil , fmt .Errorf ("unknown nexthop type: %s" , nexthopModel .Type .ValueString ())
547547}
548548
549- func toDestinationPayload (ctx context.Context , model * shared.RouteReadModel ) (* iaasalpha .RouteDestination , error ) {
549+ func toDestinationPayload (ctx context.Context , model * shared.RouteReadModel ) (* iaas .RouteDestination , error ) {
550550 if model == nil {
551551 return nil , fmt .Errorf ("nil model" )
552552 }
@@ -562,9 +562,9 @@ func toDestinationPayload(ctx context.Context, model *shared.RouteReadModel) (*i
562562
563563 switch destinationModel .Type .ValueString () {
564564 case "cidrv4" :
565- return sdkUtils .Ptr (iaasalpha .DestinationCIDRv4AsRouteDestination (iaasalpha .NewDestinationCIDRv4 ("cidrv4" , destinationModel .Value .ValueString ()))), nil
565+ return sdkUtils .Ptr (iaas .DestinationCIDRv4AsRouteDestination (iaas .NewDestinationCIDRv4 ("cidrv4" , destinationModel .Value .ValueString ()))), nil
566566 case "cidrv6" :
567- return sdkUtils .Ptr (iaasalpha .DestinationCIDRv6AsRouteDestination (iaasalpha .NewDestinationCIDRv6 ("cidrv6" , destinationModel .Value .ValueString ()))), nil
567+ return sdkUtils .Ptr (iaas .DestinationCIDRv6AsRouteDestination (iaas .NewDestinationCIDRv6 ("cidrv6" , destinationModel .Value .ValueString ()))), nil
568568 }
569569 return nil , fmt .Errorf ("unknown destination type: %s" , destinationModel .Type .ValueString ())
570570}
0 commit comments