This commit is contained in:
asteam
2024-08-23 16:55:50 +03:00
parent 6f40af6a5f
commit 003e4d656e
524 changed files with 43376 additions and 432 deletions

View File

@@ -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/cloudbroker/rg"
)
func RGCheckPresence(ctx context.Context, rgId uint64, c *decort.DecortClient) (*rg.RecordRG, error) {
tflog.Info(ctx, fmt.Sprintf("Get info about resource group with ID - %v", rgId))
recordRG, err := c.CloudBroker().RG().Get(ctx, rg.GetRequest{RGID: rgId})
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group with error: %w", err)
}
tflog.Info(ctx, "UtilityRGCheckPresence: response from CloudBroker().RG().Get", map[string]any{"rg_id": rgId, "response": recordRG})
return recordRG, err
}

View File

@@ -0,0 +1,29 @@
package utilities
import (
"context"
"fmt"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
)
func RGAffinityGroupComputesCheckPresence(ctx context.Context, plan *models.DataSourceRGAffinityGroupComputesModel, c *decort.DecortClient) (*rg.ListAffinityGroupCompute, error) {
agCompsReq := rg.AffinityGroupComputesRequest{
RGID: uint64(plan.RGID.ValueInt64()),
AffinityGroup: plan.AffinityGroup.ValueString(),
}
tflog.Info(ctx, "RGAffinityGroupComputesCheckPresence: before call CloudBroker().RG().AffinityGroupComputes", map[string]any{"req": agCompsReq})
agCompsList, err := c.CloudBroker().RG().AffinityGroupComputes(ctx, agCompsReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group affinity group computes with error: %w", err)
}
tflog.Info(ctx, "RGAffinityGroupComputesCheckPresence: response from CloudBroker().RG().AffinityGroupComputes", map[string]any{"response": agCompsList})
return &agCompsList, err
}

View File

@@ -0,0 +1,29 @@
package utilities
import (
"context"
"fmt"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
)
func RGAffinityGroupsGetCheckPresence(ctx context.Context, plan *models.DataSourceRGAffinityGroupsGetModel, c *decort.DecortClient) ([]uint64, error) {
agReq := rg.AffinityGroupsGetRequest{
RGID: uint64(plan.RGID.ValueInt64()),
AffinityGroup: plan.AffinityGroup.ValueString(),
}
tflog.Info(ctx, "RGAffinityGroupsGetCheckPresence: before call CloudBroker().RG().AffinityGroupsGet", map[string]any{"req": agReq})
agItem, err := c.CloudBroker().RG().AffinityGroupsGet(ctx, agReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group affinity groups get with error: %w", err)
}
tflog.Info(ctx, "RGAffinityGroupsGetCheckPresence: response from CloudBroker().RG().AffinityGroupsGet", map[string]any{"response": agItem})
return agItem, err
}

View File

@@ -0,0 +1,33 @@
package utilities
import (
"context"
"fmt"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
)
func RGAffinityGroupsListCheckPresence(ctx context.Context, plan *models.DataSourceRGAffinityGroupsListModel, c *decort.DecortClient) (*rg.ListAffinityGroup, error) {
agListReq := rg.AffinityGroupsListRequest{RGID: uint64(plan.RGID.ValueInt64())}
if !plan.Page.IsNull() {
agListReq.Page = uint64(plan.Page.ValueInt64())
}
if !plan.Size.IsNull() {
agListReq.Size = uint64(plan.Size.ValueInt64())
}
tflog.Info(ctx, "RGAffinityGroupsListCheckPresence: before call CloudBroker().RG().AffinityGroupsList", map[string]any{"req": agListReq})
agList, err := c.CloudBroker().RG().AffinityGroupsList(ctx, agListReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group affinity groups list with error: %w", err)
}
tflog.Info(ctx, "RGAffinityGroupsListCheckPresence: response from CloudBroker().RG().AffinityGroupsList", map[string]any{"response": agList})
return agList, err
}

View File

@@ -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/cloudbroker/rg"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
)
func RGAuditsCheckPresence(ctx context.Context, plan *models.DataSourceRGAuditsModel, c *decort.DecortClient) (*rg.ListAudits, error) {
auditsReq := rg.AuditsRequest{
RGID: uint64(plan.RGID.ValueInt64()),
}
tflog.Info(ctx, "RGAuditsCheckPresence: before call CloudBroker().RG().Audits", map[string]any{"response": auditsReq})
rgAudtis, err := c.CloudBroker().RG().Audits(ctx, auditsReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group audits with error: %w", err)
}
tflog.Info(ctx, "RGAuditsCheckPresence: response from CloudBroker().RG().Audits", map[string]any{"response": rgAudtis})
return &rgAudtis, err
}

View File

@@ -0,0 +1,25 @@
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/rg"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
)
func RGGetResourceConsumptionCheckPresence(ctx context.Context, plan *models.DataSourceRGGetResourceConsumptionModel, c *decort.DecortClient) (*rg.ItemResourceConsumption, error) {
resConsReq := rg.GetResourceConsumptionRequest{RGID: uint64(plan.RGID.ValueInt64())}
tflog.Info(ctx, "RGGetResourceConsumptionCheckPresence: before call CloudBroker().RG().GetResourceConsumption", map[string]any{"response": resConsReq})
resCons, err := c.CloudBroker().RG().GetResourceConsumption(ctx, resConsReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group get resource consumption with error: %w", err)
}
tflog.Info(ctx, "RGGetResourceConsumptionCheckPresence: response from CloudBroker().RG().GetResourceConsumption", map[string]any{"response": resCons})
return resCons, err
}

View File

@@ -0,0 +1,62 @@
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/rg"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
)
func RGListCheckPresence(ctx context.Context, plan *models.DataSourceRGListModel, c *decort.DecortClient) (*rg.ListRG, error) {
listReq := rg.ListRequest{}
if !plan.ById.IsNull() {
listReq.ByID = uint64(plan.ById.ValueInt64())
}
if !plan.Name.IsNull() {
listReq.Name = plan.Name.ValueString()
}
if !plan.AccountId.IsNull() {
listReq.AccountID = uint64(plan.AccountId.ValueInt64())
}
if !plan.AccountName.IsNull() {
listReq.AccountName = plan.AccountName.ValueString()
}
if !plan.CreatedAfter.IsNull() {
listReq.CreatedAfter = uint64(plan.CreatedAfter.ValueInt64())
}
if !plan.CreatedBefore.IsNull() {
listReq.CreatedBefore = uint64(plan.CreatedBefore.ValueInt64())
}
if !plan.Status.IsNull() {
listReq.Status = plan.Status.ValueString()
}
if !plan.LockStatus.IsNull() {
listReq.LockStatus = plan.LockStatus.ValueString()
}
if !plan.IncludeDeleted.IsNull() {
listReq.IncludeDeleted = plan.IncludeDeleted.ValueBool()
}
if !plan.SortBy.IsNull() {
listReq.SortBy = plan.SortBy.ValueString()
}
if !plan.Page.IsNull() {
listReq.Page = uint64(plan.Page.ValueInt64())
}
if !plan.Size.IsNull() {
listReq.Size = uint64(plan.Size.ValueInt64())
}
tflog.Info(ctx, "RGListCheckPresence: before call CloudBroker().RG().List", map[string]any{"response": listReq})
rgList, err := c.CloudBroker().RG().List(ctx, listReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group with error: %w", err)
}
tflog.Info(ctx, "RGListCheckPresence: response from CloudBroker().RG().List", map[string]any{"response": rgList})
return rgList, err
}

View File

@@ -0,0 +1,61 @@
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/rg"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
)
func RGListComputesCheckPresence(ctx context.Context, plan *models.DataSourceRGListComputesModel, c *decort.DecortClient) (*rg.ListComputes, error) {
listCompReq := rg.ListComputesRequest{
RGID: uint64(plan.RGID.ValueInt64()),
}
if !plan.ComputeID.IsNull() {
listCompReq.ComputeID = uint64(plan.ComputeID.ValueInt64())
}
if !plan.Name.IsNull() {
listCompReq.Name = plan.Name.ValueString()
}
if !plan.AccountID.IsNull() {
listCompReq.AccountID = uint64(plan.AccountID.ValueInt64())
}
if !plan.TechStatus.IsNull() {
listCompReq.TechStatus = plan.TechStatus.ValueString()
}
if !plan.Status.IsNull() {
listCompReq.Status = plan.Status.ValueString()
}
if !plan.IPAddress.IsNull() {
listCompReq.IPAddress = plan.IPAddress.ValueString()
}
if !plan.ExtNetName.IsNull() {
listCompReq.ExtNetName = plan.ExtNetName.ValueString()
}
if !plan.ExtNetID.IsNull() {
listCompReq.ExtNetID = uint64(plan.ExtNetID.ValueInt64())
}
if !plan.SortBy.IsNull() {
listCompReq.SortBy = plan.SortBy.ValueString()
}
if !plan.Page.IsNull() {
listCompReq.Page = uint64(plan.Page.ValueInt64())
}
if !plan.Size.IsNull() {
listCompReq.Size = uint64(plan.Size.ValueInt64())
}
tflog.Info(ctx, "RGListComputesCheckPresence: before call CloudBroker().RG().ListComputes", map[string]any{"response": listCompReq})
rgListComp, err := c.CloudBroker().RG().ListComputes(ctx, listCompReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group list computes with error: %w", err)
}
tflog.Info(ctx, "RGListComputesCheckPresence: response from CloudBroker().RG().ListComputes", map[string]any{"response": rgListComp})
return rgListComp, err
}

View File

@@ -0,0 +1,56 @@
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/rg"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
)
func RGListDeletedCheckPresence(ctx context.Context, plan *models.DataSourceRGListDeletedModel, c *decort.DecortClient) (*rg.ListRG, error) {
listDelReq := rg.ListDeletedRequest{}
if !plan.ById.IsNull() {
listDelReq.ByID = uint64(plan.ById.ValueInt64())
}
if !plan.Name.IsNull() {
listDelReq.Name = plan.Name.ValueString()
}
if !plan.AccountId.IsNull() {
listDelReq.AccountID = uint64(plan.AccountId.ValueInt64())
}
if !plan.AccountName.IsNull() {
listDelReq.AccountName = plan.AccountName.ValueString()
}
if !plan.CreatedAfter.IsNull() {
listDelReq.CreatedAfter = uint64(plan.CreatedAfter.ValueInt64())
}
if !plan.CreatedBefore.IsNull() {
listDelReq.CreatedBefore = uint64(plan.CreatedBefore.ValueInt64())
}
if !plan.SortBy.IsNull() {
listDelReq.SortBy = plan.SortBy.ValueString()
}
if !plan.LockStatus.IsNull() {
listDelReq.LockStatus = plan.LockStatus.ValueString()
}
if !plan.Page.IsNull() {
listDelReq.Page = uint64(plan.Page.ValueInt64())
}
if !plan.Size.IsNull() {
listDelReq.Size = uint64(plan.Size.ValueInt64())
}
tflog.Info(ctx, "RGListDeletedCheckPresence: before call CloudBroker().RG().ListDeleted", map[string]any{"response": listDelReq})
rgListDel, err := c.CloudBroker().RG().ListDeleted(ctx, listDelReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group list deleted with error: %w", err)
}
tflog.Info(ctx, "RGListDeletedCheckPresence: response from CloudBroker().RG().ListDeleted", map[string]any{"response": rgListDel})
return rgListDel, err
}

View File

@@ -0,0 +1,55 @@
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/rg"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
)
func RGListLBCheckPresence(ctx context.Context, plan *models.DataSourceRGListLBModel, c *decort.DecortClient) (*rg.ListLB, error) {
listLBReq := rg.ListLBRequest{
RGID: uint64(plan.RGID.ValueInt64()),
}
if !plan.ByID.IsNull() {
listLBReq.ByID = uint64(plan.ByID.ValueInt64())
}
if !plan.Name.IsNull() {
listLBReq.Name = plan.Name.ValueString()
}
if !plan.TechStatus.IsNull() {
listLBReq.TechStatus = plan.TechStatus.ValueString()
}
if !plan.Status.IsNull() {
listLBReq.Status = plan.Status.ValueString()
}
if !plan.FrontIP.IsNull() {
listLBReq.FrontIP = plan.FrontIP.ValueString()
}
if !plan.BackIP.IsNull() {
listLBReq.BackIP = plan.BackIP.ValueString()
}
if !plan.SortBy.IsNull() {
listLBReq.SortBy = plan.SortBy.ValueString()
}
if !plan.Page.IsNull() {
listLBReq.Page = uint64(plan.Page.ValueInt64())
}
if !plan.Size.IsNull() {
listLBReq.Size = uint64(plan.Size.ValueInt64())
}
tflog.Info(ctx, "RGListLBCheckPresence: before call CloudBroker().RG().ListLB", map[string]any{"response": listLBReq})
rgListLB, err := c.CloudBroker().RG().ListLB(ctx, listLBReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group list lb with error: %w", err)
}
tflog.Info(ctx, "RGListLBCheckPresence: response from CloudBroker().RG().ListLB", map[string]any{"response": rgListLB})
return rgListLB, err
}

View File

@@ -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/cloudbroker/rg"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
)
func RGListPFWCheckPresence(ctx context.Context, plan *models.DataSourceRGListPFWModel, c *decort.DecortClient) (*rg.ListPFW, error) {
listPFWReq := rg.ListPFWRequest{
RGID: uint64(plan.RGID.ValueInt64()),
}
tflog.Info(ctx, "RGListPFWCheckPresence: before call CloudBroker().RG().ListPFW", map[string]any{"response": listPFWReq})
rgListPFW, err := c.CloudBroker().RG().ListPFW(ctx, listPFWReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group list pfw with error: %w", err)
}
tflog.Info(ctx, "RGListPFWCheckPresence: response from CloudBroker().RG().ListPFW", map[string]any{"response": rgListPFW})
return rgListPFW, err
}

View File

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

View File

@@ -0,0 +1,22 @@
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/rg"
)
func RGResourceConsumptionListCheckPresence(ctx context.Context, c *decort.DecortClient) (*rg.ListResourceConsumption, error) {
tflog.Info(ctx, "RGResourceConsumptionListCheckPresence: before call CloudBroker().RG().ListResourceConsumption")
resConsList, err := c.CloudBroker().RG().ListResourceConsumption(ctx)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group resource consumption list with error: %w", err)
}
tflog.Info(ctx, "RGResourceConsumptionListCheckPresence: response from CloudBroker().RG().ListResourceConsumption", map[string]any{"response": resConsList})
return resConsList, err
}

View File

@@ -0,0 +1,29 @@
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/rg"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg/models"
)
func RGUsageCheckPresence(ctx context.Context, plan *models.DataSourceRGUsageModel, c *decort.DecortClient) (*rg.Reservation, error) {
usageReq := rg.UsageRequest{RGID: uint64(plan.RGID.ValueInt64())}
if !plan.Reason.IsNull() {
usageReq.Reason = plan.Reason.ValueString()
}
tflog.Info(ctx, "RGUsageCheckPresence: before call CloudBroker().RG().Usage", map[string]any{"response": usageReq})
usage, err := c.CloudBroker().RG().Usage(ctx, usageReq)
if err != nil {
return nil, fmt.Errorf("cannot get info about resource group resource usage with error: %w", err)
}
tflog.Info(ctx, "RGUsageCheckPresence: response from CloudBroker().RG().Usage", map[string]any{"response": usage})
return usage, err
}