0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-06-30 10:33:46 +00:00
terraform-provider-proxmox/fwprovider/vm/resource_model.go
Pavel Boldyrev d8202dd7a1
chore(vm2): initial experimental VM resource implementation using Plugin Framework (#1230)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
2024-04-19 21:57:12 +00:00

33 lines
953 B
Go

package vm
import (
"errors"
"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/bpg/terraform-provider-proxmox/proxmox/nodes/vms"
)
type vmModel struct {
Description types.String `tfsdk:"description"`
ID types.Int64 `tfsdk:"id"`
Name types.String `tfsdk:"name"`
NodeName types.String `tfsdk:"node_name"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
}
func (m *vmModel) updateFromAPI(config vms.GetResponseData, status vms.GetStatusResponseData) error {
if status.VMID == nil {
return errors.New("VM ID is missing in status API response")
}
m.ID = types.Int64Value(int64(*status.VMID))
// Optional fields can be removed from the model, use StringPointerValue to handle removal on nil
m.Description = types.StringPointerValue(config.Description)
m.Name = types.StringPointerValue(config.Name)
return nil
}