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.
146 lines
3.4 KiB
146 lines
3.4 KiB
/*
|
|
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"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
|
)
|
|
|
|
func dataSourceSepRead(d *schema.ResourceData, m interface{}) error {
|
|
desSep, err := utilitySepCheckPresence(d, m)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
id := uuid.New()
|
|
d.SetId(id.String())
|
|
|
|
d.Set("ckey", desSep.Ckey)
|
|
d.Set("meta", flattenMeta(desSep.Meta))
|
|
d.Set("consumed_by", desSep.ConsumedBy)
|
|
d.Set("desc", desSep.Desc)
|
|
d.Set("gid", desSep.Gid)
|
|
d.Set("guid", desSep.Guid)
|
|
d.Set("sep_id", desSep.Id)
|
|
d.Set("milestones", desSep.Milestones)
|
|
d.Set("name", desSep.Name)
|
|
d.Set("obj_status", desSep.ObjStatus)
|
|
d.Set("provided_by", desSep.ProvidedBy)
|
|
d.Set("tech_status", desSep.TechStatus)
|
|
d.Set("type", desSep.Type)
|
|
data, _ := json.Marshal(desSep.Config)
|
|
d.Set("config", string(data))
|
|
|
|
return nil
|
|
}
|
|
|
|
func dataSourceSepCSchemaMake() map[string]*schema.Schema {
|
|
return map[string]*schema.Schema{
|
|
"sep_id": {
|
|
Type: schema.TypeInt,
|
|
Required: true,
|
|
Description: "sep type des id",
|
|
},
|
|
"ckey": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"meta": {
|
|
Type: schema.TypeList,
|
|
Computed: true,
|
|
Elem: &schema.Schema{
|
|
Type: schema.TypeString,
|
|
},
|
|
},
|
|
"consumed_by": {
|
|
Type: schema.TypeList,
|
|
Computed: true,
|
|
Elem: &schema.Schema{
|
|
Type: schema.TypeInt,
|
|
},
|
|
},
|
|
"desc": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"gid": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"guid": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"milestones": {
|
|
Type: schema.TypeInt,
|
|
Computed: true,
|
|
},
|
|
"name": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"obj_status": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"provided_by": {
|
|
Type: schema.TypeList,
|
|
Computed: true,
|
|
Elem: &schema.Schema{
|
|
Type: schema.TypeInt,
|
|
},
|
|
},
|
|
"tech_status": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"type": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"config": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
}
|
|
}
|
|
|
|
func dataSourceSep() *schema.Resource {
|
|
return &schema.Resource{
|
|
SchemaVersion: 1,
|
|
|
|
Read: dataSourceSepRead,
|
|
|
|
Timeouts: &schema.ResourceTimeout{
|
|
Read: &Timeout30s,
|
|
Default: &Timeout60s,
|
|
},
|
|
|
|
Schema: dataSourceSepCSchemaMake(),
|
|
}
|
|
}
|