package vmfolder import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" log "github.com/sirupsen/logrus" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vmfolder" ) func flattenVMFolder(d *schema.ResourceData, folder *vmfolder.RecordVMFolder) { log.Debugf("flattenVMFolder: decoded vm folder ID %d", folder.ID) d.Set("folder_id", folder.ID) d.Set("rg_id", folder.RGID) d.Set("gid", folder.GID) d.Set("name", folder.Name) d.Set("acl", flattenVMFolderACL(folder.ACL)) d.Set("created_time", folder.CreatedTime) d.Set("parent_id", folder.ParentID) d.Set("status", folder.Status) d.Set("compute_ids", folder.ComputeIDs) } func flattenVMFolderACL(acl []vmfolder.ACL) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(acl)) for _, item := range acl { temp := map[string]interface{}{ "explicit": item.Explicit, "right": item.Right, "status": item.Status, "type": item.Type, "user_group_id": item.UserGroupID, } res = append(res, temp) } return res } func flattenVMFolderList(folderList *vmfolder.ListVMFolder) []map[string]interface{} { res := make([]map[string]interface{}, 0, len(folderList.Data)) for _, item := range folderList.Data { temp := map[string]interface{}{ "id": item.ID, "parent_id": item.ParentID, "name": item.Name, "acl": flattenVMFolderACL(item.ACL), "status": item.Status, "vm_count": item.VMCount, } res = append(res, temp) } return res }