This commit is contained in:
Nikita Sorokin
2023-10-13 13:28:19 +03:00
parent 28b60de115
commit 0602a4b693
104 changed files with 3804 additions and 301 deletions

View File

@@ -50,7 +50,7 @@ func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceDat
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenExtnetComputesList(extnetComputesList))
d.Set("entry_count", extnetComputesList.EntryCount)
return nil
}
@@ -61,6 +61,26 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "filter by account ID",
},
"rg_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by RG ID",
},
"compute_id": {
Type: schema.TypeInt,
Optional: true,
Description: "Filter by compute ID",
},
"page": {
Type: schema.TypeInt,
Optional: true,
Description: "Page number",
},
"size": {
Type: schema.TypeInt,
Optional: true,
Description: "Page size",
},
"items": {
Type: schema.TypeList,
Computed: true,
@@ -117,6 +137,10 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
},
},
},
"entry_count": {
Type: schema.TypeInt,
Computed: true,
},
}
return res
}

View File

@@ -35,7 +35,7 @@ func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
}
func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(ex))
for _, item := range ex {
temp := map[string]interface{}{
"client_type": item.ClientType,
@@ -51,7 +51,7 @@ func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
}
func flattenExtnetReservations(ers extnet.ListReservations) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(ers))
for _, er := range ers {
temp := map[string]interface{}{
"client_type": er.ClientType,
@@ -92,7 +92,7 @@ func flattenExtnetVNFS(evnfs extnet.VNFs) []map[string]interface{} {
}
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len (ecs))
for _, ec := range ecs {
temp := map[string]interface{}{
"net_id": ec.ID,
@@ -106,7 +106,7 @@ func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface
}
func flattenExtnetComputesList(ecl *extnet.ListExtNetComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(ecl.Data))
for _, ec := range ecl.Data {
temp := map[string]interface{}{
"account_id": ec.AccountID,
@@ -123,7 +123,7 @@ func flattenExtnetComputesList(ecl *extnet.ListExtNetComputes) []map[string]inte
}
func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
res := make([]map[string]interface{}, 0, len(el.Data))
for _, e := range el.Data {
temp := map[string]interface{}{
"net_id": e.ID,

View File

@@ -48,6 +48,20 @@ func utilityExtnetComputesListCheckPresence(ctx context.Context, d *schema.Resou
AccountID: uint64(d.Get("account_id").(int)),
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if compute_id, ok := d.GetOk("compute_id"); ok {
req.ComputeID = uint64(compute_id.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityExtnetComputesListCheckPresence")
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req)
if err != nil {