This commit is contained in:
2023-07-26 13:32:39 +03:00
parent f731cf246f
commit 272e385318
167 changed files with 5194 additions and 890 deletions

View File

@@ -49,6 +49,7 @@ func dataSourceVinsAuditsRead(ctx context.Context, d *schema.ResourceData, m int
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenVinsAudits(audits))
return nil
}

View File

@@ -49,6 +49,7 @@ func dataSourceVinsExtNetListRead(ctx context.Context, d *schema.ResourceData, m
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenVinsExtNetList(extNetList))
return nil
}

View File

@@ -49,6 +49,7 @@ func dataSourceVinsIpListRead(ctx context.Context, d *schema.ResourceData, m int
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenVinsIpList(ips))
return nil
}

View File

@@ -50,17 +50,43 @@ func dataSourceVinsListRead(ctx context.Context, d *schema.ResourceData, m inter
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenVinsList(vinsList))
d.Set("entry_count", vinsList.EntryCount)
return nil
}
func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"by_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by ID",
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by Name",
},
"account_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by Account ID",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by RG ID",
},
"ext_ip": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by external IP address",
},
"include_deleted": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "include deleted computes",
Description: "Include deleted computes",
},
"page": {
Type: schema.TypeInt,
@@ -144,6 +170,10 @@ func dataSourceVinsListSchemaMake() map[string]*schema.Schema {
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}

View File

@@ -50,12 +50,38 @@ func dataSourceVinsListDeletedRead(ctx context.Context, d *schema.ResourceData,
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenVinsList(vinsList))
d.Set("entry_count", vinsList.EntryCount)
return nil
}
func dataSourceVinsListDeletedSchemaMake() map[string]*schema.Schema {
res := map[string]*schema.Schema{
"by_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by ID",
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by name",
},
"account_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by account ID",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by resgroup ID",
},
"ext_ip": {
Type: schema.TypeString,
Optional: true,
Description: "Filter by external IP",
},
"page": {
Type: schema.TypeInt,
Optional: true,
@@ -138,6 +164,10 @@ func dataSourceVinsListDeletedSchemaMake() map[string]*schema.Schema {
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}

View File

@@ -277,7 +277,7 @@ func flattenGW(gw vins.RecordGW) []map[string]interface{} {
func flattenRules(rules vins.ListNATRules) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, rule := range rules {
for _, rule := range rules.Data {
tmp := map[string]interface{}{
"rule_id": rule.ID,
"local_ip": rule.LocalIP,
@@ -345,7 +345,7 @@ func flattenVNFS(vnfs vins.RecordVNFs) []map[string]interface{} {
func flattenRuleBlock(rules vins.ListNATRules) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, rule := range rules {
for _, rule := range rules.Data {
tmp := map[string]interface{}{
"int_ip": rule.LocalIP,
"int_port": rule.LocalPort,
@@ -436,9 +436,9 @@ func flattenVinsAudits(auidts vins.ListAudits) []map[string]interface{} {
return res
}
func flattenVinsExtNetList(extNetList vins.ListExtNets) []map[string]interface{} {
func flattenVinsExtNetList(extNetList *vins.ListExtNets) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, extNet := range extNetList {
for _, extNet := range extNetList.Data {
temp := map[string]interface{}{
"default_gw": extNet.DefaultGW,
"ext_net_id": extNet.ExtNetID,
@@ -453,9 +453,9 @@ func flattenVinsExtNetList(extNetList vins.ListExtNets) []map[string]interface{}
return res
}
func flattenVinsIpList(ips vins.ListIPs) []map[string]interface{} {
func flattenVinsIpList(ips *vins.ListIPs) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, ip := range ips {
for _, ip := range ips.Data {
temp := map[string]interface{}{
"client_type": ip.ClientType,
"domainname": ip.DomainName,
@@ -471,9 +471,9 @@ func flattenVinsIpList(ips vins.ListIPs) []map[string]interface{} {
return res
}
func flattenVinsList(vl vins.ListVINS) []map[string]interface{} {
func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, v := range vl {
for _, v := range vl.Data {
temp := map[string]interface{}{
"account_id": v.AccountID,
"account_name": v.AccountName,
@@ -497,9 +497,9 @@ func flattenVinsList(vl vins.ListVINS) []map[string]interface{} {
return res
}
func flattenVinsNatRuleList(natRules vins.ListNATRules) []map[string]interface{} {
func flattenVinsNatRuleList(natRules *vins.ListNATRules) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, natRule := range natRules {
for _, natRule := range natRules.Data {
temp := map[string]interface{}{
"id": natRule.ID,
"local_ip": natRule.LocalIP,

View File

@@ -21,7 +21,7 @@ func existRGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
return false, err
}
return len(rgList.FilterByID(rgId)) != 0, nil
return len(rgList.FilterByID(rgId).Data) != 0, nil
}
func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
@@ -40,7 +40,7 @@ func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (
return false, err
}
return len(extNetList.FilterByID(extNetIDParsed)) != 0, nil
return len(extNetList.FilterByID(extNetIDParsed).Data) != 0, nil
}
func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
@@ -53,7 +53,7 @@ func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{})
return false, err
}
return len(accountList.FilterByID(accountId)) != 0, nil
return len(accountList.FilterByID(accountId).Data) != 0, nil
}
func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
@@ -66,5 +66,5 @@ func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool,
return false, err
}
return len(locationList.FilterByGID(gid)) != 0, nil
return len(locationList.FilterByGID(gid).Data) != 0, nil
}

View File

@@ -40,7 +40,7 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityVinsExtNetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (vins.ListExtNets, error) {
func utilityVinsExtNetListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListExtNets, error) {
c := m.(*controller.ControllerCfg)
req := vins.ExtNetListRequest{
VINSID: uint64(d.Get("vins_id").(int)),

View File

@@ -40,7 +40,7 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityVinsIpListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (vins.ListIPs, error) {
func utilityVinsIpListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListIPs, error) {
c := m.(*controller.ControllerCfg)
req := vins.IPListRequest{
VINSID: uint64(d.Get("vins_id").(int)),

View File

@@ -42,10 +42,30 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (vins.ListVINS, error) {
func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListVINS, error) {
c := m.(*controller.ControllerCfg)
req := vins.ListRequest{}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if account_id, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(account_id.(int))
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if ext_ip, ok := d.GetOk("ext_ip"); ok {
req.ExtIP = ext_ip.(string)
}
if includeDeleted, ok := d.GetOk("include_deleted"); ok {
req.IncludeDeleted = includeDeleted.(bool)
}

View File

@@ -41,7 +41,7 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityVinsListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (vins.ListVINS, error) {
func utilityVinsListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListVINS, error) {
c := m.(*controller.ControllerCfg)
req := vins.ListDeletedRequest{}
@@ -52,6 +52,26 @@ func utilityVinsListDeletedCheckPresence(ctx context.Context, d *schema.Resource
req.Size = uint64(size.(int))
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if account_id, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(account_id.(int))
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if ext_ip, ok := d.GetOk("ext_ip"); ok {
req.ExtIP = ext_ip.(string)
}
log.Debugf("utilityVinsListDeletedCheckPresence")
vinsList, err := c.CloudAPI().VINS().ListDeleted(ctx, req)
if err != nil {

View File

@@ -40,7 +40,7 @@ import (
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityVinsNatRuleListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (vins.ListNATRules, error) {
func utilityVinsNatRuleListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListNATRules, error) {
c := m.(*controller.ControllerCfg)
req := vins.NATRuleListRequest{
VINSID: uint64(d.Get("vins_id").(int)),