terraform-provider-stackitp.../stackit/internal/services/postgresflexalpha/instance/models.go
harmsan 979220be66
chore: adjust pagination for postgres database and flavor listing (#20)
* feat: implement pagination for database listing

* fix: change database_id attribute type from string to int64

* refactor: rename getDatabase to getDatabaseById for clarity

* fix: improve error handling for database not found scenario

* feat: add validation for database_id and name attributes; implement separate functions for fetching databases by ID and name

* feat: implement database client interface and update database fetching functions

* refactor: rename matcher to filter for clarity and update pagination logic

* feat: implement flavors retrieval with pagination and filtering support

* refactor: rename flavor import for consistency and clarity

* feat: add support for InstanceStatePending in wait handler logic

* refactor: simplify GetFlavorsRequest and GetFlavorsRequestExecute by removing pagination parameters

* refactor: improve readability of test cases by formatting function signatures and restructuring test runs

* refactor: remove pagination parameters from GetFlavorsRequest in test case

* refactor: simplify function signatures and improve readability in datasource and resource files

* refactor: add descriptions for user-related attributes in datasource schema

* refactor: enhance user resource schema with additional attributes and improve logging

* refactor: delete unused file

* refactor: standardize formatting and improve function naming for user resource management

* refactor: remove skip from TestMapFields and update roles initialization in resource tests

* fix: golangci lint issues

* fix: golangci lint issues again

* fix: golangci lint issues again
2026-01-16 16:23:10 +01:00

63 lines
2.1 KiB
Go

package postgresflexalpha
import (
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
)
type Model struct {
Id types.String `tfsdk:"id"` // needed by TF
InstanceId types.String `tfsdk:"instance_id"`
ProjectId types.String `tfsdk:"project_id"`
Name types.String `tfsdk:"name"`
BackupSchedule types.String `tfsdk:"backup_schedule"`
FlavorId types.String `tfsdk:"flavor_id"`
Replicas types.Int64 `tfsdk:"replicas"`
RetentionDays types.Int64 `tfsdk:"retention_days"`
Storage types.Object `tfsdk:"storage"`
Version types.String `tfsdk:"version"`
Region types.String `tfsdk:"region"`
Encryption types.Object `tfsdk:"encryption"`
Network types.Object `tfsdk:"network"`
}
type encryptionModel struct {
KeyRingId types.String `tfsdk:"keyring_id"`
KeyId types.String `tfsdk:"key_id"`
KeyVersion types.String `tfsdk:"key_version"`
ServiceAccount types.String `tfsdk:"service_account"`
}
var encryptionTypes = map[string]attr.Type{
"keyring_id": basetypes.StringType{},
"key_id": basetypes.StringType{},
"key_version": basetypes.StringType{},
"service_account": basetypes.StringType{},
}
type networkModel struct {
ACL types.List `tfsdk:"acl"`
AccessScope types.String `tfsdk:"access_scope"`
InstanceAddress types.String `tfsdk:"instance_address"`
RouterAddress types.String `tfsdk:"router_address"`
}
var networkTypes = map[string]attr.Type{
"acl": basetypes.ListType{ElemType: types.StringType},
"access_scope": basetypes.StringType{},
"instance_address": basetypes.StringType{},
"router_address": basetypes.StringType{},
}
// Struct corresponding to Model.Storage
type storageModel struct {
Class types.String `tfsdk:"class"`
Size types.Int64 `tfsdk:"size"`
}
// Types corresponding to storageModel
var storageTypes = map[string]attr.Type{
"class": basetypes.StringType{},
"size": basetypes.Int64Type{},
}