This commit is contained in:
asteam
2024-07-25 14:33:38 +03:00
commit 6f40af6a5f
946 changed files with 98335 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
package vfpool
import (
"context"
"github.com/hashicorp/terraform-plugin-framework-timeouts/datasource/timeouts"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/flattens"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/schemas"
)
// Ensure the implementation satisfies the expected interfaces.
var (
_ datasource.DataSource = &dataSourceVFPool{}
)
func NewDataSourceVFPool() datasource.DataSource {
return &dataSourceVFPool{}
}
// dataSourceVFPool is the data source implementation.
type dataSourceVFPool struct {
client *decort.DecortClient
}
func (d *dataSourceVFPool) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
// Read Terraform configuration data into the model
var state models.ItemVFPoolModel
resp.Diagnostics.Append(req.Config.Get(ctx, &state)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Read dataSourceVFPool: Error get state")
return
}
id := uint64(state.VFPoolID.ValueInt64())
tflog.Info(ctx, "Read dataSourceVFPool: got state successfully", map[string]any{"vfpool_id": id})
// Set timeouts
readTimeout, diags := state.Timeouts.Read(ctx, constants.Timeout30s)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Read dataSourceVFPool: Error set timeout")
return
}
tflog.Info(ctx, "Read dataSourceVFPool: set timeouts successfully", map[string]any{
"vfpool_id": id,
"readTimeout": readTimeout})
ctx, cancel := context.WithTimeout(ctx, readTimeout)
defer cancel()
// Map response body to schema
resp.Diagnostics.Append(flattens.VFPoolDataSource(ctx, &state, d.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Read dataSourceVFPool: Error flatten data source")
return
}
// Set refreshed state
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Read dataSourceVFPool: Error set state")
return
}
tflog.Info(ctx, "End read vfpool", map[string]any{"vfpool_id": id})
}
func (d *dataSourceVFPool) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: schemas.MakeSchemaDataSourceVFPool(),
Blocks: map[string]schema.Block{
"timeouts": timeouts.Block(ctx),
},
}
}
func (d *dataSourceVFPool) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_vfpool"
}
// Configure adds the provider configured client to the data source.
func (d *dataSourceVFPool) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
tflog.Info(ctx, "Get Configure dataSourceVFPool")
d.client = client.DataSource(ctx, &req, resp)
tflog.Info(ctx, "Getting Configure dataSourceVFPool successfully")
}

View File

@@ -0,0 +1,89 @@
package vfpool
import (
"context"
"github.com/hashicorp/terraform-plugin-framework-timeouts/datasource/timeouts"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/flattens"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/schemas"
)
// Ensure the implementation satisfies the expected interfaces.
var (
_ datasource.DataSource = &dataSourceVFPoolList{}
)
func NewDataSourceVFPoolList() datasource.DataSource {
return &dataSourceVFPoolList{}
}
// dataSourceVFPoolList is the data source implementation.
type dataSourceVFPoolList struct {
client *decort.DecortClient
}
func (d *dataSourceVFPoolList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
// Read Terraform configuration data into the model
var state models.ListVFPoolModel
resp.Diagnostics.Append(req.Config.Get(ctx, &state)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Read dataSourceVFPoolList: Error get state")
return
}
tflog.Info(ctx, "Read dataSourceVFPoolList: got state successfully")
// Set timeouts
readTimeout, diags := state.Timeouts.Read(ctx, constants.Timeout30s)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Read dataSourceVFPoolList: Error set timeout")
return
}
tflog.Info(ctx, "Read dataSourceVFPoolList: set timeouts successfully", map[string]any{
"readTimeout": readTimeout})
ctx, cancel := context.WithTimeout(ctx, readTimeout)
defer cancel()
// Map response body to schema
resp.Diagnostics.Append(flattens.VFPoolListDataSource(ctx, &state, d.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Read dataSourceVFPoolList: Error flatten data source")
return
}
// Set refreshed state
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Read dataSourceVFPoolList: Error set state")
return
}
tflog.Info(ctx, "End read vfpool list")
}
func (d *dataSourceVFPoolList) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: schemas.MakeSchemaDataSourceVFPoolList(),
Blocks: map[string]schema.Block{
"timeouts": timeouts.Block(ctx),
},
}
}
func (d *dataSourceVFPoolList) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_vfpool_list"
}
// Configure adds the provider configured client to the data source.
func (d *dataSourceVFPoolList) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
tflog.Info(ctx, "Get Configure dataSourceVFPoolList")
d.client = client.DataSource(ctx, &req, resp)
tflog.Info(ctx, "Getting Configure dataSourceVFPoolList successfully")
}

View File

@@ -0,0 +1,92 @@
package flattens
import (
"context"
"fmt"
"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/flattens"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/utilities"
)
// VFPoolDataSource flattens data source for vfpool.
// Return error in case data source is not found on the platform.
// Flatten errors are added to tflog.
func VFPoolDataSource(ctx context.Context, state *models.ItemVFPoolModel, c *decort.DecortClient) diag.Diagnostics {
tflog.Info(ctx, "Start flattens.VFPoolDataSource")
diags := diag.Diagnostics{}
vfPoolID := uint64(state.VFPoolID.ValueInt64())
record, err := utilities.VFPoolCheckPresence(ctx, vfPoolID, c)
if err != nil {
diags.AddError(fmt.Sprintf("Cannot get info about VFpool with ID %v", vfPoolID), err.Error())
return diags
}
tflog.Info(ctx, "flattens.VFPoolDataSource: before flatten", map[string]any{"record": record})
*state = models.ItemVFPoolModel{
//required fields
VFPoolID: state.VFPoolID,
//optional fields
Timeouts: state.Timeouts,
//compute fields
AccountAccess: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, record.AccountAccess),
CreatedTime: types.Int64Value(int64(record.CreatedTime)),
Description: types.StringValue(record.Description),
GID: types.Int64Value(int64(record.GID)),
GUID: types.Int64Value(int64(record.GUID)),
Name: types.StringValue(record.Name),
RGAccess: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, record.RGAccess),
Status: types.StringValue(record.Status),
UpdatedTime: types.Int64Value(int64(record.UpdatedTime)),
}
items := make([]models.VFSModel, 0, len(record.VFS))
for _, vfsItem := range record.VFS {
i := models.VFSModel{
NodeID: types.Int64Value(int64(vfsItem.NodeID)),
}
vfList := make([]models.VFItemModel, 0, len(vfsItem.VFList))
for _, vfItem := range vfsItem.VFList {
vfI := models.VFItemModel{
NicName: types.StringValue(vfItem.NicName),
}
vfInfoList := make([]models.VFSInfoItemModel, 0, len(vfItem.VFSInfo))
for _, vfsInfoItem := range vfItem.VFSInfo {
vfsInfoI := models.VFSInfoItemModel{
ID: types.Int64Value(int64(vfsInfoItem.ID)),
Claimed: types.BoolValue(vfsInfoItem.Claimed),
VMID: types.Int64Value(int64(vfsInfoItem.VMID)),
}
vfInfoList = append(vfInfoList, vfsInfoI)
}
vfI.VFSInfo = vfInfoList
vfList = append(vfList, vfI)
}
i.VFList = vfList
items = append(items, i)
}
state.VFS = items
tflog.Info(ctx, "flattens.VFPoolDataSource: after flatten")
tflog.Info(ctx, "End flattens.VFPoolDataSource")
return nil
}

View File

@@ -0,0 +1,104 @@
package flattens
import (
"context"
"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/flattens"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/utilities"
)
// VFPoolListDataSource flattens data source for vfpool list.
// Return error in case data source is not found on the platform.
// Flatten errors are added to tflog.
func VFPoolListDataSource(ctx context.Context, state *models.ListVFPoolModel, c *decort.DecortClient) diag.Diagnostics {
tflog.Info(ctx, "Start flattens.VFPoolListDataSource")
diags := diag.Diagnostics{}
record, err := utilities.VFPoolListCheckPresence(ctx, state, c)
if err != nil {
diags.AddError("Cannot get info about fvpool list", err.Error())
return diags
}
tflog.Info(ctx, "flattens.VFPoolListDataSource: before flatten", map[string]any{"record": record})
*state = models.ListVFPoolModel{
//optional fields
Timeouts: state.Timeouts,
ByID: state.ByID,
Name: state.Name,
Description: state.Description,
Status: state.Status,
AccountAccess: state.AccountAccess,
RgAccess: state.RgAccess,
SortBy: state.SortBy,
Page: state.Page,
Size: state.Size,
//compute fields
EntryCount: types.Int64Value(int64(record.EntryCount)),
}
data := make([]models.ItemVFPoolListModel, 0, len(record.Data))
for _, item := range record.Data {
i := models.ItemVFPoolListModel{
VFPoolID: types.Int64Value(int64(item.ID)),
AccountAccess: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, item.AccountAccess),
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
Description: types.StringValue(item.Description),
GID: types.Int64Value(int64(item.GID)),
GUID: types.Int64Value(int64(item.GUID)),
Name: types.StringValue(item.Name),
RGAccess: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, item.RGAccess),
Status: types.StringValue(item.Status),
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
}
items := make([]models.VFSListModel, 0, len(item.VFS))
for _, item := range item.VFS {
i := models.VFSListModel{
NodeID: types.Int64Value(int64(item.NodeID)),
}
vfList := make([]models.VFItemListModel, 0, len(item.VFList))
for _, vfItem := range item.VFList {
vfI := models.VFItemListModel{
NicName: types.StringValue(vfItem.NicName),
}
vfInfoList := make([]models.VFSInfoItemListModel, 0, len(vfItem.VFSInfo))
for _, vfInfoItem := range vfItem.VFSInfo {
vfInfoI := models.VFSInfoItemListModel{
ID: types.Int64Value(int64(vfInfoItem.ID)),
Claimed: types.BoolValue(vfInfoItem.Claimed),
VMID: types.Int64Value(int64(vfInfoItem.VMID)),
}
vfInfoList = append(vfInfoList, vfInfoI)
}
vfI.VFSInfo = vfInfoList
vfList = append(vfList, vfI)
}
i.VFList = vfList
items = append(items, i)
}
i.VFS = items
data = append(data, i)
}
state.Items = data
tflog.Info(ctx, "flattens.VFPoolListDataSource: after flatten")
tflog.Info(ctx, "End flattens.VFPoolListDataSource")
return nil
}

View File

@@ -0,0 +1,40 @@
package models
import (
"github.com/hashicorp/terraform-plugin-framework-timeouts/datasource/timeouts"
"github.com/hashicorp/terraform-plugin-framework/types"
)
type ItemVFPoolModel struct {
//required and optional fields
VFPoolID types.Int64 `tfsdk:"vfpool_id"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
// computed fields
AccountAccess types.List `tfsdk:"account_access"`
CreatedTime types.Int64 `tfsdk:"created_time"`
Description types.String `tfsdk:"description"`
GID types.Int64 `tfsdk:"gid"`
GUID types.Int64 `tfsdk:"guid"`
Name types.String `tfsdk:"name"`
RGAccess types.List `tfsdk:"rg_access"`
Status types.String `tfsdk:"status"`
UpdatedTime types.Int64 `tfsdk:"updated_time"`
VFS []VFSModel `tfsdk:"vfs"`
}
type VFSModel struct {
NodeID types.Int64 `tfsdk:"node_id"`
VFList []VFItemModel `tfsdk:"vf_list"`
}
type VFItemModel struct {
NicName types.String `tfsdk:"nic_name"`
VFSInfo []VFSInfoItemModel `tfsdk:"vfs_info"`
}
type VFSInfoItemModel struct {
ID types.Int64 `tfsdk:"id"`
Claimed types.Bool `tfsdk:"claimed"`
VMID types.Int64 `tfsdk:"vm_id"`
}

View File

@@ -0,0 +1,55 @@
package models
import (
"github.com/hashicorp/terraform-plugin-framework-timeouts/datasource/timeouts"
"github.com/hashicorp/terraform-plugin-framework/types"
)
type ListVFPoolModel struct {
// optional fields
ByID types.Int64 `tfsdk:"by_id"`
GID types.Int64 `tfsdk:"gid"`
Name types.String `tfsdk:"name"`
Description types.String `tfsdk:"description"`
Status types.String `tfsdk:"status"`
AccountAccess types.Int64 `tfsdk:"account_access"`
RgAccess types.Int64 `tfsdk:"rg_access"`
SortBy types.String `tfsdk:"sort_by"`
Page types.Int64 `tfsdk:"page"`
Size types.Int64 `tfsdk:"size"`
Timeouts timeouts.Value `tfsdk:"timeouts"`
// compute fields
Items []ItemVFPoolListModel `tfsdk:"items"`
EntryCount types.Int64 `tfsdk:"entry_count"`
}
type ItemVFPoolListModel struct {
VFPoolID types.Int64 `tfsdk:"vfpool_id"`
AccountAccess types.List `tfsdk:"account_access"`
CreatedTime types.Int64 `tfsdk:"created_time"`
Description types.String `tfsdk:"description"`
GID types.Int64 `tfsdk:"gid"`
GUID types.Int64 `tfsdk:"guid"`
Name types.String `tfsdk:"name"`
RGAccess types.List `tfsdk:"rg_access"`
Status types.String `tfsdk:"status"`
UpdatedTime types.Int64 `tfsdk:"updated_time"`
VFS []VFSListModel `tfsdk:"vfs"`
}
type VFSListModel struct {
NodeID types.Int64 `tfsdk:"node_id"`
VFList []VFItemListModel `tfsdk:"vf_list"`
}
type VFItemListModel struct {
NicName types.String `tfsdk:"nic_name"`
VFSInfo []VFSInfoItemListModel `tfsdk:"vfs_info"`
}
type VFSInfoItemListModel struct {
ID types.Int64 `tfsdk:"id"`
Claimed types.Bool `tfsdk:"claimed"`
VMID types.Int64 `tfsdk:"vm_id"`
}

View File

@@ -0,0 +1,79 @@
package schemas
import (
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
)
func MakeSchemaDataSourceVFPool() map[string]schema.Attribute {
return map[string]schema.Attribute{
"vfpool_id": schema.Int64Attribute{
Required: true,
},
"account_access": schema.ListAttribute{
Computed: true,
ElementType: types.Int64Type,
},
"created_time": schema.Int64Attribute{
Computed: true,
},
"description": schema.StringAttribute{
Computed: true,
},
"gid": schema.Int64Attribute{
Computed: true,
},
"guid": schema.Int64Attribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},
"rg_access": schema.ListAttribute{
Computed: true,
ElementType: types.Int64Type,
},
"status": schema.StringAttribute{
Computed: true,
},
"updated_time": schema.Int64Attribute{
Computed: true,
},
"vfs": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"node_id": schema.Int64Attribute{
Computed: true,
},
"vf_list": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"nic_name": schema.StringAttribute{
Computed: true,
},
"vfs_info": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
Computed: true,
},
"claimed": schema.BoolAttribute{
Computed: true,
},
"vm_id": schema.Int64Attribute{
Computed: true,
},
},
},
},
},
},
},
},
},
},
}
}

View File

@@ -0,0 +1,119 @@
package schemas
import (
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
)
func MakeSchemaDataSourceVFPoolList() map[string]schema.Attribute {
return map[string]schema.Attribute{
"by_id": schema.Int64Attribute{
Optional: true,
},
"gid": schema.Int64Attribute{
Optional: true,
},
"name": schema.StringAttribute{
Optional: true,
},
"description": schema.StringAttribute{
Optional: true,
},
"status": schema.StringAttribute{
Optional: true,
},
"account_access": schema.Int64Attribute{
Optional: true,
},
"rg_access": schema.Int64Attribute{
Optional: true,
},
"sort_by": schema.StringAttribute{
Optional: true,
},
"page": schema.Int64Attribute{
Optional: true,
},
"size": schema.Int64Attribute{
Optional: true,
},
"items": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"account_access": schema.ListAttribute{
Computed: true,
ElementType: types.Int64Type,
},
"created_time": schema.Int64Attribute{
Computed: true,
},
"description": schema.StringAttribute{
Computed: true,
},
"gid": schema.Int64Attribute{
Computed: true,
},
"guid": schema.Int64Attribute{
Computed: true,
},
"vfpool_id": schema.Int64Attribute{
Computed: true,
},
"name": schema.StringAttribute{
Computed: true,
},
"rg_access": schema.ListAttribute{
Computed: true,
ElementType: types.Int64Type,
},
"status": schema.StringAttribute{
Computed: true,
},
"updated_time": schema.Int64Attribute{
Computed: true,
},
"vfs": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"node_id": schema.Int64Attribute{
Computed: true,
},
"vf_list": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"nic_name": schema.StringAttribute{
Computed: true,
},
"vfs_info": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"id": schema.Int64Attribute{
Computed: true,
},
"claimed": schema.BoolAttribute{
Computed: true,
},
"vm_id": schema.Int64Attribute{
Computed: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
"entry_count": schema.Int64Attribute{
Computed: true,
},
}
}

View File

@@ -0,0 +1,25 @@
package utilities
import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vfpool"
)
func VFPoolCheckPresence(ctx context.Context, vfPoolID uint64, c *decort.DecortClient) (*vfpool.RecordVFPool,
error) {
req := vfpool.GetRequest{VFPoolID: vfPoolID}
tflog.Info(ctx, "VFPoolCheckPresence: before call CloudAPI().VFPool().Get", map[string]any{"req": req})
vfPool, err := c.CloudAPI().VFPool().Get(ctx, req)
if err != nil {
return nil, fmt.Errorf("VFPoolCheckPresence: cannot get info about vfpool")
}
tflog.Info(ctx, "VFPoolCheckPresence: response from CloudAPI().VFPool().Get", map[string]any{"response": vfPool})
return vfPool, err
}

View File

@@ -0,0 +1,57 @@
package utilities
import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vfpool"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool/models"
)
func VFPoolListCheckPresence(ctx context.Context, plan *models.ListVFPoolModel, c *decort.DecortClient) (*vfpool.ListVFPool,
error) {
req := vfpool.ListRequest{}
if !plan.ByID.IsNull() {
req.ByID = uint64(plan.ByID.ValueInt64())
}
if !plan.GID.IsNull() {
req.GID = uint64(plan.GID.ValueInt64())
}
if !plan.Name.IsNull() {
req.Name = plan.Name.ValueString()
}
if !plan.Description.IsNull() {
req.Description = plan.Description.ValueString()
}
if !plan.Status.IsNull() {
req.Status = plan.Status.ValueString()
}
if !plan.AccountAccess.IsNull() {
req.AccountAccess = uint64(plan.AccountAccess.ValueInt64())
}
if !plan.RgAccess.IsNull() {
req.RGAccess = uint64(plan.RgAccess.ValueInt64())
}
if !plan.SortBy.IsNull() {
req.SortBy = plan.SortBy.ValueString()
}
if !plan.Page.IsNull() {
req.Page = uint64(plan.Page.ValueInt64())
}
if !plan.Size.IsNull() {
req.Size = uint64(plan.Size.ValueInt64())
}
tflog.Info(ctx, "VFPoolListCheckPresence: before call CloudAPI().VFPool().List", map[string]any{"req": req})
vfPool, err := c.CloudAPI().VFPool().List(ctx, req)
if err != nil {
return nil, fmt.Errorf("VFPoolListCheckPresence: cannot get info about vfpool list")
}
tflog.Info(ctx, "VFPoolListCheckPresence: response from CloudAPI().VFPool().Get", map[string]any{"response": vfPool})
return vfPool, err
}