parent
e3e7e7bd89
commit
9bad8a6947
@ -1,10 +1,23 @@
|
|||||||
## Version 3.5.2
|
## Version 3.6.0
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
- Add new datasource decort_kvmvm_snapshot_usage
|
- Added validation for required fields in the following resources:
|
||||||
- Add the ability to change the size in the 'disks' block in the decort_kvmvm resource. Now when you change 'size' field in the block, the disk size on the platform will also be changed
|
- disks
|
||||||
|
- lb
|
||||||
|
- image
|
||||||
|
- bservice
|
||||||
|
- vins
|
||||||
|
- k8s
|
||||||
|
- k8s_wg
|
||||||
|
- lb_frontend
|
||||||
|
- lb_frontend_bind
|
||||||
|
- lb_backed
|
||||||
|
- lb_backend_server
|
||||||
|
- Added status handlers in create/update functions (where present)
|
||||||
|
|
||||||
## Bug Fix
|
### Bug Fixes
|
||||||
- rule "release" in Makefile don't create the necessary archives
|
- Fixed state inconsistency in the following resources/data sources:
|
||||||
- field "register_computes" in resource decort_resgroup is not used when creating the resource
|
- data_source_account
|
||||||
- removed unused optional fields in datasources
|
- resource_k8s
|
||||||
|
- resource_k8s_wg
|
||||||
|
- resource_account
|
||||||
|
@ -0,0 +1,137 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
||||||
|
)
|
||||||
|
|
||||||
|
func flattenAccount(d *schema.ResourceData, acc AccountWithResources) error {
|
||||||
|
d.Set("dc_location", acc.DCLocation)
|
||||||
|
d.Set("resources", flattenAccResources(acc.Resources))
|
||||||
|
d.Set("ckey", acc.CKey)
|
||||||
|
d.Set("meta", flattens.FlattenMeta(acc.Meta))
|
||||||
|
d.Set("acl", flattenAccAcl(acc.Acl))
|
||||||
|
d.Set("company", acc.Company)
|
||||||
|
d.Set("companyurl", acc.CompanyUrl)
|
||||||
|
d.Set("created_by", acc.CreatedBy)
|
||||||
|
d.Set("created_time", acc.CreatedTime)
|
||||||
|
d.Set("deactivation_time", acc.DeactiovationTime)
|
||||||
|
d.Set("deleted_by", acc.DeletedBy)
|
||||||
|
d.Set("deleted_time", acc.DeletedTime)
|
||||||
|
d.Set("displayname", acc.DisplayName)
|
||||||
|
d.Set("guid", acc.GUID)
|
||||||
|
d.Set("account_id", acc.ID)
|
||||||
|
d.Set("account_name", acc.Name)
|
||||||
|
d.Set("resource_limits", flattenRgResourceLimits(acc.ResourceLimits))
|
||||||
|
d.Set("send_access_emails", acc.SendAccessEmails)
|
||||||
|
d.Set("service_account", acc.ServiceAccount)
|
||||||
|
d.Set("status", acc.Status)
|
||||||
|
d.Set("updated_time", acc.UpdatedTime)
|
||||||
|
d.Set("version", acc.Version)
|
||||||
|
d.Set("vins", acc.Vins)
|
||||||
|
d.Set("vinses", acc.Vinses)
|
||||||
|
d.Set("computes", flattenAccComputes(acc.Computes))
|
||||||
|
d.Set("machines", flattenAccMachines(acc.Machines))
|
||||||
|
|
||||||
|
if username, ok := d.GetOk("username"); ok {
|
||||||
|
d.Set("username", username)
|
||||||
|
} else {
|
||||||
|
d.Set("username", acc.Acl[0].UgroupID)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenAccComputes(acs Computes) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"started": acs.Started,
|
||||||
|
"stopped": acs.Stopped,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenAccMachines(ams Machines) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"running": ams.Running,
|
||||||
|
"halted": ams.Halted,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenAccAcl(acls []AccountAclRecord) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, acls := range acls {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"can_be_deleted": acls.CanBeDeleted,
|
||||||
|
"explicit": acls.IsExplicit,
|
||||||
|
"guid": acls.Guid,
|
||||||
|
"right": acls.Rights,
|
||||||
|
"status": acls.Status,
|
||||||
|
"type": acls.Type,
|
||||||
|
"user_group_id": acls.UgroupID,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenRgResourceLimits(rl ResourceLimits) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"cu_c": rl.CUC,
|
||||||
|
"cu_d": rl.CUD,
|
||||||
|
"cu_i": rl.CUI,
|
||||||
|
"cu_m": rl.CUM,
|
||||||
|
"cu_np": rl.CUNP,
|
||||||
|
"gpu_units": rl.GpuUnits,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenAccResources(r Resources) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"current": flattenAccResource(r.Current),
|
||||||
|
"reserved": flattenAccResource(r.Reserved),
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenAccountSeps(seps map[string]map[string]ResourceSep) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for sepKey, sepVal := range seps {
|
||||||
|
for dataKey, dataVal := range sepVal {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"sep_id": sepKey,
|
||||||
|
"data_name": dataKey,
|
||||||
|
"disk_size": dataVal.DiskSize,
|
||||||
|
"disk_size_max": dataVal.DiskSizeMax,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenAccResource(r Resource) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"cpu": r.CPU,
|
||||||
|
"disksize": r.Disksize,
|
||||||
|
"extips": r.Extips,
|
||||||
|
"exttraffic": r.Exttraffic,
|
||||||
|
"gpu": r.GPU,
|
||||||
|
"ram": r.RAM,
|
||||||
|
"seps": flattenAccountSeps(r.SEPs),
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package bservice
|
||||||
|
|
||||||
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
|
||||||
|
func flattenService(d *schema.ResourceData, bs *BasicServiceExtend) {
|
||||||
|
d.Set("account_id", bs.AccountId)
|
||||||
|
d.Set("account_name", bs.AccountName)
|
||||||
|
d.Set("base_domain", bs.BaseDomain)
|
||||||
|
d.Set("computes", flattenBasicServiceComputes(bs.Computes))
|
||||||
|
d.Set("cpu_total", bs.CPUTotal)
|
||||||
|
d.Set("created_by", bs.CreatedBy)
|
||||||
|
d.Set("created_time", bs.CreatedTime)
|
||||||
|
d.Set("deleted_by", bs.DeletedBy)
|
||||||
|
d.Set("deleted_time", bs.DeletedTime)
|
||||||
|
d.Set("disk_total", bs.DiskTotal)
|
||||||
|
d.Set("gid", bs.GID)
|
||||||
|
d.Set("groups", bs.Groups)
|
||||||
|
d.Set("groups_name", bs.GroupsName)
|
||||||
|
d.Set("guid", bs.GUID)
|
||||||
|
d.Set("milestones", bs.Milestones)
|
||||||
|
d.Set("service_name", bs.Name)
|
||||||
|
d.Set("service_id", bs.ID)
|
||||||
|
d.Set("parent_srv_id", bs.ParentSrvId)
|
||||||
|
d.Set("parent_srv_type", bs.ParentSrvType)
|
||||||
|
d.Set("ram_total", bs.RamTotal)
|
||||||
|
d.Set("rg_id", bs.RGID)
|
||||||
|
d.Set("rg_name", bs.RGName)
|
||||||
|
d.Set("snapshots", flattenBasicServiceSnapshots(bs.Snapshots))
|
||||||
|
d.Set("ssh_key", bs.SSHKey)
|
||||||
|
d.Set("ssh_user", bs.SSHUser)
|
||||||
|
d.Set("status", bs.Status)
|
||||||
|
d.Set("tech_status", bs.TechStatus)
|
||||||
|
d.Set("updated_by", bs.UpdatedBy)
|
||||||
|
d.Set("updated_time", bs.UpdatedTime)
|
||||||
|
d.Set("user_managed", bs.UserManaged)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenBasicServiceComputes(bscs BasicServiceComputes) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, bsc := range bscs {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"compgroup_id": bsc.CompGroupId,
|
||||||
|
"compgroup_name": bsc.CompGroupName,
|
||||||
|
"compgroup_role": bsc.CompGroupRole,
|
||||||
|
"id": bsc.ID,
|
||||||
|
"name": bsc.Name,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenBasicServiceSnapshots(bsrvss BasicServiceSnapshots) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, bsrvs := range bsrvss {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"guid": bsrvs.GUID,
|
||||||
|
"label": bsrvs.Label,
|
||||||
|
"timestamp": bsrvs.Timestamp,
|
||||||
|
"valid": bsrvs.Valid,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package bservice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
rgList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
rgListAPI := "/restmachine/cloudapi/rg/list"
|
||||||
|
|
||||||
|
rgListRaw, err := c.DecortAPICall(ctx, "POST", rgListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(rgListRaw), &rgList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveRG := false
|
||||||
|
rgId := d.Get("rg_id").(int)
|
||||||
|
for _, rg := range rgList {
|
||||||
|
if rg.ID == rgId {
|
||||||
|
haveRG = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveRG, nil
|
||||||
|
}
|
@ -0,0 +1,166 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
func flattenDisk(d *schema.ResourceData, disk Disk) {
|
||||||
|
diskAcl, _ := json.Marshal(disk.Acl)
|
||||||
|
|
||||||
|
d.Set("account_id", disk.AccountID)
|
||||||
|
d.Set("account_name", disk.AccountName)
|
||||||
|
d.Set("acl", string(diskAcl))
|
||||||
|
d.Set("boot_partition", disk.BootPartition)
|
||||||
|
d.Set("computes", flattenDiskComputes(disk.Computes))
|
||||||
|
d.Set("created_time", disk.CreatedTime)
|
||||||
|
d.Set("deleted_time", disk.DeletedTime)
|
||||||
|
d.Set("desc", disk.Desc)
|
||||||
|
d.Set("destruction_time", disk.DestructionTime)
|
||||||
|
d.Set("devicename", disk.DeviceName)
|
||||||
|
d.Set("disk_path", disk.DiskPath)
|
||||||
|
d.Set("gid", disk.GridID)
|
||||||
|
d.Set("guid", disk.GUID)
|
||||||
|
d.Set("disk_id", disk.ID)
|
||||||
|
d.Set("image_id", disk.ImageID)
|
||||||
|
d.Set("images", disk.Images)
|
||||||
|
d.Set("iotune", flattenIOTune(disk.IOTune))
|
||||||
|
d.Set("iqn", disk.IQN)
|
||||||
|
d.Set("login", disk.Login)
|
||||||
|
d.Set("milestones", disk.Milestones)
|
||||||
|
d.Set("disk_name", disk.Name)
|
||||||
|
d.Set("order", disk.Order)
|
||||||
|
d.Set("params", disk.Params)
|
||||||
|
d.Set("parent_id", disk.ParentId)
|
||||||
|
d.Set("passwd", disk.Passwd)
|
||||||
|
d.Set("pci_slot", disk.PciSlot)
|
||||||
|
d.Set("pool", disk.Pool)
|
||||||
|
d.Set("present_to", disk.PresentTo)
|
||||||
|
d.Set("purge_attempts", disk.PurgeAttempts)
|
||||||
|
d.Set("purge_time", disk.PurgeTime)
|
||||||
|
d.Set("reality_device_number", disk.RealityDeviceNumber)
|
||||||
|
d.Set("reference_id", disk.ReferenceId)
|
||||||
|
d.Set("res_id", disk.ResID)
|
||||||
|
d.Set("res_name", disk.ResName)
|
||||||
|
d.Set("role", disk.Role)
|
||||||
|
d.Set("sep_id", disk.SepID)
|
||||||
|
d.Set("sep_type", disk.SepType)
|
||||||
|
d.Set("size_max", disk.SizeMax)
|
||||||
|
d.Set("size_used", disk.SizeUsed)
|
||||||
|
d.Set("shareable", disk.Shareable)
|
||||||
|
d.Set("snapshots", flattenDiskSnapshotList(disk.Snapshots))
|
||||||
|
d.Set("status", disk.Status)
|
||||||
|
d.Set("tech_status", disk.TechStatus)
|
||||||
|
d.Set("type", disk.Type)
|
||||||
|
d.Set("vmid", disk.VMID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenDiskSnapshotList(sl SnapshotList) []interface{} {
|
||||||
|
res := make([]interface{}, 0)
|
||||||
|
for _, snapshot := range sl {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"guid": snapshot.Guid,
|
||||||
|
"label": snapshot.Label,
|
||||||
|
"res_id": snapshot.ResId,
|
||||||
|
"snap_set_guid": snapshot.SnapSetGuid,
|
||||||
|
"snap_set_time": snapshot.SnapSetTime,
|
||||||
|
"timestamp": snapshot.TimeStamp,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenDiskList(dl DisksList) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for _, disk := range dl {
|
||||||
|
diskAcl, _ := json.Marshal(disk.Acl)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"account_id": disk.AccountID,
|
||||||
|
"account_name": disk.AccountName,
|
||||||
|
"acl": string(diskAcl),
|
||||||
|
"computes": flattenDiskComputes(disk.Computes),
|
||||||
|
"boot_partition": disk.BootPartition,
|
||||||
|
"created_time": disk.CreatedTime,
|
||||||
|
"deleted_time": disk.DeletedTime,
|
||||||
|
"desc": disk.Desc,
|
||||||
|
"destruction_time": disk.DestructionTime,
|
||||||
|
"devicename": disk.DeviceName,
|
||||||
|
"disk_path": disk.DiskPath,
|
||||||
|
"gid": disk.GridID,
|
||||||
|
"guid": disk.GUID,
|
||||||
|
"disk_id": disk.ID,
|
||||||
|
"image_id": disk.ImageID,
|
||||||
|
"images": disk.Images,
|
||||||
|
"iotune": flattenIOTune(disk.IOTune),
|
||||||
|
"iqn": disk.IQN,
|
||||||
|
"login": disk.Login,
|
||||||
|
"machine_id": disk.MachineId,
|
||||||
|
"machine_name": disk.MachineName,
|
||||||
|
"milestones": disk.Milestones,
|
||||||
|
"disk_name": disk.Name,
|
||||||
|
"order": disk.Order,
|
||||||
|
"params": disk.Params,
|
||||||
|
"parent_id": disk.ParentId,
|
||||||
|
"passwd": disk.Passwd,
|
||||||
|
"pci_slot": disk.PciSlot,
|
||||||
|
"pool": disk.Pool,
|
||||||
|
"present_to": disk.PresentTo,
|
||||||
|
"purge_attempts": disk.PurgeAttempts,
|
||||||
|
"purge_time": disk.PurgeTime,
|
||||||
|
"reality_device_number": disk.RealityDeviceNumber,
|
||||||
|
"reference_id": disk.ReferenceId,
|
||||||
|
"res_id": disk.ResID,
|
||||||
|
"res_name": disk.ResName,
|
||||||
|
"role": disk.Role,
|
||||||
|
"sep_id": disk.SepID,
|
||||||
|
"sep_type": disk.SepType,
|
||||||
|
"shareable": disk.Shareable,
|
||||||
|
"size_max": disk.SizeMax,
|
||||||
|
"size_used": disk.SizeUsed,
|
||||||
|
"snapshots": flattenDiskSnapshotList(disk.Snapshots),
|
||||||
|
"status": disk.Status,
|
||||||
|
"tech_status": disk.TechStatus,
|
||||||
|
"type": disk.Type,
|
||||||
|
"vmid": disk.VMID,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenIOTune(iot IOTune) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"read_bytes_sec": iot.ReadBytesSec,
|
||||||
|
"read_bytes_sec_max": iot.ReadBytesSecMax,
|
||||||
|
"read_iops_sec": iot.ReadIopsSec,
|
||||||
|
"read_iops_sec_max": iot.ReadIopsSecMax,
|
||||||
|
"size_iops_sec": iot.SizeIopsSec,
|
||||||
|
"total_bytes_sec": iot.TotalBytesSec,
|
||||||
|
"total_bytes_sec_max": iot.TotalBytesSecMax,
|
||||||
|
"total_iops_sec": iot.TotalIopsSec,
|
||||||
|
"total_iops_sec_max": iot.TotalIopsSecMax,
|
||||||
|
"write_bytes_sec": iot.WriteBytesSec,
|
||||||
|
"write_bytes_sec_max": iot.WriteBytesSecMax,
|
||||||
|
"write_iops_sec": iot.WriteIopsSec,
|
||||||
|
"write_iops_sec_max": iot.WriteIopsSecMax,
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, temp)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenDiskComputes(computes map[string]string) []map[string]interface{} {
|
||||||
|
res := make([]map[string]interface{}, 0)
|
||||||
|
for computeKey, computeVal := range computes {
|
||||||
|
temp := map[string]interface{}{
|
||||||
|
"compute_id": computeKey,
|
||||||
|
"compute_name": computeVal,
|
||||||
|
}
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
accountList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
accountListAPI := "/restmachine/cloudapi/account/list"
|
||||||
|
|
||||||
|
accountListRaw, err := c.DecortAPICall(ctx, "POST", accountListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(accountListRaw), &accountList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveAccount := false
|
||||||
|
|
||||||
|
myAccount := d.Get("account_id").(int)
|
||||||
|
for _, account := range accountList {
|
||||||
|
if account.ID == myAccount {
|
||||||
|
haveAccount = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return haveAccount, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
locationList := []struct {
|
||||||
|
GID int `json:"gid"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
locationsListAPI := "/restmachine/cloudapi/locations/list"
|
||||||
|
|
||||||
|
locationListRaw, err := c.DecortAPICall(ctx, "POST", locationsListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(locationListRaw), &locationList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveGID := false
|
||||||
|
|
||||||
|
gid := d.Get("gid").(int)
|
||||||
|
for _, location := range locationList {
|
||||||
|
if location.GID == gid {
|
||||||
|
haveGID = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveGID, nil
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package image
|
||||||
|
|
||||||
|
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
|
||||||
|
func flattenHistory(history []History) []map[string]interface{} {
|
||||||
|
temp := make([]map[string]interface{}, 0)
|
||||||
|
for _, item := range history {
|
||||||
|
t := map[string]interface{}{
|
||||||
|
"id": item.Id,
|
||||||
|
"guid": item.Guid,
|
||||||
|
"timestamp": item.Timestamp,
|
||||||
|
}
|
||||||
|
|
||||||
|
temp = append(temp, t)
|
||||||
|
}
|
||||||
|
return temp
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenImage(d *schema.ResourceData, img *ImageExtend) {
|
||||||
|
d.Set("unc_path", img.UNCPath)
|
||||||
|
d.Set("ckey", img.CKey)
|
||||||
|
d.Set("account_id", img.AccountId)
|
||||||
|
d.Set("acl", img.Acl)
|
||||||
|
d.Set("architecture", img.Architecture)
|
||||||
|
d.Set("boot_type", img.BootType)
|
||||||
|
d.Set("bootable", img.Bootable)
|
||||||
|
d.Set("compute_ci_id", img.ComputeCiId)
|
||||||
|
d.Set("deleted_time", img.DeletedTime)
|
||||||
|
d.Set("desc", img.Description)
|
||||||
|
d.Set("drivers", img.Drivers)
|
||||||
|
d.Set("enabled", img.Enabled)
|
||||||
|
d.Set("gid", img.GridId)
|
||||||
|
d.Set("guid", img.GUID)
|
||||||
|
d.Set("history", flattenHistory(img.History))
|
||||||
|
d.Set("hot_resize", img.HotResize)
|
||||||
|
d.Set("image_id", img.Id)
|
||||||
|
d.Set("last_modified", img.LastModified)
|
||||||
|
d.Set("link_to", img.LinkTo)
|
||||||
|
d.Set("milestones", img.Milestones)
|
||||||
|
d.Set("image_name", img.Name)
|
||||||
|
d.Set("password", img.Password)
|
||||||
|
d.Set("pool_name", img.Pool)
|
||||||
|
d.Set("provider_name", img.ProviderName)
|
||||||
|
d.Set("purge_attempts", img.PurgeAttempts)
|
||||||
|
d.Set("present_to", img.PresentTo)
|
||||||
|
d.Set("res_id", img.ResId)
|
||||||
|
d.Set("rescuecd", img.RescueCD)
|
||||||
|
d.Set("sep_id", img.SepId)
|
||||||
|
d.Set("shared_with", img.SharedWith)
|
||||||
|
d.Set("size", img.Size)
|
||||||
|
d.Set("status", img.Status)
|
||||||
|
d.Set("tech_status", img.TechStatus)
|
||||||
|
d.Set("type", img.Type)
|
||||||
|
d.Set("username", img.Username)
|
||||||
|
d.Set("version", img.Version)
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package image
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
accountList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
accountListAPI := "/restmachine/cloudapi/account/list"
|
||||||
|
|
||||||
|
accountListRaw, err := c.DecortAPICall(ctx, "POST", accountListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(accountListRaw), &accountList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveAccount := false
|
||||||
|
|
||||||
|
myAccount := d.Get("account_id").(int)
|
||||||
|
for _, account := range accountList {
|
||||||
|
if account.ID == myAccount {
|
||||||
|
haveAccount = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return haveAccount, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
locationList := []struct {
|
||||||
|
GID int `json:"gid"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
locationsListAPI := "/restmachine/cloudapi/locations/list"
|
||||||
|
|
||||||
|
locationListRaw, err := c.DecortAPICall(ctx, "POST", locationsListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(locationListRaw), &locationList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveGID := false
|
||||||
|
|
||||||
|
gid := d.Get("gid").(int)
|
||||||
|
for _, location := range locationList {
|
||||||
|
if location.GID == gid {
|
||||||
|
haveGID = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveGID, nil
|
||||||
|
}
|
@ -0,0 +1,143 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func existK8sID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
k8sList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
k8sListAPI := "/restmachine/cloudapi/k8s/list"
|
||||||
|
|
||||||
|
k8sListRaw, err := c.DecortAPICall(ctx, "POST", k8sListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(k8sListRaw), &k8sList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveK8s := false
|
||||||
|
k8sID := d.Get("k8s_id").(int)
|
||||||
|
for _, k8s := range k8sList {
|
||||||
|
if k8s.ID == k8sID {
|
||||||
|
haveK8s = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveK8s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existK8sCIID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
k8sciList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
k8sciListAPI := "/restmachine/cloudapi/k8ci/list"
|
||||||
|
|
||||||
|
k8sciListRaw, err := c.DecortAPICall(ctx, "POST", k8sciListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(k8sciListRaw), &k8sciList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveK8sCI := false
|
||||||
|
k8sciID := d.Get("k8sci_id").(int)
|
||||||
|
for _, k8ci := range k8sciList {
|
||||||
|
if k8ci.ID == k8sciID {
|
||||||
|
haveK8sCI = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveK8sCI, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
rgList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
rgListAPI := "/restmachine/cloudapi/rg/list"
|
||||||
|
|
||||||
|
rgListRaw, err := c.DecortAPICall(ctx, "POST", rgListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(rgListRaw), &rgList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveRG := false
|
||||||
|
rgId := d.Get("rg_id").(int)
|
||||||
|
for _, rg := range rgList {
|
||||||
|
if rg.ID == rgId {
|
||||||
|
haveRG = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveRG, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
extNetID := d.Get("extnet_id").(int)
|
||||||
|
|
||||||
|
if extNetID == 0 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
extNetList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
extNetListAPI := "/restmachine/cloudapi/extnet/list"
|
||||||
|
|
||||||
|
extNetListRaw, err := c.DecortAPICall(ctx, "POST", extNetListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(extNetListRaw), &extNetList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveExtNet := false
|
||||||
|
for _, extNet := range extNetList {
|
||||||
|
if extNet.ID == extNetID {
|
||||||
|
haveExtNet = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveExtNet, nil
|
||||||
|
}
|
@ -0,0 +1,139 @@
|
|||||||
|
package lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func existLBID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
lbList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
lbListAPI := "/restmachine/cloudapi/lb/list"
|
||||||
|
|
||||||
|
lbListRaw, err := c.DecortAPICall(ctx, "POST", lbListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(lbListRaw), &lbList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveLB := false
|
||||||
|
lbId := d.Get("lb_id").(int)
|
||||||
|
|
||||||
|
for _, lb := range lbList {
|
||||||
|
if lb.ID == lbId {
|
||||||
|
haveLB = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveLB, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
rgList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
rgListAPI := "/restmachine/cloudapi/rg/list"
|
||||||
|
|
||||||
|
rgListRaw, err := c.DecortAPICall(ctx, "POST", rgListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(rgListRaw), &rgList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveRG := false
|
||||||
|
rgId := d.Get("rg_id").(int)
|
||||||
|
for _, rg := range rgList {
|
||||||
|
if rg.ID == rgId {
|
||||||
|
haveRG = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveRG, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
extNetList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
extNetListAPI := "/restmachine/cloudapi/extnet/list"
|
||||||
|
|
||||||
|
extNetListRaw, err := c.DecortAPICall(ctx, "POST", extNetListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(extNetListRaw), &extNetList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveExtNet := false
|
||||||
|
extNetID := d.Get("extnet_id").(int)
|
||||||
|
for _, extNet := range extNetList {
|
||||||
|
if extNet.ID == extNetID {
|
||||||
|
haveExtNet = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveExtNet, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existViNSID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
vinsList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
vinsListAPI := "/restmachine/cloudapi/vins/list"
|
||||||
|
|
||||||
|
vinsListRaw, err := c.DecortAPICall(ctx, "POST", vinsListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(vinsListRaw), &vinsList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveVins := false
|
||||||
|
vinsID := d.Get("vins_id").(int)
|
||||||
|
for _, vins := range vinsList {
|
||||||
|
if vins.ID == vinsID {
|
||||||
|
haveVins = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveVins, nil
|
||||||
|
}
|
@ -0,0 +1,146 @@
|
|||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
)
|
||||||
|
|
||||||
|
func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
rgList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
rgListAPI := "/restmachine/cloudapi/rg/list"
|
||||||
|
|
||||||
|
rgListRaw, err := c.DecortAPICall(ctx, "POST", rgListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(rgListRaw), &rgList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveRG := false
|
||||||
|
rgId := d.Get("rg_id").(int)
|
||||||
|
for _, rg := range rgList {
|
||||||
|
if rg.ID == rgId {
|
||||||
|
haveRG = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveRG, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
extNetID := d.Get("ext_net_id").(int)
|
||||||
|
|
||||||
|
if extNetID == 0 || extNetID == -1 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
extNetList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
extNetListAPI := "/restmachine/cloudapi/extnet/list"
|
||||||
|
|
||||||
|
extNetListRaw, err := c.DecortAPICall(ctx, "POST", extNetListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(extNetListRaw), &extNetList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveExtNet := false
|
||||||
|
for _, extNet := range extNetList {
|
||||||
|
if extNet.ID == extNetID {
|
||||||
|
haveExtNet = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveExtNet, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
accountList := []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
accountListAPI := "/restmachine/cloudapi/account/list"
|
||||||
|
|
||||||
|
accountListRaw, err := c.DecortAPICall(ctx, "POST", accountListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(accountListRaw), &accountList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveAccount := false
|
||||||
|
|
||||||
|
myAccount := d.Get("account_id").(int)
|
||||||
|
for _, account := range accountList {
|
||||||
|
if account.ID == myAccount {
|
||||||
|
haveAccount = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return haveAccount, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||||
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
|
||||||
|
locationList := []struct {
|
||||||
|
GID int `json:"gid"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
locationsListAPI := "/restmachine/cloudapi/locations/list"
|
||||||
|
|
||||||
|
locationListRaw, err := c.DecortAPICall(ctx, "POST", locationsListAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(locationListRaw), &locationList)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
haveGID := false
|
||||||
|
|
||||||
|
gid := d.Get("gid").(int)
|
||||||
|
for _, location := range locationList {
|
||||||
|
if location.GID == gid {
|
||||||
|
haveGID = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveGID, nil
|
||||||
|
}
|
Loading…
Reference in new issue