/
data_source_sdwan_vpn_interface_t1_e1_serial_feature_template.go
694 lines (673 loc) · 27 KB
/
data_source_sdwan_vpn_interface_t1_e1_serial_feature_template.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Mozilla Public 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
//
// https://mozilla.org/MPL/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.
//
// SPDX-License-Identifier: MPL-2.0
// Code generated by "gen/generator.go"; DO NOT EDIT.
package provider
import (
"context"
"fmt"
"net/url"
"github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers"
"github.com/hashicorp/terraform-plugin-framework-validators/datasourcevalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/netascode/go-sdwan"
"github.com/tidwall/gjson"
)
// Ensure the implementation satisfies the expected interfaces.
var (
_ datasource.DataSource = &VPNInterfaceT1E1SerialFeatureTemplateDataSource{}
_ datasource.DataSourceWithConfigure = &VPNInterfaceT1E1SerialFeatureTemplateDataSource{}
)
func NewVPNInterfaceT1E1SerialFeatureTemplateDataSource() datasource.DataSource {
return &VPNInterfaceT1E1SerialFeatureTemplateDataSource{}
}
type VPNInterfaceT1E1SerialFeatureTemplateDataSource struct {
client *sdwan.Client
}
func (d *VPNInterfaceT1E1SerialFeatureTemplateDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_vpn_interface_t1_e1_serial_feature_template"
}
func (d *VPNInterfaceT1E1SerialFeatureTemplateDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
// This description is used by the documentation generator and the language server.
MarkdownDescription: "This data source can read the VPN Interface T1 E1 Serial feature template.",
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
MarkdownDescription: "The id of the feature template",
Optional: true,
Computed: true,
},
"version": schema.Int64Attribute{
MarkdownDescription: "The version of the feature template",
Computed: true,
},
"template_type": schema.StringAttribute{
MarkdownDescription: "The template type",
Computed: true,
},
"name": schema.StringAttribute{
MarkdownDescription: "The name of the feature template",
Optional: true,
Computed: true,
},
"description": schema.StringAttribute{
MarkdownDescription: "The description of the feature template",
Computed: true,
},
"device_types": schema.SetAttribute{
MarkdownDescription: "List of supported device types",
ElementType: types.StringType,
Computed: true,
},
"serial_interface_name": schema.StringAttribute{
MarkdownDescription: "Serial Interface Name - slot/subslot/port:channel-group for T1/E1, slot/subslot/port for NIM-1T",
Computed: true,
},
"serial_interface_name_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"interface_description": schema.StringAttribute{
MarkdownDescription: "Interface description",
Computed: true,
},
"interface_description_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"ipv4_address": schema.StringAttribute{
MarkdownDescription: "Assign IPv4 address",
Computed: true,
},
"ipv4_address_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"ipv6_address": schema.StringAttribute{
MarkdownDescription: "Assign IPv6 address",
Computed: true,
},
"ipv6_address_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"ipv6_access_lists": schema.ListNestedAttribute{
MarkdownDescription: "Apply IPv6 access list",
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"direction": schema.StringAttribute{
MarkdownDescription: "Direction",
Computed: true,
},
"acl_name": schema.StringAttribute{
MarkdownDescription: "Name of access list",
Computed: true,
},
"acl_name_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"optional": schema.BoolAttribute{
MarkdownDescription: "Indicates if list item is considered optional.",
Computed: true,
},
},
},
},
"enable_core_region": schema.BoolAttribute{
MarkdownDescription: "Enable core region",
Computed: true,
},
"enable_core_region_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"core_region": schema.StringAttribute{
MarkdownDescription: "Enable core region",
Computed: true,
},
"core_region_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"secondary_region": schema.StringAttribute{
MarkdownDescription: "Enable secondary region",
Computed: true,
},
"secondary_region_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_encapsulations": schema.ListNestedAttribute{
MarkdownDescription: "Encapsulation for TLOC",
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"encapsulation": schema.StringAttribute{
MarkdownDescription: "Encapsulation",
Computed: true,
},
"preference": schema.Int64Attribute{
MarkdownDescription: "Set preference for TLOC",
Computed: true,
},
"preference_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"weight": schema.Int64Attribute{
MarkdownDescription: "Set weight for TLOC",
Computed: true,
},
"weight_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"optional": schema.BoolAttribute{
MarkdownDescription: "Indicates if list item is considered optional.",
Computed: true,
},
},
},
},
"tunnel_interface_groups": schema.SetAttribute{
MarkdownDescription: "List of groups",
ElementType: types.Int64Type,
Computed: true,
},
"tunnel_interface_groups_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_border": schema.BoolAttribute{
MarkdownDescription: "Set TLOC as border TLOC",
Computed: true,
},
"tunnel_interface_border_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"per_tunnel_qos": schema.BoolAttribute{
MarkdownDescription: "Per-tunnel Qos",
Computed: true,
},
"per_tunnel_qos_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"per_tunnel_qos_aggregator": schema.BoolAttribute{
MarkdownDescription: "Per-tunnel QoS Aggregator",
Computed: true,
},
"per_tunnel_qos_aggregator_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_qos_mode": schema.StringAttribute{
MarkdownDescription: "Set tunnel QoS mode",
Computed: true,
},
"tunnel_qos_mode_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_color": schema.StringAttribute{
MarkdownDescription: "Set color for TLOC",
Computed: true,
},
"tunnel_interface_color_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_last_resort_circuit": schema.BoolAttribute{
MarkdownDescription: "Set TLOC as last resort",
Computed: true,
},
"tunnel_interface_last_resort_circuit_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_low_bandwidth_link": schema.BoolAttribute{
MarkdownDescription: "Set the interface as a low-bandwidth circuit",
Computed: true,
},
"tunnel_interface_low_bandwidth_link_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_tunnel_tcp_mss": schema.Int64Attribute{
MarkdownDescription: "Tunnel TCP MSS on SYN packets, in bytes",
Computed: true,
},
"tunnel_interface_tunnel_tcp_mss_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_clear_dont_fragment": schema.BoolAttribute{
MarkdownDescription: "Enable clear dont fragment (Currently Only SDWAN Tunnel Interface)",
Computed: true,
},
"tunnel_interface_clear_dont_fragment_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_network_broadcast": schema.BoolAttribute{
MarkdownDescription: "Accept and respond to network-prefix-directed broadcasts)",
Computed: true,
},
"tunnel_interface_network_broadcast_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_control_connections": schema.Int64Attribute{
MarkdownDescription: "Set the maximum number of control connections for this TLOC",
Computed: true,
},
"tunnel_interface_control_connections_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_vbond_as_stun_server": schema.BoolAttribute{
MarkdownDescription: "Put this wan interface in STUN mode only",
Computed: true,
},
"tunnel_interface_vbond_as_stun_server_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_exclude_controller_group_list": schema.SetAttribute{
MarkdownDescription: "Exclude the following controller groups defined in this list",
ElementType: types.Int64Type,
Computed: true,
},
"tunnel_interface_exclude_controller_group_list_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_vmanage_connection_preference": schema.Int64Attribute{
MarkdownDescription: "Set interface preference for control connection to vManage <0..8>",
Computed: true,
},
"tunnel_interface_vmanage_connection_preference_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_port_hop": schema.BoolAttribute{
MarkdownDescription: "Disallow port hopping on the tunnel interface",
Computed: true,
},
"tunnel_interface_port_hop_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_restrict": schema.BoolAttribute{
MarkdownDescription: "Restrict this TLOC behavior",
Computed: true,
},
"tunnel_interface_restrict_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_carrier": schema.StringAttribute{
MarkdownDescription: "Set carrier for TLOC",
Computed: true,
},
"tunnel_interface_carrier_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_nat_refresh_interval": schema.Int64Attribute{
MarkdownDescription: "Set time period of nat refresh packets <1...60> seconds",
Computed: true,
},
"tunnel_interface_nat_refresh_interval_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_hello_interval": schema.Int64Attribute{
MarkdownDescription: "Set time period of control hello packets <100..600000> milli seconds",
Computed: true,
},
"tunnel_interface_hello_interval_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_hello_tolerance": schema.Int64Attribute{
MarkdownDescription: "Set tolerance of control hello packets <12..6000> seconds",
Computed: true,
},
"tunnel_interface_hello_tolerance_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_bind_loopback_tunnel": schema.StringAttribute{
MarkdownDescription: "Bind loopback tunnel interface to a physical interface",
Computed: true,
},
"tunnel_interface_bind_loopback_tunnel_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_all": schema.BoolAttribute{
MarkdownDescription: "Allow all traffic. Overrides all other allow-service options if allow-service all is set",
Computed: true,
},
"tunnel_interface_allow_all_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_bgp": schema.BoolAttribute{
MarkdownDescription: "Allow/deny BGP",
Computed: true,
},
"tunnel_interface_allow_bgp_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_dhcp": schema.BoolAttribute{
MarkdownDescription: "Allow/Deny DHCP",
Computed: true,
},
"tunnel_interface_allow_dhcp_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_dns": schema.BoolAttribute{
MarkdownDescription: "Allow/Deny DNS",
Computed: true,
},
"tunnel_interface_allow_dns_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_icmp": schema.BoolAttribute{
MarkdownDescription: "Allow/Deny ICMP",
Computed: true,
},
"tunnel_interface_allow_icmp_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_ssh": schema.BoolAttribute{
MarkdownDescription: "Allow/Deny SSH",
Computed: true,
},
"tunnel_interface_allow_ssh_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_ntp": schema.BoolAttribute{
MarkdownDescription: "Allow/Deny NTP",
Computed: true,
},
"tunnel_interface_allow_ntp_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_netconf": schema.BoolAttribute{
MarkdownDescription: "Allow/Deny NETCONF",
Computed: true,
},
"tunnel_interface_allow_netconf_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_ospf": schema.BoolAttribute{
MarkdownDescription: "Allow/Deny OSPF",
Computed: true,
},
"tunnel_interface_allow_ospf_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_stun": schema.BoolAttribute{
MarkdownDescription: "Allow/Deny STUN",
Computed: true,
},
"tunnel_interface_allow_stun_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_snmp": schema.BoolAttribute{
MarkdownDescription: "Allow/Deny SNMP",
Computed: true,
},
"tunnel_interface_allow_snmp_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tunnel_interface_allow_https": schema.BoolAttribute{
MarkdownDescription: "Allow/Deny Https",
Computed: true,
},
"tunnel_interface_allow_https_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"clear_dont_fragment_bit": schema.BoolAttribute{
MarkdownDescription: "Clear don't fragment bit",
Computed: true,
},
"clear_dont_fragment_bit_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"pmtu_discovery": schema.BoolAttribute{
MarkdownDescription: "Path MTU Discovery",
Computed: true,
},
"pmtu_discovery_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"ip_mtu": schema.Int64Attribute{
MarkdownDescription: "Interface MTU <68...2000>, in bytes",
Computed: true,
},
"ip_mtu_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"static_ingress_qos": schema.Int64Attribute{
MarkdownDescription: "Static ingress QoS for the port",
Computed: true,
},
"static_ingress_qos_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tcp_mss": schema.Int64Attribute{
MarkdownDescription: "TCP MSS on SYN packets, in bytes",
Computed: true,
},
"tcp_mss_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"tloc_extension": schema.StringAttribute{
MarkdownDescription: "Extends a local TLOC to a remote node only for vpn 0",
Computed: true,
},
"tloc_extension_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"shutdown": schema.BoolAttribute{
MarkdownDescription: "Administrative state",
Computed: true,
},
"shutdown_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"autonegotiate": schema.BoolAttribute{
MarkdownDescription: "Link autonegotiation",
Computed: true,
},
"autonegotiate_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"shaping_rate": schema.Int64Attribute{
MarkdownDescription: "1ge interfaces: [0..1000000]kbps; 10ge interfaces: [0..10000000]kbps",
Computed: true,
},
"shaping_rate_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"qos_map": schema.StringAttribute{
MarkdownDescription: "Name of QoS map",
Computed: true,
},
"qos_map_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"qos_map_vpn": schema.StringAttribute{
MarkdownDescription: "Name of VPN QoS map",
Computed: true,
},
"qos_map_vpn_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"interface_bandwidth_capacity": schema.Int64Attribute{
MarkdownDescription: "Interface bandwidth capacity, in kbps",
Computed: true,
},
"interface_bandwidth_capacity_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"clock_rate": schema.StringAttribute{
MarkdownDescription: "Set preference for interface Clock speed",
Computed: true,
},
"clock_rate_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"encapsulation": schema.StringAttribute{
MarkdownDescription: "Configure Encapsulation for interface",
Computed: true,
},
"encapsulation_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"interface_downstream_bandwidth_capacity": schema.Int64Attribute{
MarkdownDescription: "Interface downstream bandwidth capacity, in kbps",
Computed: true,
},
"interface_downstream_bandwidth_capacity_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"write_rule": schema.StringAttribute{
MarkdownDescription: "Name of rewrite rule",
Computed: true,
},
"write_rule_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"ipv4_access_lists": schema.ListNestedAttribute{
MarkdownDescription: "Apply ACL",
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"direction": schema.StringAttribute{
MarkdownDescription: "Direction",
Computed: true,
},
"acl_name": schema.StringAttribute{
MarkdownDescription: "Name of access list",
Computed: true,
},
"acl_name_variable": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"optional": schema.BoolAttribute{
MarkdownDescription: "Indicates if list item is considered optional.",
Computed: true,
},
},
},
},
},
}
}
func (d *VPNInterfaceT1E1SerialFeatureTemplateDataSource) ConfigValidators(ctx context.Context) []datasource.ConfigValidator {
return []datasource.ConfigValidator{
datasourcevalidator.ExactlyOneOf(
path.MatchRoot("id"),
path.MatchRoot("name"),
),
}
}
func (d *VPNInterfaceT1E1SerialFeatureTemplateDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) {
if req.ProviderData == nil {
return
}
d.client = req.ProviderData.(*SdwanProviderData).Client
}
func (d *VPNInterfaceT1E1SerialFeatureTemplateDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var config VPNInterfaceT1E1Serial
// Read config
diags := req.Config.Get(ctx, &config)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String()))
if config.Id.IsNull() && !config.Name.IsNull() {
res, err := d.client.Get("/template/feature")
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve existing templates, got error: %s", err))
return
}
if value := res.Get("data"); len(value.Array()) > 0 {
value.ForEach(func(k, v gjson.Result) bool {
if config.Name.ValueString() == v.Get("templateName").String() {
config.Id = types.StringValue(v.Get("templateId").String())
tflog.Debug(ctx, fmt.Sprintf("%s: Found feature template with name '%v', id: %v", config.Id.String(), config.Name.ValueString(), config.Id.String()))
return false
}
return true
})
}
if config.Id.IsNull() {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to find feature template with name: %s", config.Name.ValueString()))
return
}
}
res, err := d.client.Get("/template/feature/object/" + url.QueryEscape(config.Id.ValueString()))
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
return
}
config.fromBody(ctx, res)
tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString()))
diags = resp.State.Set(ctx, &config)
resp.Diagnostics.Append(diags...)
}