You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.6 KiB
79 lines
2.6 KiB
package trunk
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
log "github.com/sirupsen/logrus"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/trunk"
|
|
)
|
|
|
|
func flattenTrunkResource(d *schema.ResourceData, details *trunk.ItemTrunk) {
|
|
log.Debugf("flattenTrunk: decoded Trunk ID %s",
|
|
details.ID)
|
|
|
|
d.Set("trunk_id", details.ID)
|
|
d.Set("guid", details.GUID)
|
|
d.Set("name", details.Name)
|
|
d.Set("mac", details.MAC)
|
|
d.Set("description", details.Description)
|
|
d.Set("accountIds", details.AccountIDs)
|
|
d.Set("ovsBridge", details.OVSBridge)
|
|
d.Set("nativeVlanId", details.NativeVLANID)
|
|
d.Set("status", details.Status)
|
|
d.Set("trunkTags", details.TrunkTags)
|
|
d.Set("created_at", details.CreatedAt)
|
|
d.Set("created_by", details.CreatedBy)
|
|
d.Set("updated_at", details.UpdatedAt)
|
|
d.Set("updated_by", details.UpdatedBy)
|
|
d.Set("deleted_at", details.DeletedAt)
|
|
d.Set("deleted_by", details.DeletedBy)
|
|
}
|
|
|
|
func flattenTrunk(d *schema.ResourceData, trunkItem *trunk.ItemTrunk) {
|
|
log.Debugf("flattenTrunk: decoded Trunk ID %d",
|
|
trunkItem.ID)
|
|
|
|
d.Set("trunk_id", trunkItem.ID)
|
|
d.Set("guid", trunkItem.GUID)
|
|
d.Set("name", trunkItem.Name)
|
|
d.Set("mac", trunkItem.MAC)
|
|
d.Set("description", trunkItem.Description)
|
|
d.Set("account_ids", trunkItem.AccountIDs)
|
|
d.Set("ovs_bridge", trunkItem.OVSBridge)
|
|
d.Set("native_vlan_id", trunkItem.NativeVLANID)
|
|
d.Set("status", trunkItem.Status)
|
|
d.Set("trunk_tags", trunkItem.TrunkTags)
|
|
d.Set("created_at", trunkItem.CreatedAt)
|
|
d.Set("created_by", trunkItem.CreatedBy)
|
|
d.Set("updated_at", trunkItem.UpdatedAt)
|
|
d.Set("updated_by", trunkItem.UpdatedBy)
|
|
d.Set("deleted_at", trunkItem.DeletedAt)
|
|
d.Set("deleted_by", trunkItem.DeletedBy)
|
|
}
|
|
|
|
func flattenTrunkList(trunkList *trunk.ListTrunks) []map[string]interface{} {
|
|
res := make([]map[string]interface{}, 0, len(trunkList.Data))
|
|
for _, trunkItem := range trunkList.Data {
|
|
temp := map[string]interface{}{
|
|
"account_ids": trunkItem.AccountIDs,
|
|
"created_at": trunkItem.CreatedAt,
|
|
"created_by": trunkItem.CreatedBy,
|
|
"deleted_at": trunkItem.DeletedAt,
|
|
"deleted_by": trunkItem.DeletedBy,
|
|
"description": trunkItem.Description,
|
|
"guid": trunkItem.GUID,
|
|
"id": trunkItem.ID,
|
|
"mac": trunkItem.MAC,
|
|
"name": trunkItem.Name,
|
|
"native_vlan_id": trunkItem.NativeVLANID,
|
|
"ovs_bridge": trunkItem.OVSBridge,
|
|
"status": trunkItem.Status,
|
|
"trunk_tags": trunkItem.TrunkTags,
|
|
"updated_at": trunkItem.UpdatedAt,
|
|
"updated_by": trunkItem.UpdatedBy,
|
|
}
|
|
res = append(res, temp)
|
|
}
|
|
|
|
return res
|
|
}
|