1.0.1
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package flattens
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-framework/diag"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/vins/models"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/vins/utilities"
|
||||
)
|
||||
|
||||
// VINSListDeletedDataSource flattens data source for vins list deleted.
|
||||
// Return error in case data source is not found on the platform.
|
||||
// Flatten errors are added to tflog.
|
||||
func VINSListDeletedDataSource(ctx context.Context, state *models.DataSourceVINSListDeletedModel, c *decort.DecortClient) diag.Diagnostics {
|
||||
tflog.Info(ctx, "Start flattens.VINSListDeletedDataSource")
|
||||
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
vinsList, diags := utilities.VINSListDeletedDataSourceCheckPresence(ctx, state, c)
|
||||
if diags.HasError() {
|
||||
return diags
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "flattens.VINSListDeletedDataSource: before flatten")
|
||||
|
||||
id := uuid.New()
|
||||
*state = models.DataSourceVINSListDeletedModel{
|
||||
ByID: state.ByID,
|
||||
Name: state.Name,
|
||||
AccountID: state.AccountID,
|
||||
RGID: state.RGID,
|
||||
ExtIP: state.ExtIP,
|
||||
SortBy: state.SortBy,
|
||||
Page: state.Page,
|
||||
Size: state.Size,
|
||||
Timeouts: state.Timeouts,
|
||||
|
||||
Id: types.StringValue(id.String()),
|
||||
EntryCount: types.Int64Value(int64(vinsList.EntryCount)),
|
||||
}
|
||||
|
||||
items := make([]models.ItemVinsDeletedModel, 0, len(vinsList.Data))
|
||||
for _, item := range vinsList.Data {
|
||||
v := models.ItemVinsDeletedModel{
|
||||
AccountID: types.Int64Value(int64(item.AccountID)),
|
||||
AccountName: types.StringValue(item.AccountName),
|
||||
CreatedBy: types.StringValue(item.CreatedBy),
|
||||
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
|
||||
DefaultGW: types.StringValue(item.DefaultGW),
|
||||
DefaultQOS: flattenQOS(ctx, &item.DefaultQOS),
|
||||
DeletedBy: types.StringValue(item.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
|
||||
Description: types.StringValue(item.Description),
|
||||
ExternalIP: types.StringValue(item.ExternalIP),
|
||||
GID: types.Int64Value(int64(item.GID)),
|
||||
GUID: types.Int64Value(int64(item.GUID)),
|
||||
ID: types.Int64Value(int64(item.ID)),
|
||||
LockStatus: types.StringValue(item.LockStatus),
|
||||
ManagerID: types.Int64Value(int64(item.ManagerID)),
|
||||
ManagerType: types.StringValue(item.ManagerType),
|
||||
Milestones: types.Int64Value(int64(item.Milestones)),
|
||||
Name: types.StringValue(item.Name),
|
||||
Netmask: types.Int64Value(int64(item.NetMask)),
|
||||
Network: types.StringValue(item.Network),
|
||||
PreReservationsNum: types.Int64Value(int64(item.PreReservationsNum)),
|
||||
PriVNFDevID: types.Int64Value(int64(item.PriVNFDevID)),
|
||||
Redundant: types.BoolValue(item.Redundant),
|
||||
RGID: types.Int64Value(int64(item.RGID)),
|
||||
RGName: types.StringValue(item.RGName),
|
||||
SecVNFDefID: types.Int64Value(int64(item.SecVNFDevID)),
|
||||
Status: types.StringValue(item.Status),
|
||||
UpdatedBy: types.StringValue(item.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
|
||||
UserManaged: types.BoolValue(item.UserManaged),
|
||||
VNFs: flattenListVNFs(ctx, &item.VNFs),
|
||||
VXLANID: types.Int64Value(int64(item.VXLANID)),
|
||||
}
|
||||
items = append(items, v)
|
||||
}
|
||||
state.Items = items
|
||||
|
||||
tflog.Info(ctx, "End flattens.VINSListDeletedDataSource")
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user