1.0.0
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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/stack"
|
||||
)
|
||||
|
||||
func StackCheckPresence(ctx context.Context, stackID uint64, c *decort.DecortClient) (*stack.InfoStack,
|
||||
error) {
|
||||
req := stack.GetRequest{
|
||||
StackId: stackID,
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "StackCheckPresence: before call CloudAPI().Stack().Get", map[string]any{"req": req})
|
||||
stack, err := c.CloudAPI().Stack().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get info about stack with error: %w", err)
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "StackCheckPresence: response from CloudAPI().Stack().Get", map[string]any{"response": stack})
|
||||
|
||||
return stack, err
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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/stack"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/stack/models"
|
||||
)
|
||||
|
||||
func StackListCheckPresence(ctx context.Context, plan *models.ListStacksModel, c *decort.DecortClient) (*stack.ListStacks,
|
||||
error) {
|
||||
req := stack.ListRequest{}
|
||||
|
||||
if !plan.ByID.IsNull() {
|
||||
req.ByID = uint64(plan.ByID.ValueInt64())
|
||||
}
|
||||
if !plan.Name.IsNull() {
|
||||
req.Name = plan.Name.ValueString()
|
||||
}
|
||||
if !plan.Status.IsNull() {
|
||||
req.Status = plan.Status.ValueString()
|
||||
}
|
||||
if !plan.Type.IsNull() {
|
||||
req.Type = plan.Type.ValueString()
|
||||
}
|
||||
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, "StackListCheckPresence: before call CloudAPI().Stack().List", map[string]any{"req": req})
|
||||
stack, err := c.CloudAPI().Stack().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("StackListCheckPresence: cannot get info about stack list")
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "StackListCheckPresence: response from CloudAPI().Stack().Get", map[string]any{"response": stack})
|
||||
|
||||
return stack, err
|
||||
}
|
||||
Reference in New Issue
Block a user