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,24 @@
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/cloudbroker/stack"
)
func StackDataSourceCheckPresence(ctx context.Context, stackID uint64, c *decort.DecortClient) (*stack.InfoStack, error) {
tflog.Info(ctx, fmt.Sprintf("StackDataSourceCheckPresence: Get info about stack with ID - %v", stackID))
record, err := c.CloudBroker().Stack().Get(ctx, stack.GetRequest{StackId: stackID})
if err != nil {
return nil, fmt.Errorf("cannot get info about stack with error: %w", err)
}
tflog.Info(ctx, "StackDataSourceCheckPresence: response from CloudBroker().Stack().Get",
map[string]any{"stack_id": stackID, "response": record})
return record, err
}

View File

@@ -0,0 +1,47 @@
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/cloudbroker/stack"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/stack/models"
)
func StackListDataSourceCheckPresence(ctx context.Context, plan *models.DataSourceStackListModel, c *decort.DecortClient) (*stack.ListStacks, error) {
tflog.Info(ctx, "StackListDataSourceCheckPresence: Get info about list stacks")
req := stack.ListRequest{}
if !plan.ByID.IsNull() {
req.ByID = uint64(plan.ByID.ValueInt64())
}
if !plan.Name.IsNull() {
req.Name = plan.Name.ValueString()
}
if !plan.Type.IsNull() {
req.Type = plan.Type.ValueString()
}
if !plan.Status.IsNull() {
req.Status = plan.Status.ValueString()
}
if !plan.Page.IsNull() {
req.Page = uint64(plan.Page.ValueInt64())
}
if !plan.Size.IsNull() {
req.Size = uint64(plan.Size.ValueInt64())
}
if !plan.SortBy.IsNull() {
req.SortBy = plan.SortBy.ValueString()
}
tflog.Info(ctx, "StackListDataSourceCheckPresence: before call CloudBroker().Stack().List", map[string]any{"req": req})
listStacks, err := c.CloudBroker().Stack().List(ctx, req)
if err != nil {
return nil, fmt.Errorf("cannot get info about stack with error: %w", err)
}
tflog.Info(ctx, "StackListDataSourceCheckPresence: response from CloudBroker().Stack().List")
return listStacks, err
}