package snapshot

import (
	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
	"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
)

func flattenSnapshotList(gl *compute.ListSnapShots) []map[string]interface{} {
	res := make([]map[string]interface{}, 0, len(gl.Data))
	for _, item := range gl.Data {
		temp := map[string]interface{}{
			"label":     item.Label,
			"guid":      item.GUID,
			"disks":     item.Disks,
			"timestamp": item.Timestamp,
		}

		res = append(res, temp)
	}
	return res
}

func flattenSnapshot(d *schema.ResourceData, snapshot *compute.ItemSnapshot) {
	d.Set("timestamp", snapshot.Timestamp)
	d.Set("guid", snapshot.GUID)
	d.Set("disks", snapshot.Disks)
	d.Set("label", snapshot.Label)
}
