1.0.1
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package utilities
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/diag"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
|
||||
)
|
||||
|
||||
func NodeDataSourceCheckPresence(ctx context.Context, nodeId uint64, c *decort.DecortClient) (*node.RecordNode, diag.Diagnostics) {
|
||||
tflog.Info(ctx, fmt.Sprintf("NodeDataSourceCheckPresence: Get info about Node with ID - %v", nodeId))
|
||||
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
recordNode, err := c.CloudBroker().Node().Get(ctx, node.GetRequest{NID: nodeId})
|
||||
if err != nil {
|
||||
diags.AddError(fmt.Sprintf("Cannot get info about Node with ID %v", nodeId), err.Error())
|
||||
return nil, diags
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "NodeDataSourceCheckPresence: response from loudBroker().Node().Get", map[string]any{"node_id": nodeId, "response": recordNode})
|
||||
|
||||
return recordNode, nil
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package utilities
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/diag"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/node/models"
|
||||
)
|
||||
|
||||
func NodeListDataSourceCheckPresence(ctx context.Context, state *models.DataSourceNodeList, c *decort.DecortClient) (*node.ListNodes, diag.Diagnostics) {
|
||||
tflog.Info(ctx, "NodeListDataSourceCheckPresence: Get node list info")
|
||||
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
req := node.ListRequest{}
|
||||
|
||||
if !state.ByID.IsNull() {
|
||||
req.ByID = uint64(state.ByID.ValueInt64())
|
||||
}
|
||||
if !state.Name.IsNull() {
|
||||
req.Name = state.Name.ValueString()
|
||||
}
|
||||
if !state.Version.IsNull() {
|
||||
req.Version = state.Version.ValueString()
|
||||
}
|
||||
if !state.Release.IsNull() {
|
||||
req.Release = state.Release.ValueString()
|
||||
}
|
||||
if !state.SepID.IsNull() {
|
||||
req.SepID = uint64(state.SepID.ValueInt64())
|
||||
}
|
||||
if !state.Role.IsNull() {
|
||||
req.Role = state.Role.ValueString()
|
||||
}
|
||||
if !state.Status.IsNull() {
|
||||
req.Status = state.Status.ValueString()
|
||||
}
|
||||
if !state.SortBy.IsNull() {
|
||||
req.SortBy = state.SortBy.ValueString()
|
||||
}
|
||||
if !state.Page.IsNull() {
|
||||
req.Page = uint64(state.Page.ValueInt64())
|
||||
}
|
||||
if !state.Size.IsNull() {
|
||||
req.Size = uint64(state.Size.ValueInt64())
|
||||
}
|
||||
|
||||
recordNodeList, err := c.CloudBroker().Node().List(ctx, req)
|
||||
if err != nil {
|
||||
diags.AddError("Cannot get info about Node list", err.Error())
|
||||
return nil, diags
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "NodeListDataSourceCheckPresence: response from CloudBroker().Node().List")
|
||||
|
||||
return recordNodeList, nil
|
||||
}
|
||||
Reference in New Issue
Block a user