forked from vmware/terraform-provider-nsxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_source_nsxt_policy_host_transport_node.go
44 lines (38 loc) · 1.32 KB
/
data_source_nsxt_policy_host_transport_node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* Copyright © 2023 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: MPL-2.0 */
package nsxt
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/vmware/vsphere-automation-sdk-go/runtime/bindings"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model"
)
func dataSourceNsxtPolicyHostTransportNode() *schema.Resource {
return &schema.Resource{
Read: dataSourceNsxtPolicyHostTransportNodeRead,
Schema: map[string]*schema.Schema{
"id": getDataSourceIDSchema(),
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"unique_id": {
Type: schema.TypeString,
Computed: true,
Description: "A unique identifier assigned by the system",
},
},
}
}
func dataSourceNsxtPolicyHostTransportNodeRead(d *schema.ResourceData, m interface{}) error {
obj, err := policyDataSourceResourceRead(d, getPolicyConnector(m), getSessionContext(d, m), "HostTransportNode", nil)
if err != nil {
return err
}
converter := bindings.NewTypeConverter()
dataValue, errors := converter.ConvertToGolang(obj, model.HostTransportNodeBindingType())
if len(errors) > 0 {
return errors[0]
}
htn := dataValue.(model.HostTransportNode)
d.Set("unique_id", htn.UniqueId)
return nil
}