4.0.0
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
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 extnet
|
||||
|
||||
const extnetListAPI = "/restmachine/cloudapi/extnet/list"
|
||||
const extnetListComputesAPI = "/restmachine/cloudapi/extnet/listComputes"
|
||||
const extnetGetDefaultAPI = "/restmachine/cloudapi/extnet/getDefault"
|
||||
const extnetGetAPI = "/restmachine/cloudapi/extnet/get"
|
||||
@@ -34,12 +34,11 @@ package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
||||
)
|
||||
|
||||
func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
@@ -48,77 +47,12 @@ func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("ckey", e.CKey)
|
||||
d.Set("meta", flattens.FlattenMeta(e.Meta))
|
||||
d.Set("check__ips", e.CheckIPs)
|
||||
d.Set("check_ips", e.CheckIps)
|
||||
d.Set("default", e.Default)
|
||||
d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQos))
|
||||
d.Set("desc", e.Desc)
|
||||
d.Set("dns", e.Dns)
|
||||
d.Set("excluded", e.Excluded)
|
||||
d.Set("free_ips", e.FreeIps)
|
||||
d.Set("gateway", e.Gateway)
|
||||
d.Set("gid", e.GID)
|
||||
d.Set("guid", e.GUID)
|
||||
d.Set("ipcidr", e.IPCidr)
|
||||
d.Set("milestones", e.Milestones)
|
||||
d.Set("net_name", e.Name)
|
||||
d.Set("network", e.Network)
|
||||
d.Set("network_id", e.NetworkId)
|
||||
d.Set("pre_reservations_num", e.PreReservationsNum)
|
||||
d.Set("prefix", e.Prefix)
|
||||
d.Set("pri_vnf_dev_id", e.PriVnfDevId)
|
||||
d.Set("reservations", flattenExtnetReservations(e.Reservations))
|
||||
d.Set("shared_with", e.SharedWith)
|
||||
d.Set("status", e.Status)
|
||||
d.Set("vlan_id", e.VlanID)
|
||||
d.Set("vnfs", flattenExtnetVNFS(e.VNFS))
|
||||
d.SetId(strconv.FormatUint(e.ID, 10))
|
||||
flattenExtnet(d, e)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func flattenExtnetReservations(ers ExtnetReservations) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, er := range ers {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": er.ClientType,
|
||||
"domainname": er.DomainName,
|
||||
"hostname": er.HostName,
|
||||
"desc": er.Desc,
|
||||
"ip": er.IP,
|
||||
"mac": er.MAC,
|
||||
"type": er.Type,
|
||||
"vm_id": er.VMID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetDefaultQos(edqos ExtnetQos) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"e_rate": edqos.ERate,
|
||||
"guid": edqos.GUID,
|
||||
"in_burst": edqos.InBurst,
|
||||
"in_rate": edqos.InRate,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetVNFS(evnfs ExtnetVNFS) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"dhcp": evnfs.DHCP,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"net_id": {
|
||||
@@ -164,6 +98,10 @@ func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"e_burst": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -193,8 +131,29 @@ func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
|
||||
"excluded": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"client_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vm_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"free_ips": {
|
||||
|
||||
@@ -41,37 +41,6 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenExtnetsComputes(ecs ExtnetExtendList) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, ec := range ecs {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": ec.ID,
|
||||
"ipaddr": ec.IPAddr,
|
||||
"ipcidr": ec.IPCidr,
|
||||
"name": ec.Name,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetComputesList(ecl ExtnetComputesList) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, ec := range ecl {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": ec.AccountId,
|
||||
"account_name": ec.AccountName,
|
||||
"extnets": flattenExtnetsComputes(ec.Extnets),
|
||||
"id": ec.ID,
|
||||
"name": ec.Name,
|
||||
"rg_id": ec.RGID,
|
||||
"rg_name": ec.RGName,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
extnetComputesList, err := utilityExtnetComputesListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
|
||||
@@ -41,19 +41,6 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func flattenExtnetList(el ExtnetList) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, e := range el {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": e.ID,
|
||||
"ipcidr": e.IPCidr,
|
||||
"name": e.Name,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
extnetList, err := utilityExtnetListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
|
||||
137
internal/service/cloudapi/extnet/flattens.go
Normal file
137
internal/service/cloudapi/extnet/flattens.go
Normal file
@@ -0,0 +1,137 @@
|
||||
package extnet
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
||||
)
|
||||
|
||||
func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
|
||||
d.Set("ckey", e.CKey)
|
||||
d.Set("meta", flattens.FlattenMeta(e.Meta))
|
||||
d.Set("check__ips", e.CheckIPs)
|
||||
d.Set("check_ips", e.CheckIps)
|
||||
d.Set("default", e.Default)
|
||||
d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQOS))
|
||||
d.Set("desc", e.Description)
|
||||
d.Set("dns", e.DNS)
|
||||
d.Set("excluded", flattenExcluded(e.Excluded))
|
||||
d.Set("free_ips", e.FreeIPs)
|
||||
d.Set("gateway", e.Gateway)
|
||||
d.Set("gid", e.GID)
|
||||
d.Set("guid", e.GUID)
|
||||
d.Set("ipcidr", e.IPCIDR)
|
||||
d.Set("milestones", e.Milestones)
|
||||
d.Set("net_name", e.Name)
|
||||
d.Set("network", e.Network)
|
||||
d.Set("network_id", e.NetworkID)
|
||||
d.Set("pre_reservations_num", e.PreReservationsNum)
|
||||
d.Set("prefix", e.Prefix)
|
||||
d.Set("pri_vnf_dev_id", e.PriVNFDevID)
|
||||
d.Set("reservations", flattenExtnetReservations(e.Reservations))
|
||||
d.Set("shared_with", e.SharedWith)
|
||||
d.Set("status", e.Status)
|
||||
d.Set("vlan_id", e.VLANID)
|
||||
d.Set("vnfs", flattenExtnetVNFS(e.VNFs))
|
||||
}
|
||||
|
||||
func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, item := range ex {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": item.ClientType,
|
||||
"mac": item.MAC,
|
||||
"ip": item.IP,
|
||||
"type": item.Type,
|
||||
"vm_id": item.VMID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetReservations(ers extnet.ListReservations) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, er := range ers {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": er.ClientType,
|
||||
"domainname": er.DomainName,
|
||||
"hostname": er.Hostname,
|
||||
"desc": er.Description,
|
||||
"ip": er.IP,
|
||||
"mac": er.MAC,
|
||||
"type": er.Type,
|
||||
"vm_id": er.VMID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetDefaultQos(edqos extnet.QOS) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"e_rate": edqos.ERate,
|
||||
"e_burst": edqos.EBurst,
|
||||
"guid": edqos.GUID,
|
||||
"in_burst": edqos.InBurst,
|
||||
"in_rate": edqos.InRate,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetVNFS(evnfs extnet.VNFs) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"dhcp": evnfs.DHCP,
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, ec := range ecs {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": ec.ID,
|
||||
"ipaddr": ec.IPAddr,
|
||||
"ipcidr": ec.IPCIDR,
|
||||
"name": ec.Name,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetComputesList(ecl extnet.ListExtNetComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, ec := range ecl {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": ec.AccountID,
|
||||
"account_name": ec.AccountName,
|
||||
"extnets": flattenExtnetsComputes(ec.ExtNets),
|
||||
"id": ec.ID,
|
||||
"name": ec.Name,
|
||||
"rg_id": ec.RGID,
|
||||
"rg_name": ec.RGName,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenExtnetList(el extnet.ListExtNets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, e := range el {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": e.ID,
|
||||
"ipcidr": e.IPCIDR,
|
||||
"name": e.Name,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
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 extnet
|
||||
|
||||
type Extnet struct {
|
||||
ID int `json:"id"`
|
||||
IPCidr string `json:"ipcidr"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
type ExtnetExtend struct {
|
||||
Extnet
|
||||
IPAddr string `json:"ipaddr"`
|
||||
}
|
||||
|
||||
type ExtnetList []Extnet
|
||||
type ExtnetExtendList []ExtnetExtend
|
||||
|
||||
type ExtnetComputes struct {
|
||||
AccountId int `json:"accountId"`
|
||||
AccountName string `json:"accountName"`
|
||||
Extnets ExtnetExtendList `json:"extnets"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
RGID int `json:"rgId"`
|
||||
RGName string `json:"rgName"`
|
||||
}
|
||||
|
||||
type ExtnetComputesList []ExtnetComputes
|
||||
|
||||
type ExtnetQos struct {
|
||||
ERate int `json:"eRate"`
|
||||
GUID string `json:"guid"`
|
||||
InBurst int `json:"inBurst"`
|
||||
InRate int `json:"inRate"`
|
||||
}
|
||||
|
||||
type ExtnetReservation struct {
|
||||
ClientType string `json:"clientType"`
|
||||
Desc string `json:"desc"`
|
||||
DomainName string `json:"domainname"`
|
||||
HostName string `json:"hostname"`
|
||||
IP string `json:"ip"`
|
||||
MAC string `json:"mac"`
|
||||
Type string `json:"type"`
|
||||
VMID int `json:"vmId"`
|
||||
}
|
||||
|
||||
type ExtnetReservations []ExtnetReservation
|
||||
|
||||
type ExtnetVNFS struct {
|
||||
DHCP int `json:"dhcp"`
|
||||
}
|
||||
|
||||
type ExtnetDetailed struct {
|
||||
CKey string `json:"_ckey"`
|
||||
Meta []interface{} `json:"_meta"`
|
||||
CheckIPs []string `json:"checkIPs"`
|
||||
CheckIps []string `json:"checkIps"`
|
||||
Default bool `json:"default"`
|
||||
DefaultQos ExtnetQos `json:"defaultQos"`
|
||||
Desc string `json:"desc"`
|
||||
Dns []string `json:"dns"`
|
||||
Excluded []string `json:"excluded"`
|
||||
FreeIps int `json:"free_ips"`
|
||||
Gateway string `json:"gateway"`
|
||||
GID int `json:"gid"`
|
||||
GUID int `json:"guid"`
|
||||
ID int `json:"id"`
|
||||
IPCidr string `json:"ipcidr"`
|
||||
Milestones int `json:"milestones"`
|
||||
Name string `json:"name"`
|
||||
Network string `json:"network"`
|
||||
NetworkId int `json:"networkId"`
|
||||
PreReservationsNum int `json:"preReservationsNum"`
|
||||
Prefix int `json:"prefix"`
|
||||
PriVnfDevId int `json:"priVnfDevId"`
|
||||
Reservations ExtnetReservations `json:"reservations"`
|
||||
SharedWith []int `json:"sharedWith"`
|
||||
Status string `json:"status"`
|
||||
VlanID int `json:"vlanId"`
|
||||
VNFS ExtnetVNFS `json:"vnfs"`
|
||||
}
|
||||
@@ -34,30 +34,22 @@ package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityExtnetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*ExtnetDetailed, error) {
|
||||
extnet := &ExtnetDetailed{}
|
||||
func utilityExtnetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*extnet.RecordExtNet, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
urlValues.Add("net_id", strconv.Itoa(d.Get("net_id").(int)))
|
||||
|
||||
log.Debugf("utilityExtnetCheckPresence")
|
||||
extnetRaw, err := c.DecortAPICall(ctx, "POST", extnetGetAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
req := extnet.GetRequest{
|
||||
NetID: uint64(d.Get("net_id").(int)),
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(extnetRaw), &extnet)
|
||||
log.Debugf("utilityExtnetCheckPresence")
|
||||
extnet, err := c.CloudAPI().ExtNet().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -34,30 +34,22 @@ package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityExtnetComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ExtnetComputesList, error) {
|
||||
extnetComputesList := ExtnetComputesList{}
|
||||
func utilityExtnetComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (extnet.ListExtNetComputes, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
|
||||
|
||||
log.Debugf("utilityExtnetComputesListCheckPresence")
|
||||
extnetComputesListRaw, err := c.DecortAPICall(ctx, "POST", extnetListComputesAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
req := extnet.ListComputesRequest{
|
||||
AccountID: uint64(d.Get("account_id").(int)),
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(extnetComputesListRaw), &extnetComputesList)
|
||||
log.Debugf("utilityExtnetComputesListCheckPresence")
|
||||
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
@@ -42,13 +42,12 @@ import (
|
||||
|
||||
func utilityExtnetDefaultCheckPresence(ctx context.Context, m interface{}) (string, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
|
||||
log.Debugf("utilityExtnetDefaultCheckPresence")
|
||||
res, err := c.DecortAPICall(ctx, "POST", extnetGetDefaultAPI, urlValues)
|
||||
res, err := c.CloudAPI().ExtNet().GetDefault(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
return strconv.FormatUint(res, 10), nil
|
||||
}
|
||||
|
||||
@@ -34,38 +34,30 @@ package extnet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ExtnetList, error) {
|
||||
extnetList := ExtnetList{}
|
||||
func utilityExtnetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (extnet.ListExtNets, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
urlValues := &url.Values{}
|
||||
req := extnet.ListRequest{}
|
||||
|
||||
if accountId, ok := d.GetOk("account_id"); ok {
|
||||
urlValues.Add("accountId", strconv.Itoa(accountId.(int)))
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
urlValues.Add("page", strconv.Itoa(page.(int)))
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
urlValues.Add("size", strconv.Itoa(size.(int)))
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityExtnetListCheckPresence")
|
||||
extnetListRaw, err := c.DecortAPICall(ctx, "POST", extnetListAPI, urlValues)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(extnetListRaw), &extnetList)
|
||||
extnetList, err := c.CloudAPI().ExtNet().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user