/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.

Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort

Please see README.md to learn where to place source code so that it
builds seamlessly.

Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/

package rg

func makeQuotaRecord(arg_list []interface{}) QuotaRecord {
	quota := QuotaRecord{
		Cpu:      -1,
		Ram:      -1,
		Disk:     -1,
		ExtIPs:   -1,
		GpuUnits: -1,
	}
	if len(arg_list) != 0 {
		subres_data := arg_list[0].(map[string]interface{})

		if subres_data["cpu"].(int) > 0 {
			quota.Cpu = subres_data["cpu"].(int)
		}

		if subres_data["disk"].(int) > 0 {
			quota.Disk = subres_data["disk"].(int) // Disk capacity ib GB
		}

		if subres_data["ram"].(int) > 0 {
			quota.Ram = subres_data["ram"].(int) // RAM volume in MB
		}

		if subres_data["ext_ips"].(int) > 0 {
			quota.ExtIPs = subres_data["ext_ips"].(int)
		}

		if subres_data["gpu_units"].(int) > 0 {
			quota.GpuUnits = subres_data["gpu_units"].(int)
		}
	}
	return quota
}

// func parseQuota(quota QuotaRecord) []interface{} {
// 	quota_map := make(map[string]interface{})

// 	quota_map["cpu"] = quota.Cpu
// 	quota_map["ram"] = quota.Ram // NB: this is float64, unlike the rest of values
// 	quota_map["disk"] = quota.Disk
// 	quota_map["ext_ips"] = quota.ExtIPs
// 	quota_map["gpu_units"] = quota.GpuUnits

// 	result := make([]interface{}, 1)
// 	result[0] = quota_map

// 	return result // this result will be used to d.Set("quota,") of dataSourceResgroup schema
// }
