feat: refactor data source models and update mapping functions for improved consistency
This commit is contained in:
parent
f0e7c19cdf
commit
184e133a2a
34 changed files with 980 additions and 1017 deletions
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
// mapDataSourceFields maps API response to data source model, preserving existing ID.
|
||||
func mapDataSourceFields(userResp *postgresflex.GetUserResponse, model *DataSourceModel, region string) error {
|
||||
func mapDataSourceFields(userResp *postgresflex.GetUserResponse, model *dataSourceModel, region string) error {
|
||||
if userResp == nil {
|
||||
return fmt.Errorf("response is nil")
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ func toPayloadRoles(roles *[]string) *[]postgresflex.UserRole {
|
|||
}
|
||||
|
||||
// toUpdatePayload creates an API update payload from the resource model.
|
||||
func toUpdatePayload(model *ResourceModel, roles *[]string) (
|
||||
func toUpdatePayload(model *resourceModel, roles *[]string) (
|
||||
*postgresflex.UpdateUserRequestPayload,
|
||||
error,
|
||||
) {
|
||||
|
|
@ -86,7 +86,7 @@ func toUpdatePayload(model *ResourceModel, roles *[]string) (
|
|||
}
|
||||
|
||||
// toCreatePayload creates an API create payload from the resource model.
|
||||
func toCreatePayload(model *ResourceModel, roles *[]string) (*postgresflex.CreateUserRequestPayload, error) {
|
||||
func toCreatePayload(model *resourceModel, roles *[]string) (*postgresflex.CreateUserRequestPayload, error) {
|
||||
if model == nil {
|
||||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ func toCreatePayload(model *ResourceModel, roles *[]string) (*postgresflex.Creat
|
|||
}
|
||||
|
||||
// mapResourceFields maps API response to the resource model, preserving existing ID.
|
||||
func mapResourceFields(userResp *postgresflex.GetUserResponse, model *ResourceModel, region string) error {
|
||||
func mapResourceFields(userResp *postgresflex.GetUserResponse, model *resourceModel, region string) error {
|
||||
if userResp == nil {
|
||||
return fmt.Errorf("response is nil")
|
||||
}
|
||||
|
|
@ -118,9 +118,7 @@ func mapResourceFields(userResp *postgresflex.GetUserResponse, model *ResourceMo
|
|||
} else {
|
||||
return fmt.Errorf("user id not present")
|
||||
}
|
||||
model.TerraformID = utils.BuildInternalTerraformId(
|
||||
model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), strconv.FormatInt(userId, 10),
|
||||
)
|
||||
|
||||
model.Id = types.Int64Value(userId)
|
||||
model.UserId = types.Int64Value(userId)
|
||||
model.Name = types.StringPointerValue(user.Name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue