Add data for account deleted list

gos_tech_4.4.3
stSolo 3 years ago
parent 61b8765c82
commit eb22dee25b

@ -0,0 +1,58 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceAccountDeletedListRead(d *schema.ResourceData, m interface{}) error {
accountDeletedList, err := utilityAccountDeletedListCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenAccountList(accountDeletedList))
return nil
}
func dataSourceAccountDeletedList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceAccountDeletedListRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceAccountListSchemaMake(),
}
}

@ -997,7 +997,6 @@ const accountAddUserAPI = "/restmachine/cloudapi/account/addUser"
const accountAuditsAPI = "/restmachine/cloudapi/account/audits"
const accountCreateAPI = "/restmachine/cloudapi/account/create"
const accountDeleteAPI = "/restmachine/cloudapi/account/delete"
const accountDeleteAccountsAPI = "/cloudapi/account/deleteAccounts"
const accountDeleteUserAPI = "/restmachine/cloudapi/account/deleteUser"
const accountDisableAPI = "/restmachine/cloudapi/account/disable"
const accountEnableAPI = "/restmachine/cloudapi/account/enable"
@ -1008,7 +1007,7 @@ const accountGetReservedUnitsAPI = "/restmachine/cloudapi/account/getReservedAcc
const accountListAPI = "/restmachine/cloudapi/account/list"
const accountListComputesAPI = "/restmachine/cloudapi/account/listComputes"
const accountListCSAPI = "/cloudapi/account/listCS"
const accountListDeletedAPI = "/cloudapi/account/listDeleted"
const accountListDeletedAPI = "/restmachine/cloudapi/account/listDeleted"
const accountListDisksAPI = "/restmachine/cloudapi/account/listDisks"
const accountListFlipGroupsAPI = "/cloudapi/account/listFlipGroups"
const accountListRGAPI = "/restmachine/cloudapi/account/listRG"

@ -150,6 +150,7 @@ func Provider() *schema.Provider {
"decort_account_consumed_units_by_type": dataSourceAccountConsumedUnitsByType(),
"decort_account_reserved_units": dataSourceAccountReservedUnits(),
"decort_account_templates_list": dataSourceAccountTemplatessList(),
"decort_account_deleted_list": dataSourceAccountDeletedList(),
// "decort_pfw": dataSourcePfw(),
},

@ -0,0 +1,61 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com>
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.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"encoding/json"
"net/url"
"strconv"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilityAccountDeletedListCheckPresence(d *schema.ResourceData, m interface{}) (AccountCloudApiList, error) {
accountDeletedList := AccountCloudApiList{}
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
if page, ok := d.GetOk("page"); ok {
urlValues.Add("page", strconv.Itoa(page.(int)))
}
if size, ok := d.GetOk("size"); ok {
urlValues.Add("size", strconv.Itoa(size.(int)))
}
log.Debugf("utilityAccountDeletedListCheckPresence: load")
accountDeletedListRaw, err := controller.decortAPICall("POST", accountListDeletedAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(accountDeletedListRaw), &accountDeletedList)
if err != nil {
return nil, err
}
return accountDeletedList, nil
}

@ -31,6 +31,7 @@
- account_counsumed_units_by_type
- account_reserved_units
- account_templates_list
- account_deleted_list
- resources:
- image
- virtual_image

@ -0,0 +1,45 @@
/*
Пример использования
Получение информации об удаленных аккаунтах
Информация предоставляется только по аккаунтам, удаленным без флага permanently
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
*/
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
controller_url = "https://ds1.digitalenergy.online"
#oauth2_url = <DECORT_SSO_URL>
oauth2_url = "https://sso.digitalenergy.online"
allow_unverified_ssl = true
}
data "decort_account_deleted_list" "adl" {
#номер страницы для отображения
#опциональный параметр
#тип - число
#если не задан - выводятся все доступные данные
#page = 2
#размер страницы
#опциональный параметр
#тип - число
#если не задан - выводятся все доступные данные
#size = 3
}
output "test" {
value = data.decort_account_deleted_list.adl
}
Loading…
Cancel
Save