-
Notifications
You must be signed in to change notification settings - Fork 99
/
data_source_aci_pim_route_map_entry.go
177 lines (153 loc) · 6.28 KB
/
data_source_aci_pim_route_map_entry.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// Code generated by "gen/generator.go"; DO NOT EDIT.
// In order to regenerate this file execute `go generate` from the repository root.
// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md).
package provider
import (
"context"
"fmt"
"github.com/ciscoecosystem/aci-go-client/v2/client"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
)
// Ensure provider defined types fully satisfy framework interfaces.
var _ datasource.DataSource = &PimRouteMapEntryDataSource{}
func NewPimRouteMapEntryDataSource() datasource.DataSource {
return &PimRouteMapEntryDataSource{}
}
// PimRouteMapEntryDataSource defines the data source implementation.
type PimRouteMapEntryDataSource struct {
client *client.Client
}
func (d *PimRouteMapEntryDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
tflog.Debug(ctx, "Start metadata of datasource: aci_pim_route_map_entry")
resp.TypeName = req.ProviderTypeName + "_pim_route_map_entry"
tflog.Debug(ctx, "End metadata of datasource: aci_pim_route_map_entry")
}
func (d *PimRouteMapEntryDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
tflog.Debug(ctx, "Start schema of datasource: aci_pim_route_map_entry")
resp.Schema = schema.Schema{
// This description is used by the documentation generator and the language server.
MarkdownDescription: "The pim_route_map_entry datasource for the 'pimRouteMapEntry' class",
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Computed: true,
MarkdownDescription: "The distinguished name (DN) of the Pim Route Map Entry object.",
},
"parent_dn": schema.StringAttribute{
Required: true,
MarkdownDescription: "The distinguished name (DN) of the parent object.",
},
"action": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The route action of the Pim Route Map Entry object.`,
},
"annotation": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The annotation of the Pim Route Map Entry object.`,
},
"description": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The description of the Pim Route Map Entry object.`,
},
"group_ip": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The group ip of the Pim Route Map Entry object.`,
},
"name": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The name of the Pim Route Map Entry object.`,
},
"name_alias": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The name alias of the Pim Route Map Entry object.`,
},
"order": schema.StringAttribute{
Required: true,
MarkdownDescription: `PIM route map entry order.`,
},
"rendezvous_point_ip": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The rendezvous point ip of the Pim Route Map Entry object.`,
},
"source_ip": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The source ip of the Pim Route Map Entry object.`,
},
"annotations": schema.SetNestedAttribute{
MarkdownDescription: ``,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"key": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The key used to uniquely identify this configuration object.`,
},
"value": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The value of the property.`,
},
},
},
},
"tags": schema.SetNestedAttribute{
MarkdownDescription: ``,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"key": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The key used to uniquely identify this configuration object.`,
},
"value": schema.StringAttribute{
Computed: true,
MarkdownDescription: `The value of the property.`,
},
},
},
},
},
}
tflog.Debug(ctx, "End schema of datasource: aci_pim_route_map_entry")
}
func (d *PimRouteMapEntryDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
tflog.Debug(ctx, "Start configure of datasource: aci_pim_route_map_entry")
// Prevent panic if the provider has not been configured.
if req.ProviderData == nil {
return
}
client, ok := req.ProviderData.(*client.Client)
if !ok {
resp.Diagnostics.AddError(
"Unexpected Data Source Configure Type",
fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)
return
}
d.client = client
tflog.Debug(ctx, "End configure of datasource: aci_pim_route_map_entry")
}
func (d *PimRouteMapEntryDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Start read of datasource: aci_pim_route_map_entry")
var data *PimRouteMapEntryResourceModel
// Read Terraform configuration data into the model
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}
setPimRouteMapEntryId(ctx, data)
// Create a copy of the Id for when not found during getAndSetPimRouteMapEntryAttributes
cachedId := data.Id.ValueString()
tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_pim_route_map_entry with id '%s'", data.Id.ValueString()))
getAndSetPimRouteMapEntryAttributes(ctx, &resp.Diagnostics, d.client, data)
if data.Id.IsNull() {
resp.Diagnostics.AddError(
"Failed to read aci_pim_route_map_entry data source",
fmt.Sprintf("The aci_pim_route_map_entry data source with id '%s' has not been found", cachedId),
)
return
}
// Save data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_pim_route_map_entry with id '%s'", data.Id.ValueString()))
}