1.0.0
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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/extnet"
|
||||
)
|
||||
|
||||
func ExtNetCheckPresence(ctx context.Context, netId uint64, c *decort.DecortClient) (*extnet.RecordExtNet, error) {
|
||||
tflog.Info(ctx, fmt.Sprintf("Get info about extnet with ID - %v", netId))
|
||||
|
||||
recordExtNet, err := c.CloudAPI().ExtNet().Get(ctx, extnet.GetRequest{NetID: netId})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get info about extnet with error: %w", err)
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "ExtNetCheckPresence: response from CloudAPI().ExtNet().Get", map[string]any{"net_id": netId, "response": recordExtNet})
|
||||
|
||||
return recordExtNet, err
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package utilities
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/extnet/models"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
||||
)
|
||||
|
||||
func ExtNetComputesListCheckPresence(ctx context.Context, plan *models.DataSourceExtNetComputesListModel, c *decort.DecortClient) (*extnet.ListExtNetComputes, error) {
|
||||
tflog.Info(ctx, "ExtNetComputesListCheckPresence: Get info about extnet list")
|
||||
|
||||
listCompReq := extnet.ListComputesRequest{
|
||||
AccountID: uint64(plan.AccountID.ValueInt64()),
|
||||
}
|
||||
|
||||
if !plan.RGID.IsNull() {
|
||||
listCompReq.RGID = uint64(plan.RGID.ValueInt64())
|
||||
}
|
||||
if !plan.ComputeID.IsNull() {
|
||||
listCompReq.ComputeID = uint64(plan.ComputeID.ValueInt64())
|
||||
}
|
||||
if !plan.Page.IsNull() {
|
||||
listCompReq.Page = uint64(plan.Page.ValueInt64())
|
||||
}
|
||||
if !plan.Size.IsNull() {
|
||||
listCompReq.Size = uint64(plan.Size.ValueInt64())
|
||||
}
|
||||
if !plan.SortBy.IsNull() {
|
||||
listCompReq.SortBy = plan.SortBy.ValueString()
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "ExtNetComputesListCheckPresence: before call CloudAPI().ExtNet().ListComputes", map[string]any{"req": listCompReq})
|
||||
compList, err := c.CloudAPI().ExtNet().ListComputes(ctx, listCompReq)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get info about extnet list computes with error: %w", err)
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "ExtNetComputesListCheckPresence: response from CloudAPI().ExtNet().ListComputes", map[string]any{"response": compList})
|
||||
|
||||
return compList, err
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package utilities
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||
)
|
||||
|
||||
func ExtNetDefaultCheckPresence(ctx context.Context, c *decort.DecortClient) (uint64, error) {
|
||||
tflog.Info(ctx, "ExtNetDefaultCheckPresence: Get info about default extnet with ID - %v")
|
||||
|
||||
netId, err := c.CloudAPI().ExtNet().GetDefault(ctx)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("ExtNetDefaultCheckPresence: cannot get info about extnet with error: %w", err)
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "ExtNetDefaultCheckPresence: response from CloudAPI().ExtNet().GetDefault", map[string]any{"response": netId})
|
||||
|
||||
return netId, err
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package utilities
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/extnet/models"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
||||
)
|
||||
|
||||
func ExtNetListCheckPresence(ctx context.Context, plan *models.DataSourceExtNetListModel, c *decort.DecortClient) (*extnet.ListExtNets, error) {
|
||||
tflog.Info(ctx, "ExtNetListCheckPresence: Get info about extnet list")
|
||||
|
||||
extnetListReq := extnet.ListRequest{}
|
||||
|
||||
if !plan.AccountID.IsNull() {
|
||||
extnetListReq.AccountID = uint64(plan.AccountID.ValueInt64())
|
||||
}
|
||||
if !plan.ByID.IsNull() {
|
||||
extnetListReq.ByID = uint64(plan.ByID.ValueInt64())
|
||||
}
|
||||
if !plan.Name.IsNull() {
|
||||
extnetListReq.Name = plan.Name.ValueString()
|
||||
}
|
||||
if !plan.Network.IsNull() {
|
||||
extnetListReq.Network = plan.Network.ValueString()
|
||||
}
|
||||
if !plan.VLANID.IsNull() {
|
||||
extnetListReq.VLANID = uint64(plan.VLANID.ValueInt64())
|
||||
}
|
||||
if !plan.VNFDevID.IsNull() {
|
||||
extnetListReq.VNFDevID = uint64(plan.VNFDevID.ValueInt64())
|
||||
}
|
||||
if !plan.Status.IsNull() {
|
||||
extnetListReq.Status = plan.Status.ValueString()
|
||||
}
|
||||
if !plan.Page.IsNull() {
|
||||
extnetListReq.Page = uint64(plan.Page.ValueInt64())
|
||||
}
|
||||
if !plan.Size.IsNull() {
|
||||
extnetListReq.Size = uint64(plan.Size.ValueInt64())
|
||||
}
|
||||
if !plan.SortBy.IsNull() {
|
||||
extnetListReq.SortBy = plan.SortBy.ValueString()
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "ExtNetListCheckPresence: before call CloudAPI().ExtNet().List", map[string]any{"req": extnetListReq})
|
||||
extNetList, err := c.CloudAPI().ExtNet().List(ctx, extnetListReq)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get info about extnet with error: %w", err)
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "ExtNetListCheckPresence: response from CloudAPI().ExtNet().List", map[string]any{"response": extNetList})
|
||||
|
||||
return extNetList, err
|
||||
}
|
||||
Reference in New Issue
Block a user