-
Notifications
You must be signed in to change notification settings - Fork 98
/
data_source_aci_psuinstpol.go
49 lines (40 loc) · 1.15 KB
/
data_source_aci_psuinstpol.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
45
46
47
48
49
package aci
import (
"context"
"fmt"
"github.com/ciscoecosystem/aci-go-client/v2/client"
"github.com/ciscoecosystem/aci-go-client/v2/models"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourceAciPowerSupplyRedundancyPolicy() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceAciPowerSupplyRedundancyPolicyRead,
SchemaVersion: 1,
Schema: AppendBaseAttrSchema(AppendNameAliasAttrSchema(map[string]*schema.Schema{
"administrative_state": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Required: true,
},
})),
}
}
func dataSourceAciPowerSupplyRedundancyPolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
aciClient := m.(*client.Client)
name := d.Get("name").(string)
dn := fmt.Sprintf(models.DnPsuInstPol, name)
psuInstPol, err := getRemotePowerSupplyRedundancyPolicy(aciClient, dn)
if err != nil {
return nil
}
d.SetId(dn)
_, err = setPowerSupplyRedundancyPolicyAttributes(psuInstPol, d)
if err != nil {
return nil
}
return nil
}