This commit is contained in:
2024-05-31 14:05:21 +03:00
parent 84b7a80e1b
commit db1760cb72
815 changed files with 58194 additions and 11049 deletions

View File

@@ -307,6 +307,13 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"compute_features": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,

View File

@@ -135,6 +135,11 @@ func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Filter by extnet ID",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -101,6 +101,11 @@ func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Filter by disk type",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -46,13 +46,14 @@ func flattenAccountList(al *account.ListAccounts) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, acc := range al.Data {
temp := map[string]interface{}{
"acl": flattenRgAcl(acc.ACL),
"created_time": acc.CreatedTime,
"deleted_time": acc.DeletedTime,
"account_id": acc.ID,
"account_name": acc.Name,
"status": acc.Status,
"updated_time": acc.UpdatedTime,
"acl": flattenRgAcl(acc.ACL),
"compute_features": acc.ComputeFeatures,
"created_time": acc.CreatedTime,
"deleted_time": acc.DeletedTime,
"account_id": acc.ID,
"account_name": acc.Name,
"status": acc.Status,
"updated_time": acc.UpdatedTime,
}
res = append(res, temp)
}
@@ -112,6 +113,11 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Filter by status",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
@@ -159,6 +165,13 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
},
},
},
"compute_features": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"created_time": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -138,6 +138,11 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
Required: true,
Description: "ID of the account",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -103,6 +103,11 @@ func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Filter by type",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,

View File

@@ -54,6 +54,8 @@ func flattenAccountVinsList(avl *account.ListVINS) []map[string]interface{} {
"deleted_by": av.DeletedBy,
"deleted_time": av.DeletedTime,
"external_ip": av.ExternalIP,
"extnet_id": av.ExtnetId,
"free_ips": av.FreeIPs,
"vin_id": av.ID,
"vin_name": av.Name,
"network": av.Network,
@@ -112,6 +114,11 @@ func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
Optional: true,
Description: "Filter by external IP",
},
"sort_by": {
Type: schema.TypeString,
Optional: true,
Description: "sort by one of supported fields, format +|-(field)",
},
"page": {
Type: schema.TypeInt,
Optional: true,
@@ -160,6 +167,14 @@ func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"extnet_id": {
Type: schema.TypeInt,
Computed: true,
},
"free_ips": {
Type: schema.TypeInt,
Computed: true,
},
"vin_id": {
Type: schema.TypeInt,
Computed: true,

View File

@@ -12,6 +12,7 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
d.Set("acl", flattenAccAcl(acc.ACL))
d.Set("company", acc.Company)
d.Set("companyurl", acc.CompanyURL)
d.Set("compute_features", acc.ComputeFeatures)
d.Set("created_by", acc.CreatedBy)
d.Set("created_time", acc.CreatedTime)
d.Set("deactivation_time", acc.DeactivationTime)

View File

@@ -279,19 +279,6 @@ func resourceAccountUpdate(ctx context.Context, d *schema.ResourceData, m interf
}
}
if d.HasChange("restore") {
restore := d.Get("restore").(bool)
if restore && acc.Status == "DELETED" {
req := account.RestoreRequest{
AccountID: accountId,
}
_, err := c.CloudAPI().Account().Restore(ctx, req)
if err != nil {
return diag.FromErr(err)
}
}
}
if d.HasChange("users") {
deletedUsers := make([]interface{}, 0)
addedUsers := make([]interface{}, 0)
@@ -542,6 +529,13 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
Type: schema.TypeString,
Computed: true,
},
"compute_features": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,

View File

@@ -1,102 +1,106 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListComputes, error) {
c := m.(*controller.ControllerCfg)
var id uint64
id = uint64(d.Get("account_id").(int))
req := account.ListComputesRequest{
AccountID: id,
}
if compute_id, ok := d.GetOk("compute_id"); ok {
req.ComputeID = uint64(compute_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if rg_name, ok := d.GetOk("rg_name"); ok {
req.RGName = rg_name.(string)
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if tech_status, ok := d.GetOk("tech_status"); ok {
req.TechStatus = tech_status.(string)
}
if ip_address, ok := d.GetOk("ip_address"); ok {
req.IPAddress = ip_address.(string)
}
if extnet_name, ok := d.GetOk("extnet_name"); ok {
req.ExtNetName = extnet_name.(string)
}
if extnet_id, ok := d.GetOk("extnet_id"); ok {
req.ExtNetID = uint64(extnet_id.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountComputesListCheckPresence: load account list")
accountComputesList, err := c.CloudAPI().Account().ListComputes(ctx, req)
if err != nil {
return nil, err
}
return accountComputesList, nil
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountComputesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListComputes, error) {
c := m.(*controller.ControllerCfg)
var id uint64
id = uint64(d.Get("account_id").(int))
req := account.ListComputesRequest{
AccountID: id,
}
if compute_id, ok := d.GetOk("compute_id"); ok {
req.ComputeID = uint64(compute_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if rg_name, ok := d.GetOk("rg_name"); ok {
req.RGName = rg_name.(string)
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if tech_status, ok := d.GetOk("tech_status"); ok {
req.TechStatus = tech_status.(string)
}
if ip_address, ok := d.GetOk("ip_address"); ok {
req.IPAddress = ip_address.(string)
}
if extnet_name, ok := d.GetOk("extnet_name"); ok {
req.ExtNetName = extnet_name.(string)
}
if extnet_id, ok := d.GetOk("extnet_id"); ok {
req.ExtNetID = uint64(extnet_id.(int))
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountComputesListCheckPresence: load account list")
accountComputesList, err := c.CloudAPI().Account().ListComputes(ctx, req)
if err != nil {
return nil, err
}
return accountComputesList, nil
}

View File

@@ -1,76 +1,80 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
c := m.(*controller.ControllerCfg)
req := account.ListDeletedRequest{}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if acl, ok := d.GetOk("acl"); ok {
req.ACL = acl.(string)
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
log.Debugf("utilityAccountDeletedListCheckPresence: load")
accountDeletedList, err := c.CloudAPI().Account().ListDeleted(ctx, req)
if err != nil {
return nil, err
}
return accountDeletedList, nil
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountDeletedListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
c := m.(*controller.ControllerCfg)
req := account.ListDeletedRequest{}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if acl, ok := d.GetOk("acl"); ok {
req.ACL = acl.(string)
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
log.Debugf("utilityAccountDeletedListCheckPresence: load")
accountDeletedList, err := c.CloudAPI().Account().ListDeleted(ctx, req)
if err != nil {
return nil, err
}
return accountDeletedList, nil
}

View File

@@ -1,84 +1,88 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountDisksListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListDisks, error) {
c := m.(*controller.ControllerCfg)
var id uint64
id = uint64(d.Get("account_id").(int))
req := account.ListDisksRequest{
AccountID: id,
}
if disk_id, ok := d.GetOk("disk_id"); ok {
req.DiskID = uint64(disk_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
req.DiskMaxSize = uint64(disk_max_size.(int))
}
if typeVal, ok := d.GetOk("type"); ok {
req.Type = typeVal.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
accountDisksList, err := c.CloudAPI().Account().ListDisks(ctx, req)
if err != nil {
return nil, err
}
return accountDisksList, nil
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountDisksListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListDisks, error) {
c := m.(*controller.ControllerCfg)
var id uint64
id = uint64(d.Get("account_id").(int))
req := account.ListDisksRequest{
AccountID: id,
}
if disk_id, ok := d.GetOk("disk_id"); ok {
req.DiskID = uint64(disk_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if disk_max_size, ok := d.GetOk("disk_max_size"); ok {
req.DiskMaxSize = uint64(disk_max_size.(int))
}
if typeVal, ok := d.GetOk("type"); ok {
req.Type = typeVal.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
accountDisksList, err := c.CloudAPI().Account().ListDisks(ctx, req)
if err != nil {
return nil, err
}
return accountDisksList, nil
}

View File

@@ -1,79 +1,83 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
c := m.(*controller.ControllerCfg)
req := account.ListRequest{}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if acl, ok := d.GetOk("acl"); ok {
req.ACL = acl.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
log.Debugf("utilityAccountListCheckPresence: load account list")
accountList, err := c.CloudAPI().Account().List(ctx, req)
if err != nil {
return nil, err
}
return accountList, nil
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListAccounts, error) {
c := m.(*controller.ControllerCfg)
req := account.ListRequest{}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if acl, ok := d.GetOk("acl"); ok {
req.ACL = acl.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
log.Debugf("utilityAccountListCheckPresence: load account list")
accountList, err := c.CloudAPI().Account().List(ctx, req)
if err != nil {
return nil, err
}
return accountList, nil
}

View File

@@ -1,90 +1,94 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountRGListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListRG, error) {
c := m.(*controller.ControllerCfg)
var id uint64
id = uint64(d.Get("account_id").(int))
req := account.ListRGRequest{
AccountID: id,
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if vins_id, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vins_id.(int))
}
if vm_id, ok := d.GetOk("vm_id"); ok {
req.VMID = uint64(vm_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
log.Debugf("utilityAccountRGListCheckPresence: load account list")
accountRGList, err := c.CloudAPI().Account().ListRG(ctx, req)
if err != nil {
return nil, err
}
return accountRGList, nil
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountRGListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListRG, error) {
c := m.(*controller.ControllerCfg)
var id uint64
id = uint64(d.Get("account_id").(int))
req := account.ListRGRequest{
AccountID: id,
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if vins_id, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vins_id.(int))
}
if vm_id, ok := d.GetOk("vm_id"); ok {
req.VMID = uint64(vm_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
log.Debugf("utilityAccountRGListCheckPresence: load account list")
accountRGList, err := c.CloudAPI().Account().ListRG(ctx, req)
if err != nil {
return nil, err
}
return accountRGList, nil
}

View File

@@ -1,80 +1,83 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListTemplates, error) {
c := m.(*controller.ControllerCfg)
id := uint64(d.Get("account_id").(int))
req := account.ListTemplatesRequest{
AccountID: id,
}
if include_deleted, ok := d.GetOk("include_deleted"); ok {
req.IncludeDeleted = include_deleted.(bool)
}
if imageId, ok := d.GetOk("image_id"); ok {
req.ImageID = uint64(imageId.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if typeTemplates, ok := d.GetOk("type"); ok {
req.Type = typeTemplates.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)
if err != nil {
return nil, err
}
return accountTemplatesList, nil
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListTemplates, error) {
c := m.(*controller.ControllerCfg)
id := uint64(d.Get("account_id").(int))
req := account.ListTemplatesRequest{
AccountID: id,
}
if include_deleted, ok := d.GetOk("include_deleted"); ok {
req.IncludeDeleted = include_deleted.(bool)
}
if imageId, ok := d.GetOk("image_id"); ok {
req.ImageID = uint64(imageId.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if typeTemplates, ok := d.GetOk("type"); ok {
req.Type = typeTemplates.(string)
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)
if err != nil {
return nil, err
}
return accountTemplatesList, nil
}

View File

@@ -1,86 +1,90 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListVINS, error) {
c := m.(*controller.ControllerCfg)
var id uint64
id = uint64(d.Get("account_id").(int))
req := account.ListVINSRequest{
AccountID: id,
}
if vins_id, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vins_id.(int))
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if ext_ip, ok := d.GetOk("ext_ip"); ok {
req.ExtIP = ext_ip.(string)
}
log.Debugf("utilityAccountVinsListCheckPresence: load account list")
accountVinsList, err := c.CloudAPI().Account().ListVINS(ctx, req)
if err != nil {
return nil, err
}
return accountVinsList, nil
}
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
*/
package account
import (
"context"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityAccountVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListVINS, error) {
c := m.(*controller.ControllerCfg)
var id uint64
id = uint64(d.Get("account_id").(int))
req := account.ListVINSRequest{
AccountID: id,
}
if vins_id, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vins_id.(int))
}
if rg_id, ok := d.GetOk("rg_id"); ok {
req.RGID = uint64(rg_id.(int))
}
if sortBy, ok := d.GetOk("sort_by"); ok {
req.SortBy = sortBy.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if ext_ip, ok := d.GetOk("ext_ip"); ok {
req.ExtIP = ext_ip.(string)
}
log.Debugf("utilityAccountVinsListCheckPresence: load account list")
accountVinsList, err := c.CloudAPI().Account().ListVINS(ctx, req)
if err != nil {
return nil, err
}
return accountVinsList, nil
}