diff --git a/cmd/cmd/build/build.go b/cmd/cmd/build/build.go
index f210b8d2..30fbf552 100644
--- a/cmd/cmd/build/build.go
+++ b/cmd/cmd/build/build.go
@@ -1,6 +1,7 @@
package build
import (
+ "bufio"
"bytes"
"errors"
"fmt"
@@ -509,7 +510,7 @@ func generateServiceFiles(rootDir, generatorDir string) error {
oasFile := path.Join(generatorDir, "oas", fmt.Sprintf("%s%s.json", service.Name(), svcVersion.Name()))
if _, oasErr := os.Stat(oasFile); os.IsNotExist(oasErr) {
- slog.Warn(" coulc not find matching oas", "svc", service.Name(), "version", svcVersion.Name())
+ slog.Warn(" could not find matching oas", "svc", service.Name(), "version", svcVersion.Name())
continue
}
@@ -648,6 +649,15 @@ func generateServiceFiles(rootDir, generatorDir string) error {
return err
}
}
+
+ tfAnoErr := handleTfTagForDatasourceFile(
+ path.Join(tgtFolder, fmt.Sprintf("%s_data_source_gen.go", resource)),
+ scName,
+ resource,
+ )
+ if tfAnoErr != nil {
+ return tfAnoErr
+ }
}
}
}
@@ -655,6 +665,70 @@ func generateServiceFiles(rootDir, generatorDir string) error {
return nil
}
+// handleTfTagForDatasourceFile replaces existing "id" with "stf_original_api_id"
+func handleTfTagForDatasourceFile(filePath, service, resource string) error {
+ slog.Info(" handle terraform tag for datasource", "service", service, "resource", resource)
+ if !fileExists(filePath) {
+ slog.Warn(" could not find file, skipping", "path", filePath)
+ return nil
+ }
+ f, err := os.Open(filePath)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ tmp, err := os.CreateTemp("", "replace-*")
+ if err != nil {
+ return err
+ }
+ defer tmp.Close()
+
+ sc := bufio.NewScanner(f)
+ for sc.Scan() {
+ resLine, err := handleLine(sc.Text())
+ if err != nil {
+ return err
+ }
+ if _, err := io.WriteString(tmp, resLine+"\n"); err != nil {
+ return err
+ }
+ }
+ if scErr := sc.Err(); scErr != nil {
+ return scErr
+ }
+
+ if err := tmp.Close(); err != nil {
+ return err
+ }
+
+ if err := f.Close(); err != nil {
+ return err
+ }
+
+ if err := os.Rename(tmp.Name(), filePath); err != nil {
+ log.Fatal(err)
+ }
+ return nil
+}
+
+func handleLine(line string) (string, error) {
+ schemaRegex := regexp.MustCompile(`(\s+")(id)(": schema.[a-zA-Z0-9]+Attribute{)`)
+
+ schemaMatches := schemaRegex.FindAllStringSubmatch(line, -1)
+ if schemaMatches != nil {
+ return fmt.Sprintf("%stf_original_api_id%s", schemaMatches[0][1], schemaMatches[0][3]), nil
+ }
+
+ modelRegex := regexp.MustCompile(`(\s+Id\s+types.[a-zA-Z0-9]+\s+.tfsdk:")(id)(".)`)
+ modelMatches := modelRegex.FindAllStringSubmatch(line, -1)
+ if modelMatches != nil {
+ return fmt.Sprintf("%stf_original_api_id%s", modelMatches[0][1], modelMatches[0][3]), nil
+ }
+
+ return line, nil
+}
+
func checkCommands(commands []string) error {
for _, commandName := range commands {
if !commandExists(commandName) {
diff --git a/docs/data-sources/postgresflexalpha_flavors.md b/docs/data-sources/postgresflexalpha_flavors.md
index f90ae257..06645bb4 100644
--- a/docs/data-sources/postgresflexalpha_flavors.md
+++ b/docs/data-sources/postgresflexalpha_flavors.md
@@ -38,12 +38,12 @@ Read-Only:
- `cpu` (Number) The cpu count of the instance.
- `description` (String) The flavor description.
-- `id` (String) The id of the instance flavor.
- `max_gb` (Number) maximum storage which can be ordered for the flavor in Gigabyte.
- `memory` (Number) The memory of the instance in Gibibyte.
- `min_gb` (Number) minimum storage which is required to order in Gigabyte.
- `node_type` (String) defines the nodeType it can be either single or replica
- `storage_classes` (Attributes List) maximum storage which can be ordered for the flavor in Gigabyte. (see [below for nested schema](#nestedatt--flavors--storage_classes))
+- `tf_original_api_id` (String) The id of the instance flavor.
### Nested Schema for `flavors.storage_classes`
diff --git a/docs/data-sources/postgresflexalpha_instance.md b/docs/data-sources/postgresflexalpha_instance.md
index 54d887ea..466745a6 100644
--- a/docs/data-sources/postgresflexalpha_instance.md
+++ b/docs/data-sources/postgresflexalpha_instance.md
@@ -37,7 +37,6 @@ data "stackitprivatepreview_postgresflexalpha_instance" "example" {
⚠ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected. (see [below for nested schema](#nestedatt--encryption))
- `flavor_id` (String) The id of the instance flavor.
-- `id` (String) The ID of the instance.
- `is_deletable` (Boolean) Whether the instance can be deleted or not.
- `name` (String) The name of the instance.
- `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network))
@@ -45,6 +44,7 @@ data "stackitprivatepreview_postgresflexalpha_instance" "example" {
- `retention_days` (Number) How long backups are retained. The value can only be between 32 and 365 days.
- `status` (String) The current status of the instance.
- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage))
+- `tf_original_api_id` (String) The ID of the instance.
- `version` (String) The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters.
diff --git a/docs/data-sources/sqlserverflexalpha_database.md b/docs/data-sources/sqlserverflexalpha_database.md
index 4aab99cc..5db648f4 100644
--- a/docs/data-sources/sqlserverflexalpha_database.md
+++ b/docs/data-sources/sqlserverflexalpha_database.md
@@ -26,6 +26,6 @@ description: |-
- `collation_name` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.
- `compatibility_level` (Number) CompatibilityLevel of the Database.
-- `id` (Number) The id of the database.
- `name` (String) The name of the database.
- `owner` (String) The owner of the database.
+- `tf_original_api_id` (Number) The id of the database.
diff --git a/docs/data-sources/sqlserverflexalpha_instance.md b/docs/data-sources/sqlserverflexalpha_instance.md
index 134eb567..b05d7b8e 100644
--- a/docs/data-sources/sqlserverflexalpha_instance.md
+++ b/docs/data-sources/sqlserverflexalpha_instance.md
@@ -34,7 +34,6 @@ data "stackitprivatepreview_sqlserverflexalpha_instance" "example" {
- `edition` (String) Edition of the MSSQL server instance
- `encryption` (Attributes) this defines which key to use for storage encryption (see [below for nested schema](#nestedatt--encryption))
- `flavor_id` (String) The id of the instance flavor.
-- `id` (String) The ID of the instance.
- `is_deletable` (Boolean) Whether the instance can be deleted or not.
- `name` (String) The name of the instance.
- `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network))
@@ -42,6 +41,7 @@ data "stackitprivatepreview_sqlserverflexalpha_instance" "example" {
- `retention_days` (Number) The days for how long the backup files should be stored before cleaned up. 30 to 365
- `status` (String)
- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage))
+- `tf_original_api_id` (String) The ID of the instance.
- `version` (String) The sqlserver version used for the instance.
diff --git a/docs/data-sources/sqlserverflexbeta_instance.md b/docs/data-sources/sqlserverflexbeta_instance.md
index cc3645ef..431f95f1 100644
--- a/docs/data-sources/sqlserverflexbeta_instance.md
+++ b/docs/data-sources/sqlserverflexbeta_instance.md
@@ -34,7 +34,6 @@ data "stackitprivatepreview_sqlserverflexbeta_instance" "example" {
- `edition` (String) Edition of the MSSQL server instance
- `encryption` (Attributes) this defines which key to use for storage encryption (see [below for nested schema](#nestedatt--encryption))
- `flavor_id` (String) The id of the instance flavor.
-- `id` (String) The ID of the instance.
- `is_deletable` (Boolean) Whether the instance can be deleted or not.
- `name` (String) The name of the instance.
- `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network))
@@ -42,6 +41,7 @@ data "stackitprivatepreview_sqlserverflexbeta_instance" "example" {
- `retention_days` (Number) The days for how long the backup files should be stored before cleaned up. 30 to 365
- `status` (String)
- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage))
+- `tf_original_api_id` (String) The ID of the instance.
- `version` (String) The sqlserver version used for the instance.
diff --git a/stackit/internal/services/postgresflexalpha/database/resources_gen/database_resource_gen.go b/stackit/internal/services/postgresflexalpha/database/resources_gen/database_resource_gen.go
index 95f6b6e5..6affc956 100644
--- a/stackit/internal/services/postgresflexalpha/database/resources_gen/database_resource_gen.go
+++ b/stackit/internal/services/postgresflexalpha/database/resources_gen/database_resource_gen.go
@@ -4,6 +4,8 @@ package postgresflexalpha
import (
"context"
+ "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
+ "github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
@@ -12,11 +14,23 @@ import (
func DatabaseResourceSchema(ctx context.Context) schema.Schema {
return schema.Schema{
Attributes: map[string]schema.Attribute{
+ "database_id": schema.Int64Attribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the database.",
+ MarkdownDescription: "The ID of the database.",
+ },
"id": schema.Int64Attribute{
Computed: true,
Description: "The id of the database.",
MarkdownDescription: "The id of the database.",
},
+ "instance_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The ID of the instance.",
+ MarkdownDescription: "The ID of the instance.",
+ },
"name": schema.StringAttribute{
Required: true,
Description: "The name of the database.",
@@ -28,12 +42,33 @@ func DatabaseResourceSchema(ctx context.Context) schema.Schema {
Description: "The owner of the database.",
MarkdownDescription: "The owner of the database.",
},
+ "project_id": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The STACKIT project ID.",
+ MarkdownDescription: "The STACKIT project ID.",
+ },
+ "region": schema.StringAttribute{
+ Optional: true,
+ Computed: true,
+ Description: "The region which should be addressed",
+ MarkdownDescription: "The region which should be addressed",
+ Validators: []validator.String{
+ stringvalidator.OneOf(
+ "eu01",
+ ),
+ },
+ },
},
}
}
type DatabaseModel struct {
- Id types.Int64 `tfsdk:"id"`
- Name types.String `tfsdk:"name"`
- Owner types.String `tfsdk:"owner"`
+ DatabaseId types.Int64 `tfsdk:"database_id"`
+ Id types.Int64 `tfsdk:"id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Name types.String `tfsdk:"name"`
+ Owner types.String `tfsdk:"owner"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
}
diff --git a/stackit/internal/services/postgresflexalpha/flavors/datasources_gen/flavors_data_source_gen.go b/stackit/internal/services/postgresflexalpha/flavors/datasources_gen/flavors_data_source_gen.go
index 924d1375..dbfe5cc9 100644
--- a/stackit/internal/services/postgresflexalpha/flavors/datasources_gen/flavors_data_source_gen.go
+++ b/stackit/internal/services/postgresflexalpha/flavors/datasources_gen/flavors_data_source_gen.go
@@ -33,7 +33,7 @@ func FlavorsDataSourceSchema(ctx context.Context) schema.Schema {
Description: "The flavor description.",
MarkdownDescription: "The flavor description.",
},
- "id": schema.StringAttribute{
+ "tf_original_api_id": schema.StringAttribute{
Computed: true,
Description: "The id of the instance flavor.",
MarkdownDescription: "The id of the instance flavor.",
diff --git a/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go b/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go
index 5ff386fe..047d0176 100644
--- a/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go
+++ b/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go
@@ -88,7 +88,7 @@ func InstanceDataSourceSchema(ctx context.Context) schema.Schema {
Description: "The id of the instance flavor.",
MarkdownDescription: "The id of the instance flavor.",
},
- "id": schema.StringAttribute{
+ "tf_original_api_id": schema.StringAttribute{
Computed: true,
Description: "The ID of the instance.",
MarkdownDescription: "The ID of the instance.",
@@ -204,7 +204,7 @@ type InstanceModel struct {
ConnectionInfo ConnectionInfoValue `tfsdk:"connection_info"`
Encryption EncryptionValue `tfsdk:"encryption"`
FlavorId types.String `tfsdk:"flavor_id"`
- Id types.String `tfsdk:"id"`
+ Id types.String `tfsdk:"tf_original_api_id"`
InstanceId types.String `tfsdk:"instance_id"`
IsDeletable types.Bool `tfsdk:"is_deletable"`
Name types.String `tfsdk:"name"`
diff --git a/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go b/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go
index 2a8a12b5..fbc442e4 100644
--- a/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go
+++ b/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go
@@ -164,6 +164,11 @@ func TestAccPostgresFlexFlexResource(t *testing.T) {
Steps: []resource.TestStep{
// Creation
{
+ // testdata/
+ // ConfigDirectory: config.TestNameDirectory(),
+
+ // testdata//
+ // ConfigDirectory: config.TestStepDirectory(),
Config: configResources(instanceResource["backup_schedule"], &testutil.Region),
Check: resource.ComposeAggregateTestCheckFunc(
// Instance
diff --git a/stackit/internal/services/postgresflexalpha/user/datasource.go b/stackit/internal/services/postgresflexalpha/user/datasource.go
index 70d05aba..7b3a1428 100644
--- a/stackit/internal/services/postgresflexalpha/user/datasource.go
+++ b/stackit/internal/services/postgresflexalpha/user/datasource.go
@@ -274,10 +274,7 @@ func mapDataSourceFields(userResp *postgresflex.GetUserResponse, model *DataSour
}
model.Roles = rolesSet
}
- model.Host = types.StringPointerValue(user.Host)
- model.Port = types.Int64PointerValue(user.Port)
model.Region = types.StringValue(region)
model.Status = types.StringPointerValue(user.Status)
- model.ConnectionString = types.StringPointerValue(user.ConnectionString)
return nil
}
diff --git a/stackit/internal/services/postgresflexalpha/user/datasources_gen/user_data_source_gen.go b/stackit/internal/services/postgresflexalpha/user/datasources_gen/user_data_source_gen.go
index fb2a7644..29a7cca0 100644
--- a/stackit/internal/services/postgresflexalpha/user/datasources_gen/user_data_source_gen.go
+++ b/stackit/internal/services/postgresflexalpha/user/datasources_gen/user_data_source_gen.go
@@ -14,17 +14,7 @@ import (
func UserDataSourceSchema(ctx context.Context) schema.Schema {
return schema.Schema{
Attributes: map[string]schema.Attribute{
- "connection_string": schema.StringAttribute{
- Computed: true,
- Description: "The connection string for the user to the instance.",
- MarkdownDescription: "The connection string for the user to the instance.",
- },
- "host": schema.StringAttribute{
- Computed: true,
- Description: "The host of the instance in which the user belongs to.",
- MarkdownDescription: "The host of the instance in which the user belongs to.",
- },
- "id": schema.Int64Attribute{
+ "tf_original_api_id": schema.Int64Attribute{
Computed: true,
Description: "The ID of the user.",
MarkdownDescription: "The ID of the user.",
@@ -39,11 +29,6 @@ func UserDataSourceSchema(ctx context.Context) schema.Schema {
Description: "The name of the user.",
MarkdownDescription: "The name of the user.",
},
- "port": schema.Int64Attribute{
- Computed: true,
- Description: "The port of the instance in which the user belongs to.",
- MarkdownDescription: "The port of the instance in which the user belongs to.",
- },
"project_id": schema.StringAttribute{
Required: true,
Description: "The STACKIT project ID.",
@@ -80,15 +65,12 @@ func UserDataSourceSchema(ctx context.Context) schema.Schema {
}
type UserModel struct {
- ConnectionString types.String `tfsdk:"connection_string"`
- Host types.String `tfsdk:"host"`
- Id types.Int64 `tfsdk:"id"`
- InstanceId types.String `tfsdk:"instance_id"`
- Name types.String `tfsdk:"name"`
- Port types.Int64 `tfsdk:"port"`
- ProjectId types.String `tfsdk:"project_id"`
- Region types.String `tfsdk:"region"`
- Roles types.List `tfsdk:"roles"`
- Status types.String `tfsdk:"status"`
- UserId types.Int64 `tfsdk:"user_id"`
+ Id types.Int64 `tfsdk:"tf_original_api_id"`
+ InstanceId types.String `tfsdk:"instance_id"`
+ Name types.String `tfsdk:"name"`
+ ProjectId types.String `tfsdk:"project_id"`
+ Region types.String `tfsdk:"region"`
+ Roles types.List `tfsdk:"roles"`
+ Status types.String `tfsdk:"status"`
+ UserId types.Int64 `tfsdk:"user_id"`
}
diff --git a/stackit/internal/services/postgresflexalpha/user/resource.go b/stackit/internal/services/postgresflexalpha/user/resource.go
index 4df9577d..3aa5f519 100644
--- a/stackit/internal/services/postgresflexalpha/user/resource.go
+++ b/stackit/internal/services/postgresflexalpha/user/resource.go
@@ -556,11 +556,8 @@ func mapFields(userResp *postgresflex.GetUserResponse, model *Model, region stri
}
model.Roles = rolesSet
}
- model.Host = types.StringPointerValue(user.Host)
- model.Port = types.Int64PointerValue(user.Port)
model.Region = types.StringValue(region)
model.Status = types.StringPointerValue(user.Status)
- model.ConnectionString = types.StringPointerValue(user.ConnectionString)
return nil
}
diff --git a/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go b/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go
index 9734c2a9..f07ab701 100644
--- a/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go
+++ b/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go
@@ -19,11 +19,6 @@ func UserResourceSchema(ctx context.Context) schema.Schema {
Description: "The connection string for the user to the instance.",
MarkdownDescription: "The connection string for the user to the instance.",
},
- "host": schema.StringAttribute{
- Computed: true,
- Description: "The host of the instance in which the user belongs to.",
- MarkdownDescription: "The host of the instance in which the user belongs to.",
- },
"id": schema.Int64Attribute{
Computed: true,
Description: "The ID of the user.",
@@ -45,11 +40,6 @@ func UserResourceSchema(ctx context.Context) schema.Schema {
Description: "The password for the user.",
MarkdownDescription: "The password for the user.",
},
- "port": schema.Int64Attribute{
- Computed: true,
- Description: "The port of the instance in which the user belongs to.",
- MarkdownDescription: "The port of the instance in which the user belongs to.",
- },
"project_id": schema.StringAttribute{
Optional: true,
Computed: true,
@@ -91,12 +81,10 @@ func UserResourceSchema(ctx context.Context) schema.Schema {
type UserModel struct {
ConnectionString types.String `tfsdk:"connection_string"`
- Host types.String `tfsdk:"host"`
Id types.Int64 `tfsdk:"id"`
InstanceId types.String `tfsdk:"instance_id"`
Name types.String `tfsdk:"name"`
Password types.String `tfsdk:"password"`
- Port types.Int64 `tfsdk:"port"`
ProjectId types.String `tfsdk:"project_id"`
Region types.String `tfsdk:"region"`
Roles types.List `tfsdk:"roles"`
diff --git a/stackit/internal/services/sqlserverflexalpha/database/datasources_gen/database_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/database/datasources_gen/database_data_source_gen.go
index 25406f5f..82250802 100644
--- a/stackit/internal/services/sqlserverflexalpha/database/datasources_gen/database_data_source_gen.go
+++ b/stackit/internal/services/sqlserverflexalpha/database/datasources_gen/database_data_source_gen.go
@@ -29,7 +29,7 @@ func DatabaseDataSourceSchema(ctx context.Context) schema.Schema {
Description: "The name of the database.",
MarkdownDescription: "The name of the database.",
},
- "id": schema.Int64Attribute{
+ "tf_original_api_id": schema.Int64Attribute{
Computed: true,
Description: "The id of the database.",
MarkdownDescription: "The id of the database.",
@@ -72,7 +72,7 @@ type DatabaseModel struct {
CollationName types.String `tfsdk:"collation_name"`
CompatibilityLevel types.Int64 `tfsdk:"compatibility_level"`
DatabaseName types.String `tfsdk:"database_name"`
- Id types.Int64 `tfsdk:"id"`
+ Id types.Int64 `tfsdk:"tf_original_api_id"`
InstanceId types.String `tfsdk:"instance_id"`
Name types.String `tfsdk:"name"`
Owner types.String `tfsdk:"owner"`
diff --git a/stackit/internal/services/sqlserverflexalpha/flavors/datasources_gen/flavors_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/flavors/datasources_gen/flavors_data_source_gen.go
index 43ac64f5..40f086e2 100644
--- a/stackit/internal/services/sqlserverflexalpha/flavors/datasources_gen/flavors_data_source_gen.go
+++ b/stackit/internal/services/sqlserverflexalpha/flavors/datasources_gen/flavors_data_source_gen.go
@@ -33,7 +33,7 @@ func FlavorsDataSourceSchema(ctx context.Context) schema.Schema {
Description: "The flavor description.",
MarkdownDescription: "The flavor description.",
},
- "id": schema.StringAttribute{
+ "tf_original_api_id": schema.StringAttribute{
Computed: true,
Description: "The id of the instance flavor.",
MarkdownDescription: "The id of the instance flavor.",
diff --git a/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen/instance_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen/instance_data_source_gen.go
index dcf7f6dd..5880a392 100644
--- a/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen/instance_data_source_gen.go
+++ b/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen/instance_data_source_gen.go
@@ -65,7 +65,7 @@ func InstanceDataSourceSchema(ctx context.Context) schema.Schema {
Description: "The id of the instance flavor.",
MarkdownDescription: "The id of the instance flavor.",
},
- "id": schema.StringAttribute{
+ "tf_original_api_id": schema.StringAttribute{
Computed: true,
Description: "The ID of the instance.",
MarkdownDescription: "The ID of the instance.",
@@ -178,7 +178,7 @@ type InstanceModel struct {
Edition types.String `tfsdk:"edition"`
Encryption EncryptionValue `tfsdk:"encryption"`
FlavorId types.String `tfsdk:"flavor_id"`
- Id types.String `tfsdk:"id"`
+ Id types.String `tfsdk:"tf_original_api_id"`
InstanceId types.String `tfsdk:"instance_id"`
IsDeletable types.Bool `tfsdk:"is_deletable"`
Name types.String `tfsdk:"name"`
diff --git a/stackit/internal/services/sqlserverflexalpha/user/datasources_gen/user_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/user/datasources_gen/user_data_source_gen.go
index 3d252237..329469ea 100644
--- a/stackit/internal/services/sqlserverflexalpha/user/datasources_gen/user_data_source_gen.go
+++ b/stackit/internal/services/sqlserverflexalpha/user/datasources_gen/user_data_source_gen.go
@@ -98,7 +98,7 @@ func UserDataSourceSchema(ctx context.Context) schema.Schema {
"users": schema.ListNestedAttribute{
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
- "id": schema.Int64Attribute{
+ "tf_original_api_id": schema.Int64Attribute{
Computed: true,
Description: "The ID of the user.",
MarkdownDescription: "The ID of the user.",
diff --git a/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/database_data_source_fix.go b/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/database_data_source_fix.go
deleted file mode 100644
index 92b1064e..00000000
--- a/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/database_data_source_fix.go
+++ /dev/null
@@ -1,81 +0,0 @@
-// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
-
-package sqlserverflexbeta
-
-import (
- "context"
- "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-framework/types"
-
- "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
-)
-
-func DatabaseDataSourceSchema(ctx context.Context) schema.Schema {
- return schema.Schema{
- Attributes: map[string]schema.Attribute{
- "collation_name": schema.StringAttribute{
- Computed: true,
- Description: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
- MarkdownDescription: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
- },
- "compatibility_level": schema.Int64Attribute{
- Computed: true,
- Description: "CompatibilityLevel of the Database.",
- MarkdownDescription: "CompatibilityLevel of the Database.",
- },
- "database_name": schema.StringAttribute{
- Required: true,
- Description: "The name of the database.",
- MarkdownDescription: "The name of the database.",
- },
- "tf_original_api_id": schema.Int64Attribute{
- Computed: true,
- Description: "The id of the database.",
- MarkdownDescription: "The id of the database.",
- },
- "instance_id": schema.StringAttribute{
- Required: true,
- Description: "The ID of the instance.",
- MarkdownDescription: "The ID of the instance.",
- },
- "name": schema.StringAttribute{
- Computed: true,
- Description: "The name of the database.",
- MarkdownDescription: "The name of the database.",
- },
- "owner": schema.StringAttribute{
- Computed: true,
- Description: "The owner of the database.",
- MarkdownDescription: "The owner of the database.",
- },
- "project_id": schema.StringAttribute{
- Required: true,
- Description: "The STACKIT project ID.",
- MarkdownDescription: "The STACKIT project ID.",
- },
- "region": schema.StringAttribute{
- Required: true,
- Description: "The region which should be addressed",
- MarkdownDescription: "The region which should be addressed",
- Validators: []validator.String{
- stringvalidator.OneOf(
- "eu01",
- ),
- },
- },
- },
- }
-}
-
-type DatabaseModel struct {
- CollationName types.String `tfsdk:"collation_name"`
- CompatibilityLevel types.Int64 `tfsdk:"compatibility_level"`
- DatabaseName types.String `tfsdk:"database_name"`
- Id types.Int64 `tfsdk:"tf_original_api_id"`
- InstanceId types.String `tfsdk:"instance_id"`
- Name types.String `tfsdk:"name"`
- Owner types.String `tfsdk:"owner"`
- ProjectId types.String `tfsdk:"project_id"`
- Region types.String `tfsdk:"region"`
-}
diff --git a/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/databases_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/databases_data_source_gen.go
deleted file mode 100644
index 71ec8fb4..00000000
--- a/stackit/internal/services/sqlserverflexbeta/database/datasources_gen/databases_data_source_gen.go
+++ /dev/null
@@ -1,1180 +0,0 @@
-// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
-
-package sqlserverflexbeta
-
-import (
- "context"
- "fmt"
- "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
- "github.com/hashicorp/terraform-plugin-framework/attr"
- "github.com/hashicorp/terraform-plugin-framework/diag"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-framework/types"
- "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
- "github.com/hashicorp/terraform-plugin-go/tftypes"
- "strings"
-
- "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
-)
-
-func DatabasesDataSourceSchema(ctx context.Context) schema.Schema {
- return schema.Schema{
- Attributes: map[string]schema.Attribute{
- "databases": schema.ListNestedAttribute{
- NestedObject: schema.NestedAttributeObject{
- Attributes: map[string]schema.Attribute{
- "created": schema.StringAttribute{
- Computed: true,
- Description: "The date when the database was created in RFC3339 format.",
- MarkdownDescription: "The date when the database was created in RFC3339 format.",
- },
- "id": schema.Int64Attribute{
- Computed: true,
- Description: "The id of the database.",
- MarkdownDescription: "The id of the database.",
- },
- "name": schema.StringAttribute{
- Computed: true,
- Description: "The name of the database.",
- MarkdownDescription: "The name of the database.",
- },
- "owner": schema.StringAttribute{
- Computed: true,
- Description: "The owner of the database.",
- MarkdownDescription: "The owner of the database.",
- },
- },
- CustomType: DatabasesType{
- ObjectType: types.ObjectType{
- AttrTypes: DatabasesValue{}.AttributeTypes(ctx),
- },
- },
- },
- Computed: true,
- Description: "A list containing all databases for the instance.",
- MarkdownDescription: "A list containing all databases for the instance.",
- },
- "instance_id": schema.StringAttribute{
- Required: true,
- Description: "The ID of the instance.",
- MarkdownDescription: "The ID of the instance.",
- },
- "page": schema.Int64Attribute{
- Optional: true,
- Computed: true,
- Description: "Number of the page of items list to be returned.",
- MarkdownDescription: "Number of the page of items list to be returned.",
- },
- "pagination": schema.SingleNestedAttribute{
- Attributes: map[string]schema.Attribute{
- "page": schema.Int64Attribute{
- Computed: true,
- },
- "size": schema.Int64Attribute{
- Computed: true,
- },
- "sort": schema.StringAttribute{
- Computed: true,
- },
- "total_pages": schema.Int64Attribute{
- Computed: true,
- },
- "total_rows": schema.Int64Attribute{
- Computed: true,
- },
- },
- CustomType: PaginationType{
- ObjectType: types.ObjectType{
- AttrTypes: PaginationValue{}.AttributeTypes(ctx),
- },
- },
- Computed: true,
- },
- "project_id": schema.StringAttribute{
- Required: true,
- Description: "The STACKIT project ID.",
- MarkdownDescription: "The STACKIT project ID.",
- },
- "region": schema.StringAttribute{
- Required: true,
- Description: "The region which should be addressed",
- MarkdownDescription: "The region which should be addressed",
- Validators: []validator.String{
- stringvalidator.OneOf(
- "eu01",
- ),
- },
- },
- "size": schema.Int64Attribute{
- Optional: true,
- Computed: true,
- Description: "Number of items to be returned on each page.",
- MarkdownDescription: "Number of items to be returned on each page.",
- },
- "sort": schema.StringAttribute{
- Optional: true,
- Computed: true,
- Description: "Sorting of the databases to be returned on each page.",
- MarkdownDescription: "Sorting of the databases to be returned on each page.",
- Validators: []validator.String{
- stringvalidator.OneOf(
- "created_at.desc",
- "created_at.asc",
- "database_id.desc",
- "database_id.asc",
- "database_name.desc",
- "database_name.asc",
- "database_owner.desc",
- "database_owner.asc",
- "index.asc",
- "index.desc",
- ),
- },
- },
- },
- }
-}
-
-type DatabasesModel struct {
- Databases types.List `tfsdk:"databases"`
- InstanceId types.String `tfsdk:"instance_id"`
- Page types.Int64 `tfsdk:"page"`
- Pagination PaginationValue `tfsdk:"pagination"`
- ProjectId types.String `tfsdk:"project_id"`
- Region types.String `tfsdk:"region"`
- Size types.Int64 `tfsdk:"size"`
- Sort types.String `tfsdk:"sort"`
-}
-
-var _ basetypes.ObjectTypable = DatabasesType{}
-
-type DatabasesType struct {
- basetypes.ObjectType
-}
-
-func (t DatabasesType) Equal(o attr.Type) bool {
- other, ok := o.(DatabasesType)
-
- if !ok {
- return false
- }
-
- return t.ObjectType.Equal(other.ObjectType)
-}
-
-func (t DatabasesType) String() string {
- return "DatabasesType"
-}
-
-func (t DatabasesType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
- var diags diag.Diagnostics
-
- attributes := in.Attributes()
-
- createdAttribute, ok := attributes["created"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `created is missing from object`)
-
- return nil, diags
- }
-
- createdVal, ok := createdAttribute.(basetypes.StringValue)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`created expected to be basetypes.StringValue, was: %T`, createdAttribute))
- }
-
- idAttribute, ok := attributes["id"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `id is missing from object`)
-
- return nil, diags
- }
-
- idVal, ok := idAttribute.(basetypes.Int64Value)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
- }
-
- nameAttribute, ok := attributes["name"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `name is missing from object`)
-
- return nil, diags
- }
-
- nameVal, ok := nameAttribute.(basetypes.StringValue)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
- }
-
- ownerAttribute, ok := attributes["owner"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `owner is missing from object`)
-
- return nil, diags
- }
-
- ownerVal, ok := ownerAttribute.(basetypes.StringValue)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`owner expected to be basetypes.StringValue, was: %T`, ownerAttribute))
- }
-
- if diags.HasError() {
- return nil, diags
- }
-
- return DatabasesValue{
- Created: createdVal,
- Id: idVal,
- Name: nameVal,
- Owner: ownerVal,
- state: attr.ValueStateKnown,
- }, diags
-}
-
-func NewDatabasesValueNull() DatabasesValue {
- return DatabasesValue{
- state: attr.ValueStateNull,
- }
-}
-
-func NewDatabasesValueUnknown() DatabasesValue {
- return DatabasesValue{
- state: attr.ValueStateUnknown,
- }
-}
-
-func NewDatabasesValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (DatabasesValue, diag.Diagnostics) {
- var diags diag.Diagnostics
-
- // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
- ctx := context.Background()
-
- for name, attributeType := range attributeTypes {
- attribute, ok := attributes[name]
-
- if !ok {
- diags.AddError(
- "Missing DatabasesValue Attribute Value",
- "While creating a DatabasesValue value, a missing attribute value was detected. "+
- "A DatabasesValue must contain values for all attributes, even if null or unknown. "+
- "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
- fmt.Sprintf("DatabasesValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
- )
-
- continue
- }
-
- if !attributeType.Equal(attribute.Type(ctx)) {
- diags.AddError(
- "Invalid DatabasesValue Attribute Type",
- "While creating a DatabasesValue value, an invalid attribute value was detected. "+
- "A DatabasesValue must use a matching attribute type for the value. "+
- "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
- fmt.Sprintf("DatabasesValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
- fmt.Sprintf("DatabasesValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
- )
- }
- }
-
- for name := range attributes {
- _, ok := attributeTypes[name]
-
- if !ok {
- diags.AddError(
- "Extra DatabasesValue Attribute Value",
- "While creating a DatabasesValue value, an extra attribute value was detected. "+
- "A DatabasesValue must not contain values beyond the expected attribute types. "+
- "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
- fmt.Sprintf("Extra DatabasesValue Attribute Name: %s", name),
- )
- }
- }
-
- if diags.HasError() {
- return NewDatabasesValueUnknown(), diags
- }
-
- createdAttribute, ok := attributes["created"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `created is missing from object`)
-
- return NewDatabasesValueUnknown(), diags
- }
-
- createdVal, ok := createdAttribute.(basetypes.StringValue)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`created expected to be basetypes.StringValue, was: %T`, createdAttribute))
- }
-
- idAttribute, ok := attributes["id"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `id is missing from object`)
-
- return NewDatabasesValueUnknown(), diags
- }
-
- idVal, ok := idAttribute.(basetypes.Int64Value)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`id expected to be basetypes.Int64Value, was: %T`, idAttribute))
- }
-
- nameAttribute, ok := attributes["name"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `name is missing from object`)
-
- return NewDatabasesValueUnknown(), diags
- }
-
- nameVal, ok := nameAttribute.(basetypes.StringValue)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`name expected to be basetypes.StringValue, was: %T`, nameAttribute))
- }
-
- ownerAttribute, ok := attributes["owner"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `owner is missing from object`)
-
- return NewDatabasesValueUnknown(), diags
- }
-
- ownerVal, ok := ownerAttribute.(basetypes.StringValue)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`owner expected to be basetypes.StringValue, was: %T`, ownerAttribute))
- }
-
- if diags.HasError() {
- return NewDatabasesValueUnknown(), diags
- }
-
- return DatabasesValue{
- Created: createdVal,
- Id: idVal,
- Name: nameVal,
- Owner: ownerVal,
- state: attr.ValueStateKnown,
- }, diags
-}
-
-func NewDatabasesValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) DatabasesValue {
- object, diags := NewDatabasesValue(attributeTypes, attributes)
-
- if diags.HasError() {
- // This could potentially be added to the diag package.
- diagsStrings := make([]string, 0, len(diags))
-
- for _, diagnostic := range diags {
- diagsStrings = append(diagsStrings, fmt.Sprintf(
- "%s | %s | %s",
- diagnostic.Severity(),
- diagnostic.Summary(),
- diagnostic.Detail()))
- }
-
- panic("NewDatabasesValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
- }
-
- return object
-}
-
-func (t DatabasesType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
- if in.Type() == nil {
- return NewDatabasesValueNull(), nil
- }
-
- if !in.Type().Equal(t.TerraformType(ctx)) {
- return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
- }
-
- if !in.IsKnown() {
- return NewDatabasesValueUnknown(), nil
- }
-
- if in.IsNull() {
- return NewDatabasesValueNull(), nil
- }
-
- attributes := map[string]attr.Value{}
-
- val := map[string]tftypes.Value{}
-
- err := in.As(&val)
-
- if err != nil {
- return nil, err
- }
-
- for k, v := range val {
- a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
-
- if err != nil {
- return nil, err
- }
-
- attributes[k] = a
- }
-
- return NewDatabasesValueMust(DatabasesValue{}.AttributeTypes(ctx), attributes), nil
-}
-
-func (t DatabasesType) ValueType(ctx context.Context) attr.Value {
- return DatabasesValue{}
-}
-
-var _ basetypes.ObjectValuable = DatabasesValue{}
-
-type DatabasesValue struct {
- Created basetypes.StringValue `tfsdk:"created"`
- Id basetypes.Int64Value `tfsdk:"id"`
- Name basetypes.StringValue `tfsdk:"name"`
- Owner basetypes.StringValue `tfsdk:"owner"`
- state attr.ValueState
-}
-
-func (v DatabasesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
- attrTypes := make(map[string]tftypes.Type, 4)
-
- var val tftypes.Value
- var err error
-
- attrTypes["created"] = basetypes.StringType{}.TerraformType(ctx)
- attrTypes["id"] = basetypes.Int64Type{}.TerraformType(ctx)
- attrTypes["name"] = basetypes.StringType{}.TerraformType(ctx)
- attrTypes["owner"] = basetypes.StringType{}.TerraformType(ctx)
-
- objectType := tftypes.Object{AttributeTypes: attrTypes}
-
- switch v.state {
- case attr.ValueStateKnown:
- vals := make(map[string]tftypes.Value, 4)
-
- val, err = v.Created.ToTerraformValue(ctx)
-
- if err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- vals["created"] = val
-
- val, err = v.Id.ToTerraformValue(ctx)
-
- if err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- vals["id"] = val
-
- val, err = v.Name.ToTerraformValue(ctx)
-
- if err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- vals["name"] = val
-
- val, err = v.Owner.ToTerraformValue(ctx)
-
- if err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- vals["owner"] = val
-
- if err := tftypes.ValidateValue(objectType, vals); err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- return tftypes.NewValue(objectType, vals), nil
- case attr.ValueStateNull:
- return tftypes.NewValue(objectType, nil), nil
- case attr.ValueStateUnknown:
- return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
- default:
- panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
- }
-}
-
-func (v DatabasesValue) IsNull() bool {
- return v.state == attr.ValueStateNull
-}
-
-func (v DatabasesValue) IsUnknown() bool {
- return v.state == attr.ValueStateUnknown
-}
-
-func (v DatabasesValue) String() string {
- return "DatabasesValue"
-}
-
-func (v DatabasesValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
- var diags diag.Diagnostics
-
- attributeTypes := map[string]attr.Type{
- "created": basetypes.StringType{},
- "id": basetypes.Int64Type{},
- "name": basetypes.StringType{},
- "owner": basetypes.StringType{},
- }
-
- if v.IsNull() {
- return types.ObjectNull(attributeTypes), diags
- }
-
- if v.IsUnknown() {
- return types.ObjectUnknown(attributeTypes), diags
- }
-
- objVal, diags := types.ObjectValue(
- attributeTypes,
- map[string]attr.Value{
- "created": v.Created,
- "id": v.Id,
- "name": v.Name,
- "owner": v.Owner,
- })
-
- return objVal, diags
-}
-
-func (v DatabasesValue) Equal(o attr.Value) bool {
- other, ok := o.(DatabasesValue)
-
- if !ok {
- return false
- }
-
- if v.state != other.state {
- return false
- }
-
- if v.state != attr.ValueStateKnown {
- return true
- }
-
- if !v.Created.Equal(other.Created) {
- return false
- }
-
- if !v.Id.Equal(other.Id) {
- return false
- }
-
- if !v.Name.Equal(other.Name) {
- return false
- }
-
- if !v.Owner.Equal(other.Owner) {
- return false
- }
-
- return true
-}
-
-func (v DatabasesValue) Type(ctx context.Context) attr.Type {
- return DatabasesType{
- basetypes.ObjectType{
- AttrTypes: v.AttributeTypes(ctx),
- },
- }
-}
-
-func (v DatabasesValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
- return map[string]attr.Type{
- "created": basetypes.StringType{},
- "id": basetypes.Int64Type{},
- "name": basetypes.StringType{},
- "owner": basetypes.StringType{},
- }
-}
-
-var _ basetypes.ObjectTypable = PaginationType{}
-
-type PaginationType struct {
- basetypes.ObjectType
-}
-
-func (t PaginationType) Equal(o attr.Type) bool {
- other, ok := o.(PaginationType)
-
- if !ok {
- return false
- }
-
- return t.ObjectType.Equal(other.ObjectType)
-}
-
-func (t PaginationType) String() string {
- return "PaginationType"
-}
-
-func (t PaginationType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) {
- var diags diag.Diagnostics
-
- attributes := in.Attributes()
-
- pageAttribute, ok := attributes["page"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `page is missing from object`)
-
- return nil, diags
- }
-
- pageVal, ok := pageAttribute.(basetypes.Int64Value)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
- }
-
- sizeAttribute, ok := attributes["size"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `size is missing from object`)
-
- return nil, diags
- }
-
- sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
- }
-
- sortAttribute, ok := attributes["sort"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `sort is missing from object`)
-
- return nil, diags
- }
-
- sortVal, ok := sortAttribute.(basetypes.StringValue)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
- }
-
- totalPagesAttribute, ok := attributes["total_pages"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `total_pages is missing from object`)
-
- return nil, diags
- }
-
- totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
- }
-
- totalRowsAttribute, ok := attributes["total_rows"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `total_rows is missing from object`)
-
- return nil, diags
- }
-
- totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
- }
-
- if diags.HasError() {
- return nil, diags
- }
-
- return PaginationValue{
- Page: pageVal,
- Size: sizeVal,
- Sort: sortVal,
- TotalPages: totalPagesVal,
- TotalRows: totalRowsVal,
- state: attr.ValueStateKnown,
- }, diags
-}
-
-func NewPaginationValueNull() PaginationValue {
- return PaginationValue{
- state: attr.ValueStateNull,
- }
-}
-
-func NewPaginationValueUnknown() PaginationValue {
- return PaginationValue{
- state: attr.ValueStateUnknown,
- }
-}
-
-func NewPaginationValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (PaginationValue, diag.Diagnostics) {
- var diags diag.Diagnostics
-
- // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521
- ctx := context.Background()
-
- for name, attributeType := range attributeTypes {
- attribute, ok := attributes[name]
-
- if !ok {
- diags.AddError(
- "Missing PaginationValue Attribute Value",
- "While creating a PaginationValue value, a missing attribute value was detected. "+
- "A PaginationValue must contain values for all attributes, even if null or unknown. "+
- "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
- fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()),
- )
-
- continue
- }
-
- if !attributeType.Equal(attribute.Type(ctx)) {
- diags.AddError(
- "Invalid PaginationValue Attribute Type",
- "While creating a PaginationValue value, an invalid attribute value was detected. "+
- "A PaginationValue must use a matching attribute type for the value. "+
- "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
- fmt.Sprintf("PaginationValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+
- fmt.Sprintf("PaginationValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)),
- )
- }
- }
-
- for name := range attributes {
- _, ok := attributeTypes[name]
-
- if !ok {
- diags.AddError(
- "Extra PaginationValue Attribute Value",
- "While creating a PaginationValue value, an extra attribute value was detected. "+
- "A PaginationValue must not contain values beyond the expected attribute types. "+
- "This is always an issue with the provider and should be reported to the provider developers.\n\n"+
- fmt.Sprintf("Extra PaginationValue Attribute Name: %s", name),
- )
- }
- }
-
- if diags.HasError() {
- return NewPaginationValueUnknown(), diags
- }
-
- pageAttribute, ok := attributes["page"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `page is missing from object`)
-
- return NewPaginationValueUnknown(), diags
- }
-
- pageVal, ok := pageAttribute.(basetypes.Int64Value)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`page expected to be basetypes.Int64Value, was: %T`, pageAttribute))
- }
-
- sizeAttribute, ok := attributes["size"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `size is missing from object`)
-
- return NewPaginationValueUnknown(), diags
- }
-
- sizeVal, ok := sizeAttribute.(basetypes.Int64Value)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`size expected to be basetypes.Int64Value, was: %T`, sizeAttribute))
- }
-
- sortAttribute, ok := attributes["sort"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `sort is missing from object`)
-
- return NewPaginationValueUnknown(), diags
- }
-
- sortVal, ok := sortAttribute.(basetypes.StringValue)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`sort expected to be basetypes.StringValue, was: %T`, sortAttribute))
- }
-
- totalPagesAttribute, ok := attributes["total_pages"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `total_pages is missing from object`)
-
- return NewPaginationValueUnknown(), diags
- }
-
- totalPagesVal, ok := totalPagesAttribute.(basetypes.Int64Value)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`total_pages expected to be basetypes.Int64Value, was: %T`, totalPagesAttribute))
- }
-
- totalRowsAttribute, ok := attributes["total_rows"]
-
- if !ok {
- diags.AddError(
- "Attribute Missing",
- `total_rows is missing from object`)
-
- return NewPaginationValueUnknown(), diags
- }
-
- totalRowsVal, ok := totalRowsAttribute.(basetypes.Int64Value)
-
- if !ok {
- diags.AddError(
- "Attribute Wrong Type",
- fmt.Sprintf(`total_rows expected to be basetypes.Int64Value, was: %T`, totalRowsAttribute))
- }
-
- if diags.HasError() {
- return NewPaginationValueUnknown(), diags
- }
-
- return PaginationValue{
- Page: pageVal,
- Size: sizeVal,
- Sort: sortVal,
- TotalPages: totalPagesVal,
- TotalRows: totalRowsVal,
- state: attr.ValueStateKnown,
- }, diags
-}
-
-func NewPaginationValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) PaginationValue {
- object, diags := NewPaginationValue(attributeTypes, attributes)
-
- if diags.HasError() {
- // This could potentially be added to the diag package.
- diagsStrings := make([]string, 0, len(diags))
-
- for _, diagnostic := range diags {
- diagsStrings = append(diagsStrings, fmt.Sprintf(
- "%s | %s | %s",
- diagnostic.Severity(),
- diagnostic.Summary(),
- diagnostic.Detail()))
- }
-
- panic("NewPaginationValueMust received error(s): " + strings.Join(diagsStrings, "\n"))
- }
-
- return object
-}
-
-func (t PaginationType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
- if in.Type() == nil {
- return NewPaginationValueNull(), nil
- }
-
- if !in.Type().Equal(t.TerraformType(ctx)) {
- return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type())
- }
-
- if !in.IsKnown() {
- return NewPaginationValueUnknown(), nil
- }
-
- if in.IsNull() {
- return NewPaginationValueNull(), nil
- }
-
- attributes := map[string]attr.Value{}
-
- val := map[string]tftypes.Value{}
-
- err := in.As(&val)
-
- if err != nil {
- return nil, err
- }
-
- for k, v := range val {
- a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v)
-
- if err != nil {
- return nil, err
- }
-
- attributes[k] = a
- }
-
- return NewPaginationValueMust(PaginationValue{}.AttributeTypes(ctx), attributes), nil
-}
-
-func (t PaginationType) ValueType(ctx context.Context) attr.Value {
- return PaginationValue{}
-}
-
-var _ basetypes.ObjectValuable = PaginationValue{}
-
-type PaginationValue struct {
- Page basetypes.Int64Value `tfsdk:"page"`
- Size basetypes.Int64Value `tfsdk:"size"`
- Sort basetypes.StringValue `tfsdk:"sort"`
- TotalPages basetypes.Int64Value `tfsdk:"total_pages"`
- TotalRows basetypes.Int64Value `tfsdk:"total_rows"`
- state attr.ValueState
-}
-
-func (v PaginationValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) {
- attrTypes := make(map[string]tftypes.Type, 5)
-
- var val tftypes.Value
- var err error
-
- attrTypes["page"] = basetypes.Int64Type{}.TerraformType(ctx)
- attrTypes["size"] = basetypes.Int64Type{}.TerraformType(ctx)
- attrTypes["sort"] = basetypes.StringType{}.TerraformType(ctx)
- attrTypes["total_pages"] = basetypes.Int64Type{}.TerraformType(ctx)
- attrTypes["total_rows"] = basetypes.Int64Type{}.TerraformType(ctx)
-
- objectType := tftypes.Object{AttributeTypes: attrTypes}
-
- switch v.state {
- case attr.ValueStateKnown:
- vals := make(map[string]tftypes.Value, 5)
-
- val, err = v.Page.ToTerraformValue(ctx)
-
- if err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- vals["page"] = val
-
- val, err = v.Size.ToTerraformValue(ctx)
-
- if err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- vals["size"] = val
-
- val, err = v.Sort.ToTerraformValue(ctx)
-
- if err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- vals["sort"] = val
-
- val, err = v.TotalPages.ToTerraformValue(ctx)
-
- if err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- vals["total_pages"] = val
-
- val, err = v.TotalRows.ToTerraformValue(ctx)
-
- if err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- vals["total_rows"] = val
-
- if err := tftypes.ValidateValue(objectType, vals); err != nil {
- return tftypes.NewValue(objectType, tftypes.UnknownValue), err
- }
-
- return tftypes.NewValue(objectType, vals), nil
- case attr.ValueStateNull:
- return tftypes.NewValue(objectType, nil), nil
- case attr.ValueStateUnknown:
- return tftypes.NewValue(objectType, tftypes.UnknownValue), nil
- default:
- panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state))
- }
-}
-
-func (v PaginationValue) IsNull() bool {
- return v.state == attr.ValueStateNull
-}
-
-func (v PaginationValue) IsUnknown() bool {
- return v.state == attr.ValueStateUnknown
-}
-
-func (v PaginationValue) String() string {
- return "PaginationValue"
-}
-
-func (v PaginationValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
- var diags diag.Diagnostics
-
- attributeTypes := map[string]attr.Type{
- "page": basetypes.Int64Type{},
- "size": basetypes.Int64Type{},
- "sort": basetypes.StringType{},
- "total_pages": basetypes.Int64Type{},
- "total_rows": basetypes.Int64Type{},
- }
-
- if v.IsNull() {
- return types.ObjectNull(attributeTypes), diags
- }
-
- if v.IsUnknown() {
- return types.ObjectUnknown(attributeTypes), diags
- }
-
- objVal, diags := types.ObjectValue(
- attributeTypes,
- map[string]attr.Value{
- "page": v.Page,
- "size": v.Size,
- "sort": v.Sort,
- "total_pages": v.TotalPages,
- "total_rows": v.TotalRows,
- })
-
- return objVal, diags
-}
-
-func (v PaginationValue) Equal(o attr.Value) bool {
- other, ok := o.(PaginationValue)
-
- if !ok {
- return false
- }
-
- if v.state != other.state {
- return false
- }
-
- if v.state != attr.ValueStateKnown {
- return true
- }
-
- if !v.Page.Equal(other.Page) {
- return false
- }
-
- if !v.Size.Equal(other.Size) {
- return false
- }
-
- if !v.Sort.Equal(other.Sort) {
- return false
- }
-
- if !v.TotalPages.Equal(other.TotalPages) {
- return false
- }
-
- if !v.TotalRows.Equal(other.TotalRows) {
- return false
- }
-
- return true
-}
-
-func (v PaginationValue) Type(ctx context.Context) attr.Type {
- return PaginationType{
- basetypes.ObjectType{
- AttrTypes: v.AttributeTypes(ctx),
- },
- }
-}
-
-func (v PaginationValue) AttributeTypes(ctx context.Context) map[string]attr.Type {
- return map[string]attr.Type{
- "page": basetypes.Int64Type{},
- "size": basetypes.Int64Type{},
- "sort": basetypes.StringType{},
- "total_pages": basetypes.Int64Type{},
- "total_rows": basetypes.Int64Type{},
- }
-}
diff --git a/stackit/internal/services/sqlserverflexbeta/database/resources_gen/database_resource_gen.go b/stackit/internal/services/sqlserverflexbeta/database/resources_gen/database_resource_gen.go
deleted file mode 100644
index dccae0c4..00000000
--- a/stackit/internal/services/sqlserverflexbeta/database/resources_gen/database_resource_gen.go
+++ /dev/null
@@ -1,99 +0,0 @@
-// Code generated by terraform-plugin-framework-generator DO NOT EDIT.
-
-package sqlserverflexbeta
-
-import (
- "context"
- "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
- "github.com/hashicorp/terraform-plugin-framework/schema/validator"
- "github.com/hashicorp/terraform-plugin-framework/types"
-
- "github.com/hashicorp/terraform-plugin-framework/resource/schema"
-)
-
-func DatabaseResourceSchema(ctx context.Context) schema.Schema {
- return schema.Schema{
- Attributes: map[string]schema.Attribute{
- "collation": schema.StringAttribute{
- Optional: true,
- Computed: true,
- Description: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
- MarkdownDescription: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
- },
- "collation_name": schema.StringAttribute{
- Computed: true,
- Description: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
- MarkdownDescription: "The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.",
- },
- "compatibility": schema.Int64Attribute{
- Optional: true,
- Computed: true,
- Description: "CompatibilityLevel of the Database.",
- MarkdownDescription: "CompatibilityLevel of the Database.",
- },
- "compatibility_level": schema.Int64Attribute{
- Computed: true,
- Description: "CompatibilityLevel of the Database.",
- MarkdownDescription: "CompatibilityLevel of the Database.",
- },
- "database_name": schema.StringAttribute{
- Optional: true,
- Computed: true,
- Description: "The name of the database.",
- MarkdownDescription: "The name of the database.",
- },
- "id": schema.Int64Attribute{
- Computed: true,
- Description: "The id of the database.",
- MarkdownDescription: "The id of the database.",
- },
- "instance_id": schema.StringAttribute{
- Optional: true,
- Computed: true,
- Description: "The ID of the instance.",
- MarkdownDescription: "The ID of the instance.",
- },
- "name": schema.StringAttribute{
- Required: true,
- Description: "The name of the database.",
- MarkdownDescription: "The name of the database.",
- },
- "owner": schema.StringAttribute{
- Required: true,
- Description: "The owner of the database.",
- MarkdownDescription: "The owner of the database.",
- },
- "project_id": schema.StringAttribute{
- Optional: true,
- Computed: true,
- Description: "The STACKIT project ID.",
- MarkdownDescription: "The STACKIT project ID.",
- },
- "region": schema.StringAttribute{
- Optional: true,
- Computed: true,
- Description: "The region which should be addressed",
- MarkdownDescription: "The region which should be addressed",
- Validators: []validator.String{
- stringvalidator.OneOf(
- "eu01",
- ),
- },
- },
- },
- }
-}
-
-type DatabaseModel struct {
- Collation types.String `tfsdk:"collation"`
- CollationName types.String `tfsdk:"collation_name"`
- Compatibility types.Int64 `tfsdk:"compatibility"`
- CompatibilityLevel types.Int64 `tfsdk:"compatibility_level"`
- DatabaseName types.String `tfsdk:"database_name"`
- Id types.Int64 `tfsdk:"id"`
- InstanceId types.String `tfsdk:"instance_id"`
- Name types.String `tfsdk:"name"`
- Owner types.String `tfsdk:"owner"`
- ProjectId types.String `tfsdk:"project_id"`
- Region types.String `tfsdk:"region"`
-}
diff --git a/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen/instance_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen/instance_data_source_gen.go
index 87476c3c..f3226581 100644
--- a/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen/instance_data_source_gen.go
+++ b/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen/instance_data_source_gen.go
@@ -65,7 +65,7 @@ func InstanceDataSourceSchema(ctx context.Context) schema.Schema {
Description: "The id of the instance flavor.",
MarkdownDescription: "The id of the instance flavor.",
},
- "id": schema.StringAttribute{
+ "tf_original_api_id": schema.StringAttribute{
Computed: true,
Description: "The ID of the instance.",
MarkdownDescription: "The ID of the instance.",
@@ -178,7 +178,7 @@ type InstanceModel struct {
Edition types.String `tfsdk:"edition"`
Encryption EncryptionValue `tfsdk:"encryption"`
FlavorId types.String `tfsdk:"flavor_id"`
- Id types.String `tfsdk:"id"`
+ Id types.String `tfsdk:"tf_original_api_id"`
InstanceId types.String `tfsdk:"instance_id"`
IsDeletable types.Bool `tfsdk:"is_deletable"`
Name types.String `tfsdk:"name"`
diff --git a/stackit/internal/services/sqlserverflexbeta/instance/resource_test.go b/stackit/internal/services/sqlserverflexbeta/instance/resource_test.go
index 64acf850..effced4e 100644
--- a/stackit/internal/services/sqlserverflexbeta/instance/resource_test.go
+++ b/stackit/internal/services/sqlserverflexbeta/instance/resource_test.go
@@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
+ "github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/hashicorp/terraform-plugin-testing/statecheck"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
@@ -160,6 +161,12 @@ func TestAccResourceExample_basic(t *testing.T) {
// test create
{
Config: exBefore,
+ ConfigPlanChecks: resource.ConfigPlanChecks{
+ PreApply: []plancheck.PlanCheck{
+ plancheck.ExpectResourceAction(resName, plancheck.ResourceActionCreate),
+ plancheck.ExpectNonEmptyPlan(),
+ },
+ },
ConfigStateChecks: []statecheck.StateCheck{
compareValuesSame.AddStateValue(
resName,
diff --git a/stackit/internal/services/sqlserverflexbeta/user/datasources_gen/user_data_source_gen.go b/stackit/internal/services/sqlserverflexbeta/user/datasources_gen/user_data_source_gen.go
index 1950c24e..34aef9ca 100644
--- a/stackit/internal/services/sqlserverflexbeta/user/datasources_gen/user_data_source_gen.go
+++ b/stackit/internal/services/sqlserverflexbeta/user/datasources_gen/user_data_source_gen.go
@@ -98,7 +98,7 @@ func UserDataSourceSchema(ctx context.Context) schema.Schema {
"users": schema.ListNestedAttribute{
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
- "id": schema.Int64Attribute{
+ "tf_original_api_id": schema.Int64Attribute{
Computed: true,
Description: "The ID of the user.",
MarkdownDescription: "The ID of the user.",