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/account"
)
func AccountDataSourceCheckPresence(ctx context.Context, accountId uint64, c *decort.DecortClient) (*account.InfoAccount, error) {
tflog.Info(ctx, fmt.Sprintf("CbAccountDataSourceCheckPresence: Get info about account with ID - %v", accountId))
recordAccount, err := c.CloudBroker().Account().Get(ctx, account.GetRequest{AccountID: accountId})
if err != nil {
return nil, fmt.Errorf("cannot get info about account with error: %w", err)
}
tflog.Info(ctx, "CbAccountDataSourceCheckPresence: response from CloudBroker().Account().Get",
map[string]any{"account_id": accountId, "response": recordAccount})
return &recordAccount.InfoAccount, 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/account"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/account/models"
)
func AccountListDataSourceCheckPresence(ctx context.Context, plan *models.DataSourceAccountListModel, c *decort.DecortClient) (*account.ListAccounts, error) {
tflog.Info(ctx, "AccountListDataSourceCheckPresence: Get info about list accounts")
req := account.ListRequest{}
if !plan.ByID.IsNull() {
req.ByID = uint64(plan.ByID.ValueInt64())
}
if !plan.Name.IsNull() {
req.Name = plan.Name.ValueString()
}
if !plan.ACL.IsNull() {
req.ACL = plan.ACL.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, "AccountListDataSourceCheckPresence: before call CloudBroker().Account().List", map[string]any{"req": req})
listAccounts, err := c.CloudBroker().Account().List(ctx, req)
if err != nil {
return nil, fmt.Errorf("cannot get info about accounts with error: %w", err)
}
tflog.Info(ctx, "AccountListDataSourceCheckPresence: response from CloudBroker().Account().List")
return listAccounts, err
}

View File

@@ -0,0 +1,52 @@
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/account"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/account/models"
)
func AccountVinsListCheck(ctx context.Context, plan *models.DataSourceAccountVinsListModel, c *decort.DecortClient) (*account.ListVINS, error) {
tflog.Info(ctx, "AccountVinsListCheck: Get info about list vins")
vinsListReq := account.ListVINSRequest{}
if !plan.AccountID.IsNull() {
vinsListReq.AccountID = uint64(plan.AccountID.ValueInt64())
}
if !plan.VinsID.IsNull() {
vinsListReq.VINSID = uint64(plan.VinsID.ValueInt64())
}
if !plan.Name.IsNull() {
vinsListReq.Name = plan.Name.ValueString()
}
if !plan.RGID.IsNull() {
vinsListReq.RGID = uint64(plan.RGID.ValueInt64())
}
if !plan.ExtIp.IsNull() {
vinsListReq.ExtIP = plan.ExtIp.ValueString()
}
if !plan.SortBy.IsNull() {
vinsListReq.SortBy = plan.SortBy.ValueString()
}
if !plan.Page.IsNull() {
vinsListReq.Page = uint64(plan.Page.ValueInt64())
}
if !plan.Size.IsNull() {
vinsListReq.Size = uint64(plan.Size.ValueInt64())
}
tflog.Info(ctx, "AccountVinsListCheck: before call CloudBroker().Account().ListVINS", map[string]any{"req": vinsListReq})
vinsList, err := c.CloudBroker().Account().ListVINS(ctx, vinsListReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about vins list with error: %w", err)
}
tflog.Info(ctx, "AccountVinsListCheck: response from CloudBroker().Account().ListVINS")
return vinsList, err
}