Skip to content

Commit

Permalink
refactor: fixed resources transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
vmyroslav committed Dec 5, 2024
1 parent b052c93 commit 296ff25
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,15 @@ func resourceOrganizationUserGroupCreate(ctx context.Context, d *schema.Resource
req usergroup.UserGroupCreateIn
)

if err := schemautil.ResourceDataGet(d, &req); err != nil {
// replace the key in terraform with the correct key in the API
if err := schemautil.ResourceDataGet(
d,
&req,
schemautil.RenameAliases(map[string]string{"name": "user_group_name"}),
); err != nil {
return err
}

req.UserGroupName = d.Get("name").(string)

resp, err := client.UserGroupCreate(ctx, orgID, &req)
if err != nil {
return err
Expand All @@ -99,19 +102,15 @@ func resourceOrganizationUserGroupReadGen(ctx context.Context, d *schema.Resourc
return err
}

if err = d.Set("name", resp.UserGroupName); err != nil {
return err
}
if err = d.Set("description", resp.Description); err != nil {
return err
}
if err = d.Set("create_time", resp.CreateTime.String()); err != nil {
return err
}
if err = d.Set("update_time", resp.UpdateTime.String()); err != nil {
return err
}
if err = d.Set("group_id", resp.UserGroupId); err != nil {
if err = schemautil.ResourceDataSet(
aivenOrganizationUserGroupSchema,
d,
resp,
schemautil.RenameAliases(map[string]string{
"user_group_name": "name",
"user_group_id": "group_id",
}),
); err != nil {
return err
}

Expand Down

0 comments on commit 296ff25

Please sign in to comment.