Skip to content

Commit 369fcd2

Browse files
authored
[dataSourceNetboxVlans] - Add netbox_vlan.id in netbox_vlans.vlans DataSources (#662)
* update(dataSourceNetboxVlans): Add netbox_vlan.id info in return info of netbox_vlans.vlans * update(dataSourceNetboxVlans): Add documentation * feature(test): Add missing test
1 parent 59b7712 commit 369fcd2

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

docs/data-sources/vlans.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Read-Only:
4141

4242
- `description` (String)
4343
- `group_id` (Number)
44+
- `id` (Number)
4445
- `name` (String)
4546
- `role` (Number)
4647
- `site` (Number)

netbox/data_source_netbox_vlans.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ func dataSourceNetboxVlans() *schema.Resource {
4343
Computed: true,
4444
Elem: &schema.Resource{
4545
Schema: map[string]*schema.Schema{
46+
"id": {
47+
Type: schema.TypeInt,
48+
Computed: true,
49+
},
4650
"vid": {
4751
Type: schema.TypeInt,
4852
Computed: true,
@@ -200,6 +204,7 @@ func dataSourceNetboxVlansRead(d *schema.ResourceData, m interface{}) error {
200204
for _, v := range filteredVlans {
201205
var mapping = make(map[string]interface{})
202206

207+
mapping["id"] = v.ID
203208
mapping["vid"] = v.Vid
204209
mapping["name"] = v.Name
205210
mapping["description"] = v.Description

netbox/data_source_netbox_vlans_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ func TestAccNetboxVlansDataSource_basic(t *testing.T) {
7272
resource.TestCheckResourceAttr("netbox_vlan.test_1", "vid", "1234"),
7373
),
7474
},
75+
{
76+
Config: setUp + testAccNetboxVlansByVid(),
77+
Check: resource.ComposeTestCheckFunc(
78+
resource.TestCheckResourceAttr("data.netbox_vlans.test", "vlans.#", "1"),
79+
resource.TestCheckResourceAttrPair("data.netbox_vlans.test", "vlans.0.id", "netbox_vlan.test_1", "id"),
80+
),
81+
},
7582
{
7683
Config: setUp + testAccNetboxVlansByVid(),
7784
Check: resource.ComposeTestCheckFunc(

0 commit comments

Comments
 (0)